/ban and /kick problem: You are not admin
#1

Hi guys! I have problem, I got /ban and /kick on my script, Im server owner and If I write /ban or /kick then I got message /kick: You are not admin. /ban: You are not admin.
How I can fix that?
PM! Some things is Translated to My language

Here is /ban:
PHP код:
if(strcmp(cmd"/ban"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
playersip[64];
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"KASUTUS: /ban [playerid/PartOfName] <reason>");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            new 
string3[256];
            if (
PlayerInfo[playerid][pAdmin] >= || IsPlayerAdmin(playerid))
            {
                if(
IsPlayerConnected(giveplayerid))
                {
                    if(
giveplayerid != INVALID_PLAYER_ID)
                    {
                        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                        
GetPlayerIp(giveplayerid,playersip,sizeof(playersip));
                        new 
length strlen(cmdtext);
                        while ((
idx length) && (cmdtext[idx] <= ' '))
                        {
                            
idx++;
                        }
                        new 
offset idx;
                        new 
result[128];
                        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                        {
                            
result[idx offset] = cmdtext[idx];
                            
idx++;
                        }
                        
result[idx offset] = EOS;
                        if(!
strlen(result))
                        {
                               
SendClientMessage(playeridCOLOR_GRAD2"KASUTUS: /ban [playerid/PartOfName] [reason]");
                            return 
1;
                        }
                        if(
giveplayerid != playerid && Untouchable[giveplayerid]) return SendClientMessage(playeridCOLOR_GREY" Nice try dude...");
                        new 
targetlevel PlayerInfo[giveplayerid][pAdmin];
                        new 
playerlevel PlayerInfo[playerid][pAdmin];
                        if(
targetlevel playerlevel) return SendClientMessage(playeridCOLOR_GREY"[Totaalne-AC] - You can't use this command on that person!");
                        new 
ymd;
                        new 
h,mi,s;
                        
getdate(y,m,d);
                        
gettime(h,mi,s);
                        
format(string3,sizeof(string3), "(%d/%d/%d)[%d:%d:%d] %s Has been banned by %s for: %s",d,m,y,h,mi,s,giveplayer,sendername, (result));
                        
BanLog(string3);
                        
format(string3,sizeof(string3), "(%d/%d/%d)[%d:%d:%d] Banned by %s - Reason: %s",d,m,y,h,mi,s,sendername,(result));
                        
AddPunishment(giveplayeridstring3);
                        
format(string3sizeof(string3), "%s (%d), Has been Banned by Administrator %s for %s"giveplayergiveplayeridsendername, (result));
                        
SendClientMessageToAll(COLOR_NICEREDstring3);
                        
format(string3sizeof(string3), "[ADMIN]: %s Has Been Added to the Ban list by %s"playersipsendername);
                        
SendAdminMessage(COLOR_WHITEstring3);
                        
format(string3sizeof(string3), "You have Been Banned by Administrator %s for %s"sendername, (result));
                        
SendClientMessage(giveplayerid,COLOR_NICEREDstring3);
                        
SendClientMessage(giveplayerid,COLOR_BLUE"If You Feel that This has Been an Error, Report the Admin to www.totalroleplay.zxq.net/index.php");
                        
SendClientMessage(giveplayerid,COLOR_BLUE"To Get Unbanned Post an Unban Request at Our Forums www.totalroleplay.zxq.net/index.php");
                        
SendClientMessage(giveplayerid,COLOR_LIGHTRED"Don't Evade, Otherwise you wont get unbanned");
                          
SafeSetPlayerPos(giveplayerid,264.6288,77.5742,1001.0391);
                        
SafeSetPlayerInterior(giveplayerid6);
                           
PlayerInfo[giveplayerid][pJailTime] = 300;
                        
PlayerInfo[giveplayerid][pJailed] = 1;
                        
PlayerInfo[giveplayerid][pBanned] = 1;
                        
format(string3sizeof(string3), "~r~~h~Admin Ban: ~n~~r~%s",(result));
                        
GameTextForPlayer(giveplayeridstring360003);
                        
PlayerInfo[giveplayerid][pPending] = 0;
                        
//ScriptBan(giveplayerid,playerid,result);
                        
BanEx(giveplayerid/*,playerid*/,result);
                        return 
1;
                    }
                }
//not connected
            
}
            else
            {
                
format(stringsizeof(string), " %d is not an active player."giveplayerid);
                
SendClientMessage(playeridCOLOR_ORANGEstring);
            }
        }
        return 
1;
    } 
