Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 235 36 37338 339 Next To the start

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
info.txt has written
- 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

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

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

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

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
#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

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
saladface27 has written
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.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
KaiserWilhelm has written
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.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

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

old Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Quote
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?

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
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.

old Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Quote
@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?
edited 1×, last 05.08.09 01:58:22 pm

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
Blazzingxx has written
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..."

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
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.
To the start Previous 1 235 36 37338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview