Server Sided money problem
#1

hello everyone so tittle says all i have problem in my server sided money hack it adds money when somone respawn or kill himself
like ihve $60 and after respawn it will be $120

60 + 60 = 120 ( after respawn) and again respawn it will be ( 120 + 120 = 240) what is the problem


PHP код:

#define ResetMoneyBar ResetPlayerMoney
#define UpdateMoneyBar GivePlayerMoney
GivePlayerCash(playeridmoney)
{
    
pInfo[playerid][Money] += money;
    
ResetMoneyBar(playerid);//Resets the money in the M4 moneybar, Do not remove!
    
UpdateMoneyBar(playerid,pInfo[playerid][Money]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    
return pInfo[playerid][Money];
}
SetPlayerCash(playeridmoney)
{
    
pInfo[playerid][Money] = money;
    
ResetMoneyBar(playerid);//Resets the money in the M4 moneybar, Do not remove!
    
UpdateMoneyBar(playerid,pInfo[playerid][Money]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    
return pInfo[playerid][Money];
}
ResetPlayerCash(playerid)
{
    
pInfo[playerid][Money] = 0;
    
ResetMoneyBar(playerid);//Resets the money in the M4 moneybar, Do not remove!
    
UpdateMoneyBar(playerid,pInfo[playerid][Money]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    
return pInfo[playerid][Money];
}
GetPlayerCash(playerid)
{
    return 
pInfo[playerid][Money];
}
function 
MoneyTimer()
{
    new 
str[64];
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
GetPlayerCash(i) < GetPlayerMoney(i))
            {
                
ResetMoneyBar(i);//Resets the money in the M4 moneybar, Do not remove!
                
UpdateMoneyBar(i,GetPlayerCash(i));//Sets the money in the moneybar to the serverside cash, Do not remove!
                
new hack GetPlayerMoney(i) - GetPlayerCash(i);
                
format(strsizeof(str),"AC ALERT: %s (ID:%d) has cheated $%d",GetName(i),i,hack);
                
printf("%s has picked up/attempted to spawn $%d."GetName(i),hack);
            }
        }
    }
    return 
1;
}
// under onplayerspawn
    
ResetMoneyBar(playerid);//Resets the money in the M4 moneybar, Do not remove!
    
GivePlayerCash(playerid,pInfo[playerid][Money]);
// under onplayerconnect
    
ResetPlayerCash(playerid); //Resetting the players cash variable to zero. 
Reply
#2

Код:
// under onplayerspawn 
    ResetMoneyBar(playerid);//Resets the money in the M4 moneybar, Do not remove! 
    GivePlayerCash(playerid,pInfo[playerid][Money]);
You are adding money to the player when he spawns.Dont use "GivePlayerCash" under onplayerspawn,instead use "SetPlayerCash"

And another advice

Код:
if(GetPlayerCash(i) < GetPlayerMoney(i)) 
            { 
                ResetMoneyBar(i);//Resets the money in the M4 moneybar, Do not remove! 
                UpdateMoneyBar(i,GetPlayerCash(i));//Sets the money in the moneybar to the serverside cash, Do not remove! 
                new hack = GetPlayerMoney(i) - GetPlayerCash(i); 
                format(str, sizeof(str),"AC ALERT: %s (ID:%d) has cheated $%d",GetName(i),i,hack); 
                printf("%s has picked up/attempted to spawn $%d.", GetName(i),hack); 
            }
Buying drinks from vendor machines also triggers the anti cheat.And if the player cant get any use from the money,Why print it?
Just reset his money

Код:
if(GetPlayerCash(i) < GetPlayerMoney(i)) 
            { 
                ResetMoneyBar(i);
                UpdateMoneyBar(i,GetPlayerCash(i));
            }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)