26.01.2011, 12:38
is posible to creat a timer that give -5hp each 10seconds only if the player is in water ?
stock IsPlayerInWater(playerid)
{
new animlib[32],tmp[32];
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,tmp,32);
if(!strcmp(animlib, "SWIM") && !IsPlayerInAnyVehicle(playerid)) return true;
return false;
}
This code will only work as long as a player is not in a vehicle
pawn Код:
|
stock IsPlayerInWater(playerid) { new animlib[32], animname[32]; GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32); if(strcmp(animlib, "SWIM", true) == 0) { if(team[playerid] == 2) return 1; if(team[playerid] == 6) return 1; SetPlayerDrunkLevel (playerid, 400) GameTextForPlayer(playerid, "~r~ Water is infected ", 3000, 4); } }
//OnPlayerConnect:
SetTimerEx("blah", 1000, 1, "i", playerid); //You might want to kill or something like that when the player disconnect
//Bottom of your script:
forward Blah(playerid);
public Blah(playerid)
{
if(IsPlayerInWater(playerid) && team[playerid] ! = 2 || team[playerid] ! = 6)
{
SetPlayerDrunkLevel (playerid, 400);
GameTextForPlayer(playerid, "~r~ Water is infected ", 3000, 4);
}
return 1;
}