No Pain
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Only lag can kill us!
 
HomePortalLatest imagesSearchRegisterLog in

 

 Very Easy and basic lua guide

Go down 
+2
Kratos
«[R]e|ÐøXx~*
6 posters
AuthorMessage
«[R]e|ÐøXx~*
Newbie member
«[R]e|ÐøXx~*


Posts : 163
Reputation : 2
Join date : 2012-04-19
Age : 26
Location : Argentina (but im from Uruguay)
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Very Easy and basic lua guide   Very Easy and basic lua guide EmptyFri 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
Back to top Go down
http://www.unrealsoftware.de
Kratos
Owner/Admin
Owner/Admin
Kratos


Posts : 850
Reputation : 4
Join date : 2011-12-18
Age : 26
Location : England
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptyFri 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.
Back to top Go down
https://nopain.forumotion.net
«[R]e|ÐøXx~*
Newbie member
«[R]e|ÐøXx~*


Posts : 163
Reputation : 2
Join date : 2012-04-19
Age : 26
Location : Argentina (but im from Uruguay)
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptyFri Apr 27, 2012 8:04 pm

Okay Thanks
Back to top Go down
http://www.unrealsoftware.de
7Up
Newbie member
7Up


Posts : 80
Reputation : -1
Join date : 2012-02-10
Age : 26
Location : Jordan
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptyFri Apr 27, 2012 8:10 pm

i got the first one Very Happy thanks Smile
Back to top Go down
-CazaCuervos-
Newbie member
-CazaCuervos-


Posts : 535
Reputation : 7
Join date : 2012-02-19
Age : 25
Location : Madrid(SPAIN)
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptyFri 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 Very Happy
Back to top Go down
http://www.nopain2d.enjin.com
«[R]e|ÐøXx~*
Newbie member
«[R]e|ÐøXx~*


Posts : 163
Reputation : 2
Join date : 2012-04-19
Age : 26
Location : Argentina (but im from Uruguay)
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptyFri 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


Back to top Go down
http://www.unrealsoftware.de
-CazaCuervos-
Newbie member
-CazaCuervos-


Posts : 535
Reputation : 7
Join date : 2012-02-19
Age : 25
Location : Madrid(SPAIN)
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptyFri 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 Very Happy
Back to top Go down
http://www.nopain2d.enjin.com
«[R]e|ÐøXx~*
Newbie member
«[R]e|ÐøXx~*


Posts : 163
Reputation : 2
Join date : 2012-04-19
Age : 26
Location : Argentina (but im from Uruguay)
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptyFri Apr 27, 2012 11:11 pm

Sure why not.
Back to top Go down
http://www.unrealsoftware.de
Larz
Forum Moderator
Forum Moderator
Larz


Posts : 759
Reputation : -1
Join date : 2012-01-02
Age : 28
Location : Spain
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptySat Apr 28, 2012 1:52 pm

Great, I hope it will help members that want to be scripters.
Back to top Go down
TonyTheX1
Member
Member
TonyTheX1


Posts : 456
Reputation : 4
Join date : 2012-03-14
Age : 25
Location : Greece/thessaloniki
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptySat Apr 28, 2012 3:29 pm

1st. That helped me somehow Very Happy .
2nd. I'm asking my self. WHY EVERYTIME I LEARN LUA I FEEL SAD????? O_O
3rd. Kratos , where can I find a teacher? Very Happy
Back to top Go down
«[R]e|ÐøXx~*
Newbie member
«[R]e|ÐøXx~*


Posts : 163
Reputation : 2
Join date : 2012-04-19
Age : 26
Location : Argentina (but im from Uruguay)
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptySat Apr 28, 2012 3:34 pm

Tony You can find a Teacher at school.
Back to top Go down
http://www.unrealsoftware.de
TonyTheX1
Member
Member
TonyTheX1


Posts : 456
Reputation : 4
Join date : 2012-03-14
Age : 25
Location : Greece/thessaloniki
Warning level : 0

Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide EmptySat 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.
Back to top Go down
Sponsored content





Very Easy and basic lua guide Empty
PostSubject: Re: Very Easy and basic lua guide   Very Easy and basic lua guide Empty

Back to top Go down
 
Very Easy and basic lua guide
Back to top 
Page 1 of 1
 Similar topics
-
» Need someone to make easy sprites

Permissions in this forum:You cannot reply to topics in this forum
No Pain :: Fun :: Off-topic-
Jump to: