Forum

> > CS2D > Scripts > Script Addhook and Function
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script Addhook and Function

10 replies
To the start Previous 1 Next To the start

old Script Addhook and Function

MethodMan
User Off Offline

Quote
Hi all,someone has a tutorial with tips and ADDHOOK FUNCTION to create a LUA?, or a small video tutorial from now thank!

old Re: Script Addhook and Function

Suprise
BANNED Off Offline

Quote
addhook is add a hook (Mr. obviously me :3)with a function.
There are several hooks. Check this page for it: http://www.cs2d.com/help.php?hookcat=all

Let's start with an easy.
1
2
addhook("spawn","_spawn")
function _spawn(id)
It's a spawn hook. When someone spawn it does something.

addhook --add a hook to the game.
spawn --Hook name
_spawn --function name of our hook

Here is an example with spawn hook

1
2
3
4
5
6
7
8
addhook("spawn","_spawn")
function _spawn(id)
	if player(id,"team") == 1 then       --If the spawned player team is Terrorists
		parse("equip "..id.." 30")	  --He/she get Ak-47
	elseif player(id,"team") == 2 then   --If the spawned player team is Counter Terrorist
		parse("equip "..id.." 32")    --He/She get M4A1
	end   --Close the first if.
end   --Close the function.

I might helped, might not.

old Re: Script Addhook and Function

sheeL
User Playing CS2D

Quote
You can see other examples here
lua-users.org/wiki/LuaTutorial
http://www.unrealsoftware.de/forum_posts.php?post=226033
if you need help with hooks
http://www.cs2d.com/help.php?hookcat=all


1
2
3
4
addhook("HookName","HookFunction")
function HookFunction (value)
...
end -- Function

Look this example :
1
2
3
4
5
6
addhook("serveraction","MyAction")
function MyAction(id,ActionButton)
if ActionButton == 1 then -- F2
 msg2(id,"Your Message Here") --  Your Message when you press F2
 end -- close function
end -- close if

other example

1
2
3
4
5
6
7
addhook("say","_say')
function _say(id,text)
if text == "MyText" then -- Text
 msg2(id,"Your Message")
  return 1 -- don't appears in chat - return 0 appears
  end -- close function
end -- close if

if you need help or other examples, send PM to me
#45813
edited 1×, last 10.12.12 12:48:22 am

old Re: Script Addhook and Function

sheeL
User Playing CS2D

Quote
user Shawni has written
@user Jynxxx : This is just your fault, never expect something good(helpful) from Brazilian kids


@user Shawni:
I do it my way, @user Shawni: nobody called you in the conversation, all Algerians are less well than in brazil recognized.
P.S = i am not a child, you say
teens ...

@user Suprise: sorry, i'll use the next time, not like much ...
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview