Integrer error
#1

All ints in commands are 0 even if i don't put 0.

Ex.

Код:
CMD:givemoney(playerid, params[])
{
	new id, ammountcash, givemstring[128];
	if(sscanf(params, "ud", id, ammountcash)) return SendClientMessage(playerid, -1, "Use: /pay [Player] [Ammount]");
	PlayerInfo[playerid][Money] += ammountcash;
        format(givemstring, 128, "You gave him $%d", ammountcash);
        SendClientMessage(playerid, -1, givemstring);
	return 1;
}
even if i use "ui" except "ud" for params it's the same
Reply
#2

pawn Код:
CMD:givemoney(playerid, params[])
{
    new id, ammountcash, givemstring[128];
    if(sscanf(params, "ui", id, ammountcash))
            return SendClientMessage(playerid, -1, "Use: /pay [Player] [Ammount]");

    GivePlayerMoney(playerid, ammountcash);
    //PlayerInfo[playerid][Money] += ammountcash; - This won't work because there's no stock that updates the Money.

    format(givemstring, sizeof(givemstring), "You gave him $%d", ammountcash);
    SendClientMessage(playerid, -1, givemstring);
    return 1;
}
or this Pattern

pawn Код:
CMD:givemoney(playerid, params[])
{
    new id, ammountcash, givemstring[128];
    if(sscanf(params, "ui", id, ammountcash))
            return SendClientMessage(playerid, -1, "Use: /pay [Player] [Ammount]");

    GiveLegitMoney(playerid, ammountcash);

    format(givemstring, sizeof(givemstring), "You gave him $%d", ammountcash);
    SendClientMessage(playerid, -1, givemstring);
    return true;
}

stock GiveLegitMoney(playerid, ammount)
{
    GivePlayerMoney(playerid, ammount);
    PlayerInfo[playerid][Money] += ammount;
    return true;
}
The problem isn't the integer, the problem is how you assign the variable & not updating the money bar
Reply
#3

By the way, it looks like you're sending the cash to yourself and not the target
pawn Код:
CMD:givemoney(playerid, params[])
{
    new id, ammountcash, givemstring[128];
    if(sscanf(params, "ud", id, ammountcash)) return SendClientMessage(playerid, -1, "Use: /pay [Player] [Ammount]");
    PlayerInfo[id][Money] += ammountcash; // PlayerInfo[playerid][Money] += ammountcash;
    format(givemstring, 128, "You gave him $%d", ammountcash);
    SendClientMessage(playerid, -1, givemstring);
    return 1;
}
Reply
#4

It's okay I made that cmd as an example, but I already got stock. Was the error %d parameter except %i or what?
Reply
#5

For more info:
Quote:
Originally Posted by ******
Посмотреть сообщение
Specifier(s) Name Example values
b Binary 01001, 0b1100
c Character a, o, *
f Float 0.7, -99.5
g IEEE Float 0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
h, x Hex 1A, 0x23
i, d Integer 1, 42, -10
l Logical true, false
n Number 42, 0b010, 0xAC, 045
o Octal 045 12
q Bot name/id ShopBot, 27
r Player name/id ******, 42
u User name/id (bots and players) ******, 0
Reply
#6

Still same Same comand worked just fine 2 days ago
Reply
#7

Fixed it was sscanf error
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)