SA-MP Forums Archive
Server side problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Server side problem (/showthread.php?tid=587614)



Server side problem - jamal1992 - 01.09.2015

I did a server side for SetPlayerHealth and look:
PHP код:
PUBLIC: SetPlayerHealthEx(playeridFloat:health)
{
    new 
Float:tmp_health health,Float:newhp;
    if (
tmp_health 0.0tmp_health 0.0;
    else if (
tmp_health 100.0tmp_health 100.0;
    
AntiCheatInfo[playerid][acHealth] = tmp_health;
    
SetPlayerHealth(playeridtmp_health);
    
GetPlayerHealth(playeridnewhp);
    
printf("GetPlayerHealth: %.01f\nAntiCheatHealth: %.01f\nHealth: %.01f"newhpAntiCheatInfo[playerid][acHealth], tmp_health);
    return 
1;

This is debug
PHP код:
GetPlayerHealth99.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:oldhealthFloat:amount;
    foreach(
Playerx)
    {
        if(
PlayerInfo[x][pStatus] == 1)
        {
            
GetPlayerHealth(xoldhealth);
            
amount floatsub(oldhealth1.0);
            
SetPlayerHealthEx(xamount);
        }
    }
    return 
1;

This function is called per every minute


Re: Server side problem - MarvinPWN - 01.09.2015

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"newhpAntiCheatInfo[playerid][acHealth], tmp_health);
    return 
1;

What will print now?


Re: Server side problem - jamal1992 - 01.09.2015

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"newhpAntiCheatInfo[playerid][acHealth], tmp_health);
    return 
1;

What will print now?
PHP код:
[14:21:45AntiCheatHealth99.0
[14:21:45GetPlayerHealth100.0
AntiCheatHealth
99.0
Health
99.0 



Re: Server side problem - jamal1992 - 01.09.2015

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


Re: Server side problem - jamal1992 - 01.09.2015

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


Re: Server side problem - Vince - 01.09.2015

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


Re: Server side problem - jamal1992 - 01.09.2015

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