/setadmin and /setvip etc.
#1

I was wondering how I can change some ones variables from ingame, like their admin level, vip level, etc and I STILL need help with checkpoints if anyone can point me to a good tutorial or explain it, thanks!
Reply
#2

Depends on your setup, are you using something already made or starting from scratch?

I'm converting my old stuff to use ZCMD and sscanf2 at the moment. ZCMD let's you write pretty simple functions which act on someone typing /whatever in-game, so you could have a /setadminlevel [level] using a combination of ZCMD and sscanf2.

But the question is, do you already store and track who is admin or not? (some people have a user enum that tracks all per user data including if they are admin and what level, are they banned, their level, blah blah). Because if you do, I can show you a simple bit of script using those 2 products above to do just that.
Reply
#3

This is the one Im using. Edit it by yourself:
pawn Code:
COMMAND:makeadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
    new id, lvl;
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName] [Level]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
    else if(lvl > 1) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE"[ADMIN]"#COL_LRED" Administrator level cannot be higher then 1!");
    else
    {
     PlayerInfo[id][Adminlevel] = lvl;
    }
    return 1;
}
Reply
#4

@GrimR I'm using Zcmd and SSCANF if(PlayerInfo[playerid][pAdmin]
Reply
#5

Then use Kingunit's command above ?
Reply
#6

It compiles alright and everything after I edited it
pawn Code:
CMD:makeadmin(playerid, params[]){
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_GRAY,"ERROR: You're not authorized to use this command!");
    new id, lvl;
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /makeadmin [PlayerID/PartOfName] [Level]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
    else
    {
     PlayerInfo[playerid][pAdmin] = lvl;
    }
    return 1;
}
but when I go ingame and do /makeadmin 0 (my ID) 1 it says Invalid ID...
Reply
#7

pawn Code:
CMD:makeadmin(playerid, params[]){
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_GRAY,"ERROR: You're not authorized to use this command!");
    new id, lvl;
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /makeadmin [PlayerID/PartOfName] [Level]");
    else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
    else
    {
     PlayerInfo[playerid][pAdmin] = lvl;
    }
    return 1;
}
Try like this
Reply
#8

Still get the same error...
Reply
#9

Are you sure that you're using a valid ID? the code is alright...i think
Reply
#10

Valid ID? I type /makeadmin 0 1 (to test) and I get invalid ID, same with my kick command...

pawn Code:
CMD:kick(playerid,params[]){
    new id,reason[128];
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid,COLOR_GRAY,"ERROR: You're not authorized to use this command!");
    else if(sscanf(params, "uz",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /kick [ID] [REASON]");
    else if(id==playerid)SendClientMessage(playerid,COLOR_WHITE,"Error: You can not kick yourself!");
    else if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_GRAY,"You can not kick an admin!");
    else if(id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_GRAY,"Error: Player not connected!");
    else{
    new name,string[128];
    format(string,sizeof(string),"%s has just kicked %s, Reason: %s",GetName(playerid),name);
    SendClientMessageToAll(COLOR_RED,string);
    Kick(playerid);
    }
    return 1;
}
It keeps saying "Player is not connected"
Reply
#11

pawn Code:
CMD:setadminlevel(playerid, params[])
{
  new oID, oLvl;

  if (sscanf(params, "ui", oID, oLvl)) { return SendClientMessage(playerid, COLOR_WHITE, "... How to use it."); }

  if (PlayerInfo[playerid][pAdmin] > 0)
  {
    if (oID != INVALID_PLAYER_ID)
    {
       if (PlayerInfo[playerid][pAdmin] > oLvl) { PlayerInfo[oID][pAdmin] = oLvl; }
       else { return SendClientMessage(playerid, COLOR_WHITE, "... Can't set player as high or higher than you.");
    }
    else { return SendClientMessage(playerid, COLOR_WHITE, "... ID not connected/valid."); }
  }
  else { return SendClientMessage(playerid, COLOR_WHITE, "... Not an admin."); }

  // Here you can spit out all the, admin has done blah blah, you have successfully blah blah.
  // You can do it here, because if not successful, any 1 of the else cases will exit early.

  return 1;
}
That should just about suffice.

It can be different, but I just wrote this off the top of my head in the reply, it makes sure the admin setting a user as an admin, can not make them of equal or higher admin level. The messages are just place holders, can change them and of course add all your format/broadcast etc where the comments are.

If this still gives you an invalid ID, it's an invalid ID, press TAB in game to find out what ID's are actually connected.
Reply
#12

I bet that you have 0.3c R5 server and old sscanf plugin
I had same problem needed 2 days to figure out that i didnt updated plugin on my host :/
So check it
Reply
#13

Holy shit, you were right, Repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)