i need very simple Admin lvls :) 1+ Repotions
#1

hi guys i need very very Simple admin lvl sys give me only two lvls 1"Admin" 2"Owner"
Thanks
i really need one for my TDM server
Reply
#2

Compile as Filterscript and load onto your server:
pawn Код:
#include <a_samp>
new aLevel[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new index;
    cmd = strtok(cmdtext, index);
   
    if(!strcmp(cmd, "/makeadmin", true))
    {
        if(IsPlayerAdmin(playerid) || aLevel[playerid] == 2) // You must be RCon logged or aLevel 2 to make someone an admin
        {
            new param1[256];
            param1 = strtok(cmdtext, index);
            new param2[256];
            param2 = strtok(cmdtext, index);
           
            new player = strval(param1);
            new level = strval(param2);
           
            if(!IsPlayerConnected(player)) return 0;
            if(level < 0 || level > 2) return 0;
           
            aLevel[player] = level;
            SendClientMessage(playerid, 0x00FF00FF, "You have made this player an admin.");
            SendClientMessage(player, 0x00FF00FF, "You are now an admin.");
            return 1;
        }
    }
   
    if(!strcmp(cmd, "/mycommand", true))
    {
        if(aLevel[playerid] == 1)
        {
            // Make your command
        }
    }
    return 0;
}

stock strtok(const string[], &index)
{

    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#3

Hmm Can u make it as ZCMD?
cuz i dunno how do it with this
Reply
#4

Hmm i got 5 errors
Код:
CMD:makeadmin(playerid, params[])
{
	new cmd[256];
	new index;
	cmd = strtok(cmdtext, index);

	if(!strcmp(cmd, "/makeadmin", true))
	{
		if(IsPlayerAdmin(playerid) || aLevel[playerid] == 2) // You must be RCon logged or aLevel 2 to make someone an admin
		{
			new param1[256];
			param1 = strtok(cmdtext, index);
			new param2[256];
			param2 = strtok(cmdtext, index);

			new player = strval(param1);
			new level = strval(param2);

			if(!IsPlayerConnected(player)) return 0;
			if(level < 0 || level > 2) return 0;

			aLevel[player] = level;
			SendClientMessage(playerid, 0x00FF00FF, "You have made this player an admin.");
			SendClientMessage(player, 0x00FF00FF, "You are now an admin.");
			return 1;
		}
 }
 }
stock strtok(const string[], &index)
{

	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}
there is the ERRORS
Код:
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(8) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(8) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(795) : error 017: undefined symbol "cmdtext"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(802) : error 017: undefined symbol "cmdtext"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(804) : error 017: undefined symbol "cmdtext"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(794) : warning 203: symbol is never used: "index"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(794 -- 818) : warning 209: function "cmd_makeadmin" should return a value
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#5

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new cmd[256];
    new index;
    cmd = strtok(cmdtext, index);

    if(!strcmp(cmd, "/makeadmin", true))
    {
        if(IsPlayerAdmin(playerid) || aLevel[playerid] == 2) // You must be RCon logged or aLevel 2 to make someone an admin
        {
            new param1[256];
            param1 = strtok(cmdtext, index);
            new param2[256];
            param2 = strtok(cmdtext, index);

            new player = strval(param1);
            new level = strval(param2);

            if(!IsPlayerConnected(player)) return 0;
            if(level < 0 || level > 2) return 0;

            aLevel[player] = level;
            SendClientMessage(playerid, 0x00FF00FF, "You have made this player an admin.");
            SendClientMessage(player, 0x00FF00FF, "You are now an admin.");
       
        }
         }
         return 1;
 }
