Help with commands
#4

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

Reply


Messages In This Thread
Help with commands - by lolumadd - 02.10.2009, 00:43
Re: Help with commands - by ded - 02.10.2009, 00:51
Re: Help with commands - by lolumadd - 02.10.2009, 01:26
Re: Help with commands - by ded - 02.10.2009, 01:45
Re: Help with commands - by lolumadd - 02.10.2009, 02:04

Forum Jump:


Users browsing this thread: 1 Guest(s)