sscanf problem with a command -
diego200052 - 29.07.2014
I have this code
pawn Код:
CMD:sellweapon(playerid, params[])
{
if(sscanf(params, "us[50]n",giveplayerid, weaponname, price)) return SendClientMessage(playerid, -1,"Use /sellweapon [id] [weapon] [price]");
if(IsPlayerConnectedEx(giveplayerid))
{
if(sscanf(params, "colt-45", weaponname))
{
more code.... but not necesary
The problem is when for example I have a player with id 5 and another with id 12 but when introduce the command /sellweapon 5 colt-45 100 says in the chat "that player is not connected to the server" but y thing the problem is here:
pawn Код:
if(sscanf(params, "us[50]n",giveplayerid, weaponname, price))
I donґt know if the "us[50]n" is correct.
Re: sscanf problem with a command -
Battlezone - 29.07.2014
us[50]i is correct
Re: sscanf problem with a command -
Blademaster680 - 29.07.2014
Quote:
if(IsPlayerConnectedEx(giveplayerid))
|
Use
Код:
if(IsPlayerConnected(giveplayerid))
Re: sscanf problem with a command -
Don_Cage - 29.07.2014
Quote:
Originally Posted by Blademaster680
Use
Код:
if(IsPlayerConnected(giveplayerid))
|
Or he could show his IsPlayerConnectedEx
Re: sscanf problem with a command -
Blademaster680 - 29.07.2014
Quote:
Originally Posted by Don_Cage
Or he could show his IsPlayerConnectedEx
|
He could, but IsPlayerConnected does what he is wanting to do. and that is checking if the player is connected. Unless in his IsPlayerConnectedEx, it declares they are logged in...
Re: sscanf problem with a command -
Don_Cage - 29.07.2014
Quote:
Originally Posted by Blademaster680
He could, but IsPlayerConnected does what he is wanting to do. and that is checking if the player is connected. Unless in his IsPlayerConnectedEx, it declares they are logged in...
|
I think it declares logged in or something else, if not.. There is no reason to make a new function for it
Re: sscanf problem with a command -
SickAttack - 29.07.2014
pawn Код:
CMD:sellweapon(playerid, params[])
{
new giveplayerid, weaponname[50], price;
if(sscanf(params, "us[50]i", giveplayerid, weaponname, price)) return SendClientMessage(playerid, -1, "Use /sellweapon [id] [weapon] [price]");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1, "Player isn't connected to the server right now.");
if(strcmp(weaponname, "colt-45", true) == 0)
// Code..
return 1;
}
Re: sscanf problem with a command -
PT - 29.07.2014
on sscanf put the string on the end
and this
pawn Код:
if(sscanf(params, "colt-45", weaponname))
replace for strcmp.
Re: sscanf problem with a command -
Beckett - 29.07.2014
Why did you use us
n price is an integer use "
i" for it.
Re: sscanf problem with a command -
diego200052 - 29.07.2014
Problem Solved I donґt define the string correct. new weaponname[50];
And have a another error I solved change this
pawn Код:
if(sscanf(params, "colt-45", weaponname))
for this:
pawn Код:
if(strcmp(weaponname, "colt-45", true) == 0)
Thanks for all