SA-MP Forums Archive
Serverside money and clientside not synced anymore? - 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: Serverside money and clientside not synced anymore? (/showthread.php?tid=346094)



Serverside money and clientside not synced anymore? - Supercop - 27.05.2012

Hello,

In the script I got it used to work fine; if you lose money (like if you buy a car or give money to another player) it was distracted from your clientside money (the cash at the right top of the screen), but since 0.3e this isn't the case anymore.

If a player logs in and his cash got loaded, he gets the money tho'.


Re: Serverside money and clientside not synced anymore? - Verbal - 27.05.2012

Maybe under OnPlayerConnect there's GivePlayerMoney or something like that.
Or maybe you didn't save his new amount of money after buying a car/whatever..


Re: Serverside money and clientside not synced anymore? - Supercop - 27.05.2012

I think I didn't explain the issue that well :P

If a player logs in, his money gets loaded properly. If the player has 15.000 dollar cash, he gets the 15.000 dollar.

However, if a player buys something in-game, like a car, the money doesn't get distracted from the green amount in the right of the screen, however he loses the money clientside.
Let's say the car costs 5.000 dollar, then if he logs off and logs back in he gets 10.000 again.


Re: Serverside money and clientside not synced anymore? - milanosie - 27.05.2012

Something wrong with your loading/saving system, since 0.3e didn't change that part of the code.


Re: Serverside money and clientside not synced anymore? - WooTFTW - 27.05.2012

Show us the function, with what you give the server-sided money.


Re: Serverside money and clientside not synced anymore? - Supercop - 01.06.2012

No, the problem is not loading and saving money, this works as it has to.

However, if the player joins the server and purchases and item, like a car, the money only gets removed serverside(/stats) and not serverside (cash at the right top)

This is a part where the player has to lose clientside money:

pawn Код:
command(pay, playerid, params[])
{
    new id, plmoney, string[128];
    if(sscanf(params, "ud", id, plmoney))
    {
        SendClientMessage(playerid, WHITE, "SYNTAX: /pay [playerid] [amount]");
    }
    else
    {
        if(Player[playerid][Money] >= plmoney)
        {
            if(IsPlayerConnectedEx(id) || id != playerid)
            {
                if(Spectator[id][SpecSpectatingPlayer] != -1)
                {
                    SendClientMessage(playerid, WHITE, "You're too far away.");
                }
                else
                {
                    if(plmoney > 0 && plmoney < 20000)
                    {
                        if(GetDistanceBetweenPlayers(playerid, id) < 5)
                        {
                            Player[playerid][Money] -= plmoney;
                            Player[id][Money] += plmoney;
                            format(string, sizeof(string), "You have paid $%s to %s.", IntToFormattedStr(plmoney), GetName(id));
                            SendClientMessage(playerid, WHITE, string);
                            format(string, sizeof(string), "* %s has paid %s some money ($%s).", GetName(playerid), GetName(id), IntToFormattedStr(plmoney));
                            NearByMessage(id, NICESKY, string);
                            new tmpip1[128], tmpip2[128];
                            GetPlayerIp(playerid, tmpip1, sizeof(tmpip1));
                            GetPlayerIp(id, tmpip2, sizeof(tmpip2));
                            new hour, minute, second, day, year, month;
                            gettime(hour, minute, second);
                            getdate(year, month, day);
                            format(string, sizeof(string), "[PAY] %s (IP: %s) has paid %s (IP: %s) $%s on %d/%d/%d (%d:%d:%d)", GetName(playerid), tmpip1, GetName(id), tmpip2, IntToFormattedStr(plmoney), day, month, year, hour, minute, second);
                            MoneyLog(string);
                            format(string, sizeof(string), "You have been paid $%s, by %s.", IntToFormattedStr(plmoney), GetName(playerid));
                            SendClientMessage(id, WHITE, string);
                           
                            if(Player[playerid][PlayingHours] == 0 && plmoney >= 999 && Player[playerid][AdminLevel] < 1)
                            {
                                format(string, sizeof(string), "WARNING: %s may possibly be money-farming, they've given $%s to %s (w/ 0 playing hours)", GetName(playerid), IntToFormattedStr(plmoney), GetName(id));
                                SendToAdmins(ADMINORANGE, string, 0);
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, WHITE, "You're too far away.");
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, WHITE, "You can't pay under $1, or over $19,999.");
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, WHITE, "Player not connected or not logged in, or is you.");
            }
        }
    }
    return 1;
}



Re: Serverside money and clientside not synced anymore? - Babul - 01.06.2012

search in your LoadStats function, there has to be a "GivePlayerMoney(" somewhere. i dont see that function being called in your posted code above (/pay). the server sided money needs to be synced 1 way only, means: just
pawn Код:
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,Player[playerid][Money]);
this is how to sync the clients money from the server - a pay n spray costing $100 will be ignored when the money gets synced later again, but that doesnt matter (for now) i guess..