SA-MP Forums Archive
Command not working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command not working (/showthread.php?tid=366477)



Command not working - Riddy - 06.08.2012

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?


Re: Command not working - Elysian` - 06.08.2012

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;
}



Re: Command not working - Riddy - 06.08.2012

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.


Re: Command not working - Ranama - 06.08.2012

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 ^^


Re: Command not working - Riddy - 06.08.2012

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?


Re: Command not working - Riddy - 06.08.2012

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

and am using strcmp, check the first post


Re: Command not working - SA-MPDrifter - 06.08.2012

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.


Re: Command not working - Riddy - 07.08.2012

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


Respuesta: Re: Command not working - HarlemSAMP - 07.08.2012

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!


Re: Respuesta: Re: Command not working - Riddy - 07.08.2012

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.