PDA

View Full Version : this cmd doesnt work..


xMCx
16/09/2012, 01:35 PM
CMD:givemoney(playerid, params[])
{
new targetid, ammount;
if(sscanf(params, "ui",targetid)) return SendClientMessage(playerid, 0xFFFFFFF, "USAGE: /givemoney [PlayerID] [Ammount]");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, red, "Error: This CMD is only for Admins!");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, red, "Error: This Player isnt Connected!");
GivePlayerMoney(targetid,ammount);
return 1;
}
help Dx

Seven_of_Nine
16/09/2012, 01:37 PM
sscanf(params, "ui",targetid,ammount)

instead of

sscanf(params, "ui",targetid)

funny, I could never get "u" to work..

Sig Hansen
16/09/2012, 01:54 PM
^^^^^ He Fixed It Now For The Whole Command
CMD:givemoney(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 4)
{
new string[128], giveplayerid, money;
if(sscanf(params, "ud", giveplayerid, money)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /givemoney [player] [money]");

if(IsPlayerConnected(giveplayerid))
{
GivePlayerCash(giveplayerid, money);
format(string, sizeof(string), "You have given %s $%d !",GetPlayerNameEx(giveplayerid),money);
SendClientMessageEx(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "%s has given %s $%d (/givemoney)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid),money);
Log("logs/stats.log", string);
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
}
return 1;
}

AtItsMax
16/09/2012, 02:29 PM
^^^^^ He Fixed It Now For The Whole Command
CMD:givemoney(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 4)
{
new string[128], giveplayerid, money;
if(sscanf(params, "ud", giveplayerid, money)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /givemoney [player] [money]");

if(IsPlayerConnected(giveplayerid))
{
GivePlayerCash(giveplayerid, money);
format(string, sizeof(string), "You have given %s $%d !",GetPlayerNameEx(giveplayerid),money);
SendClientMessageEx(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "%s has given %s $%d (/givemoney)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid),money);
Log("logs/stats.log", string);
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
}
return 1;
}

Please mention the error/problem.

Glint
16/09/2012, 02:33 PM
^^^^^ He Fixed It Now For The Whole Command
CMD:givemoney(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 4)
{
new string[128], giveplayerid, money;
if(sscanf(params, "ud", giveplayerid, money)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /givemoney [player] [money]");

if(IsPlayerConnected(giveplayerid))
{
GivePlayerCash(giveplayerid, money);
format(string, sizeof(string), "You have given %s $%d !",GetPlayerNameEx(giveplayerid),money);
SendClientMessageEx(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "%s has given %s $%d (/givemoney)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid),money);
Log("logs/stats.log", string);
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
}
return 1;
}


It's ui not ud.

AtItsMax
16/09/2012, 02:36 PM
It's ui not ud.
i and d, both fits the situation since they both are used for integers.

Lordzy
16/09/2012, 02:45 PM
It's ui not ud.

According to sscanf specifers, "i" works same like "d".
I saw it on sscanf 2.6 topic

Format Use
L(true/false) Optional logical truthity
l Logical truthity
K<callback>(default text) Optional custom operator
k<callback> Custom operator
B(binary) Optional binary number
b Binary number
N(any format number) Optional number
n Number
C(character) Optional character
c Character
I(integer) Optional integer
i Integer
D(integer) Optional integer
d Integer
H(hex value) Optional hex number
h Hex number
O(octal value) Optional octal value
o Octal value
F(float) Optional floating point number
f Floating point number
G(float/INFINITY/-INFINITY/NAN/NAN_E) Optional float with IEEE definitions
g Float with IEEE definitions
{ Open quiet section
} Close quiet section
P<delimiter> Invalid delimiter change
p<delimiter> Delimiter change
Z(string)[length] Invalid optional string
z(string)[length] Deprecated optional string
S(string)[length] Optional string
s[length] String
U(name/id) Optional user (bot/player)
u User (bot/player)
Q(name/id) Optional bot (bot)
q Bot (bot)
R(name/id) Optional player (player)
r Player (player)
A<type>(default)[length] Optional array of given type
a<type>[length] Array of given type
E<specification>(default) Optional enumeration of given layout
e<specification> Enumeration of given layout
'string' Search string
% Deprecated optional specifier prefix
Here "i" and "d" are integer specifiers.
So I think we can use "d" specifier also.

Glint
16/09/2012, 03:03 PM
d means doubles like 2.5 9.3 ...
i means integer numbers from infinite negative to infinity positive.

However yes mostly they are the same but i preffer i for this specific operation.

EDIT: and i don't think you can set player's money to a negative amount using d