Server side problem
#1

I did a server side for SetPlayerHealth and look:
PHP код:
PUBLIC: SetPlayerHealthEx(playerid, Float:health)
{
    new 
Float:tmp_health = health,Float:newhp;
    if (
tmp_health < 0.0) tmp_health = 0.0;
    else if (
tmp_health > 100.0) tmp_health = 100.0;
    
AntiCheatInfo[playerid][acHealth] = tmp_health;
    
SetPlayerHealth(playerid, tmp_health);
    
GetPlayerHealth(playerid, newhp);
    
printf("GetPlayerHealth: %.01f\nAntiCheatHealth: %.01f\nHealth: %.01f", newhp, AntiCheatInfo[playerid][acHealth], tmp_health);
    return 
1;
} 
This is debug
PHP код:
GetPlayerHealth: 99.0
AntiCheatHealth
: 98.0
Health
: 98.0 
Where is the problem i don`t understand, i don`t found any bugs ....

PHP код:
PUBLIC: PlayerHealthLoss()
{
    new 
Float:oldhealth, Float:amount;
    foreach(
Player, x)
    {
        if(
PlayerInfo[x][pStatus] == 1)
        {
            
GetPlayerHealth(x, oldhealth);
            
amount = floatsub(oldhealth, 1.0);
            
SetPlayerHealthEx(x, amount);
        }
    }
    return 
1;
} 
This function is called per every minute
Reply
#2

PHP код:
PUBLIC: SetPlayerHealthEx(playerid,Float:health)
{
    new 
Float:newhp;
    if(
health < 0.0)health = 0.0;
    else if(
health > 100.0)health = 100.0;
    
AntiCheatInfo[playerid][acHealth] = health;
    
printf("AntiCheatHealth: %.01f",AntiCheatInfo[playerid][acHealth]);
    
SetPlayerHealth(playerid,health);
    
GetPlayerHealth(playerid,newhp);
    
printf("GetPlayerHealth: %.01f\nAntiCheatHealth: %.01f\nHealth: %.01f", newhp, AntiCheatInfo[playerid][acHealth], tmp_health);
    return 
1;
} 
What will print now?
Reply
#3

Quote:
Originally Posted by MarvinPWN
Посмотреть сообщение
PHP код:
PUBLIC: SetPlayerHealthEx(playerid,Float:health)
{
    new 
Float:newhp;
    if(
health < 0.0)health = 0.0;
    else if(
health > 100.0)health = 100.0;
    
AntiCheatInfo[playerid][acHealth] = health;
    
printf("AntiCheatHealth: %.01f",AntiCheatInfo[playerid][acHealth]);
    
SetPlayerHealth(playerid,health);
    
GetPlayerHealth(playerid,newhp);
    
printf("GetPlayerHealth: %.01f\nAntiCheatHealth: %.01f\nHealth: %.01f", newhp, AntiCheatInfo[playerid][acHealth], tmp_health);
    return 
1;
} 
What will print now?
PHP код:
[14:21:45] AntiCheatHealth: 99.0
[14:21:45] GetPlayerHealth: 100.0
AntiCheatHealth
: 99.0
Health
: 99.0 
Reply
#4

it is a delay or something like that ? On /stats show me correctly.
Reply
#5

Anti-Cheat
PHP код:
GetPlayerHealth(i, health);
            if(
health > AntiCheatInfo[i][acHealth])
            {
                
format(string, sizeof(string), "AdmCmd: %s has been kicked by AdmBot, reason: using cheats (health hack)",PlayerInfo[i][pUsername]);
                
KickWithMessage(i, COLOR_LIGHTRED, string);
                
printf("GetPlayerHealth: %.01f\nAntiCheatHealth: %.01f", health, AntiCheatInfo[i][acHealth]);
            } 
This repeat per every second and look to debug:
PHP код:
[15:17:16] GetPlayerHealth: 100.0
AntiCheatHealth
: 99.0 
This is annoying
Reply
#6

Get functions do not work right after Set functions because the update must first be sent to the player.
Reply
#7

Problem solved, i did a function like on junkbuster synctime. I think is good .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)