Command is connected to each other?
#1

Hello,
i'm making a simple Role-Play server to learn scripting with
Pawno and have a little problem. I've made a [/b] command
which is used for OOC chat. And i made a [/ban] command
which is used by admins to ban players who don't follow the
rules. This is the script(s):

Код:
    if(!strcmp(cmdtext, "/b", true, 2))
    {
        if(!cmdtext[2])return SendClientMessage(playerid, COLOR_LIGHTRED, "[GEBRUIK]: /o [OOC Tekst]");
        	new str[128], Float:Pos[3];
        	GetPlayerName(playerid, str, sizeof(str));
       		GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
        	format(str, sizeof(str), "(( [%d] %s: %s ))", playerid, str, cmdtext[3]);

        	if(IsPlayerConnected(playerid))
	    	{
				if(IsPlayerInRangeOfPoint(playerid, 40, Pos[0], Pos[1], Pos[2]))
			    SendClientMessage(playerid, COLOR_GREY, str);
			}
			SetPlayerChatBubble(playerid, str, COLOR_GREY, 40, 4000);
			return 1;
		}
	if(strcmp("/ban", cmd, true) == 0)
	{
		if(dini_Int(bestand, "AdminLevel") > 3)
		{
			tmp = strtok(cmdtext,idx);
			if(!strlen(tmp) || strlen(tmp) > 5) {
				return SendClientMessage(playerid, COLOR_LIGHTRED,"[GEBRUIK]: /ban [id] [reden]");
			}

			new id = strval(tmp);

			if(!IsPlayerConnected(id)) {
				SendClientMessage(playerid, COLOR_RED,"[KICK]: De speler die u heeft geprobeerd te 'Bannen' was niet te bereiken.");
				return 1;
			}

			gMessage = strrest(cmdtext,idx);

			GetPlayerName(id,iName,sizeof(iName));
			SendClientMessage(id, COLOR_DARKRED,"[EGAMING]: Je bent verbannen uit eGaming RP.");

			if(strlen(gMessage) > 0) {
				format(Message,sizeof(Message),"Reden: %s",gMessage);
				SendClientMessage(id,COLOR_DARKRED,Message);
			}
			
            format(Message,sizeof(Message),"[ %s(%d) is verbannen door een anonieme Admin. Reden: %s ]",iName,id, gMessage);
			SendClientMessage(playerid, COLOR_DARKRED,Message);

			Ban(id);
			return 1;
			}
			else
			{
            SendClientMessage(playerid, COLOR_RED,"[BAN]: Deze commando is alleen te gebruiken door Moderators en Admins.");
				return 1;
			}
		}
The [/ban] command is copied from the base.pwn in the Samp server folder and
the [/b] is made by myself.

So when i'm ingame and type: "/b Hello." i see this:
(( [0] Ihsan_Cingisiz: Hello. )) --> That's okay, this is how it needs to be.
And when i'm ingame and type "/ban", i don't see the "[GEBRUIK]: ..." but i
see this:
(( [0] Ihsan_Cingisiz: n )) --> I just see the 'n' instead of the "[GEBRUIK]: ..."
thing. So this is completely wrong. What did i have do wrong and how can i
fix this problem?

Kind regards,
I. C.
Reply
#2

You see, thats becouse you use strcmp, i perfer dcmd or zcmd to you. You can ****** for it, im sure you'll find it..
Reply
#3

I think you forget return somewhere
Reply
#4

Moving the /ban command above the /b command, or setting a length (4) for the /ban command will most likely solve the problem.

See, commands are checked from top to bottom. So if you type /ban, the first thing the script encounters is /b. And since only the first 2 characters are compared /ban is the same as /b.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)