24.01.2014, 12:11
If I am not mistaken the games are run by the clients and the server only transmit data
Therefore it needs some time till the health is synced
Therefore it needs some time till the health is synced
pawn Код:
/*
Dont use custom MAX_PLAYERS definitions because (if you use include from other people) the value of MAX_PLAYERS won't change accordingly
Undef it and redefine it with your new value as the old value isn't needed anymore
*/
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
new
Float: gScriptHealth[MAX_PLAYERS],
bool: gSyncHealth[MAX_PLAYERS char]
;
Check_Health(playerid) {
new
Float: health
;
if(GetPlayerHealth(playerid, health)) {
if(!gSyncHealth{playerid}) {
if(fHealth <= gScriptHealth[playerid]) {
gSyncHealth{playerid} = true;
}
return true;
}
return (fHealth <= gScriptHealth[playerid]);
}
return false;
}
stock SetPlayerHealthSync(playerid, Float: health) {
if(SetPlayerHealth(playerid, health) {
gScriptHealth[playerid] = health;
gSyncHealth{playerid} = false;
return true;
}
return false;
}
//OnPlayerSpawn
SetPlayerHealthSync(playerid, 50.0);
//OnPlayerUpdate
if(!Check_Health()) {
Kick(playerid);
}