anti cheat
#1

i have this but given 10 massage in 1 sec!! how to fix it?

PHP код:
stock SendMoneyWarn(playerid){
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    for(new 
0MAX_PLAYERSi++){
        if(
PlayerInfo[i][pAdmin] >=|| IsPlayerAdmin(i)){
            new 
tmp2[50],str[128];
            
GetPlayerIp(playerid,tmp2,sizeof(tmp2));
            
format(str,sizeof(str),"%s-%s(%d) maby used money cheat.check him",tmp2,name,playerid);
            
SendClientMessage(i,COLOR_RED,str);}}
    return 
1;}
public 
OnPlayerUpdate(playerid)
{
    if(
GetPlayerMoney(playerid) > PlayerInfo[playerid][pMoney]){
        
moneyanticheattimer[playerid] = SetTimerEx("moneyanticheat"5000false"i"playerid);}
    return 
1;
}
forward moneyanticheat(playerid);
public 
moneyanticheat(playerid)
{
    if(
AOptions[amoney] == 0)return 1;
    for(new 
0MAX_PLAYERSi++)
    {
        if(
PlayerInfo[i][pAdmin] >=|| IsPlayerAdmin(i))
        {
            
SendMoneyWarn(i);
        }
    }
    return 
1;

Reply
#2

Delete all of this and make a timer which repeats himself every 1000 - 1500ms and then add in it a new function:

PHP код:
SetPlayerMoney(playerid,PlayerInfo[playerid][pMoney]); 
if you didn't have the stock:
PHP код:
stock SetPlayerMoney(playerid,howmuch
{
    
PRIVATE_Last_Money[playerid]=howmuch;
    return 
GivePlayerMoney(playerid,howmuch-GetPlayerMoney(playerid));

Reply
#3

With your moneyanticheat function, why are you using a loop? There is playerid parameter with the function already, your code makes no sense at all. Also, why do you have to use a timer inside OnPlayerUpdate callback? That's extremely stupid cause OnPlayerUpdate callback gets called constantly for the player.

I would recommend you to read this thread once and learn something about making anti cheat yourself; https://sampforum.blast.hk/showthread.php?tid=220089
Reply
#4

Why not just do away with the shitty GetPlayerMoney() and SetPlayerMoney() functions and do it all server sided.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)