Get player banned reason
#1

Hi,I'm making my server ban system and when a player is banned it succesfuly sets his ban reason in playername.txt

pawn Код:
BanReason=Speedhack
Now I want when a player connets that the ban reason is shown to him but i don't know how.

Thanks!
Reply
#2

What file saving system are you using? (y_ini, dini, etcetra)
Reply
#3

Yes I'm using dini.

I set the reason with sscanf and saved with dini
pawn Код:
dini_Set(file,"Reason",reason);
Reply
#4

pawn Код:
dini_Int(file, "Reason");
Use that to get the reason.

For example...

pawn Код:
new name[MAX_PLAYER_NAME];
format(file,sizeof(file),"LOCATIONHERE/%s.ini", GetPlayerName(playerid, name, sizeof(name)));
if(dini_Exists(file))
{
    if(banvariablehere = 1) //or something
    {
        format(string, sizeof(string), "You are banned.  Reason: %s", dini_Int(file, "Reason"));
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    //Login dialog or whatever
}
Near the login dialog thing or something.

Never used dini, not sure if I did this correctly. Like I said, just an example.
Reply
#5

lol "Reason" is not an integer, u gotta use dini_Get
Reply
#6

I did that like you said
pawn Код:
if(PlayerInfo[playerid][Baned] == 1)
    {
        new file[64];
        new string1[128];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        format(file,sizeof(file),"/users/%s.txt",name);
        SendClientMessage(playerid,RED,"Your account is banned on this server!");
        format(string1,sizeof(string1),"Ban reason: %s", dini_Int(file, "Reason"));
        SendClientMessage(playerid,RED,string1);
    }
It only shows like this

pawn Код:
Ban reason:
Reply
#7

Quote:
Originally Posted by LaGrande
Посмотреть сообщение
lol "Reason" is not an integer, u gotta use dini_Get
That.
Reply
#8

Yeah I'm blind,works fine now +rep for you all!
Reply
#9

1 more question,how can I unban a player by his name when he is not online?
Reply
#10

Get the name from the file and if the variable is true (that is banned) unban him.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)