SA-MP Forums Archive
Server Sided money 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 Sided money problem (/showthread.php?tid=586199)



Server Sided money problem - JeaSon - 20.08.2015

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. 



Re: Server Sided money problem - _Mohit_ - 20.08.2015

Код:
// 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));
            }