SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/08/2017, 03:27 PM   #1
baki
Little Clucker
 
Join Date: Jun 2011
Location: Serbia and Monterego
Posts: 31
Reputation: 0
Default /admins bug

I have a problem with ym /admins command when i get in the players rank changes to Server Owner but when im out he is back to his normal rank

PHP Code:
CMD:admins(playeridparams[])
{
    new 
id;
    new 
n[MAX_PLAYER_NAME];
    new 
count 0string19[256];
    
GetPlayerName(id,n,sizeof(n));
    for(new 
0MAX_PLAYERS++)
    {
    if(
IsPlayerConnected(i))
    {
    if(
GetPVarInt(i"PlayerAdminLevel") < 1)
    {
    
format(string19sizeof(string19), "Trial Moderator : %s (%i)",,playerid);
    
count++;
    }
    if(
GetPVarInt(i"PlayerAdminLevel") < 2)
    {
    
format(string19sizeof(string19), "Moderator : %s (%i)",,playerid);
    
count++;
    }
    if(
GetPVarInt(i"PlayerAdminLevel") < 3)
    {
    
format(string19sizeof(string19), "Administrator : %s (%i)",,playerid);
    
count++;
    }
    if(
GetPVarInt(i"PlayerAdminLevel") < 4)
    {
    
format(string19sizeof(string19), "Chief Administrator : %s (%i)",,playerid);
    
count++;
    }
    if(
GetPVarInt(i"PlayerAdminLevel") < 5)
    {
    
format(string19sizeof(string19), "Server Owner : %s (%i)",,playerid);
    
count++;
    }
    }
    }
    if(
count == 0)
    {
    
SendClientMessage(playeridCOLOR_GREEN"");
    
SendClientMessage(playeridCOLOR_GREEN"|======== Online Admins =======|");
    
SendClientMessage(playeridCOLOR_WHITE"- No Admins Online at Time!");
    
SendClientMessage(playeridCOLOR_GREEN"|==============================|");
    
SendClientMessage(playeridCOLOR_GREEN"");
    }
    else
    {
    
SendClientMessage(playeridCOLOR_GREEN"");
    
SendClientMessage(playeridCOLOR_GREEN"|======== Online Admins =======|");
    
SendClientMessage(playeridCOLOR_WHITEstring19);
    
SendClientMessage(playeridCOLOR_GREEN"|==============================|");
    
SendClientMessage(playeridCOLOR_GREEN"");
    }
    return 
1;

__________________
I HATE HACKERS!!
baki is offline   Reply With Quote
Old 13/08/2017, 03:52 PM   #2
FuNkYTheGreat
Big Clucker
 
FuNkYTheGreat's Avatar
 
Join Date: Jun 2016
Location: Pakistan.
Posts: 177
Reputation: 57
Default Re: /admins bug

The problem isn't in the command, its just showing online admins, Please show us the code where you saves the player admin level , or if you didn't than save it, by using Y INI, its much easy/simple.
FuNkYTheGreat is online now   Reply With Quote
Old 13/08/2017, 05:18 PM   #3
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,903
Reputation: 2581
Default Re: /admins bug

Basic logic operators: < means smaller than, > means greater than. Although in this situation it is much better to use a switch instead because there is no fall-through.

PHP Code:
new title[24];
        
switch(
GetPVarInt(i"PlayerAdminLevel"))
{
    case 
1title "Trial Moderator";
    case 
2title "Moderator";
    case 
3title "Administrator";
    case 
4title "Chief Administrator";
    case 
5title "Server Owner";
}

format(string19sizeof(string19), "%s : %s (%i)"titlenplayerid);
count++; 
Much shorter, much cleaner, less unnecessary repetition.
__________________
Vince is offline   Reply With Quote
Old 13/08/2017, 06:53 PM   #4
pabloalber84ban
Little Clucker
 
Join Date: Jun 2016
Posts: 23
Reputation: 0
Default Re: /admins bug

Quote:
Originally Posted by Vince View Post
Basic logic operators: < means smaller than, > means greater than. Although in this situation it is much better to use a switch instead because there is no fall-through.

PHP Code:
new title[24];
        
switch(
GetPVarInt(i"PlayerAdminLevel"))
{
    case 
1title "Trial Moderator";
    case 
2title "Moderator";
    case 
3title "Administrator";
    case 
4title "Chief Administrator";
    case 
5title "Server Owner";
}

format(string19sizeof(string19), "%s : %s (%i)"titlenplayerid);
count++; 
Much shorter, much cleaner, less unnecessary repetition.
This save much unnecessary code:

Code:
new const AdminLevels[6][] = {
	{"User"},
	{"Trial Moderator"},
	{"Moderator"},
	{"Administrator"},
	{"Chief Administrator"},
	{"Server Owner"},
}
Code:
AdminsLevels[GetPVarInt(i, "PlayerAdminLevel")]
pabloalber84ban is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PlayerPlaySound to admins when new report is up. and level 4 admins can read it only zrelly Scripting Help 12 07/09/2013 09:26 AM
Making it work both Admins and Rcon Admins JaKe Elite Scripting Help 7 31/05/2012 12:57 PM
[HELP]/admins <Show current admins online by ID, Name, Rank and Duty> Deal-or-die Help Archive 7 01/06/2011 11:00 AM
How do I make level 1 admins secret from /admins seanny Help Archive 4 27/05/2011 08:00 AM


All times are GMT. The time now is 11:52 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.