SA-MP Forums Archive
/buygold command - 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: /buygold command (/showthread.php?tid=609586)



/buygold command - Micko123 - 14.06.2016

So i have problem with this /buygold command
PHP код:
YCMD:kupizlato(playeridparams[], help)
{
    
#pragma unused help
    
if(IsPlayerInRangeOfPoint(playerid1.01696.5371,-1183.6985,23.8899))
    {
        new 
string[128], ammountcash ammount 300;
        if(
GetPlayerMoney(playerid) < cash)
        {
            
SCM(playerid, -1"[ES:RPG] "CRVENA"Nemate dovoljno novca!");
            return 
1;
        }
        else
        {
            if(
sscanf(params"u"ammount))
            {
                
SCM(playerid,-1,"ES:RPG Pomoc | "SPLAVA"/kupizlato [Kolicina]");
                
SCM(playerid,-1,"ES:RPG Pomoc | "SPLAVA"Cijena grama je 300");
                return 
1;
            }
            else
            {
                
PlayerInfo[playerid][pZlato] += ammount;
                
GivePlayerMoney(playerid, - cash);
                
format(stringsizeof(string), ""SPLAVA"Kupili ste "ZUTA"%d g zlata za "ZELENA"%d$"ammountcash);
                
SCM(playerid, -1string);
                return 
1;
            }
        }
    }
    else
    {
        
SCM(playerid, -1"[ES:RPG] "CRVENA"Niste na mjestu kupovine zlata!");
        return 
1;
    }

No warns no erros but it says that i bought 65535g of gold for 0$. Why is that happening??
And it gives me 65535 gold WTF!


Re: /buygold command - Konstantinos - 14.06.2016

Change to "i" specifier in sscanf. "u" is used for players (+ NPCs) and since the given number is not a connected player, it returns INVALID_PLAYER_ID (65535).


Re: /buygold command - Stinged - 14.06.2016

Код:
new string[128], ammount, cash = ammount * 300;
if(GetPlayerMoney(playerid) < cash)
Might I ask what this is?
'cash' will always be 0 because 'ammount' is 0, 0 * 300 = 0..


Re: /buygold command - saffierr - 14.06.2016

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Код:
new string[128], ammount, cash = ammount * 300;
if(GetPlayerMoney(playerid) < cash)
Might I ask what this is?
'cash' will always be 0 because 'ammount' is 0, 0 * 300 = 0..
lol ikr... unless he gives 'ammount' a value.


Re: /buygold command - Micko123 - 14.06.2016

Thank you all