SA-MP Forums Archive
Count - 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: Count (/showthread.php?tid=658341)



Count - DarkMythHunter - 02.09.2018

Код:
else if(pInfo[playerid][pBlood] <= 1000)
		{

			SendClientMessage(playerid,-1,"*"COL_RED" You have low amount of blood! Use a blood bag or a medical kit to replenish your health!");
 		}
So this detects if the user have 1000 blood or lower. The thing is, everytime it goes lower, it just sends that warning. What I want is, if the player have 1000 blood or less, it gives a message then if the user still have that 1000 blood or lower he will get another message, but after a decent amount of time. Like every 10 minutes.

So how?



[/hr]


Also check this please: https://sampforum.blast.hk/showthread.php?tid=658313

I need a solution, I can't find any...


Re: Count - Shinja - 02.09.2018

PHP код:
new BloodWarning[MAX_PLAYERS];
else if(
pInfo[playerid][pBlood] <= 1000 && gettime() > BloodWarning[playerid] + 600)// 10 minutes
{
     
SendClientMessage(playerid,-1,"*"COL_RED" You have low amount of blood! Use a blood bag or a medical kit to replenish your health!");
     
BloodWarning[playerid]=gettime();




Re: Count - DarkMythHunter - 03.09.2018

Quote:
Originally Posted by Shinja
Посмотреть сообщение
PHP код:
new BloodWarning[MAX_PLAYERS];
else if(
pInfo[playerid][pBlood] <= 1000 && gettime() > BloodWarning[playerid] + 600)// 10 minutes
{
     
SendClientMessage(playerid,-1,"*"COL_RED" You have low amount of blood! Use a blood bag or a medical kit to replenish your health!");
     
BloodWarning[playerid]=gettime();

Utils/PlayerFunctions.pwn(109 : error 029: invalid expression, assumed zero
Utils/PlayerFunctions.pwn(109 : warning 215: expression has no effect
Utils/PlayerFunctions.pwn(109 : error 001: expected token: ";", but found "if"


Re: Count - Shinja - 03.09.2018

Line? and show code above aswell


Re: Count - DarkMythHunter - 03.09.2018

Quote:
Originally Posted by Shinja
Посмотреть сообщение
Line? and show code above aswell
correction;


Utils/PlayerFunctions.pwn(110 : error 029: invalid expression, assumed zero
Utils/PlayerFunctions.pwn(110 : warning 215: expression has no effect
Utils/PlayerFunctions.pwn(110 : error 001: expected token: ";", but found "if"

Line 1108:
Код:
else if(pInfo[playerid][pBlood] <= 1000 && gettime() > BloodWarning[playerid] + 600)// 10 minutes
The whole part:
PHP код:
CheckBars(playerid)
{
    if(
pInfo[playerid][pIsPlayerSpawned] == true && pInfo[playerid][pIsPlayerInMenu] == false)
    {
        if(
pInfo[playerid][pHunger] <= 0)
        {
            new 
str[65];
            
format(str,sizeof(str),"* "COL_GREY" %s has starved to death!"pInfo[playerid][pUsername]);
            
SendNearbyMessage(60.0playeridstr, -1);
            
SendClientMessage(playerid,-1,"*"COL_GREY" You starved to death!");
            
SetPlayerHealth(playerid0.0);
        }
        else if(
pInfo[playerid][pThirst] <= 0)
        {
            new 
str[65];
            
format(str,sizeof(str),"* "COL_GREY" %s has died of thirst!"pInfo[playerid][pUsername]);
            
SendNearbyMessage(60.0playeridstr, -1);
            
SendClientMessage(playerid,-1,"*"COL_GREY" You died of thirst!");
            
SetPlayerHealth(playerid0.0);
        }
        else if(
pInfo[playerid][pBlood] <= 0)
        {
            new 
str[65];
            
format(str,sizeof(str),"* "COL_GREY" %s has died of blood loss!"pInfo[playerid][pUsername]);
            
SendNearbyMessage(60.0playeridstr, -1);
            
SendClientMessage(playerid,-1,"*"COL_GREY" You died of blood loss!");
            
SetPlayerHealth(playerid0.0);
        }
        
        else if(
pInfo[playerid][pTemperature] <= 0.0)
        {
            new 
str[65];
            
format(str,sizeof(str),"* "COL_GREY" %s has frozen to death!"pInfo[playerid][pUsername]);
            
SendNearbyMessage(60.0playeridstr, -1);
            
SendClientMessage(playerid,-1,"*"COL_GREY" You froze to death!");
            
SetPlayerHealth(playerid0.0);
        }
        new 
BloodWarning[MAX_PLAYERS]; 
        else if(
pInfo[playerid][pBlood] <= 1000 && gettime() > BloodWarning[playerid] + 600)// 10 minutes 
        

            
SendClientMessage(playerid,-1,"*"COL_RED" You have low amount of blood! Use a blood bag or a medical kit to replenish your health!"); 
            
BloodWarning[playerid]=gettime(); 
        }  
    }
    return 
1;




Re: Count - Shinja - 03.09.2018

PHP код:
else if(pInfo[playerid][pBlood] <= 1000 && gettime() > (BloodWarning[playerid] + 600))// 10 minutes 



Re: Count - DarkMythHunter - 03.09.2018

Still gives the same error tho

Utils/PlayerFunctions.pwn(110 : error 029: invalid expression, assumed zero
Utils/PlayerFunctions.pwn(110 : warning 215: expression has no effect
Utils/PlayerFunctions.pwn(110 : error 001: expected token: ";", but found "if"


Re: Count - Shinja - 03.09.2018

new BloodWarning[MAX_PLAYERS]; Must be at top of script not inside the function


Re: Count - DarkMythHunter - 03.09.2018

Quote:
Originally Posted by Shinja
Посмотреть сообщение
new BloodWarning[MAX_PLAYERS]; Must be at top of script not inside the function
Ah yeah, thanks.