SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 15/08/2009, 06:34 AM   #11
Gappy
Huge Clucker
 
Gappy's Avatar
 
Join Date: Apr 2009
Posts: 493
Reputation: 16
Default Re: [INC] zcmd - simple command system [updated]

Quote:
Originally Posted by ZeeX
I think you placed first else statement where "Invalid rank" message is sent not to where it should be and also strtok should be called for rank too.
Try this:
pawn Code:
zcmd(setrank, playerid, params[])
{
  new string[128];
    new idx;
    new tmp[256];
    new sendername[MAX_PLAYER_NAME];
    new giveplayername[MAX_PLAYER_NAME];

  if (AccountInfo[playerid][AdminLevel] >= 3 || IsPlayerAdmin(playerid))
    {
        tmp = strtok(params, idx);
        if(isnull(tmp))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /giverank [playername/id] [rank 1-8]");
            SendClientMessage(playerid, COLOR_WHITE, "FUNCTION: Will give selected player selective rank.");
            return 1;
        }
        new giveplayerid = ReturnUser(tmp, playerid);
        new rank = strval(tmp);
        if(giveplayerid != INVALID_PLAYER_ID)
        {
          if ((rank >= 1) && (rank <= 8))
          {
                GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                printf("ADMIN: %s gave %s rank %s.", sendername, giveplayername, RankNames[rank-1]);
                format(string, sizeof(string), "Admin %s has set your rank to %s.", sendername, RankNames[rank-1]);
                SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
                format(string, sizeof(string), "ADMIN: Administrator %s has given %s rank %s.", sendername,giveplayername,RankNames[rank-1]);
                SendClientMessageToAll(COLOR_LIGHTRED, string);
                AccountInfo[giveplayerid][Rank] = rank-1;
                format(string, sizeof(string), "You have given %s rank %s.", giveplayername,RankNames[AccountInfo[giveplayerid][Rank]]);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
            }
        }
        else return SendClientMessage(playerid, COLOR_RED, "Invalid Rank!");
    }
    else SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
    return 1;
}
#else
That would say "Invalid Rank" if I tried to set the rank of a person that isn't connected to the server.
__________________
Gappy is offline   Reply With Quote
Old 15/08/2009, 07:01 AM   #12
Zeex
Guest
 
Posts: n/a
Default Re: [INC] zcmd - simple command system [updated]

pawn Code:
zcmd(setrank, playerid, params[])
{
  if (AccountInfo[playerid][AdminLevel] >= 3 || IsPlayerAdmin(playerid))
  {
     new tmp[256], idx;
     
     if (isnull(params) || isnull((tmp = strtok(params, idx))))
     {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /giverank [playername/id] [rank 1-8]");
        SendClientMessage(playerid, COLOR_WHITE, "FUNCTION: Will give selected player selective rank.");
        return 1;
     }
       
     new giveplayerid = ReturnUser(tmp, playerid);
     new rank = strval(strtok(params, idx));
       
     if (giveplayerid != INVALID_PLAYER_ID)
     {
       if ((rank >= 1) && (rank <= 8))
       {
         new sendername[MAX_PLAYER_NAME];
         new giveplayername[MAX_PLAYER_NAME];
         
         GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
         GetPlayerName(playerid, sendername, sizeof(sendername));
         printf("ADMIN: %s gave %s rank %s.", sendername, giveplayername, RankNames[rank-1]);
         format(tmp, sizeof(tmp), "Admin %s has set your rank to %s.", sendername, RankNames[rank-1]);
         SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, tmp);
         format(tmp, sizeof(tmp), "ADMIN: Administrator %s has given %s rank %s.", sendername,giveplayername,RankNames[rank-1]);
         SendClientMessageToAll(COLOR_LIGHTRED, tmp);
         AccountInfo[giveplayerid][Rank] = rank-1;
         format(tmp, sizeof(tmp), "You have given %s rank %s.", giveplayername,RankNames[AccountInfo[giveplayerid][Rank]]);
         SendClientMessage(playerid, COLOR_LIGHTBLUE, tmp);
      }
      else return SendClientMessage(playerid, COLOR_RED, "Invalid Rank!");
     }
     else return SendClientMessage(playerid, COLOR_RED, "Invalid Player ID!");
  }
  else SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
  return 1;
}
  Reply With Quote
Old 15/08/2009, 07:15 AM   #13
Gappy
Huge Clucker
 
Gappy's Avatar
 
Join Date: Apr 2009
Posts: 493
Reputation: 16
Default Re: [INC] zcmd - simple command system [updated]

The command doesn't work at all now, it just get "Unknown Command"
__________________
Gappy is offline   Reply With Quote
Old 15/08/2009, 08:07 AM   #14
Zeex
Guest
 
Posts: n/a
Default Re: [INC] zcmd - simple command system [updated]

hm... replace
pawn Code:
if (isnull(params) || isnull((tmp = strtok(params, idx))))
with
pawn Code:
tmp = strtok(params, idx);
if (isnull(tmp))
It should work.
  Reply With Quote
Old 15/08/2009, 08:38 AM   #15
Gappy
Huge Clucker
 
Gappy's Avatar
 
Join Date: Apr 2009
Posts: 493
Reputation: 16
Default Re: [INC] zcmd - simple command system [updated]

Thanks it works now.
__________________
Gappy is offline   Reply With Quote
Old 15/08/2009, 01:23 PM   #16
[MeTalgEaR]
Little Clucker
 
Join Date: Aug 2009
Posts: 5
Reputation: 0
Default Re: [INC] zcmd - simple command system [updated]

i do recommend u use dcmd instead its all out easier and more efficient for this type of thing although zcmd is good too
[MeTalgEaR] is offline   Reply With Quote
Old 15/08/2009, 01:32 PM   #17
GTA_Rules
Huge Clucker
 
Join Date: Aug 2008
Posts: 456
Reputation: 3
Default Re: [INC] zcmd - simple command system [updated]

Except for the parameter thingy, this is really nice. Good job.
GTA_Rules is offline   Reply With Quote
Old 15/08/2009, 06:27 PM   #18
.::: Ecko :::.
Huge Clucker
 
Join Date: May 2009
Posts: 389
Reputation: 2
Default Re: [INC] zcmd - simple command system [updated]

I WILL use this definitely.

Ecko
.::: Ecko :::. is offline   Reply With Quote
Old 16/08/2009, 02:16 AM   #19
RayPoda
Big Clucker
 
Join Date: Jun 2009
Posts: 88
Reputation: 0
Default Re: [INC] zcmd - simple command system [updated]

Nice release, ZeeX. Going to use this, bro.
RayPoda is offline   Reply With Quote
Old 16/08/2009, 10:16 AM   #20
Google63
Big Clucker
 
Join Date: Jun 2008
Posts: 113
Reputation: 0
Default Re: [INC] zcmd - simple command system [updated]

I really recommend you to use "zcmd" combined with "sscanf" function to check params; because strtok is really pieace of shit
Google63 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HowTo] Fast command processor: DCMD (0.3 Ready) DracoBlue Help Archive 8 28/11/2010 11:13 AM
fast command processor [mad]MLK Help Archive 1 22/08/2009 01:32 AM
Fast rcon command processor: RCMD (modified DCMD) Correlli Filterscripts 7 01/08/2009 12:02 PM
[INC+FS] Aero File Processor by Luby * Updated! luby Filterscripts 15 14/05/2009 01:07 PM


All times are GMT. The time now is 02:05 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.