Command not working as intended
#5

Quote:
Originally Posted by Golf
Посмотреть сообщение
Hello,

PHP код:
CMD:makedonator(playeridparams[])
{
    if (
PlayerData[playerid][pAdmin] < 5)
        return 
SendErrorMessage(playerid"You don't have permission to use this command!");
    static
        
userid,
        
type[16],
        
message[128];
    if (
sscanf(params"us[16]"userid,type))
        return 
SendSyntaxMessage(playerid"/makedonator [playerid/name] [bronze/silver/gold/none]");
    if (
userid == INVALID_PLAYER_ID)
        return 
SendErrorMessage(playerid"You have specified an invalid player.");
    if (!
strcmp(param"bronze"true6))
    {
        
format(messagesizeof(message), "You have sed &s's donator rank to Bronze."ReturnName(userid0));
        
SendClientMessage(playeridCOLOR_REDmessage);
        
format(messagesizeof(message), "Your donator rank has been set to Bronze by %s."ReturnName(playerid0));
        
SendClientMessage(useridCOLOR_REDmessage);
        
PlayerData[userid][pDonator] = 1;
    }
    if (!
strcmp(param"silver"true6))
    {
        
format(messagesizeof(message), "You have sed &s's donator rank to Silver."ReturnName(userid0));
        
SendClientMessage(playeridCOLOR_REDmessage);
        
format(messagesizeof(message), "Your donator rank has been set to Silver by %s."ReturnName(playerid0));
        
SendClientMessage(useridCOLOR_REDmessage);
        
PlayerData[userid][pDonator] = 2;
    }
    if (!
strcmp(param"gold"true4))
    {
        
format(messagesizeof(message), "You have sed &s's donator rank to Gold."ReturnName(userid0));
        
SendClientMessage(playeridCOLOR_REDmessage);
        
format(messagesizeof(message), "Your donator rank has been set to Gold by %s."ReturnName(playerid0));
        
SendClientMessage(useridCOLOR_REDmessage);
        
PlayerData[userid][pDonator] = 3;
    }
    return 
1;

Quote:
Originally Posted by Bible
Посмотреть сообщение
Glad you asked. The person above your post left you over to the guess-what-you-did-wrong part.

CMD:makedonator requires two parameters. In your case: the targetid and the type of donator. You defined everything correctly till the sscanf function.
pawn Код:
(sscanf(params, "u", userid))
You 'told' sscanf that there is 1 parameter to look out for: targetid.
Since no 'type' parameter was defined in your sscanf function, it will ignore all the strcmp functions underneath returning 1 for the command after inserting the target's id.

We define the second parameter (the 'type' parameter) in the following code:
pawn Код:
(sscanf(params, "us[16]", userid, type))
And we define a size to the 's' specifier since 'type' is a string.
Thank you.

I have just tested the command but it still isn't working for some reason, you don't get the message nor does the playerdata update.
Reply


Messages In This Thread
Command not working as intended - by Luke_James - 22.02.2015, 17:33
Re: Command not working as intended - by Golf - 22.02.2015, 17:39
Re: Command not working as intended - by Luke_James - 22.02.2015, 18:17
Re: Command not working as intended - by AndySedeyn - 22.02.2015, 18:47
Re: Command not working as intended - by Luke_James - 22.02.2015, 20:08
Re: Command not working as intended - by AndySedeyn - 22.02.2015, 20:40
Re: Command not working as intended - by Luke_James - 22.02.2015, 21:08
Re: Command not working as intended - by AndySedeyn - 22.02.2015, 21:14
Re: Command not working as intended - by Luke_James - 22.02.2015, 21:24
Re: Command not working as intended - by AndySedeyn - 22.02.2015, 21:26

Forum Jump:


Users browsing this thread: 1 Guest(s)