health regeneration for my vip players.
#1

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

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;
}
Reply
#3

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);
            }
        }
    }
}
Reply
#4

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?
Reply
#5

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....
Reply
#6

like this in my OnPlayerConnect?

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

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;
}
Reply
#8

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
Reply
#9

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...
Reply
#10

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)