Here is /kick:
PHP код:
if(strcmp(cmd"/kick"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"KASUTUS: /kick [playerid/PartOfName] <reason>");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            if(
giveplayerid != playerid && Untouchable[giveplayerid]) return SendClientMessage(playeridCOLOR_GREY"* Sa ei saa seda selle mдngijaga teha!");
              new 
targetlevel PlayerInfo[giveplayerid][pAdmin];
            new 
playerlevel PlayerInfo[playerid][pAdmin];
            if(
targetlevel playerlevel) return SendClientMessage(playeridCOLOR_GREY"* You can not Kick People that is higher Than You!");
            if (
PlayerInfo[playerid][pAdmin] >= || IsPlayerAdmin(playerid))
            {
                if(
IsPlayerConnected(giveplayerid))
                {
                    if(
giveplayerid != INVALID_PLAYER_ID)
                    {
                        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                        new 
length strlen(cmdtext);
                        while ((
idx length) && (cmdtext[idx] <= ' '))
                        {
                            
idx++;
                        }
                        new 
offset idx;
                        new 
result[128];
                        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                        {
                            
result[idx offset] = cmdtext[idx];
                            
idx++;
                        }
                        
result[idx offset] = EOS;
                        if(!
strlen(result))
                        {
                            new 
ymd;
                            new 
h,mi,s;
                            
getdate(y,m,d);
                            
gettime(h,mi,s);
                            
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has been kicked by %s, No Reason Given",d,m,y,h,mi,s,giveplayer,sendername);
                            
KickLog(string);
                            
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Kicked by %s - No Reason Given.",d,m,y,h,mi,s,sendername);
                            
AddPunishment(giveplayeridstring);
                            
format(stringsizeof(string), "%s (%d), Has been kicked by Administrator %s, No Reason Given"giveplayergiveplayeridsendername);
                            
SendClientMessageToAll(COLOR_NICEREDstring);
                            
format(stringsizeof(string), "You have Been Kicked by Administrator %s, No Reason Given"sendername);
                            
SendClientMessage(giveplayerid,COLOR_LIGHTBLUEstring);
                             
SafeSetPlayerPos(giveplayerid,1601.8762,-1671.9099,-40.5941);
                            
SafeSetPlayerInterior(giveplayerid0);
                            
GameTextForPlayer(giveplayerid"~r~~h~Admin Kicked: ~n~~r~No Reason Given"60003);
                            
SetTimerEx("KickOut",500,false,"i",giveplayerid);
                            return 
1;
                        }
                        new 
ymd;
                        new 
h,mi,s;
                        
getdate(y,m,d);
                        
gettime(h,mi,s);
                        
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has been kicked by %s for: %s",d,m,y,h,mi,s,giveplayer,sendername, (result));
                        
KickLog(string);
                        
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Kicked by %s - Reason: %s",d,m,y,h,mi,s,sendername,(result));
                        
AddPunishment(giveplayeridstring);
                        
format(stringsizeof(string), "%s (%d), Has been kicked by Administrator %s for: %s"giveplayergiveplayeridsendername, (result));
                        
SendClientMessageToAll(COLOR_NICEREDstring);
                        
format(stringsizeof(string), "You have Been Kicked by Administrator %s for: %s"sendername, (result));
                        
SendClientMessage(giveplayerid,COLOR_LIGHTBLUEstring);
                         
SafeSetPlayerPos(giveplayerid,1601.8762,-1671.9099,-40.5941);
                        
SafeSetPlayerInterior(giveplayerid0);
                         
format(stringsizeof(string), "~r~~h~Admin Kicked: ~n~~r~%s",(result));
                        
GameTextForPlayer(giveplayeridstring60003);
                        
SetTimerEx("KickOut",500,false,"i",giveplayerid);
                        return 
1;
                    }
                }
            }
            else
            {
                
format(stringsizeof(string), "** %d is not an active player."giveplayerid);
                
SendClientMessage(playeridCOLOR_GRAD1string);
            }
        }
        return 
1;
    } 
Reply
#2

You have
pawn Код:
IsPlayerAdmin
This means you must login to the rcon to use it.
Reply
#3

If you knew anything about scripting you'd know || means or.

Anyways, use this(download zcmd and sscanf2, much easier and quicker):
pawn Код:
forward KickPublic(playerid)
{
    Kick(playerid);
}


CMD:ban(playerid, params[])
{
    new id, y, m, d, h, mi, s, string1[128], string[1024], string2[128], string3[128], string4[128];
    if(PlayerInfo[playerid][pAdmin] >= 3 || IsPlayerAdmin(playerid))
    {
        if(sscanf(params, "us[50]", id, string1)) return SendClientMessage(playerid, GREY, "Usage: /ban <playerid/name> <reason>");
        {
            if(id != INVALID_PLAYER_ID)
            {
                if(PlayerInfo[id][pAdmin] < Player[playerid][pAdmin])
                {
                    getdate(y, m, d);
                    gettime(h, mi, s);
                    format(string, sizeof(string), "(%d/%d/%d) [%d:%d:$d] %s has been banned by %s. [Reason: %s]", d, m, y, h, mi, s, pName(playerid), pName(id), string1);
                    BanLog(string);
                    format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] Banned by %s - Reason: %s",d, m, y, h, mi, s, pName(id), string1);
                    AddPunishment(string);
                    format(string, sizeof(string), "%s (%d), Has been Banned by Administrator %s for %s", pName(id), pName(playerid), string1);
                    SendClientMessageToAll(COLOR_NICERED, string);
                   
                    format(string2, sizeof(string2), "You have been banned. If you feel this ban has been an error, you can appeal and report the admin.\n");
                    format(string3, sizeof(string3), "If you want to be unbanned, post an unban appeal here: www.totalroleplay.zxg.net\n");
                    format(string4, sizeof(string4), "Don't evade, otherwise you will not be unbanned from our server.\n");
                    format(string5, sizeof(string5, "%s%s%s", string2, string3, string4);
                    SendClientMessage(playerid, WHITE, string5);
                    SetTimer("KickPublic", 3000, 0);
                }
                else return SendClientMessage(playerid, GREY, "You may not ban admins that are a higher rank than you!");
            }
            else return SendClientMessage(playerid, GREY, "Invalid playerid.");
        }
    }
    else return SendClientMessage(playerid, GREY, "You are not a high enough administrator rank/you are not rcon admin.");
}

stock pName(playerid)
{
    new pname;
    GetPlayerName(playerid, pname, 24);
    return pname;
}

stock getIP(playerid)
{
    new pIp;
    GetPlayerIp(playerid, pIp, 16);
    return pIp;
}
Try and follow the same format for the other command.

sscanf2 DL: https://sampforum.blast.hk/showthread.php?tid=120356
zcmd DL: https://sampforum.blast.hk/showthread.php?tid=91354
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)