Command not working
#1

pawn Код:
if(strcmp(cmdtext, "/makehelper", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] >= 5 || PlayerInfo[playerid][pHelpers] >= 3)
    {
        new targetid, level;
        if(sscanf(cmdtext,"ui", targetid, level)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE] /makehelper [id] [level]");
        format(string, sizeof(string), "You have made (%d) %s a Helper, current level: %d", targetid, PlayerName(targetid), level);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "You were made a Helper by admin/head Helper (%d)%s", playerid, PlayerName(playerid));
        SendClientMessage(targetid, COLOR_WHITE, string);
        PlayerInfo[targetid][pHelpers] = level;
    }
    printf("/makehlper command returned");
    return 1;
}
This command isnt reaching the return point, is there some srt of problem?
Reply
#2

try this
pawn Код:
CMD:makehelper(playerid, params[])
{
    new id, level;
    if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");
     format(string, sizeof(string), "You have made (%d) %s a Helper, current level: %d", id, PlayerName(id), level);
     SendClientMessage(playerid, COLOR_WHITE, string);
     format(string, sizeof(string), "You were made a Helper by admin/head Helper (%d)%s", playerid, PlayerName(playerid));
     SendClientMessage(targetid, COLOR_WHITE, string);
     PlayerInfo[id][pHelpers] = level;
    return 1;
}
Reply
#3

Quote:
Originally Posted by Windows32
Посмотреть сообщение
try this
pawn Код:
CMD:makehelper(playerid, params[])
{
    new id, level;
    if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");
     format(string, sizeof(string), "You have made (%d) %s a Helper, current level: %d", id, PlayerName(id), level);
     SendClientMessage(playerid, COLOR_WHITE, string);
     format(string, sizeof(string), "You were made a Helper by admin/head Helper (%d)%s", playerid, PlayerName(playerid));
     SendClientMessage(targetid, COLOR_WHITE, string);
     PlayerInfo[id][pHelpers] = level;
    return 1;
}
Not using ZCMD yet... I think SSCANF is bugged, I get no warnings/errors and stuff the sscanf prefers to not work.
Reply
#4

Yeah, sscanf is the problem, use:

Код:
if(sscanf(cmdtext, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");//your code
//change cmdtext to params and it should work(as Windows32 did in his post to)
if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");//your code
Hope It helped ^^
Reply
#5

Quote:
Originally Posted by Ranama
Посмотреть сообщение
Yeah, sscanf is the problem, use:

Код:
if(sscanf(cmdtext, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");//your code
//change cmdtext to params and it should work(as Windows32 did in his post to)
if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid,-1, "USAGE: /makehelper [id] [level]");//your code
Hope It helped ^^
No, troll, params isnt part of the command is it?
Reply
#6

It seems like sscanf is stopping the rest of the command from working.

and am using strcmp, check the first post
Reply
#7

Just a note. ZCMD is the exact same principle as for when you're using strcmp. The only difference is the parameters of the command.

STRCMP:
pawn Код:
if(strcmp(cmdtext, "/makehelper", true) == 0)
ZCMD:
pawn Код:
CMD:makehelper(playerid, params[])
It's the exact same and much more efficient.
Reply
#8

Quote:
Originally Posted by SA-MPDrifter
Посмотреть сообщение
Just a note. ZCMD is the exact same principle as for when you're using strcmp. The only difference is the parameters of the command.

STRCMP:
pawn Код:
if(strcmp(cmdtext, "/makehelper", true) == 0)
ZCMD:
pawn Код:
CMD:makehelper(playerid, params[])
It's the exact same and much more efficient.
I actually found a solution for mixing ZCMD & STRCMP in the script, I've fixed the sscanf issue but whenever I do that command, it returns, Unknown Command at the bottom, so it isnt reaching return 1; <- its a zcmd version now
Reply
#9

Quote:
Originally Posted by Riddy
Посмотреть сообщение
I actually found a solution for mixing ZCMD & STRCMP in the script, I've fixed the sscanf issue but whenever I do that command, it returns, Unknown Command at the bottom, so it isnt reaching return 1; <- its a zcmd version now
You can't run strcmd and Zcmd at the same time! either you use strcmd or zcmd! else it will throw SERVER:UNKNOWN COMMAND!
Reply
#10

Quote:
Originally Posted by HarlemSAMP
Посмотреть сообщение
You can't run strcmd and Zcmd at the same time! either you use strcmd or zcmd! else it will throw SERVER:UNKNOWN COMMAND!
Erm, not really

Quote:
Originally Posted by ******
Посмотреть сообщение
Yes you can. "OnPlayerCommandText" is never called, but there are two new callbacks - "OnPlayerCommandReceived" and "OnPlayerCommandPerformed" added. If you put your strcmp commands in the former they should work - not that it's at all recommended.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)