The "local" variables will not be compared

Hi folks, I’m making an addon which is taking me much of my time and take me by surprise as the variables without the “local” are not “useful” on the internet as if you are … why? I do not know … only if “variable = true” all players will have true … unlike the earlier result that gave me …

Well, I learned to use the “local” (I guess)
But when I perform a comparison operation, it passes as if it were defined from the beginning of the code

and try to redefine the variable as if it were a “local” or not have this, but no results, look at some of my code

[LUA]local funcion = 0

if(SERVER) then

if (ply:KeyDown(IN_WALK)) and GetConVarNumber("gzg_Dazzer") > 0 then
		if (ply:KeyDown(IN_USE)) and non_repeat == false then
		non_repeat = true
		timer.Simple(1 , function()
		non_repeat = false
		funcion = funcion + 1

		if funcion == 0 then
		on_fliying = false
		dazzing = false
		Msg("Funcion 0 activada")
		ply:PrintMessage( HUD_PRINTCENTER, "Suit Especial Desactivado" )

//Funcion vida recuperacion

		if funcion == 1 then
		if ply:Alive() then
		timer.Simple(1, function()
		ply_health = ply:Health()
		if ply_health <= 200 then
		ply:SetHealth(ply_health + (math.random(1,10)))
		ply:SetMaxSpeed( 100 )
		on_fliying = true
		dazzing = true
		ply:PrintMessage( HUD_PRINTCENTER, "Suit de regeneracion Activado" )

//the rest of the code here


As you can see, I do that if you press ALT + E “function” increases value, and if you press “ALT” (where “function” = 1) recovery of life, but … this is not only often miss my courage, but he does infinitely (if you hold E)

I mean, you miss the variable “non_repeat” which causes me no time to let the variable “function” at a constant value

if your making a local variable outside a function it will only count in the file, if your making a local variable in a function it will only count in the function and down if your making a local varibale in a “if” it will only count to the “end”

hope it helped u …

All your values are Global, you use no function!
The code called only one time, if you load the file.


age = 6 // Use in the complete file
alive = true // Use in the complete file

function Checklife()
// Check older then 0
if( age > 0 and alive != false ) then
alive = true
alive = false

function IamDie()
local Dietime = 90 // i can use “Dietime” only in this function
if( age >= Dietime ) then
alive = false


I hope this is useful for you :slight_smile: