Help! and thank you all!
#1

Here is ban commands i have made it all work i try it its nice but what i need can someone help me to add something thats cant make me ban my self and high admin level



Код:
dcmd_ban(playerid,params[])
{
	new
        
 		Reason[256],
   		pID,
		i;
    if(Player[playerid][admin] < 4){
    	return SendClientMessage(playerid,COLOR_RED,"You Dont Have Right To Use This Command");
        }
    if(sscanf(params,"us",pID,Reason)){
        return SendClientMessage(playerid,COLOR_RED,"|| Usage: /ban [playerid] [reason] ||");
        }
    if(!IsPlayerConnected(pID)) {
    	return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
     	}
    new
   			 name[MAX_PLAYER_NAME],
      		 string[256], string1[256], string2[256], string3[256], string4[256];
    GetPlayerName(pID,name,sizeof(name));
    format(string,sizeof(string),"**(ADMIN BAN)** %s(%d) %s",name,pID,Reason);
    format(string3,sizeof(string1),"You Have Been BANNED By Admin For Reason: %s",Reason);
    format(string2,sizeof(string2),"**If You Think Your Ban UNFAIR**");
    format(string3,sizeof(string3),"**Go To Out Website mkd-rp.tk**");
    format(string4,sizeof(string4),"**And Make Unban Apply With Right Format**");
    SendClientMessageToAll(COLOR_RED,string);
    SendClientMessage(i,COLOR_RED,string1);
    SendClientMessage(i,COLOR_RED,string2);
    SendClientMessage(i,COLOR_RED,string3);
    SendClientMessage(i,COLOR_RED,string4);
    SaveToFile("BanLog", string); Ban(pID);
    return 1;
}
Reply
#2

pawn Код:
dcmd_ban(playerid,params[])
{
    new
       
        Reason[256],
        pID,
        i;
    if(Player[playerid][admin] < 4){
        return SendClientMessage(playerid,COLOR_RED,"You Dont Have Right To Use This Command");
        }
    if(sscanf(params,"us",pID,Reason)){
        return SendClientMessage(playerid,COLOR_RED,"|| Usage: /ban [playerid] [reason] ||");
        }
    if(!IsPlayerConnected(pID)) {
        return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
        }

    if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot ban yourself!");
    if(Player[pID][admin] >= Player[playerid][admin]) return SendClientMessage(playerid, COLOR_RED,"That admin has a higher or the same level as you. You cannot ban him!");

    new
             name[MAX_PLAYER_NAME],
             string[256], string1[256], string2[256], string3[256], string4[256];
    GetPlayerName(pID,name,sizeof(name));
    format(string,sizeof(string),"**(ADMIN BAN)** %s(%d) %s",name,pID,Reason);
    format(string3,sizeof(string1),"You Have Been BANNED By Admin For Reason: %s",Reason);
    format(string2,sizeof(string2),"**If You Think Your Ban UNFAIR**");
    format(string3,sizeof(string3),"**Go To Out Website mkd-rp.tk**");
    format(string4,sizeof(string4),"**And Make Unban Apply With Right Format**");
    SendClientMessageToAll(COLOR_RED,string);
    SendClientMessage(i,COLOR_RED,string1);
    SendClientMessage(i,COLOR_RED,string2);
    SendClientMessage(i,COLOR_RED,string3);
    SendClientMessage(i,COLOR_RED,string4);
    SaveToFile("BanLog", string); Ban(pID);
    return 1;
}
Reply
#3

And just some thing I've noticed in your code:

1.) - Don't use 256 cells FFS!
You don't need them, just reduce them to 128. ( You don't even need 128 but.... it looks nicer than 256.)

2.) - You don't need to use this:
pawn Код:
string[256], string1[256], string2[256], string3[256], string4[256];
Just use new string[128], format it and in the next step send it to client in the way you like.
You'll lose a lot of resources doing it your way.
Reply
#4

why what the diffrent bhind the 256 and 128
Reply
#5

Quote:
Originally Posted by [MKD]Max
Посмотреть сообщение
why what the diffrent bhind the 256 and 128
https://sampforum.blast.hk/showthread.php?tid=55261
Reply
#6

The maximum output of text (meaning how much text can be sent to the chat window) is 128. So you will never need an array bigger than 128 - if its for sending text to the chat box. Anything over 128 is a waste of memory.
Reply
#7

Because you don't need them. Max input is 128 and max output is 128, using too much for nothing. (roughly explained)

If you have some interests for this, you can read this: Why you shouldn't make your strings 256 cells big
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)