[Tutorial] [Basics] Making Commands with Parameters [ZMCD && Sscanf]
#15

Good evening!

I've used your tutorial to do the following command but somehow, somewhere, i've failed:

pawn Code:
CMD:phone(playerid, params[])
{
    new cmd[6];
    if(sscanf(params,"s[6]", cmd))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /phone <cmd>");
        SendClientMessage(playerid, COLOR_WHITE, "COMMANDS: call <number>, answer, hangup, toggle, sms <number> <text>");
    }
    else if(PlayerInfo[playerid][pPhone] == 0) return SendClientMessage(playerid, COLOR_RED, "You don't have a phone!");
    else if(!strcmp(cmd, "call", true))
    {
        new phonenumber;
        if(sscanf(params, "i", phonenumber)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /phone call <number>");
        else
        {
            format(gString, sizeof(gString), "** You are calling: %d **", phonenumber);
            SendClientMessage(playerid, COLOR_DARK_RED, gString);
            foreach (Player, i)
            {
                if(PlayerInfo[i][pPhone] == phonenumber && i != playerid)
                {
                    SpeakingWith[playerid] = i;
                    SpeakingWith[i] = playerid;
                    format(gString, sizeof(gString), "%s's phone rings.", RemoveUnderScore(i));
                    SendLocalMessage(i, COLOR_ACTION, gString, 15.0);
                    format(gString, sizeof(gString), "** You are being called by: %d **", PlayerInfo[playerid][pPhone]);
                    SendClientMessage(i, COLOR_DARK_RED, gString);
                    SendClientMessage(i, COLOR_WHITE, "HINT: Type /phone answer to talk or /phone hangup to reject the call.");
                    return 1;
                }
            }
            SendClientMessage(playerid, COLOR_DARK_RED, "** Busy tone **");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "COMMANDS: call <number>, answer, hangup, toggle, sms <number> <text>");
    }
    return 1;
}
When I type /phone call 123456 it's says

Quote:

USAGE: /phone call <number>

Can you please tell me what am I doing wrong?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)