English Script Addhook and Function

10 replies
Goto Page
To the start Previous 1 Next To the start
09.12.12 03:19:02 am
Up
MethodMan
User
Offline Off
Hi all,someone has a tutorial with tips and ADDHOOK FUNCTION to create a LUA?, or a small video tutorial from now thank!
09.12.12 03:30:39 am
Up
MikuAuahDark
User
Offline Off
Hello? Are you there, Tae Hanazono?
09.12.12 10:07:34 am
Up
IPC CS2D
User
Offline Off
That's true. There you go.
Even if someone says it's piece of shit, just don't listen to them ~ Factis Words.

Admin/mod comment:

rules §2.1 - Needless and/or doubled posts (spam) are forbidden, no "+1", "inb4" etc. - only post stuff that is necessary/helpful. Thanks /DC
09.12.12 10:55:25 am
Up
Suprise
BANNED
Offline Off
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.
Code:
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

Code:
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.
09.12.12 09:53:14 pm
Up
sheeL
User
Offline Off
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


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


Look this example :
Code:
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

Code:
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
10.12.12 12:13:22 am
Up
Jynxxx
User
Offline Off
@user sheeL: Why do you never use the tab button? Space tabbing isn't real tabbing learn how to do it!
10.12.12 12:19:47 pm
Up
Suprise
BANNED
Offline Off
Agree use Tabs. Waay easier to read your scripts.
10.12.12 01:30:08 pm
Up
Shawni
User
Offline Off
@user Jynxxx : This is just your fault, never expect something good(helpful) from Brazilian kids
We die once, do i have to hide to be visible ?
10.12.12 02:13:59 pm
Up
sheeL
User
Offline Off
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 ...
10.12.12 05:27:10 pm
Up
MethodMan
User
Offline Off
thanks to those who helped me, and fuck who has racism to Brazil!
10.12.12 05:35:05 pm
Up
Shawni
User
Offline Off
At least we arn't kids, unlike brazilians

There are only 2Algerian users here ( am inculded )
We die once, do i have to hide to be visible ?
To the start Previous 1 Next To the start