SA-MP Forums Archive
Help with commands - 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: Help with commands (/showthread.php?tid=99985)



Help with commands - lolumadd - 02.10.2009

As an example, If I want to do a /kick command (/kick <id> <reason>) I can do

id = strval(cmdtext[9]);

As for the <reason> param of the command I am unsure. I have tried this (untested). Is the correct way?

pawn Код:
if((pos = strfind(cmdtext, " ", 6)) != -1) return pos = strfind(cmdtext, " ", 6)) != -1);
Then
pawn Код:
if(strval[pos] >= 0) return The number cannot be a number!
Im just using an example. Would that work?


Re: Help with commands - ded - 02.10.2009

Why are you using strfind? O_o




Re: Help with commands - lolumadd - 02.10.2009

Quote:
Originally Posted by » Pawnst★r «
Why are you using strfind? O_o

Well, my friend made the code and he sent it to me O_o


Re: Help with commands - ded - 02.10.2009

Oooh, well .. here is an example. This is from "base.pwn" which is shipped with the 0.3 scripting package:

pawn Код:
if(strcmp("/kick", cmd, true) == 0)
    {
      if(IsPlayerAdmin(playerid)) {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp) || strlen(tmp) > 5) {
                return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /kick (id) [reason]");
            }
           
            new id = strval(tmp);

            if(!IsPlayerConnected(id)) {
                SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/kick : Bad player ID");
                return 1;
            }
           
            gMessage = strrest(cmdtext,idx);
           
            GetPlayerName(id,iName,sizeof(iName));
            SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been kicked from the server.");

            if(strlen(gMessage) > 0) {
                format(Message,sizeof(Message),"Reason: %s",gMessage);
                SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
            }
           
            format(Message,sizeof(Message),">> %s(%d) has been kicked.",iName,id);
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);
           
            Kick(id);
            return 1;
        } else {
      SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/kick : You are not an admin");
            return 1;
        }
    }




Re: Help with commands - lolumadd - 02.10.2009

Im not using strtok.