Ban is not off y_ini -
maximthepain - 19.03.2015
Hello,
I'm encountering problem which is stupid and I'm sure the fix is quick & i didnt notice it. I dont even know how to ****** this problem so i'll just ask you.
When player gets banned I'm saving with y_ini the reason, banned by, and Ban =1... When player connects he sees the "you are banned" however, when im erasing by hand from his file those variables and reconnect he is still "banned", its impossiable, I'm checking if Ban = 1 and server finds it is? I'm not sure why. Its not exists in the file.
It seems like if INI_ParseFile used once, it doesn't matter if player reconnects the variables won't change? why?
OnPlayerConnect:
pawn Код:
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUserBans_%s", .bExtra = true, .extra = playerid);
if(PlayerInfo[playerid][pBan] == 1)
{
format(bdialog, sizeof(bdialog), "You are banned from our server.\nIP: %s\nBanned By: %s\nBan Reason: %s\nForums: "FORUM"", PlayerInfo[playerid][pIP], PlayerInfo[playerid][pBannedBy], PlayerInfo[playerid][pBanReason]);
ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "Ban Info", bdialog, "Close", "");
Kick(playerid);
return 1;
}
}
Ban command is just writting into the file info about the ban & kicking player.
If you need anything else from codes, I will add.
Re: Ban is not off y_ini -
Misiur - 19.03.2015
Please add your LoadUserBans function.
Re: Ban is not off y_ini -
maximthepain - 19.03.2015
Quote:
Originally Posted by Misiur
Please add your LoadUserBans function.
|
Alright, here it is:
pawn Код:
forward LoadUserBans_data(playerid,name[],value[]);
public LoadUserBans_data(playerid,name[],value[])
{
INI_Int("Ban",PlayerInfo[playerid][pBan]);
if(PlayerInfo[playerid][pBan])
{
INI_String("BanReason", PlayerInfo[playerid][pBanReason], 64);
INI_String("BannedBy", PlayerInfo[playerid][pBannedBy], 24);
}
return 1;
}
Re: Ban is not off y_ini -
Misiur - 19.03.2015
Ok, the reason is if you don't have "Ban" key at all (Ban = 0 will work), PlayerInfo[playerid][pBan] value won't change. So, OnPlayerDisconnect (post data load) or OnPlayerConnect (pre data load) reset that variable to default:
pawn Код:
PlayerInfo[playerid][pBan] = 0;
In fact, it's recommended to reset all player variables. Include YSI\y_utils and do this:
pawn Код:
memset(PlayerInfo[0][0], 0, MAX_PLAYERS * _:pInfo)
(if pInfo is the name of player enum).
Re: Ban is not off y_ini -
maximthepain - 19.03.2015
Quote:
Originally Posted by Misiur
Ok, the reason is if you don't have "Ban" key at all (Ban = 0 will work), PlayerInfo[playerid][pBan] value won't change. So, OnPlayerDisconnect (post data load) or OnPlayerConnect (pre data load) reset that variable to default:
pawn Код:
PlayerInfo[playerid][pBan] = 0;
In fact, it's recommended to reset all player variables. Include YSI\y_utils and do this:
pawn Код:
memset(PlayerInfo[0][0], 0, MAX_PLAYERS * _:pInfo)
(if pInfo is the name of player enum).
|
I guess you are right! I forgot to reset all the keys.
Now there is "warning 213: tag mismatch" for "memset(PlayerInfo[0][0], 0, MAX_PLAYERS * _
Info);"
Re: Ban is not off y_ini -
Misiur - 19.03.2015
Argh, sorry, that's what happens when applying hacky solutions from memory:
pawn Код:
memset(PlayerInfo[0], 0, MAX_PLAYERS * _:pInfo)
Re: Ban is not off y_ini -
maximthepain - 19.03.2015
Quote:
Originally Posted by Misiur
Argh, sorry, that's what happens when applying hacky solutions from memory:
pawn Код:
memset(PlayerInfo[0], 0, MAX_PLAYERS * _:pInfo)
|
Oh wait. I was sure this will fix it.
I'm still banned when entering the server, I added at the top of OnPlayerConnect the code you gave me and its not changing at all the problem im encountering. :/
Re: Ban is not off y_ini -
Misiur - 19.03.2015
Ok, sorry about that, it seems you are using YSI 3, not 4.
This should work now:
pawn Код:
memset(PlayerInfo[0], MAX_PLAYERS * _:pInfo, 0)
But if it doesn't simply try:
pawn Код:
for(new i = 0; i != MAX_PLAYERS; ++i) {
for(new pInfo:j = 0; j != pInfo; j++) {
PlayerInfo[i][j] = 0;
}
}
Re: Ban is not off y_ini -
maximthepain - 19.03.2015
Quote:
Originally Posted by Misiur
Ok, sorry about that, it seems you are using YSI 3, not 4.
This should work now:
pawn Код:
memset(PlayerInfo[0], MAX_PLAYERS * _:pInfo, 0)
But if it doesn't simply try:
pawn Код:
for(new i = 0; i != MAX_PLAYERS; ++i) { for(new pInfo:j = 0; j != pInfo; j++) { PlayerInfo[i][j] = 0; } }
|
Yes! this worked well