Question
#7

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

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


Messages In This Thread
Question - by gtaplayer1 - 24.01.2014, 10:38
Re: Question - by Shetch - 24.01.2014, 10:56
Re: Question - by gtaplayer1 - 24.01.2014, 11:01
Re: Question - by Threshold - 24.01.2014, 11:18
Re: Question - by Shetch - 24.01.2014, 11:27
Re: Question - by gtaplayer1 - 24.01.2014, 11:31
AW: Question - by Nero_3D - 24.01.2014, 12:11

Forum Jump:


Users browsing this thread: 1 Guest(s)