Ban command problem
#1

Hello guys,i've create my ban command i have read about ban ip i mean at the last of command
pawn Код:
Ban(playerid);
I just want to ban player account not his ip so i tried to create command
pawn Код:
enum pInfo
{
    pAdminLevel,
    pCash,
    pScore,
    pVip,
    pBanned,
}
OnPlayerConnect
pawn Код:
if(PlayerInfo[playerid][pBanned] == 1)return ShowPlayerDialog(playerid,12341,DIALOG_STYLE_MSGBOX,"Banned","You are banned from playing in this server","quit","");
Ban command:
pawn Код:
CMD:ban(playerid, params[])
{
    new id, reason[28];
    if(PlayerInfo[playerid][pAdminLevel] <= 2)return SendClientMessage(playerid,-1,"{FF0000}[ERROR]:{FAF5F5}You are not{FF0000} Administrator {FAF5F5}level 2 to use this command");
    else if(sscanf(params, "us", id, reason))SendClientMessage(playerid,-1,"{FF0000}[System Usage]:{FAF5F5}/ban [playerid] [reason]");
    else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,-1,"{FF0000}[ERROR]:{FAF5F5}Player is not connected!");
    else {
          new Name[MAX_PLAYER_NAME], BanMessage[128];
          new Name2[MAX_PLAYER_NAME];
          GetPlayerName(playerid, Name, sizeof(Name));
          GetPlayerName(id, Name2, sizeof(Name2));
          format(BanMessage, sizeof(BanMessage),"{FF0000}[Ban]:{FAF5F5}Adminstrator %s banned %s from server | reason: {FF0000}%s",Name,Name2,reason);
          SendClientMessageToAll(-1,BanMessage);
          PlayerInfo[id][pBanned] = 1;
          Kick(id);
         }
    return 1;
}
The problem is its working while i am starting samp-server when i restart server i can connect it doesn't check if i am banned or not...sorry for my bad english , thanks.
Reply
#2

Any help please guys ? sorry for bump up but i really need help.
Reply
#3

Is ur cmd writing banned = 1 in player's user files?
Reply
#4

Put this line at the OnDialogResponse for dialog login, once he logs in, he will be kicked, because the actual PlayerInfo[playerid][variable] files load once he's logged in.

pawn Код:
// this line goes OnDialogResponse for the login dialog

if(PlayerInfo[playerid][pBanned] == 1)
{
    ShowPlayerDialog(playerid,12341,DIALOG_STYLE_MSGBOX,"Banned","You are banned from playing in this server","quit","");
    return 1;
}
Reply
#5

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
Put this line at the OnDialogResponse for dialog login, once he logs in, he will be kicked, because the actual PlayerInfo[playerid][variable] files load once he's logged in.

pawn Код:
// this line goes OnDialogResponse for the login dialog

if(PlayerInfo[playerid][pBanned] == 1)
{
    ShowPlayerDialog(playerid,12341,DIALOG_STYLE_MSGBOX,"Banned","You are banned from playing in this server","quit","");
    return 1;
}
First thank you for reply , i already try to add it in dialog of login but when i join server it show me only the login dialog not this while i am on User's.ini
Banned =1
Reply
#6

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
First thank you for reply , i already try to add it in dialog of login but when i join server it show me only the login dialog not this while i am on User's.ini
Banned =1
I know.. I said above:

Код:
once he logs in, he will be kicked because the actual PlayerInfo[playerid][variable] files load once he's logged in.
If I'm wrong by saying this, then I have no idea what the problem is .
Reply
#7

Quote:
Originally Posted by PrinceKumar
Посмотреть сообщение
Is ur cmd writing banned = 1 in player's user files?
Yes.
Reply
#8

FIXED
Reply
#9

Learn sscanf.. "u" is a parameter of an ID (e.g. playerid, giveplayerid, ReturnUser etc.) Strings are the words, that you can use, so using an "s[arrays]" instead of a "u" will work.

pawn Код:
CMD:ac(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] == 0)return SendClientMessage(playerid,-1,"{FF0000}[ERROR]:{FAF5F5}You are not{FF0000} Administrator {FAF5F5}to use admin chat");
    new name[MAX_PALYER_NAME]/*why was this over 1k? a name isn't over 1k characters*/,i , text[126], string[200];
    if(sscanf(params, "s[126]", text))return SendClientMessage(playerid,-1,"{FF0000}[System Usage]:{FAF5F5}/ac [text]");
    GetPlayerName(i, name, sizeof(name));
    format(string, sizeof(string), "{FFD700}[%s] %s: %s", GetPlayerAdminRank(i),name ,text);
    SendMessageToAdmins(string);
    return 1;
}
Scroll down to "Specifiers" on this page: https://sampforum.blast.hk/showthread.php?tid=120356.
Reply
#10

Thank you it's now working , sorry for my mistakes but i just start learning from 3 days i didn't read well about this its my fault , but any way thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)