07.06.2012, 15:15
Ok recently I've been trying to make something where the gamemode detects when a player is close to another player and gives them health. I tried using OnPlayerUpdate, but that ended up lagging the server. Now I've tried a timer, and it isn't working. If someone could take a look at it I would appreciate that.
under OnGamemodeInit
pawn Код:
forward MedicTimer(playerid)
pawn Код:
SetTimer( "MedicTimer", 1000, true);
pawn Код:
public MedicTimer(playerid)
{
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][Medic] == 1 && PlayerInfo[i][Army] == 1)
{
if(playerid == i) return 0;
{
new Float:x, Float:y, Float:z;
GetPlayerPos(i, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 1.0, x, y, z))
{
SendClientMessage(playerid, COLOUR_GREEN, "HEALED" );
SendClientMessage(playerid, COLOUR_GREEN, "Thank the medic, who risked his life to save yours!" );
}
else
{
if(PlayerInfo[playerid][Medic] == 1 || PlayerInfo[playerid][Enemy] == 1 || PlayerInfo[playerid][OutOfMedKits] == 1)
{
return 0;
}
}
}
}
}
}
return 1;
}