09 Juni, 2012

PAWNO Programming | A simple admin script for SA-MP.

Hallo guys..

Where ever you're, hope you're in fine condition, okay let's go to the point.

In this script, we need ZCMD , sscanf , and a_samp absolutely, haha.

Okay let's begin...

firstly, you must type this on top of your script

#include <a_samp>
#include <Zcmd>
#include <sscanf>

Okay we've included the plugins, and then type this under of that words

enum pDetails {
       Admin
};
new pInfo[MAX_PLAYERS][pDetails];

Alright now, we can create the CMDs. Type this on bottom of your script

CMD:setadmin(playerid, params[])
{
      new id, level, msg[240], aname[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
      if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, [YOUR COLOR], "COMMAND: /setadmin [playerid] [level]");


It means you've set how the command gonna work, so they shall get your target id by the numbers you've typed, and the level too. Okay let's continue this.

     if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, [YOURCOLOR], "COMMAND: Player doesn't connect");

It means, if your target hasn't connect they'll denied your command following that reason, okay go on.

   if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, [YOURCOLOR], "COMMAND: You're not an admin");

Okay I'll explain it. It means only RCON Admin can acess this command, so you must logged in as an admin to promote someone.

    else
    {
           GetPlayerName(playerid, aname, sizeof(aname));
           GetPlayerName(id, name, sizeof(name));
           format(msg, sizeof(msg), "Administrator %s has just promoted %s[%d] to be an admin level %d", aname, name, id, level);
           SendClientMessageToAll([YOURCOLOR], msg);
           pInfo[id][Admin] = level;
    }
  return 1;
}

Okay I'm going to explain it guys, haha. It means this part gonna get your name, and your target name too. Then it'll inform all players about this news, then set your target being an admin quickly :D

In complete parts

CMD:setadmin(playerid, params[])
{
      new id, level, msg[240], aname[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
      if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, [YOUR COLOR], "COMMAND: /setadmin [playerid] [level]");
       if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, [YOURCOLOR], "COMMAND: Player doesn't connect");
       if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, [YOURCOLOR], "COMMAND: You're not an admin");
       else
      {
           GetPlayerName(playerid, aname, sizeof(aname));
           GetPlayerName(id, name, sizeof(name));
           format(msg, sizeof(msg), "Administrator %s has just promoted %s[%d] to be an admin level %d", aname, name, id, level);
           SendClientMessageToAll([YOURCOLOR], msg);
           pInfo[id][Admin] = level;
      }
  return 1;
}

At last you've done a CMD, okay guys thanks for visiting my blog, i'll post the other CMD, see you.
Byee...

Best regrads, Ryu

Tidak ada komentar:

Posting Komentar