SA-MP Forums Archive
Sscanf 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: Sscanf error. (/showthread.php?tid=583842)



Sscanf error. - danielpalade - 31.07.2015

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;
}



Re: Sscanf error. - PMH - 31.07.2015

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


Re: Sscanf error. - danielpalade - 31.07.2015

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!


AW: Sscanf error. - Kaliber - 31.07.2015

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);




Re: Sscanf error. - Jakwob - 31.07.2015

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;
}



AW: Re: Sscanf error. - Kaliber - 31.07.2015

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

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