28.04.2013, 01:13
how i can make this: health regeneration for my vip players.
give me example script code please
give me example script code please
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;
}
#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);
}
}
}
}
pawn Код:
|
if(GetPlayerState(playerid) == 1)
if(GetPlayerState(playerid) == 1)
{
SetTimerEx("VipHealth", 30000, true, "i", playerid);
}
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;
}
if(MemberVip[playerid][Vip] >= 1)
{
VipTimer[playerid] = SetTimerEx("VipHealth", 5000, true, "i", playerid);
}