Forum

> > CS2D > General > Lua scripting tutorial
ForenübersichtCS2D-ÜbersichtGeneral-ÜbersichtEinloggen, um zu antworten

Englisch Lua scripting tutorial

51 Antworten
Seite
Zum Anfang Vorherige 1 2 3 Nächste Zum Anfang

alt Re: Lua scripting tutorial

lenz-_-
User Off Offline

Zitieren
And i don't get the hook part for some reason..
I watched at DC's samples as well, but i think i owe this misunderstanding to my bad english..
and i really want to teach myself..
Well, in this case , i guess i am a newbie, not a noob...

alt Re: Lua scripting tutorial

SQ
Moderator Off Offline

Zitieren
In cs2d hook means when to apply function.
Example:

addhook("Period when to apply function","function name")

Periods like :
Join - every player join
minute - each minute
spawn - every time player spawn
1× editiert, zuletzt 03.07.09 17:11:24

alt Re: Lua scripting tutorial

ohaz
User Off Offline

Zitieren
you need to add hooks, which are called when something in game happens and then call their function.
addhook(1, 2)
function 2(param1, param2,....)
1 is a special text, you need to either know it, or watch into the info.txt in your /sys/lua folder.
it's always something like say, kill, die, spawn, ....
2 is a name you can give this hook. When the hook is called, it will call the function which has the same name.
(in this case function 2)

alt Re: Lua scripting tutorial

ohaz
User Off Offline

Zitieren
1
2
3
4
5
6
addhook("kill", "restartonkill")
function restartonkill(killer, victim)
if (victim == 1) then
	parse("sv_restart 0")
end
end

alt Re: Lua scripting tutorial

Alpha Beta
User Off Offline

Zitieren
Then try that:
1
2
3
4
5
6
addhook("die", "restartonkill")
function restartonkill(victim,killer,weapon,x,y)
	if (victim == 1) then
		parse("sv_restart 0")
	end
end
Should work for team gate ,too...
1× editiert, zuletzt 03.07.09 19:39:10

alt Re: Lua scripting tutorial

ohaz
User Off Offline

Zitieren
1
2
3
4
5
6
addhook("die", "restartondie")
function restartondie(victim)
if (victim == 1) then
	parse("sv_restart 0")
end
end
@ heavy: you mixed the parameters!

alt geschlossen Re: Lua scripting tutorial

mortyr22
User Off Offline

Zitieren
how to create reloading after 2 shots?

Admin/Mod Kommentar

Don't spam around with your question! Everybody here has read it at least a thousand times already. /TheKilledDeath
Zum Anfang Vorherige 1 2 3 Nächste Zum Anfang
Einloggen, um zu antwortenGeneral-ÜbersichtCS2D-ÜbersichtForenübersicht