Forum

> > CS2D > Scripts > spawn hook
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch spawn hook

11 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt spawn hook

kalis
User Off Offline

Zitieren
hey all
who can help me ?
i create new script
but i have problem
ex :
when play i get portal and m4a1
when die i'm lost it
and i use hook spawn
i want that, when spawn lua give all item i got(portal,m4a1)!
1
2
3
4
5
6
7
8
addhook("spawn","sp")
function sp(id)
i_tem[id] = playerweapons(id)
if level[id] >= 1 then 
parse("equip "..id.." "..i_tem[id])
return 1
end
end
added array of item , level
help pls

alt Re: spawn hook

EnderCrypt
User Off Offline

Zitieren
hm i dont se what your trying to do, but have you initzialized the array

i_item= {}

you gotta do that with all tables first

and can you show the error?
1× editiert, zuletzt 23.06.11 15:13:51

alt Re: spawn hook

kalis
User Off Offline

Zitieren
wait i testing your code darkcrypt
who can give me right lua =.=

alt Re: spawn hook

EnderCrypt
User Off Offline

Zitieren
oh wait now i se a problem, you put

i_tem[id] = playerweapons(id)
here you put a table if weapns on the table using id as index¨

if level[id] >= 1 then
now you check if level[id] > or = as 1, however level[id] contains a table, not a number

alt Re: spawn hook

kalis
User Off Offline

Zitieren
level[id] worked =.=
it give me error item 0 does exists (ERROR : CANT EQUIP)

alt Re: spawn hook

EnderCrypt
User Off Offline

Zitieren
ok listen now
i_tem[id] = playerweapons(id)
this puts all weapobs player got (a table), into the table

parse("equip "..id.." "..i_tem[id])
here you try equip id with the TABLE,

so player needs to be equiped with a weapon id, not a table comtaining weapon id

alt Re: spawn hook

Infinite Rain
Reviewer Off Offline

Zitieren
loool
1
2
3
4
5
6
7
8
9
10
11
addhook('die', 'die_hook')
function die_hook(v, k)
	i_item[v] = playerweapons(v)
end

addhook('spawn', 'spawn_hook')
function spawn_hook(id)
	for n, w in ipairs(i_item[id]) do
		parse('equip '.. id ..' '..w)
	end
end

If I understands you right

alt Re: spawn hook

DC
Admin Off Offline

Zitieren
general common mistake: NEVER EVER use the equip command during a spawn hook!

spawn itself will equip stuff so it's a really bad idea. instead use the return command within the spawn hook to define the items that you want to equip!

see
cs2d lua hook spawn

alt Re: spawn hook

Infinite Rain
Reviewer Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
addhook('die', 'die_hook')
function die_hook(v, k)
     i_item[v] = playerweapons(v)
end

addhook('spawn', 'spawn_hook')
function spawn_hook(id)
	parse('strip '.. id ..' 0')
     for n, w in ipairs(i_item[id]) do
          parse('equip '.. id ..' '..w)
     end
end

alt Re: spawn hook

kalis
User Off Offline

Zitieren
thank all
@factis699
it work but have error
1
bad argument #1 to 'ipairs' (taqble expected, got number)
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht