Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 235 36 37338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

DC
Admin On Online

Zitieren
info.txt hat geschrieben
- playerweapons(id)          Return a table containing the
                                             types of all items carried by
                                             this player


a table is like an array. you can iterate through it to check if it contains the type id of a certain weapon

alt Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Zitieren
How to end "for" loop sooner then end? (done)

console command "removeitem" removes the whole entity.
How to remove item without deleting entity?
2× editiert, zuletzt 02.08.09 09:43:25

alt Re: Lua Scripts/Questions/Help

wups
User Off Offline

Zitieren
#Vectar666

1
2
3
4
5
6
7
8
9
10
11
addhook("say","mm")
function mm(p,t)
	if (t == "!weapons") then
	
		wep = playerweapons(p)
		
		for x=1, #wep do
			msg2(p,itemtype(wep[x],"name"))
		end
	end
end

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
saladface27 hat geschrieben
can you force players to change teams with lua?

Yuo mean Something like:
1
2
maket id
makect id
You can use those commands to change players team.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
KaiserWilhelm hat geschrieben
Note to self: create guide explaining to noobs what the difference between a string and normal characters/numbers/variables are.


Actually it would've been string/numbers vs variables since the former are immutable literals.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Why this dont work...
1
2
3
addhook("spray","pl_spray")
function pl_spray(id)
end
Edit : I see in lab that its bug

alt Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Zitieren
very simple lives script:

addhook("second","sec")
function sec()
for i=1,32 do
if(player(i,"deaths")==3)then
parse("makespec "..i"")
end
end
end

when I run I get this error:
LUA ERROR: sys/lua/server.lua:5: attempt to call local 'i' (a number value)

seems to be this line that gets the error
parse("makespec "..i"")

any suggestions?

alt Re: Lua Scripts/Questions/Help

DC
Admin On Online

Zitieren
parse("makespec "..i"")
the ..i"" is nonsense.

you only need to have quotes around strings and spaces. that's it. "makespec " is a string. so the quots are right. then you use .. to attach the value of i to the string. thats right as well.

then you start to do pointless things.

1. mistake: you start with quotes right after i! it doesn't work! you would need to add .. in order to attach it! you did it right in front of the i so why do you do it wrong behind the i?!

2. mistake: there are two quotes "". this means it's a string (a collection of characters [words, numbers, letters]) without any content. moreover this means "" equals NOTHING. it doesn't server any purpose in this case. it's not necessary!

so you can ignore 1. just leave the "".

hint:
imagine what Lua actually does and how it works!
for example i is 10.
Lua will connect "makespec " and i (10) to makespec 10
and this will be passed to the cs2d parser in order to execute the command (same like entering makespec 10 in the console)

now imagine that there is also a "" behind the i (as you wrote it). Lua doesn't get it. there is no .. so Lua is forced to try weird stuff. which fails obviously.

alt Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Zitieren
@DC: thanks for helping me out, my script works now and i'm going to expand on it.

edit: what does player(id,"team") equal if player id is a spectator?
1× editiert, zuletzt 05.08.09 13:58:22

alt Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Zitieren
Blazzingxx hat geschrieben
I guess team=3 if player is spectator.
          
1
2
3
[b]if[/b] ([i]player[/i]([b]p[/b],"[i]team[/i]")==[u]0[/u]) [b]then[/b]
 -- do something here
[b]end[/b]
I believe this is the right script. It's like saying "When you are spectator..."

alt Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Zitieren
How to make sound to all players but in range?
sv_sound plays sound to all players with the same volume.
sv_sound2 playes sound exactly to 1 player.

I need smth like entity env_sound but in lua.
Zum Anfang Vorherige 1 235 36 37338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht