Admin Rankings - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Admin Rankings (
/showthread.php?tid=240230)
Admin Rankings -
rubygta - 15.03.2011
Hello!
This time I'm really stuck.. So, I'm trying to make an Admin system, and it isn't going too well.
I've been searching through scripts that I downloaded for help, searching the forums, and nothing really seems to help me.
The problem is, when I try to make like a
command, I get really stuck. Here's an attempt that's probably way off track.
pawn Код:
COMMAND:setadmin(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerAdmin(playerid))
{
new id[MAX_PLAYER_NAME], level;
if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid, RED, "SYNTAX: /setadmin <id> <level>");
PlayerInfo[playerid][Adminlevel] = level;
dini_IntSet(file, "Adminlevel", level);
}
}
return 1;
}
My OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
gPlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME];
new file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if (!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please register!", "You're not registered.Please register below", "Register", "Register");
}
if (fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You're registered!", "You are registered. Login below","Login", "Login");
}
return 1;
}
And OnPlayerDisconnect:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME];
new file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if (gPlayerLogged[playerid] == 1)
{
dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
dini_IntSet(file, "Cash", PlayerInfo[playerid][pCash]);
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][pAdminlevel]);
}
gPlayerLogged[playerid] = 0;
return 1;
}
Thanks in advance!
Kind regards,
Ruby.
Re: Admin Rankings -
HyperZ - 15.03.2011
Command:
pawn Код:
CMD:setadmin( playerid, params[ ] )
{
new ID, string[128], level;
if(sscanf(params, "ud", ID, level)) return SendClientMessage(playerid, -1, "USAGE: /setlevel [ID] [Level]");
else if(ID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player is not connected!");
else
{
if(gPlayerLogged[ID] == 1)
{
if(level > 0)
format(string,sizeof(string),"Administrator \"%s\" has set you to Administrator Status Admin Level: %d",pName(playerid), level);
else
format(string,sizeof(string),"Administrator \"%s\" has set you to Player Status Level: (%d)",pName(playerid), level);
SendClientMessage(ID, -1,string);
if(level > PlayerInfo[playerid][Adminlevel])
GameTextForPlayer(ID,"Promoted", 2000, 3);
else GameTextForPlayer(ID,"Demoted", 2000, 3);
format(string,sizeof(string),"You have given \"%s\" Level: (%d)", pName(ID), level);
SendClientMessage(playerid, -1,string);
PlayerInfo[ID][Adminlevel] = level;
dini_IntSet(file, "Adminlevel", level);
}
else return SendClientMessage(playerid, -1,"ERROR: This player is not Registred or Logged!");
}
return 1;
}
Somewhere in your script:
pawn Код:
stock pName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
Re: Admin Rankings -
rubygta - 15.03.2011
I feel silly.. I really appreciate it. Thank you.