SA-MP Forums Archive
Weird command issue - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Weird command issue (/showthread.php?tid=255729)



Weird command issue - Jonteh - 17.05.2011

I'm not the best at SA-MP scripting and i'm coding a server from scratch to train my skills and build my community up.

pawn Код:
if(!strcmp(cmdtext, "/b", true, 3))
    {
        if(!cmdtext[2])return SendClientMessage(playerid, COLOR_ERRORRED, "USAGE: /b [ooc chat]");

        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "(( %s: %s ))", str, cmdtext[3]);
       
        ProxDetector(10.0, playerid, str, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);

        return 1;
    }
When I type /b text it works properly, but when I type /ban userid reason it will show up like this:

(( Jonty: an 1 noob ))

So, it's using the /b not the /ban

Can anyone help?


Re: Weird command issue - Seven_of_Nine - 17.05.2011

Yes, because it finds in /ban the /b. So I recommend you to use a proper command processor. Like ZCMD, or DCMD.


Re: Weird command issue - Jonteh - 17.05.2011

I don't like ZCMD or DCMD


Re: Weird command issue - park4bmx - 17.05.2011

change if(!strcmp(cmdtext, "/b", true, 3))
to
if(!strcmp(cmdtext, "/b", true, 10))
see if it works


Re: Weird command issue - Naruto_Emilio - 17.05.2011

pawn Код:
if(!strcmp(cmdtext, "/b", true, 2))// Here it must be 2 cause there is not 3 words (Ex: /=> 1, b=> 2)
    {
        if(!cmdtext[2])return SendClientMessage(playerid, COLOR_ERRORRED, "USAGE: /b [ooc chat]");

        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "(( %s: %s ))", str, cmdtext[3]);
       
        ProxDetector(10.0, playerid, str, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);

        return 1;
    }



Re: Weird command issue - park4bmx - 17.05.2011

Quote:
Originally Posted by Naruto_Emilio
Посмотреть сообщение
pawn Код:
if(!strcmp(cmdtext, "/b", true, 2))// Here it must be 2 cause there is not 3 words (Ex: /=> 1, b=> 2)
    {
        if(!cmdtext[2])return SendClientMessage(playerid, COLOR_ERRORRED, "USAGE: /b [ooc chat]");

        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "(( %s: %s ))", str, cmdtext[3]);
       
        ProxDetector(10.0, playerid, str, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);

        return 1;
    }
yeah but then if you have a command starting with /b like
Example
/bike the command /b will be run because you put it as
true, 2 that means anything starting with /b will be recognized as the /b command if you see what i mean correct me if im wrong


Re: Weird command issue - grand.Theft.Otto - 17.05.2011

The 3 in that line should be a 2 since /b is 2 characters, not 3.

/ban should be 4 because it has 4 characters. Yes, a forward slash (/) counts as one of the characters in pawn.

Tell me if it works.


Re: Weird command issue - Jonteh - 17.05.2011

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
The 3 in that line should be a 2 since /b is 2 characters, not 3.

/ban should be 4 because it has 4 characters. Yes, a forward slash (/) counts as one of the characters in pawn.

Tell me if it works.
Same issue

Does anyone want to help me convert my script to DCMD tonight? I'll be out during the day and this could bring you into my project which is sure to be big...


Re: Weird command issue - grand.Theft.Otto - 17.05.2011

I'll convert your /b command for you:

pawn Код:
// top of script

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

// OnPlayerCommandText

dcmd(b,1,cmdtext) // b = command name 1 = command length cmdtext = not 100% sure what it is lol

// bottom of script

dcmd_b(playerid,params[])
{
    if(!strlen(params))  return SendClientMessage(playerid, COLOR_ERRORRED, "USAGE: /b [ooc chat]");
       
    new str[128];
    GetPlayerName(playerid, str, sizeof(str));
    format(str, sizeof(str), "(( %s: %s ))", str, cmdtext[3]);      
    ProxDetector(10.0, playerid, str, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
    return 1;
}



Re: Weird command issue - Jonteh - 18.05.2011

thanks, i've now rewritten my whole script. thanks for doing that it has helped me learn a much better command handler.

<3