stock strtok(const string[], &index)
{

    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Have you got the ZCMD-include?
Reply
#6

Hmm idk but all my command with ZCMD so i guess yes
Reply
#7

Код:
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(8) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(8) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(795) : error 017: undefined symbol "cmdtext"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(802) : error 017: undefined symbol "cmdtext"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(804) : error 017: undefined symbol "cmdtext"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(818) : warning 217: loose indentation
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(794) : warning 203: symbol is never used: "index"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#8

pawn Код:
stock GetName(playerid)
{
    new name[24];
    GetPlayerName(playerid,name,sizeof(name));
    return name;
}

new pAdmin[MAX_PLAYERS];
CMD:makeadmin(playerid,params[])
{
     new
         targetid,
         level,
         targetstring[128],
         string[128];

     if(pAdmin[playerid] <= 1 && !IsPlayerAdmin(playerid))
     {
        return SendClientMessage(playerid,-1,"You are not authorised to use that command.");
     }
     if(sscanf(params,"ui",targetid,level))
     {
        return SendClientMessage(playerid,-1,"USAGE: /makeadmin [playerid] [level]");
     }
     if(targetid == INVALID_PLAYER_ID)
     {
        return SendClientMessage(playerid,-1,"Player not found.");
     }
     if(level == 0 || level >= 3)
     {
        return SendClientMessage(playerid,-1,"Only levels available are level 1 and 2.");
     }
     else
     {
        format(targetstring,sizeof(targetstring),"Administrator %s has promoted you to Level %d Admin.",GetName(playerid),level);
        format(string,sizeof(string),"You have made %s a level %d Admin.",GetName(targetid),level);
        SendClientMessage(targetid,-1,targetstring);
        SendClientMessage(playerid,-1,string);
        pAdmin[targetid] = level;
     }
     return 1;
}
Reply
#9

Код:
#include <sscanf2>
#include <zcmd>

new aLevel[MAX_PLAYERS];

CMD:makeadmin(playerid, params[])
{
    if(IsPlayerAdmin(playerid) || aLevel[playerid] == 2) // You must be RCon logged or aLevel 2 to make someone an admin
    {
    new ID,level;
    if(sscanf(params,"ui",ID,level)) return SendClientMessage(playerid,0x00FF00FF,"Usage: /makeadmin <playerid> <level>");
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,0x00FF00FF,"Player not connected.");
    if(level < 0 || level > 2) return SendClientMessage(playerid,0x00FF00FF,"Please enter a level above 0 and below 3");
    aLevel[ID] = level;
    SendClientMessage(playerid, 0x00FF00FF, "You have made this player an admin.");
    SendClientMessage(ID, 0x00FF00FF, "You are now an admin.");
    }
    return 1;
}
Should do the job.
Reply
#10

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
pawn Код:
stock GetName(playerid)
{
    new name[24];
    GetPlayerName(playerid,name,sizeof(name));
    return name;
}

new pAdmin[MAX_PLAYERS];
CMD:makeadmin(playerid,params[])
{
     new
         targetid,
         level,
         targetstring[128],
         string[128];

     if(pAdmin[playerid] <= 1 && !IsPlayerAdmin(playerid))
     {
        return SendClientMessage(playerid,-1,"You are not authorised to use that command.");
     }
     if(sscanf(params,"ui",targetid,level))
     {
        return SendClientMessage(playerid,-1,"USAGE: /makeadmin [playerid] [level]");
     }
     if(targetid == INVALID_PLAYER_ID)
     {
        return SendClientMessage(playerid,-1,"Player not found.");
     }
     if(level == 0 || level >= 3)
     {
        return SendClientMessage(playerid,-1,"Only levels available are level 1 and 2.");
     }
     else
     {
        format(targetstring,sizeof(targetstring),"Administrator %s has promoted you to Level %d Admin.",GetName(playerid),level);
        format(string,sizeof(string),"You have made %s a level %d Admin.",GetName(targetid),level);
        SendClientMessage(targetid,-1,targetstring);
        SendClientMessage(playerid,-1,string);
        pAdmin[targetid] = level;
     }
     return 1;
}
oh!!!!! thanks u very much man
and thanks to eveyone !
it's working 100%
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)