PDA

View Full Version : Making admin names[Will give rep for help]


Calvingreen17
18/07/2013, 08:59 PM
Look I know I'm around here alot but spare me, I'm a noob.

I managed to actually make my /setlevel command make me an admin but my arank stock is buggy. I need help making names for different admin levels. For instance: Level 1: Jr Moderator, Level 2:Moderator, Leve 3:Admin.

Here's the stock I used (it was from my "undefined symbol when I defined...." topic)

stock arank(playerid)
{
new string[128];
{
case 0: string = "Jr Moderator";
case 1: string = "Moderator";
case 2: string = "Admin";
}
return string;
}


When I do /setlevel <playerid> 1, "it says player has promoted player to", doesnt even tell what admin rank they were made. If I do the command twice, it'll say they were promoted to Jr Moderator.

If I do /setlevel <playerid> 2, it'll say I promoted them to Admin, when they're supposed to be moderator.

When I do /setlevel <playerid> 3, it says I promoted them to Moderator, which is supposed to be Admin.

Please help, I DID search the forum and ******, nothing helped. I will give rep to those who help me.

BigETI
18/07/2013, 09:05 PM
How did this even compile? There should be atleast a "switch" statement.

Djole1337
18/07/2013, 09:06 PM
That stock above makes no sense.


stock arank(playerid)
{
new
iStr[12]
;
switch (adminVariable[playerid])
{
case 1: iStr = "something";
case 2: iStr = "something";
case 3: iStr = "something";
case 4: iStr = "something";
case 5: iStr = "something";
}
return iStr;
}

Elie1996
18/07/2013, 09:15 PM
How about we do it as a command using ZCMD? It would work perfectly anyway...

Here's what I mean:

// This is considering you have an enum called pInfo[playerid][arank]
// This function will return the admin names
public GetAdminsName(playerid)
{
new str[MAX_PLAYER_NAME];
switch(pInfo[playerid][arank])
{
case 0: { str = "Jr. Moderator"; }
case 1: { str = "Moderator"; }
case 2: { str = "Admin"; }
}
return string;
}

// Now we will make a command using ZCMD to work with that function, and it will set a player's admin rank to
// whatever you want
CMD:makeadmin(playerid, params[]) // Command Name
{
if(pInfo[playerid][arank] == 0) // Checks if Player is a Jn. Moderator
SendClientMessage(playerid, COLOR, "You are not authorized to use this command!"); // If he is, tell him he cant
else { // if he's not...
new targetid, Level; // targetid is the player we will make an admin
// Level, is the Administrative Level you're willing to give them
if(sscanf2(params, "ui", targetid, Level)) { SendClientMessage(playerid, COLOR, "USAGE: /makeadmin [playerid] [Admin Level]"); } // Checks parameters and sends him a correcting message
else { // If all parameters are correct
if(!IsPlayerConnected(targetid)) SendClientMessage(playerid, COLOR, "SERVER: Invalid ID!"); // then we check whether the player is connected or not
else {
new became[256], Name[MAX_PLAYER_NAME]; // Two strings, each will be used differently twice.
pInfo[targetid][arank] = Level; // Gives Player his Administrative level
Name = GetAdminsName(targetid); // Using the function we made earlier and getting his Rank Level
format(became, sizeof(became), "You have been given Administrator rank of %s", Name); // use format to tell the new admin his reward
SendClientMessage(targetid, COLOR, became); // Actually tells the new admin he became admin
Name = GetPlayersName(targetid); // Getting the new admin's name and saving it in Name
format(became, sizeof(became), "You have given %s, Admin rank %i", Name, Level); // telling the Old admin a message telling him he has made the new admin, admin
SendClientMessage(playerid, COLOR, became); // actually sending him the message
}
}

}
return 1;
} // Easy right? ":)

Calvingreen17
18/07/2013, 09:53 PM
How did this even compile? There should be atleast a "switch" statement.
I forgot to update it cause I tried something new before making the topic. I did have a switch statement.
That stock above makes no sense.


