Sscanf error.
#1

I really have no idea how to fix this.

This is my error:
Код:
error 035: argument type mismatch (argument 1)
This is my command
Код:
CMD:givemoney(playerid, params)
{
	new id, idname[MAX_PLAYERS], string[256], amount;
	GetPlayerName(id, idname, sizeof(idname));
	if(IsPlayerConnected(id))
	{
		if(sscanf(params, "ui", id,amount)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/givemoney [playerid] [money]");
		GivePlayerMoney(id, amount);
		format(string, sizeof(string), "AdmCmd: You have given %s %d$.", idname, amount);
		SendClientMessage(playerid, COLOR_ADMIN, string);
	}
	else return SendClientMessage(playerid, COLOR_LOL, "Acel jucator nu este connectat.");
	return 1;
}
Reply
#2

PHP код:
CMD:givemoney(playeridparams[])
{
    new 
ididname[MAX_PLAYERS], string[256], amount;
    
GetPlayerName(ididnamesizeof(idname));
    if(
IsPlayerConnected(id))
    {
        if(
sscanf(params"ui"id,amount)) return SendClientMessage(playeridCOLOR_GREY"Syntax: {FFFFFF}/givemoney [playerid] [money]");
        
GivePlayerMoney(idamount);
        
format(stringsizeof(string), "AdmCmd: You have given %s %d$."idnameamount);
        
SendClientMessage(playeridCOLOR_ADMINstring);
    }
    else return 
SendClientMessage(playeridCOLOR_LOL"Acel jucator nu este connectat.");
    return 
1;

This shud work, just added [] infront of params
Reply
#3

Quote:
Originally Posted by PMH
Посмотреть сообщение
PHP код:
CMD:givemoney(playeridparams[])
{
    new 
ididname[MAX_PLAYERS], string[256], amount;
    
GetPlayerName(ididnamesizeof(idname));
    if(
IsPlayerConnected(id))
    {
        if(
sscanf(params"ui"id,amount)) return SendClientMessage(playeridCOLOR_GREY"Syntax: {FFFFFF}/givemoney [playerid] [money]");
        
GivePlayerMoney(idamount);
        
format(stringsizeof(string), "AdmCmd: You have given %s %d$."idnameamount);
        
SendClientMessage(playeridCOLOR_ADMINstring);
    }
    else return 
SendClientMessage(playeridCOLOR_LOL"Acel jucator nu este connectat.");
    return 
1;

This shud work, just added [] infront of params
Damn, thanks!
Reply
#4

The command logic is false!

It should be:

PHP код:
CMD:givemoney(playeridparams[])
{
    new 
id,amout;
    if(
sscanf(params"ui"id,amount)) return SendClientMessage(playeridCOLOR_GREY"Syntax: {FFFFFF}/givemoney [playerid] [money]");
    if(!
IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_LOL"Acel jucator nu este connectat.");
    new 
string[128];
    
GetPlayerName(idstringMAX_PLAYER_NAME);
    
GivePlayerMoney(idamount);
    
format(stringsizeof(string), "AdmCmd: You have given %s %d$."stringamount);
    return 
SendClientMessage(playeridCOLOR_ADMINstring);

Reply
#5

Quote:
Originally Posted by danielpalade
Посмотреть сообщение
I really have no idea how to fix this.

This is my error:
Код:
error 035: argument type mismatch (argument 1)
This is my command
Код:
CMD:givemoney(playerid, params)
{
	new id, idname[MAX_PLAYERS], string[256], amount;
	GetPlayerName(id, idname, sizeof(idname));
	if(IsPlayerConnected(id))
	{
		if(sscanf(params, "ui", id,amount)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/givemoney [playerid] [money]");
		GivePlayerMoney(id, amount);
		format(string, sizeof(string), "AdmCmd: You have given %s %d$.", idname, amount);
		SendClientMessage(playerid, COLOR_ADMIN, string);
	}
	else return SendClientMessage(playerid, COLOR_LOL, "Acel jucator nu este connectat.");
	return 1;
}
I dont think that IsPlayerConnected(id) will actually check if the player is connected as it is before the sscanf function is called.

try this:

Код:
CMD:givemoney(playerid, params)
{
	new id, idname[MAX_PLAYERS], string[256], amount;
	GetPlayerName(id, idname, sizeof(idname));
	if(sscanf(params, "ui", id,amount)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/givemoney [playerid] [money]");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_LOL, "Acel jucator nu este connectat.");
	GivePlayerMoney(id, amount);
	format(string, sizeof(string), "AdmCmd: You have given %s %d$.", idname, amount);
	SendClientMessage(playerid, COLOR_ADMIN, string);
	return 1;
}
Reply
#6

Quote:
Originally Posted by Jakwob
Посмотреть сообщение
try this:
Idiot, you're Code is false too.

It's hard to read the post above you!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)