makeAdmin Command urgent -
Mriss - 07.03.2014
Could I have a makeadmin command that works with rcon AND my enum thing
pawn Код:
if (P_DATA[playerid][pAdmin] < 6) return SendClientMessage(playerid, ERRORCOL, "You need to be admin to use this command!");
Re: makeAdmin Command urgent -
ConnorHunter - 07.03.2014
pawn Код:
CMD:makeadmin(playerid, params[])
{
new admlvl, id, string[128], output[48];
if (P_DATA[playerid][pAdmin] < 6) return SendClientMessage(playerid, ERRORCOL, "You need to be admin to use this command!");
if(sscanf(params, "ui", id, admlvl)) return SendClientMessage(playerid, ERRORCOL, "SYNTAX: /makeadmin [id] [adminlevel]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, ERRORCOL, "This player is not connected");
if(admlvl > 6 || admlvl < 0) return SendClientMessage(playerid, ERRORCOL,"Admin levels reach from '0' to '6'");
{
switch(admlvl)
{
case 1: output = "a Probationary Admin";
case 2: output = "a General Admin";
case 3: output = "a Senior Admin";
case 4: output = "a Server Manager";
case 5: output = "an Executive Admin";
case 6: output = "a 'ur rank here'";
default: output = "an Undefined Admin";
}
if(P_DATA[id][pAdmin] != admlvl)
{
if(admlvl < P_DATA[id][pAdmin])
{
format(string, sizeof(string),"You have been demoted to %s by %s", output ,GetPlayerNameEx(playerid));
}
if(admlvl > P_DATA[id][pAdmin])
{
format(string, sizeof(string),"You have been promoted to %s by %s", output ,GetPlayerNameEx(playerid));
}
if(admlvl == 0)
{
format(string, sizeof(string),"You have been fired from the administration team by %s", GetPlayerNameEx(playerid));
}
P_DATA[id][pAdmin] = admlvl;
SendClientMessage(id, 0xFF0000FF, string);
}
else SendClientMessage(playerid, 0xFFFFFFFF, "User already has that admin level");
}
return 1;
}
stock GetPlayerNameEx(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
strreplace(name, '_', ' ');
return name;
}
This is the makeadmin in my script, you can edit it how you like. I filled in the P_DATA ect for you.
Re: makeAdmin Command urgent -
Mriss - 07.03.2014
cnr.pwn(1335) : warning 202: number of arguments does not match definition
cnr.pwn(1335) : warning 202: number of arguments does not match definition
cnr.pwn(1339) : warning 202: number of arguments does not match definition
cnr.pwn(1339) : warning 202: number of arguments does not match definition
cnr.pwn(1343) : warning 202: number of arguments does not match definition
cnr.pwn(1343) : warning 202: number of arguments does not match definition
cnr.pwn(1316) : warning 204: symbol is assigned a value that is never used: "str"
I dont like warnings,
Re: makeAdmin Command urgent -
ConnorHunter - 07.03.2014
Updated it
Re: makeAdmin Command urgent -
Mriss - 07.03.2014
cnr.pwn(1336) : warning 202: number of arguments does not match definition
cnr.pwn(1336) : warning 202: number of arguments does not match definition
cnr.pwn(1340) : warning 202: number of arguments does not match definition
cnr.pwn(1340) : warning 202: number of arguments does not match definition
cnr.pwn(1344) : warning 202: number of arguments does not match definition
cnr.pwn(1344) : warning 202: number of arguments does not match definition
Re: makeAdmin Command urgent -
ConnorHunter - 07.03.2014
EDIT:
pawn Код:
CMD:makeadmin(playerid, params[])
{
new admlvl, id, string[128], output[48];
if (P_DATA[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, ERRORCOL, "You need to be admin to use this command!");
if(sscanf(params, "ui", id, admlvl)) return SendClientMessage(playerid, ERRORCOL, "SYNTAX: /makeadmin [id] [adminlevel]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, ERRORCOL, "This player is not connected");
if(admlvl > 6 || admlvl < 0) return SendClientMessage(playerid, ERRORCOL,"Admin levels reach from '0' to '6'");
{
switch(admlvl)
{
case 1: output = "a Probationary Admin";
case 2: output = "a General Admin";
case 3: output = "a Senior Admin";
case 4: output = "a Server Manager";
case 5: output = "an Executive Admin";
case 6: output = "a 'ur rank here'";
default: output = "an Undefined Admin";
}
if(P_DATA[id][pAdmin] != admlvl)
{
if(admlvl < P_DATA[id][pAdmin])
{
format(string, sizeof(string),"You have been demoted to %s by %s", output ,GetPlayerNameEx(playerid));
}
if(admlvl > P_DATA[id][pAdmin])
{
format(string, sizeof(string),"You have been promoted to %s by %s", output ,GetPlayerNameEx(playerid));
}
if(admlvl == 0)
{
format(string, sizeof(string),"You have been fired from the administration team by %s", GetPlayerNameEx(playerid));
}
P_DATA[id][pAdmin] = admlvl;
SendClientMessage(id, 0xFF0000FF, string);
}
else SendClientMessage(playerid, 0xFFFFFFFF, "User already has that admin level");
}
return 1;
}
stock GetPlayerNameEx(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
strreplace(name, '_', ' ');
return name;
}
Re: makeAdmin Command urgent -
Mriss - 07.03.2014
can u make it so Rcon can use it too?
Re: makeAdmin Command urgent -
ConnorHunter - 07.03.2014
Quote:
Originally Posted by Mriss
can u make it so Rcon can use it too?
|
pawn Код:
if (P_DATA[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, ERRORCOL, "You need to be admin to use this command!");
Re: makeAdmin Command urgent -
Mriss - 07.03.2014
and error 017: undefined symbol "strreplace"
Re: makeAdmin Command urgent -
ConnorHunter - 07.03.2014
Quote:
Originally Posted by Mriss
and error 017: undefined symbol "strreplace"
|
pawn Код:
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++)
{
if(string[i] == find)
{
string[i] = replace;
}
}
}