Integrer error - 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: Integrer error (
/showthread.php?tid=478084)
Integrer error -
feartonyb - 27.11.2013
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
Re: Integrer error - Patrick - 27.11.2013
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
Re: Integrer error -
Loot - 27.11.2013
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;
}
Re: Integrer error -
feartonyb - 27.11.2013
It's okay I made that cmd as an example, but I already got stock. Was the error %d parameter except %i or what?
Re: Integrer error -
Loot - 27.11.2013
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 |
|
Re: Integrer error -
feartonyb - 28.11.2013
Still same

Same comand worked just fine 2 days ago
Re: Integrer error -
feartonyb - 28.11.2013
Fixed it was sscanf error