stock arank(playerid)
{
new
iStr[12]
;
switch (adminVariable[playerid])
{
case 1: iStr = "something";
case 2: iStr = "something";
case 3: iStr = "something";
case 4: iStr = "something";
case 5: iStr = "something";
}
return iStr;
}

For one thing, the specified string size is too small, 12?, i'll just get the "destination array is too small" error.
How about we do it as a command using ZCMD? It would work perfectly anyway...

Here's what I mean:

// This is considering you have an enum called pInfo[playerid][arank]
// This function will return the admin names
public GetAdminsName(playerid)
{
new str[MAX_PLAYER_NAME];
switch(pInfo[playerid][arank])
{
case 0: { str = "Jr. Moderator"; }
case 1: { str = "Moderator"; }
case 2: { str = "Admin"; }
}
return string;
}

// Now we will make a command using ZCMD to work with that function, and it will set a player's admin rank to
// whatever you want
CMD:makeadmin(playerid, params[]) // Command Name
{
if(pInfo[playerid][arank] == 0) // Checks if Player is a Jn. Moderator
SendClientMessage(playerid, COLOR, "You are not authorized to use this command!"); // If he is, tell him he cant
else { // if he's not...
new targetid, Level; // targetid is the player we will make an admin
// Level, is the Administrative Level you're willing to give them
if(sscanf2(params, "ui", targetid, Level)) { SendClientMessage(playerid, COLOR, "USAGE: /makeadmin [playerid] [Admin Level]"); } // Checks parameters and sends him a correcting message
else { // If all parameters are correct
if(!IsPlayerConnected(targetid)) SendClientMessage(playerid, COLOR, "SERVER: Invalid ID!"); // then we check whether the player is connected or not
else {
new became[256], Name[MAX_PLAYER_NAME]; // Two strings, each will be used differently twice.
pInfo[targetid][arank] = Level; // Gives Player his Administrative level
Name = GetAdminsName(targetid); // Using the function we made earlier and getting his Rank Level
format(became, sizeof(became), "You have been given Administrator rank of %s", Name); // use format to tell the new admin his reward
SendClientMessage(targetid, COLOR, became); // Actually tells the new admin he became admin
Name = GetPlayersName(targetid); // Getting the new admin's name and saving it in Name
format(became, sizeof(became), "You have given %s, Admin rank %i", Name, Level); // telling the Old admin a message telling him he has made the new admin, admin
SendClientMessage(playerid, COLOR, became); // actually sending him the message
}
}

}
return 1;
} // Easy right? ":)


You would still have to ask me what form of stats saving do I use, which is y_ini (sorry if I sound like a asshole :I, i still thank you for your help)

I dont really need help with the setlevel command, just the stock, enum, or something to give each admin level a name.

Elie1996
18/07/2013, 10:03 PM
You would still have to ask me what form of stats saving do I use, which is y_ini (sorry if I sound like a asshole :I, i still thank you for your help)


That's fine just easily convert it to whatever you want, if that's what you're comfortable with it's easily converted to anything: YCMD, dcmd, etc..



I dont really need help with the setlevel command, just the stock.

And that's why I made the command, I just thought you could choose not to use the stock, it works the same.


or something to give each admin level a name.

That's what GetAdminsName function is for.

Calvingreen17
18/07/2013, 10:11 PM
I got this:

C:\Users\di$t0rt3d_p1ctur3\Saved Games\GTA San Andreas\Server\gamemodes\coolbeans.pwn(1035) : error 090: public functions may not return arrays (symbol "GetAdminsName")

EDIT: And I dont have an enum for that, I thought I would but I wouldnt figure out how to structure it.

Calvingreen17
19/07/2013, 12:17 AM
nvm this was sorted. I figured it out, was another noob problem. It was working the whole time.

I will rep everyone who posted in his topic (before this post, not you rep whores)

Thanks dudes for your time, it is greatly appreciated

Elie1996
19/07/2013, 02:50 AM
Sure, no problem :D glad to be of help