| Very Easy and basic lua guide | |
|
|
Author | Message |
---|
«[R]e|ÐøXx~* Newbie member
Posts : 163 Reputation : 2 Join date : 2012-04-19 Age : 26 Location : Argentina (but im from Uruguay) Warning level : 0
| Subject: Very Easy and basic lua guide Fri Apr 27, 2012 4:10 pm | |
| Hello im posting a lua guide that my friend teached me,i remember something anyway,i copied some of hes lua guide BTW this is not all made by me,this is for help people that dont understand to make lua , and they want to do lua okay
Items needed: Time Patience
So, we need to start with hook, like this: addhook("spawn", "_spawn")
Now you have this one covered, we can do the function!
function _spawn(id)
You may wonder why there is the ID. It is because player spawns, it takes his id what we need in script.
Lets look of the script now:
addhook("spawn", "_spawn") function _spawn(id)
So, now we probably need to equip the player, so we use parse("equip") command
addhook("spawn", "_spawn") function _spawn(id) parse("equip "..id.." 30") end
so, in spawn it equips the player with AK-47. Thats it, your first script. But you may need some randomness to make it more fun, always spawning with AK-47 isn't that fun. So, we use math.random
addhook("spawn", "_spawn") function _spawn(id) local random = math.random(1, 2) if random == 1 then parse("equip "..id.." 30") elseif random == 2 then parse("equip "..id.." 32") end end
Now you have the randomness between guns, so you can now possibly end with an AK-47 or M4A1. You can also use the math.random in equip as well, like this:
parse("equip "..id.." "..math.random(1,89))
That should equip you with random item.
You may want that only CT get certain equips and Tr another. Then you can use this: player(id, "team")
addhook("spawn", "_spawn") function _spawn(id) local random = math.random(1, 2) if player(id, "team") == 1 then if random == 1 then parse("equip "..id.." 30") elseif random == 2 then parse("equip "..id.." 10") end elseif player(id, "team") == 2 then if random == 1 then parse("equip "..id.." 32") elseif random == 2 then parse("equip "..id.." 11") end end end
See? Now if you are in TR team you have possibility to get M3 or AK-47, and if your in CT you have possibility to get XM1014 or AK-47.
Thats all i hope u enjoyed this. P.S: i got permisson of my friend to post this on here | |
|
| |
Kratos Owner/Admin
Posts : 850 Reputation : 4 Join date : 2011-12-18 Age : 26 Location : England Warning level : 0
| Subject: Re: Very Easy and basic lua guide Fri Apr 27, 2012 5:30 pm | |
| you can use "return " instead of equipping with parse in spawn hook.
Also, have you tried this script, cause I have a feeling random functions need ostime function.
If anyone needs a guide for a different kind of script, tell me I'll do it. | |
|
| |
«[R]e|ÐøXx~* Newbie member
Posts : 163 Reputation : 2 Join date : 2012-04-19 Age : 26 Location : Argentina (but im from Uruguay) Warning level : 0
| Subject: Re: Very Easy and basic lua guide Fri Apr 27, 2012 8:04 pm | |
| | |
|
| |
7Up Newbie member
Posts : 80 Reputation : -1 Join date : 2012-02-10 Age : 26 Location : Jordan Warning level : 0
| Subject: Re: Very Easy and basic lua guide Fri Apr 27, 2012 8:10 pm | |
| i got the first one thanks | |
|
| |
-CazaCuervos- Newbie member
Posts : 535 Reputation : 7 Join date : 2012-02-19 Age : 25 Location : Madrid(SPAIN) Warning level : 0
| Subject: Re: Very Easy and basic lua guide Fri Apr 27, 2012 10:12 pm | |
| :O Red is a good mapping and scripting, Congratz. I think we're going to be helpful in the clan, I'm happy | |
|
| |
«[R]e|ÐøXx~* Newbie member
Posts : 163 Reputation : 2 Join date : 2012-04-19 Age : 26 Location : Argentina (but im from Uruguay) Warning level : 0
| Subject: Re: Very Easy and basic lua guide Fri Apr 27, 2012 10:34 pm | |
| Anyway thanks for your comment, Actually im 100 % mapper , but im 10 % scripter . i dont know so much about lua
| |
|
| |
-CazaCuervos- Newbie member
Posts : 535 Reputation : 7 Join date : 2012-02-19 Age : 25 Location : Madrid(SPAIN) Warning level : 0
| Subject: Re: Very Easy and basic lua guide Fri Apr 27, 2012 10:47 pm | |
| NP because you are friendly and you like me how person. if you need help, please ask for it | |
|
| |
«[R]e|ÐøXx~* Newbie member
Posts : 163 Reputation : 2 Join date : 2012-04-19 Age : 26 Location : Argentina (but im from Uruguay) Warning level : 0
| Subject: Re: Very Easy and basic lua guide Fri Apr 27, 2012 11:11 pm | |
| | |
|
| |
Larz Forum Moderator
Posts : 759 Reputation : -1 Join date : 2012-01-02 Age : 28 Location : Spain Warning level : 0
| Subject: Re: Very Easy and basic lua guide Sat Apr 28, 2012 1:52 pm | |
| Great, I hope it will help members that want to be scripters. | |
|
| |
TonyTheX1 Member
Posts : 456 Reputation : 4 Join date : 2012-03-14 Age : 25 Location : Greece/thessaloniki Warning level : 0
| Subject: Re: Very Easy and basic lua guide Sat Apr 28, 2012 3:29 pm | |
| 1st. That helped me somehow . 2nd. I'm asking my self. WHY EVERYTIME I LEARN LUA I FEEL SAD????? O_O 3rd. Kratos , where can I find a teacher? | |
|
| |
«[R]e|ÐøXx~* Newbie member
Posts : 163 Reputation : 2 Join date : 2012-04-19 Age : 26 Location : Argentina (but im from Uruguay) Warning level : 0
| Subject: Re: Very Easy and basic lua guide Sat Apr 28, 2012 3:34 pm | |
| Tony You can find a Teacher at school. | |
|
| |
TonyTheX1 Member
Posts : 456 Reputation : 4 Join date : 2012-03-14 Age : 25 Location : Greece/thessaloniki Warning level : 0
| Subject: Re: Very Easy and basic lua guide Sat Apr 28, 2012 4:48 pm | |
| 1st. That wasn't fun. 2nd. I'll continue learning with my teacher. He tought me some things about LUA today. | |
|
| |
Sponsored content
| Subject: Re: Very Easy and basic lua guide | |
| |
|
| |
| Very Easy and basic lua guide | |
|