18.03.2012, 16:24
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
Thanks
i really need one for my TDM server
#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;
}
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; }
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.
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;
}
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.
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;
}
#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; }
pawn Код:
|