SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 27/06/2019, 05:34 PM   #1
Mortyka
Little Clucker
 
Join Date: Mar 2019
Location: The Universe
Posts: 9
Reputation: 0
Post [HELP] makeadmin with isPlayerAdmin

Hey! I want to add isPlayerAdmin but i got some errors
Plez help me


Command:
PHP Code:
CMD:makeadmin(playeridparams[])
{
    new 
targetidlevel;

    if(
PlayerInfo[playerid][pAdmin] < 0)
    {
        return 
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
    }
    if(
sscanf(params"ui"targetidlevel))
    {
        return 
SendClientMessage(playeridCOLOR_GREY3"[Usage]: /makeadmin [playerid] [level]");
    }
    if(!
IsPlayerConnected(targetid))
    {
        return 
SendClientMessage(playeridCOLOR_GREY"The player specified is disconnected.");
    }
    if(!
PlayerInfo[targetid][pLogged])
    {
        return 
SendClientMessage(playeridCOLOR_GREY"That player hasn't logged in yet.");
    }
    if(!(
<= level <= 6))
    {
        return 
SendClientMessage(playeridCOLOR_GREY"Invalid level. Valid levels range from 0 to 6.");
    }
    if(
PlayerInfo[targetid][pAdmin] > PlayerInfo[playerid][pAdmin] && level PlayerInfo[targetid][pAdmin])
    {
        return 
SendClientMessage(playeridCOLOR_GREY"The player specified has a higher admin level than you. They cannot be demoted.");
    }

    if(
level == && PlayerInfo[targetid][pAdminDuty])
    {
        
SetPlayerName(targetidPlayerInfo[targetid][pUsername]);
        
SetPlayerSpecialTag(targetidTAG_NONE);
        
PlayerInfo[targetid][pAdminDuty] = 0;
    }

    
PlayerInfo[targetid][pAdmin] = level;
    
SendAdminMessage(COLOR_LIGHTRED"AdmCmd: %s has made %s a %s (%i)."GetPlayerRPName(playerid), GetPlayerRPName(targetid), GetAdminRank(targetid), level);

    
mysql_format(connectionIDqueryBuffersizeof(queryBuffer), "UPDATE users SET adminlevel = %i WHERE uid = %i"levelPlayerInfo[targetid][pID]);
    
mysql_tquery(connectionIDqueryBuffer);

    if(
level == 0)
    {
        
SendClientMessageEx(playeridCOLOR_AQUA"You have removed %s's administrator powers."GetPlayerRPName(targetid));
        
SendClientMessageEx(targetidCOLOR_AQUA"%s has removed your administrator powers."GetPlayerRPName(playerid));
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_AQUA"You have set %s's admin level to {FF6347}%s{33CCFF} (%i)."GetPlayerRPName(targetid), GetAdminRank(targetid), level);
        
SendClientMessageEx(targetidCOLOR_AQUA"%s has set your admin level to {FF6347}%s{33CCFF} (%i)."GetPlayerRPName(playerid), GetAdminRank(targetid), level);
    }

    
Log_Write("log_admin""%s (uid: %i) set %s's (uid: %i) admin level to %i"GetPlayerNameEx(playerid), PlayerInfo[playerid][pID], GetPlayerNameEx(targetid), PlayerInfo[targetid][pID], level);
    return 
1;

Mortyka is offline   Reply With Quote
Old 27/06/2019, 05:44 PM   #2
nbx2000
Big Clucker
 
Join Date: Dec 2016
Posts: 150
Reputation: 5
Default Re: [HELP] makeadmin with isPlayerAdmin

Code:
CMD:makeadmin(playerid, params[]) 
{ 
    new targetid, level; 

    if(PlayerInfo[playerid][pAdmin] < 6 || IsPlayerAdmin(playerid)) 
    { 
        return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); 
    } 
    if(sscanf(params, "ui", targetid, level)) 
    { 
        return SendClientMessage(playerid, COLOR_GREY3, "[Usage]: /makeadmin [playerid] [level]"); 
    } 
    if(!IsPlayerConnected(targetid)) 
    { 
        return SendClientMessage(playerid, COLOR_GREY, "The player specified is disconnected."); 
    } 
    if(!PlayerInfo[targetid][pLogged]) 
    { 
        return SendClientMessage(playerid, COLOR_GREY, "That player hasn't logged in yet."); 
    } 
    if(!(0 <= level <= 6)) 
    { 
        return SendClientMessage(playerid, COLOR_GREY, "Invalid level. Valid levels range from 0 to 6."); 
    } 
    if(PlayerInfo[targetid][pAdmin] > PlayerInfo[playerid][pAdmin] && level < PlayerInfo[targetid][pAdmin]) 
    { 
        return SendClientMessage(playerid, COLOR_GREY, "The player specified has a higher admin level than you. They cannot be demoted."); 
    } 

    if(level == 0 && PlayerInfo[targetid][pAdminDuty]) 
    { 
        SetPlayerName(targetid, PlayerInfo[targetid][pUsername]); 
        SetPlayerSpecialTag(targetid, TAG_NONE); 
        PlayerInfo[targetid][pAdminDuty] = 0; 
    } 

    PlayerInfo[targetid][pAdmin] = level; 
    SendAdminMessage(COLOR_LIGHTRED, "AdmCmd: %s has made %s a %s (%i).", GetPlayerRPName(playerid), GetPlayerRPName(targetid), GetAdminRank(targetid), level); 

    mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET adminlevel = %i WHERE uid = %i", level, PlayerInfo[targetid][pID]); 
    mysql_tquery(connectionID, queryBuffer); 

    if(level == 0) 
    { 
        SendClientMessageEx(playerid, COLOR_AQUA, "You have removed %s's administrator powers.", GetPlayerRPName(targetid)); 
        SendClientMessageEx(targetid, COLOR_AQUA, "%s has removed your administrator powers.", GetPlayerRPName(playerid)); 
    } 
    else 
    { 
        SendClientMessageEx(playerid, COLOR_AQUA, "You have set %s's admin level to {FF6347}%s{33CCFF} (%i).", GetPlayerRPName(targetid), GetAdminRank(targetid), level); 
        SendClientMessageEx(targetid, COLOR_AQUA, "%s has set your admin level to {FF6347}%s{33CCFF} (%i).", GetPlayerRPName(playerid), GetAdminRank(targetid), level); 
    } 

    Log_Write("log_admin", "%s (uid: %i) set %s's (uid: %i) admin level to %i", GetPlayerNameEx(playerid), PlayerInfo[playerid][pID], GetPlayerNameEx(targetid), PlayerInfo[targetid][pID], level); 
    return 1; 
}
nbx2000 is offline   Reply With Quote
Old 27/06/2019, 05:51 PM   #3
Mortyka
Little Clucker
 
Join Date: Mar 2019
Location: The Universe
Posts: 9
Reputation: 0
Default Re: [HELP] makeadmin with isPlayerAdmin

Working, thanks!
Mortyka 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
IsPlayerAdmin can't use [i] KillerStrike23 Scripting Help 4 22/01/2016 02:52 AM
IsPlayerAdmin help Meinstad Scripting Help 5 13/04/2012 07:17 PM
IsPlayerAdmin [HELP]!!!! [PDS]DarioKeic Scripting Help 7 18/03/2012 06:46 AM
Whats the difference between "!IsPlayerAdmin(playerid))" and "IsPlayerAdmin(playerid))" lewismichaelbbc Help Archive 4 21/08/2011 08:42 PM
IsPlayerAdmin Kevin_Joshen Help Archive 5 28/07/2010 07:36 PM


All times are GMT. The time now is 02:05 PM.


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