SA-MP Forums Archive
health regeneration for my vip players. - 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: health regeneration for my vip players. (/showthread.php?tid=433614)



health regeneration for my vip players. - zudokuxd10 - 28.04.2013

how i can make this: health regeneration for my vip players.
give me example script code please


Re: health regeneration for my vip players. - Glad2BeHere - 28.04.2013

pawn Код:
new vip[MAX_PLAYERS]; //Variable for VIP

//under gamemode or fs init

SetTimerEx("VipHealth", 60000, true, "i", playerid); //every minute since the server start


forward VipHealth(playerid);
public VipHealth(playerid)
{
   if(vip[playerid] >= 1 && IsPlayerConnected(playerid)) // checks to see if the player is connect and is a vip
   {
     new Float: vHealth;//variable
     GetPlayerHealth(playerid, vHealth); // setting a value to vHealth which is = to the player health
     SetPlayerHealth(playerid, vHealth + 5); // Sets the player Health +5
   }
   return 1;
}



Re: health regeneration for my vip players. - Pottus - 28.04.2013

pawn Код:
#define         HEALTH_REGEN_TIME           53640 // Approximately 1 minute
#define         HP_INCREMENT                1.0

public OnGameModeInit()
{
    SetTimer("VIPHealthRegen", HEALTH_REGEN_TIME, true);
}

forward VIPHealthRegen();
public VIPHealthRegen()
{
    new Float:hp;
    foreach(new i : Player)
    {
        if(VipPlayer[i])
        {
            GetPlayerHealth(i, hp);
            if(hp < 100.0)
            {
                hp += HP_INCREMENT;
                if(hp > 100.0) hp = 100.0;
                SetPlayerHealth(i, hp);
            }
        }
    }
}



Re: health regeneration for my vip players. - zudokuxd10 - 28.04.2013

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
pawn Код:
new vip[MAX_PLAYERS]; //Variable for VIP

//under gamemode or fs init

SetTimerEx("VipHealth", 60000, true, "i", playerid); //every minute since the server start


forward VipHealth(playerid);
public VipHealth(playerid)
{
   if(vip[playerid] >= 1 && IsPlayerConnected(playerid)) // checks to see if the player is connect and is a vip
   {
     new Float: vHealth;//variable
     GetPlayerHealth(playerid, vHealth); // setting a value to vHealth which is = to the player health
     SetPlayerHealth(playerid, vHealth + 5); // Sets the player Health +5
   }
   return 1;
}
cause problems if the player dies and regenerates?


Re: health regeneration for my vip players. - Glad2BeHere - 28.04.2013

https://sampwiki.blast.hk/wiki/GetPlayerState
https://sampwiki.blast.hk/wiki/Playerstates
pawn Код:
if(GetPlayerState(playerid) == 1)
BTW chance my timer to to under on player connect...... or u can use his timer and make adjustments....


Re: health regeneration for my vip players. - zudokuxd10 - 28.04.2013

like this in my OnPlayerConnect?

PHP код:
    if(GetPlayerState(playerid) == 1)
    {
    
SetTimerEx("VipHealth"30000true"i"playerid);
    } 



Re: health regeneration for my vip players. - Glad2BeHere - 28.04.2013

pawn Код:
new vip[MAX_PLAYERS]; //Variable for VIP
new VipTimer[MAX_PLAYERS];

 //every minute since the server start


forward VipHealth(playerid);
public VipHealth(playerid)
{
   new vipstate = GetPlayerState(playerid);
   if(IsPlayerConnected(playerid) && vipstate == 1 || vipstate == 2 && IsPlayerConnected(playerid)) // checks to see if the player is connect and is a vip
   {
     new Float: vHealth;//variable
     GetPlayerHealth(playerid, vHealth); // setting a value to vHealth which is = to the player health
     SetPlayerHealth(playerid, vHealth + 5); // Sets the player Health +5
   }
   return 1;
}

public OnPlayerConnect(playerid)
{
    if(vip[playerid] >= 1)
    {
        VipTimer[playerid] = SetTimerEx("VipHealth", 60000, true, "i", playerid);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(VipTimer[playerid]);
    return 1;
}



Re: health regeneration for my vip players. - Pottus - 28.04.2013

That will just keep giving them HP even past 100, IsPlayerConnected(playerid) is a completely useless check since you kill the timer when they disconnect, when they connect how do you know if they're VIP before you even load their userfile and lastly 60000 is not one minute read here https://sampforum.blast.hk/showthread.php?tid=289675


Re: health regeneration for my vip players. - Glad2BeHere - 28.04.2013

So what if it pass 100 you don't know whats the minimum health amount on his server.....the timer is a separate timer for each player.... about loading the variable Read the first sentence its just and example.... Work with what you are provided with....I am just showing him the simple way with the time and it averages a minute...


Re: health regeneration for my vip players. - zudokuxd10 - 28.04.2013

already place it like you said but I do not regenerate anything
this is my OnPlayerConnect

PHP код:
    if(MemberVip[playerid][Vip] >= 1)
    {
        
VipTimer[playerid] = SetTimerEx("VipHealth"5000true"i"playerid);
    } 
MemberVip is my variable for vip (also i use this for others functions vips)