sscanf problem with a command
#1

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.
Reply
#2

us[50]i is correct
Reply
#3

Quote:

if(IsPlayerConnectedEx(giveplayerid))

Use
Код:
if(IsPlayerConnected(giveplayerid))
Reply
#4

Quote:
Originally Posted by Blademaster680
Посмотреть сообщение
Use
Код:
if(IsPlayerConnected(giveplayerid))
Or he could show his IsPlayerConnectedEx
Reply
#5

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...
Reply
#6

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
Reply
#7

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;
}
Reply
#8

on sscanf put the string on the end

and this

pawn Код:
if(sscanf(params, "colt-45", weaponname))
replace for strcmp.
Reply
#9

Why did you use usn price is an integer use "i" for it.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)