/buygold command
#1

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!
Reply
#2

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).
Reply
#3

Код:
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..
Reply
#4

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.
Reply
#5

Thank you all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)