How do you make a variable that can be used on another function?
Eg. a kill combo counter?
I am using this so when you get 3 in a row kills you get a chance to get an RPG.
Variables in Lua are global by default.
Wait what?
So how do i define one?
[lua]
global combonumber = combonumber + 1
[/lua]
???
No, you don't need any type thing in front.
[lua]
Variable = 20
[/lua]
[QUOTE=benjojo;17655601]Wait what?
So how do i define one?
[lua]
global combonumber = combonumber + 1
[/lua]
???[/QUOTE]
Global variable:
[lua]Randomvariable = Randomvariable + 2[/lua]
Local variable:
[lua]local Randomvariable = Randomvariable + 2[/lua]
Ok
can you store an Ent in there for exapmple
[lua]
Randomvariable = ply
[/lua]
?
Ah, how would I make a combo counter?
For a player.
You know how many kill's until death in a game mode?
ply:Frag I think.. Not sure..
[QUOTE=benjojo;17656062]Ok
can you store an Ent in there for exapmple
[lua]
Randomvariable = ply
[/lua]
?
Ah, how would I make a combo counter?
For a player.
You know how many kill's until death in a game mode?[/QUOTE]
You can store entitys in variables. You would also use player:Frags() and player:Deaths()
You can also do this :
[lua]local Meta = FindMetaTable("Player")
function Meta:GetCombo()
if self.Combo then
return self.Combo
else
return 0
end
end
function Meta:ChangeComboCounter(points)
self.Combo = points + self:GetCombo()
end
local ply = player.GetByID(1)
print(ply:GetCombo()) // Prints 0
ply:ChangeComboCounter(34)
print(ply:GetCombo()) // Prints 34[/lua]
Sorry, you need to Log In to post a reply to this thread.