Problem with admin commands [/level /ban]
#1

Hey guys,

Today I found a problem, when i try to set a players admin level in blablabla, it works good, but the admin didnt get a message that he has set his level to blablabla.

But now I tried to make a message that the admin who want to set a players level in blablabla got a message namely: Succes, you have succesfully set %s's level granted to %d.

I was trying if it works but it wont, after I do /level blablabla my server is offline.

Anyone who see that this is wrong?

PHP код:
dcmd_level(playerid,params[])
{
        new 
tmp2[300],tmp[300], Index;
        
tmp strtok(params,Index), tmp2 strtok(params,Index);
        new 
id strval(tmp), level strval(tmp2);
        if(
IsPlayerAdminLevel(playerid,5))
        {
        if(!
IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_ORANGE,"That player is not connected");//if player not connected
        
new str[256],aname[128];
        
GetPlayerName(playerid,aname,sizeof(aname));
        
format(str,sizeof(str),"Succes, Admin level %d has granted to you by Admin %s.",aname);//message to player
        
format(str,sizeof(str),"Succes, you have succesfully set %s's level granted to %d.",aname);//message to admin
        
SendClientMessage(id,COLOR_YELLOW,str);
        
Stats[id][AdminLvl] = level;
        }
        else
        {
        
SendClientMessage(playerid,COLOR_ORANGE,"Sorry, only admins level 5+ can do that command.");
        }
        return 
1;

And when I was try to ban a people he is banned succesfully but, when i will do the reason you didnt see the full reason that I was just to add, And when a player try to join the server I ddint see a message just likes this: Mickos0087 has been automatically kicked (banned).
Thats just a example I didnt know how to do that,

Code:

PHP код:
dcmd_ban(playerid,params[]) {
                if(
Stats[playerid][AdminLvl] >= 1)
                {
                        new 
tmp[256], tmp2[256], Index;
                        
tmp strtok(params,Index), tmp2 strtok(params,Index);
                        if(!
strlen(params)) return SendClientMessage(playerid,COLOR_ORANGE"You must be type /ban <playerid> <reason>");
                        if(!
strlen(tmp2)) return SendClientMessage(playerid,COLOR_ORANGE"ERROR: No reason specified.");
                        new 
idpn[120], aname[120], string[128];
                        
id strval(tmp);
                        if(
Stats[id][AdminLvl] >= Stats[playerid][AdminLvl]) return SendClientMessage(playerid,COLOR_ORANGE,"You cant ban this admin.");
                        
GetPlayerName(idpnsizeof(pn));
                        
GetPlayerName(playeridanamesizeof(aname));
                          
format(string,sizeof(string),"%s has been banned by Admin %s [Reason: %s]",pn,aname,params[2]);
                        
SendClientMessageToAll(COLOR_RED,string);
                        
BanEx(idstring);
                }
                else return 
SendClientMessage(playerid,COLOR_ORANGE,"Sorry, only admins level 1+ can do that command.");
                return 
1;

Anyone that know how I can fix that problems?

Thanks
Reply
#2

/level problems
Quote:

format(str,sizeof(str),"Succes, Admin level %d has granted to you by Admin %s.",aname);//message to player
format(str,sizeof(str),"Succes, you have succesfully set %s's level granted to %d.",aname);//message to admin
SendClientMessage(id,COLOR_YELLOW,str);

to
pawn Код:
format(str,sizeof(str),"Succes, Admin level %d has granted to you by Admin %s.",level,aname);//message to player
SendClientMessage(id,COLOR_YELLOW,str);
GetPlayerName(id,aname,sizeof(aname));
format(str,sizeof(str),"Succes, you have succesfully set %s's level granted to %d.",aname,level);//message to admin
SendClientMessage(playerid,COLOR_YELLOW,str);
Ban problems
Quote:

string[128]

to
pawn Код:
string[MAX_PLAYER_NAME*2+256+36]; // I made this by using size of tmps. You can make it smaller. But, then make tmps also smaller.256=tmp
Quote:

format(string,sizeof(string),"%s has been banned by Admin %s [Reason: %s]",pn,aname,params[2]);

to
pawn Код:
format(string,sizeof(string),"%s has been banned by Admin %s [Reason: %s]",pn,aname,tmp2);
EDIT: /level problems edited 2 times
Reply
#3

Thanks, I gonna try it now thx +rep

[EDIT] And how can I make a message when the banned player tried to join the server?
I Mean:

Mickos0087 has been automatically kicked (banned)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)