SA-MP Forums Archive
Some errors - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Some errors (/showthread.php?tid=327198)



Some errors - viddo - 20.03.2012

I get those errors:
Код:
p.pwn(19989) : error 017: undefined symbol "Health"
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(19991) : error 076: syntax error in the expression, or invalid function call
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(19995) : warning 235: public function lacks forward declaration (symbol "hptimer")
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(19997) : error 017: undefined symbol "Health"
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(19999) : error 010: invalid function or declaration
When i add this:
Код:
public CheckHealth(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid,health);

	if(Health < 20)
	{
			hptimer = SetTimer("losehp",1000,true);
		}
	return 1;
}
public hptimer(playerid)
{
   SetPlayerHealth(playerid, Health -5); //player loses 5hp each time the timer is called.
}
return 1;
}
Need fix plz, Thx


Re: Some errors - mineralo - 20.03.2012

pawn Код:
new Float:Health;
public CheckHealth(playerid)
{
    GetPlayerHealth(playerid,Health);

    if(Health < 20)
    {
            hptimer = SetTimer("losehp",1000,true);
        }
    return 1;
}
public losehp(playerid)
{
   SetPlayerHealth(playerid, Health -5); //player loses 5hp each time the timer is called.
}
return 1;
}
try that or
pawn Код:
public CheckHealth(playerid)
{
    GetPlayerHealth(playerid,Health);

    if(Health < 20)
    {
            SetTimerEx("losehp",1000,false,"i",playerid);
        }
    return 1;
}
public losehp(playerid)
{
   SetPlayerHealth(playerid, Health -5); //player loses 5hp each time the timer is called.
}



Re: Some errors - Reklez - 20.03.2012

pawn Код:
new hptimer; //at the top of script

new Float:Health;

public CheckHealth(playerid)
{
    GetPlayerHealth(playerid,Health);
    if(Health < 20)
    {
        hptimer = SetTimer("losehp",1000,true);
    }
    return 1;
}

forward hptimer(playerid);
public hptimer(playerid)
{
   GetPlayerHealth(playerid, Health);
   SetPlayerHealth(playerid, Health -5);
   return 1;
}



Re: Some errors - Bogdan1992 - 20.03.2012

PHP код:
new Float:health;
new 
hptimer[MAX_PLAYERS];
public 
CheckHealth(playerid){
    
GetPlayerHealth(playerid,health);
    if(
Health 20){
         
hptimer[playerid] = SetTimer("losehp",1000,true);
    }
    return 
1;
}
public 
losehp(playerid){
       
SetPlayerHealth(playeridhealth-5);
    return 
1;




Re: Some errors - mineralo - 20.03.2012

you shouldn't use SetTimer because its at general, better use SetTimerEx, that function work for exactly player


Re: Some errors - viddo - 20.03.2012

Код:
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(78185) : warning 219: local variable "Health" shadows a variable at a preceding level
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(79014) : warning 219: local variable "Health" shadows a variable at a preceding level
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(79045) : warning 219: local variable "Health" shadows a variable at a preceding level
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(80720) : warning 219: local variable "Health" shadows a variable at a preceding level
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(80734) : warning 219: local variable "Health" shadows a variable at a preceding level
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(80748) : warning 219: local variable "Health" shadows a variable at a preceding level
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(80762) : warning 219: local variable "Health" shadows a variable at a preceding level
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(81566) : warning 219: local variable "Health" shadows a variable at a preceding level
LOL !


Re: Some errors - Bogdan1992 - 20.03.2012

Somewhere you have already defined the Health, find the local variable(new Float:Health) and remove it.


Re: Some errors - viddo - 20.03.2012

Yea but when i remove (new Float:Health It give me that Health is undefined in those things..


Re: Some errors - Bogdan1992 - 20.03.2012

Don't remove the global variable(that one from the top of your gamemode).


Re: Some errors - Skribblez - 20.03.2012

Quote:
Originally Posted by viddo
Посмотреть сообщение
Yea but when i remove (new Float:Health It give me that Health is undefined in those things..
double check, using the find tool in pawno is very very helpful for this cases.