Ban a offline player
#1

How can I ban a player that logged off besides using the rcon command?
Reply
#2

You have save player stats ? like this
pawn Код:
enum pInfo
{
  pBan,
}
Reply
#3

Yea I do
Reply
#4

https://sampforum.blast.hk/showthread.php?pid=2194818#pid2194818

Try to use the search feature next time.
Reply
#5

EDITED!
Reply
#6

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
I will use zcmd , y_ini,sscanf2 i think you know about includes
In the top of your script add
pawn Код:
#include <zcmd>
#include <sscanf2>
#include <YSI\y_ini>
If you already got that its okay
pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Now just edit to
pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pBanned,
    BannedIP[22]
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Now go to your dialoge or /cmd or login/register and add this
pawn Код:
new IP[22];
          GetPlayerIp(playerid, IP, sizeof(IP));
          INI_WriteString(File, "Ip", IP);

Now the whole command.
pawn Код:
CMD:offlineban(playerid, params[])
{
    new targetname[24], filestring[79];
    if(sscanf(params, "s[24]", targetname)) return SendClientMessage(playerid, -1, "Usage: /oflineban [Player's Name]");
    format(filestring, sizeof(filestring), "/Users/%s.ini", targetname);
    if(!fexist(filestring)) return SendClientMessage(playerid, -1, "Error: Player name not in your user.ini file!");
    else
    {
        new INI:File = INI_Open(UserPath(filestring));
        INI_SetTag(File, "data");
        INI_WriteInt(File, "Banned", 1);
        INI_Close(File);
        new done[128];
        format(string, sizeof(done), "You have banned player %s!", targetname);
        SendClientMessage(playerid,-1 , string);
    }
    return 1;
}
Now Type in your keyboard Control+F OnPlayerConnect
pawn Код:
if(PlayerInfo[playerid][pBanned] == 1)
{
    SendClientMessage(playerid,-1,"You are banned from playing in this server");
    Ban(playerid);
}
Add this
pawn Код:
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Banned", PlayerInfo[playerid][pBanned]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
Hope it was helpfull
You got a mistake in there. Exactly the same mistake I had in my tutorial. Copy-paste, eh?

You should atleast include the source from where you got it from.
Reply
#7

I already learned from the guy you posted thread link , i try to help him faster if there is errors i will try to fix.
Reply
#8

Sorry i didn't notice that you are the owner I'm sorry.
Reply
#9

Thanks, I searched for a while tho untill I couldn't find any tutorials like you just linked me I decided to post a help request so yea thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)