this cmd doesnt work..
#1

pawn Код:
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
Reply
#2

Код:
sscanf(params, "ui",targetid,ammount)
instead of
Код:
sscanf(params, "ui",targetid)
funny, I could never get "u" to work..
Reply
#3

^^^^^ He Fixed It Now For The Whole Command
PHP код:
CMD:givemoney(playeridparams[])
{
    if (
PlayerInfo[playerid][pAdmin] >= 4)
    {
        new 
string[128], giveplayeridmoney;
        if(
sscanf(params"ud"giveplayeridmoney)) return SendClientMessageEx(playeridCOLOR_GREY"USAGE: /givemoney [player] [money]");

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

Reply
#4

Quote:
Originally Posted by Sig Hansen
Посмотреть сообщение
^^^^^ He Fixed It Now For The Whole Command
PHP код:
CMD:givemoney(playeridparams[])
{
    if (
PlayerInfo[playerid][pAdmin] >= 4)
    {
        new 
string[128], giveplayeridmoney;
        if(
sscanf(params"ud"giveplayeridmoney)) return SendClientMessageEx(playeridCOLOR_GREY"USAGE: /givemoney [player] [money]");
        if(
IsPlayerConnected(giveplayerid))
        {
            
GivePlayerCash(giveplayeridmoney);
            
format(stringsizeof(string), "You have given %s $%d !",GetPlayerNameEx(giveplayerid),money);
            
SendClientMessageEx(playeridCOLOR_WHITEstring);
            
format(stringsizeof(string), "%s has given %s $%d (/givemoney)"GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid),money);
            
Log("logs/stats.log"string);
        }
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_GRAD1"You are not authorized to use that command.");
    }
    return 
1;

Please mention the error/problem.
Reply
#5

Quote:
Originally Posted by Sig Hansen
Посмотреть сообщение
^^^^^ He Fixed It Now For The Whole Command
PHP код:
CMD:givemoney(playeridparams[])
{
    if (
PlayerInfo[playerid][pAdmin] >= 4)
    {
        new 
string[128], giveplayeridmoney;
        if(
sscanf(params"ud"giveplayeridmoney)) return SendClientMessageEx(playeridCOLOR_GREY"USAGE: /givemoney [player] [money]");
        if(
IsPlayerConnected(giveplayerid))
        {
            
GivePlayerCash(giveplayeridmoney);
            
format(stringsizeof(string), "You have given %s $%d !",GetPlayerNameEx(giveplayerid),money);
            
SendClientMessageEx(playeridCOLOR_WHITEstring);
            
format(stringsizeof(string), "%s has given %s $%d (/givemoney)"GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid),money);
            
Log("logs/stats.log"string);
        }
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_GRAD1"You are not authorized to use that command.");
    }
    return 
1;

It's ui not ud.
Reply
#6

Quote:
Originally Posted by Lexi'
Посмотреть сообщение
It's ui not ud.
i and d, both fits the situation since they both are used for integers.
Reply
#7

Quote:
Originally Posted by Lexi'
Посмотреть сообщение
It's ui not ud.
According to sscanf specifers, "i" works same like "d".
I saw it on sscanf 2.6 topic
Quote:
Originally Posted by ******
Код:
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.
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)