SA-MP Forums Archive
Problem with Ban Command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with Ban Command (/showthread.php?tid=412053)



Problem with Ban Command - Biess - 31.01.2013

Alright i have this command

pawn Код:
CMD:ban(playerid,params[]) {
    new reason[100], id,szString[64];
    if(PInfo[playerid][Level] < 2) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");
        if(sscanf(params,"ds",id,reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ban <playerid> <reason>");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
        new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(id, PlayerName, sizeof(PlayerName));
        new GPlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));
        new plrIP[64];
        GetPlayerIp(id, plrIP, 64);
        new Year, Month, Day;
        getdate(Year, Month, Day);
        format(szString, sizeof(szString), "%s (ID:%d) has been banned by %s Reason: %s", PlayerName,GPlayerName, id, reason);
        SendClientMessageToAll(0xFF444499, szString);
        format(szString, sizeof(szString), "Admin %s, Used The Command: 'BAN' Target: %s", GPlayerName, PlayerName);
        SendClientMessageToAdmins(szString);
        format(szString, sizeof(szString), "You Have Been Banned By Admin: %s (ID:%d)", GPlayerName, playerid);
        SendClientMessage(id, 0x00B359FF, szString);
        format(szString, sizeof(szString), "Reason: %s", reason);
        SendClientMessage(id, 0x00B359FF, szString);
        format(szString, sizeof(szString), "Date: %02d/%02d/%d", Day, Month, Year);
        SendClientMessage(id, 0x00B359FF, szString);
        SendClientMessage(id, 0xF74646FF, "If you wish to appeal this ban, Then Appeal At: TOBEANNOUNCED");
        format(szString, sizeof(szString), "[BAN] | Admin: %s | Name: %s | Reason: %s | Date: %02d/%02d/%d | IP: %s<hr/>", GPlayerName, PlayerName, reason, Day, Month, Year, plrIP);
        Ban(id);
        return 1;
 }
But i want it to save a banned variable what i already made but i can't get it working properly
I'm using SII include.
pawn Код:
INI_WriteInt("Banned",1);
And than onplayerconnect when the Banned = 1 i want it to send a message

"You are banned from this server
Banned By:
Reason:"
Date:"

As you can see in my ban cmd. thanks.


Re: Problem with Ban Command - iGetty - 31.01.2013

Well, when you are doing the connecting, select the file from the username, then read if the "banned" integer is set to 1, if it is, then kick the player. If not, let the player play.

Simple.


Re: Problem with Ban Command - Biess - 31.01.2013

I need help with saving the variable on the ban cmd...
and than i move on too the onplayerconnect thingy.


Re: Problem with Ban Command - tyler12 - 31.01.2013

Assuming you save OnPlayerDisconnect, Just set the variable.


Re: Problem with Ban Command - Biess - 31.01.2013

Quote:
Originally Posted by tyler12
Посмотреть сообщение
Assuming you save OnPlayerDisconnect, Just set the variable.
This is onplayerdisconnect

pawn Код:
INI_Open(file);
        INI_WriteInt("Rank", PInfo[playerid][Rank]);
        INI_WriteInt("Level", PInfo[playerid][Level]);
        INI_WriteInt("Operator", PInfo[playerid][Operator]);
        INI_WriteInt("Banned", PInfo[playerid][Banned]);
        INI_WriteInt("Kills", PInfo[playerid][Kills]);
        INI_WriteInt("Deaths", PInfo[playerid][Deaths]);
        INI_WriteInt("Score", scores);
        INI_WriteInt("Money", money);
        INI_Save();
        INI_Close();



Re: Problem with Ban Command - iGetty - 31.01.2013

Then under the /ban command, add

PInfo[id][Banned] = 1;

That should work, then it will call onplayerdisconnect.

Edit: Also, change

Ban(id);

to

Kick(id);

as it will ban them from the server and just show "You are banned from this server.".

That way, you can add your own custom message under OnPlayerConnect.


Re: Problem with Ban Command - Biess - 31.01.2013

Quote:
Originally Posted by iGetty
Посмотреть сообщение
Then under the /ban command, add

PInfo[id][Banned] = 1;

That should work, then it will call onplayerdisconnect.

Edit: Also, change

Ban(id);

to

Kick(id);

as it will ban them from the server and just show "You are banned from this server.".

That way, you can add your own custom message under OnPlayerConnect.
Yep tested that works but now how do i make that custom message saying

You are banned from this server
Banned by:
Reason:"
Date:

Just like in the ban cmd?

pawn Код:
public OnPlayerConnect(playerid) {
    SendClientMessage(playerid,red,"Welcome to United Kingdom TDM! Dont forget to check /updates ! ");
    SendClientMessage(playerid,GREEN,"Remember to /buyrank to buy a rank ");
    new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "** %s has joined United Kingdom TDM", name);
    IsOnAdminDuty[playerid] = false;
    PInfo[playerid][Money] = 0;
    PInfo[playerid][Score] = 0;
    PInfo[playerid][Kills] = 0;
    PInfo[playerid][Deaths] = 0;
    PInfo[playerid][Level] = 0;
    PInfo[playerid][Rank] = 0;
    SendClientMessageToAll(-1, string);
    PMEnabled[playerid] = 1;
    IsMuted[playerid] = 0;
    TogglePlayerSpectating(playerid, false);
   
    new file[64],PlayerName[25];//Creating a variable where we can store the file path, and the variable to store the player's name.
    GetPlayerName(playerid,PlayerName,sizeof PlayerName);//Storing the players name in the PlayerName variable.
    format(file,sizeof file,"Admin/%s.ini",PlayerName);//Storing the file path with the players name.
    if(fexist(file)) {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login Below", "Enter Your Password To Login!", "Login", "Quit");
    } else {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below", "Enter A Password To Register And Play!", "Register", "Quit");
    }
    return 1;
}



Re: Problem with Ban Command - tyler12 - 31.01.2013

You'd have to store the stuff within your players file.


Re: Problem with Ban Command - Biess - 31.01.2013

Anyway how can i make that message can you add it into onplayerconnect?


Re: Problem with Ban Command - tyler12 - 31.01.2013

The same as you made it on the /ban command, but replacing the strings with the stuff saved in the file.