#1

I got this /ban command and for some reason I keep getting this error :

Код:
(13957) : warning 217: loose indentation
Here is line 13957

PHP код:
format(str,sizeof(str),"%s has been banned by administrator %s. Reason: %s "PlayernameAdminnamereason); 
Here is the full ban command:

PHP код:
CMD:ban(playeridparams[])
{
        if(
APlayerData[playerid][PlayerLevel] >= 5) {
            new 
PID//define the playerid we wanna ban
            
new reason[64]; //the reason, put into a string
            
new str[128]; //a new message string
            
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
            
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
            
GetPlayerName(PIDPlayernamesizeof(Playername));
            if(
sscanf(params"us[64]"PID,reason)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /ban [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
            
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
                
return SendClientMessage(playeridCOLOR_GREY"Player is not connected!");
        
format(str,sizeof(str),"%s has been banned by administrator %s. Reason: %s "PlayernameAdminnamereason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
        
SendClientMessageToAll(COLOR_RED,str); //send that message to all
        
Ban(PID); //Ban the playerid we've defined
        
}
        else 
//if he has not got the permissions
        
{
            
SendClientMessage(playeridCOLOR_GREY"You have to be level 5 to use that command!"); //return this message
        
}
        return 
1;

Reply
#2

try this out
PHP код:
CMD:ban(playeridparams[])
{
            if(
APlayerData[playerid][PlayerLevel] >= 5) {
            new 
PID//define the playerid we wanna ban
            
new reason[64]; //the reason, put into a string
            
new str[128]; //a new message string
            
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
            
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
            
GetPlayerName(PIDPlayernamesizeof(Playername));
            if(
sscanf(params"us[64]"PID,reason)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /ban [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
            
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
            
return SendClientMessage(playeridCOLOR_GREY"Player is not connected!");
            
format(str,sizeof(str),"%s has been banned by administrator %s. Reason: %s "PlayernameAdminnamereason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
            
SendClientMessageToAll(COLOR_RED,str); //send that message to all
            
Ban(PID); //Ban the playerid we've defined
        
}
        else 
//if he has not got the permissions
        
{
            
SendClientMessage(playeridCOLOR_GREY"You have to be level 5 to use that command!"); //return this message
        
}
        return 
1;

or try this
PHP код:
CMD:ban(playeridparams[])
{
            if(
APlayerData[playerid][PlayerLevel] >= 5) {
            new 
PID//define the playerid we wanna ban
            
new reason[64]; //the reason, put into a string
            
new str[128]; //a new message string
            
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
            
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
            
GetPlayerName(PIDPlayernamesizeof(Playername));
            if(
sscanf(params"us[64]"PID,reason)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /ban [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
            
{
            if(!
IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
            
return SendClientMessage(playeridCOLOR_GREY"Player is not connected!");
            {
            
format(str,sizeof(str),"%s has been banned by administrator %s. Reason: %s "PlayernameAdminnamereason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
            
SendClientMessageToAll(COLOR_RED,str); //send that message to all
            
Ban(PID); //Ban the playerid we've defined
        
}
        else 
//if he has not got the permissions
        
{
            
SendClientMessage(playeridCOLOR_GREY"You have to be level 5 to use that command!"); //return this message
        
}
        return 
1;

Reply
#3

None of that works, but I figured it out !
Reply
#4

pawn Код:
CMD:ban(playerid, params[])
{
    if(APlayerData[playerid][PlayerLevel] >= 5) {
    new PID; //define the playerid we wanna ban
    new reason[64]; //the reason, put into a string
    new str[128]; //a new message string
    new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
    GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
    GetPlayerName(PID, Playername, sizeof(Playername));
    if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /ban [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
    if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
    return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
    format(str,sizeof(str),"%s has been banned by administrator %s. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
    SendClientMessageToAll(COLOR_RED,str); //send that message to all
    Ban(PID); //Ban the playerid we've defined
    }
    else //if he has not got the permissions
    {
    SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message
    }
    return 1;
}
Here you go
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)