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



/bet command help - Face9000 - 15.05.2012

error 012: invalid function call, not a valid address
error 017: undefined symbol "d"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

pawn Код:
CMD:bet(playerid,params[])
{
    if(!sscanf(params, "d"))
    {
    new money = params(d),rand = random(10);
    if(rand == 5)
    {
        SendClientMessage(playerid,green,"You won! %i$",money*2);
        GivePlayerMoney(playerid,money*2);
    } else
    {
        SendClientMessage(playerid,red,"You lose %i$...AHAH!",money);
        GivePlayerMoney(playerid,-money);
    }
    if(money < 0) SendClientMessage(playerid red,"Invalid ammount to bet.");
    }
    else return SendClientMessage(playerid, red, "Usage: /bet [Money to bet]");
    return 1;
}
Line 3227:

pawn Код:
new money = params(d),rand = random(10);



Re: /bet command help - ViniBorn - 15.05.2012

pawn Код:
CMD:bet(playerid,params[])
{
    new money;
    if(!sscanf(params, "d",money))
    {
        new rand = random(10);
        if(rand == 5)
        {
            SendClientMessage(playerid,green,"You won! %i$",money*2);
            GivePlayerMoney(playerid,money*2);
        }
        else
        {
            SendClientMessage(playerid,red,"You lose %i$...AHAH!",money);
            GivePlayerMoney(playerid,-money);
        }
        if(money < 0) SendClientMessage(playerid red,"Invalid ammount to bet.");
    }
    else return SendClientMessage(playerid, red, "Usage: /bet [Money to bet]");
    return 1;
}



AW: /bet command help - Forbidden - 15.05.2012

Why if(!sscanf(params, "d")) this dont make any Sense because ! is if not.

Firstly you must define d , so if d is a float so simply do:
new test(for example)
new
test
if (sscanf(params, "d", test))
so the variable Test is for d.


Re: /bet command help - Face9000 - 15.05.2012

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
pawn Код:
CMD:bet(playerid,params[])
{
    new money;
    if(!sscanf(params, "d",money))
    {
        new rand = random(10);
        if(rand == 5)
        {
            SendClientMessage(playerid,green,"You won! %i$",money*2);
            GivePlayerMoney(playerid,money*2);
        }
        else
        {
            SendClientMessage(playerid,red,"You lose %i$...AHAH!",money);
            GivePlayerMoney(playerid,-money);
        }
        if(money < 0) SendClientMessage(playerid red,"Invalid ammount to bet.");
    }
    else return SendClientMessage(playerid, red, "Usage: /bet [Money to bet]");
    return 1;
}
Thanks,now i get errors at this lines:
pawn Код:
SendClientMessage(playerid,green,"You won %i$!",money*2);
pawn Код:
SendClientMessage(playerid,red,"You lose %i$...AHAH!",money);
pawn Код:
if(money < 0) SendClientMessage(playerid red,"Invalid ammount to bet.");
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
error 001: expected token: ",", but found "-integer value-"
warning 215: expression has no effect
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line


Re: /bet command help - ViniBorn - 15.05.2012

Use format before SendClientMessage...

pawn Код:
format(YourString,sizeof YourString,"You won %i$!",money*2);
SendClientMessage(playerid,green,YourString);



format(YourString,sizeof YourString,"You lose %i$...AHAH!",money);
SendClientMessage(playerid,green,YourString);


if(money < 0) SendClientMessage(playerid, red,"Invalid ammount to bet.");



Re: /bet command help - Face9000 - 15.05.2012

Thanks,+rep.