Need help with my ban system
#1

Ok so im trying to improve the ban system, anyways these are the issues that i'm currently having, I want to make it that when a player connects and they are banned it will show the reason why they are banned but when i tried to do it , it doesn't work...
PHP код:
enum PlayerInfo
{
Banres[200]
}
new 
pInfo[MAX_PLAYERS][PlayerInfo];
public 
LoadUser_data(playerid,name[],value[])
{
INI_String("Reason",pInfo[playerid][Banres],200);
return 
1;
}  
if(
pInfo[playerid][Banned] == 1)
    {
        new 
reso[128];
        
SendClientMessage(playerid,red,"=====================================================");
        
SendClientMessage(playerid,red"{FF6347}You are banned from this server.");
        
SendClientMessage(playerid,red,"{FF6347}Make an Ban Appeal on our forums. An Staff member will review it as soon as possible.");
        
SendClientMessage(playerid,red,"{FF6347}Visit our forums at: "SERVER_FORUMS"");
    
    
format(reso,sizeof(reso),"{85BB65}Reason: {f0f000}%s",pInfo[playerid][Banres]);
        
SendClientMessage(playerid,-1,reso);
        
SendClientMessage(playerid,red,"=====================================================");
        
SendClientMessage(playerid,red"[AdmCmd]:{FF6347}This Account has been banned from the server."); 
Another issue is why does my unban command creates another line called Ban Reason instead of editing the one which is currently already in the .ini because the banned by edits the old one but the Ban reason creates a new line..

PHP код:
CMD:unban(playeridparams[])
{
       if(
IsPlayerAdmin(playerid) || pInfo[playerid][Admin] >= 3)
    {
        new 
Name[25],file[256];
        if(
sscanf(params"s[24]"Name)) return SendClientMessage(playeriderror"Usage: /unban <Player Name>");    format(file100PATHName);
        if (!
fexist(file)) return SendClientMessage(playerid,error,"Error: This player doesn't have an account!");
        new 
INI:File INI_Open(file);
           
INI_SetTag(File,"data");
          
INI_WriteInt(File,"Banned",0);
        
INI_WriteString(File,"Bannedby","");
        
INI_WriteString(File,"Ban Reason","");
        
INI_Close(File);
        
format(astringsizeof(astring),"You have successfully unbanned '%s'",Name);
        
SendClientMessage(playerid,-1,astring);
        
format(astring,sizeof(astring),"[UNBAN] %s has UNBANNED Account: %s",GetName(playerid),Name);
        
WriteToLog(astring,"Unban");
        
CommandToAdmins(playerid,"unban");
        return 
1;
    }
     else return 
ShowMessage(playeriderror1);

And how can i make it case sensitive.
Reply
#2

In regards to the ban reason not showing, is it just the reason that doesn't show or does the entire "You are banned from this server" string not show?

Are you certain you're saving the string accordingly in the INI file?

Код:
public LoadUser_data(playerid,name[],value[]) 
{ 
INI_String("Reason",pInfo[playerid][Banres],200); 
return 1; 
}
Reply
#3

Show the ban cmd
Reply
#4

Quote:
Originally Posted by Debjit
Посмотреть сообщение
Show the ban cmd
PHP код:
CMD:ban(playeridparams[])
{
      new 
targetidreason[200];
    if(
IsPlayerAdmin(playerid) || pInfo[playerid][Admin] >= 3)
    {
        if(
sscanf(params"us[24]"targetidreason)) return SendClientMessage(playerid,error"Usage: /ban [PlayerName/Playerid] [reason]");
        if(
strlen(reason) < || strlen(reason) > 200) return SendClientMessage(playeriderror"Your reason can only contain 1-100 characters.");
        if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeriderror"Player not found.");
        {
            
pInfo[targetid][Banned] = 1;
             
GetPlayerIp(targetid,pIP,16);
            new 
y,m,d,hour,mint,sec,message[300];
            
getdate(y,m,d);
            
gettime(hour,mint,sec);
        
//    pInfo[targetid][Banned] = 1;
            
pInfo[targetid][Banres] = reason;
            new 
INI:File INI_Open(UserPath(targetid));
               
INI_SetTag(File,"data");
              
//INI_WriteString(File,"Ban Reason",reason);
               
INI_WriteInt(File,"Banned",1);
            
INI_WriteString(File,"Bannedby",GetName(playerid));
            
INI_Close(File);
            
format(messagesizeof(message), "[AdmCmd]:{FF6347}%s has been Banned from the server. | Reason: %s"GetName(targetid), reason);
            
SendClientMessageToAll(redmessage);
            
SendClientMessage(targetid,red,"=====================================================");
            
SendClientMessage(targetid,red,"{FF6347}You have been Banned from Caribbean Mafia Warz.");
            
format(messagesizeof(message),"{FF6347}Banned by: %s "GetName(playerid));
            
SendClientMessage(targetid,red,message);
            
format(messagesizeof(message),"{FF6347}Banned Reason: %s "reason);
            
SendClientMessage(targetid,red,message);
            
format(messagesizeof(message),"{FF6347}Date: %d/%d/%d || Time: %d:%d:%d",d,m,y,hour,mint,sec );
            
SendClientMessage(targetid,red,message);
            
format(messagesizeof(message),"{FF6347}IP Address: %s"pIP);
            
SendClientMessage(targetid,red,message);
            
SendClientMessage(targetid,red,"{FF6347}You will need to take a screenshot of this message for your appeal.");
               
SendClientMessage(targetid,red,"{FF6347}Make an Ban Appeal on our forums. An Staff member will review it as soon as possible.");
            
SendClientMessage(targetid,red,"{FF6347}Visit our forums at:"SERVER_FORUMS"");
            
SendClientMessage(targetid,red,"=====================================================");
            
SendClientMessage(targetid,red,"{FF6347}Server Administrators has been notified.");
              
SetTimerEx("BanPlayer",200,false,"ud"targetid,2);
               
CommandToAdmins(playerid,"ban");
        }
    }
      else return 
ShowMessage(playeriderror1);
     return 
1;

Quote:
Originally Posted by McBan
Посмотреть сообщение
In regards to the ban reason not showing, is it just the reason that doesn't show or does the entire "You are banned from this server" string not show?

Are you certain you're saving the string accordingly in the INI file?

Код:
public LoadUser_data(playerid,name[],value[]) 
{ 
INI_String("Reason",pInfo[playerid][Banres],200); 
return 1; 
}
Ok mate as i have said it saves in the .ini file successfully, but when the player logs on to the server and the server runs a ban check on the account it doesnt show the reason why the player is banned but yet it is saved in the player .ini file, so i assume the issue would be with how im loading the user data.. what do you think?


IMAGES:

https://ibb.co/i7qTy6
https://ibb.co/d2YdWR
Reply
#5

You aren't writing the reason for ban, that's why it couldn't load the string here
PHP код:
public LoadUser_data(playerid,name[],value[]) 

INI_String("Reason",pInfo[playerid][Banres],200); 
return 
1

Changes
PHP код:
CMD:ban(playeridparams[]) 

//contents
               
INI_WriteString(File,"Reason"reason); //it should work now as you were not saving it and the name was not same
    //contents
    
     
return 1

Reply
#6

Quote:
Originally Posted by Debjit
Посмотреть сообщение
You aren't writing the reason for ban, that's why it couldn't load the string here
PHP код:
public LoadUser_data(playerid,name[],value[]) 

INI_String("Reason",pInfo[playerid][Banres],200); 
return 
1

Changes
PHP код:
CMD:ban(playeridparams[]) 

//contents
               
INI_WriteString(File,"Reason"reason); //it should work now as you were not saving it and the name was not same
    //contents
    
     
return 1

Damn good attention to details, i didn't realise i was loading the wrong name XD, thanks for the help man rep+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)