admin commands
#1

could someone give me and exsample of a kick or a ban command? i need it so i can continue making more on my own.


thanks!
Reply
#2

Here is a command to kick a player.

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp("/kick", cmd, true) == 0)
{
if(AdminLevel[playerid] < 1) return 0;
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_PDRIVER, "[ ! ] USAGE : /kick <ID du joueur>");
if(!isNumeric(tmp)) return SendClientMessage(playerid, COLOR_RED, "[ ! ] ID du joueur invalide !");
new otherid = strval(tmp);
if(!IsPlayerConnected(otherid)) return SendClientMessage(playerid, COLOR_RED, "[ ! ] Ce joueur n'est pas connectй !");
if(otherid == playerid) return SendClientMessage(playerid, COLOR_RED, "[ ! ] Vous ne pouvez pas vous kicker vous mкme !");
if(AdminLevel[otherid] - AdminLevel[playerid] >= 0) return SendClientMessage(playerid, COLOR_RED, "[ ! ] Vous n'avez pas le droit de kicker ce joueur !");
new AdminName[MAX_PLAYER_NAME], KickedName[MAX_PLAYER_NAME];
GetPlayerName(playerid, AdminName, sizeof(AdminName));
GetPlayerName(otherid, KickedName, sizeof(KickedName));
new string[256];
format(string, 256,"[ ! ] %s a йtй kickй par %s !", KickedName,AdminName);
TogglePlayerControllable(otherid,0);
SendClientMessageToAll( 0xff6348ff, string);
SendClientMessage(otherid,0xff6348ff, "[ ! ] Vous кtes kickй pour ( VOUS ETES KICKЙ DU SERVEUR !!! )");
new Float: x, Float: y, Float: z;
GetPlayerPos(otherid,x,y,z);
SetPlayerPos(otherid,x,y,z);
Kick(otherid);
return 1;
}
return 0;
}
Reply
#3

All you need is to look better in filter scripts you downloaded in server files.
Reply
#4

Here you go!
pawn Код:
dcmd_banip(playerid, params[])
{
    new index = 0;
  tmp2 = strtok(params, index);
    if (pInfo[playerid][pAdmin] == 0)
    {
        SystemMessage(playerid, "You are not an Administrator.");
        return 1;
    }
  if(!strlen(tmp2))
    {
        SystemMessage(playerid, "Correct usage: '/banip [playername] [reason]'");
        return 1;
    }
    new string[MAX_STRING];
    new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp2);
    if (IsPlayerConnected(giveplayerid))
    {
        format(string, sizeof(string), "You have been IP banned by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
        SendClientMessage(giveplayerid, COLOR_SYSTEM, string);
        format(string, sizeof(string), "Player %s has been IP banned by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
        SendClientMessageToAll(COLOR_SYSTEM, string);
        format(string, sizeof(string), "%s has been IP banned by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
        print(string);
        gettime(hour, minute, second);
        getdate(year, month, day);
        format(string,sizeof(string),"Player %s IP banned player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
        ServerLog(string);
        BanPlayer(giveplayerid, "");
  }
    else
  {
        SendClientMessage(playerid, COLOR_SYSTEM, "That player is not active.");
    }
  return 1;
}
Reply
#5

yes good, but these two are from a admin script:

1. i dont use admin levels, it should be for Rcon admins.
2. i use the standard way, so
Код:
if (strcmp("/help", cmdtext, true, 10) == 0)
	{
that way.
Reply
#6

Il tell you the main bit,
Il update later with the full one,

The main bit of kick and ban commands are:
Kick(playerid);
and
Ban(playerid);
Reply
#7

i know, but if i do only that, it'll ban me myself xD
Reply
#8

Quote:
Originally Posted by laserhel50
i know, but if i do only that, it'll ban me myself xD
Add it to a id system,
well i call it a id system anyway xd
So if you put that on a "id system"
it would be

Kick(giveplayerid);
and
Ban(giveplayerid);
Reply
#9

1. www.sa-mp.com and download the R4 server.
2. Unrar and open base.pwn with pawno. (It includes rcon /kick and /ban, plus a /pm command.)
Hope I helped.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)