SA-MP Forums Archive
Ban Checking - Is this effective? - 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: Ban Checking - Is this effective? (/showthread.php?tid=295839)



Ban Checking - Is this effective? - GAMER_PS2 - 08.11.2011

Now i have made my own ban checking but i dont think this will be effective
Yeah it will work but when he/she change name he/she can now join the server
again because i use this

pawn Код:
if(PlayerInfo[playerid][pBanned] == 1)
{
//Message here blahblahblah
}
Now i also want to check the IP too heres my command of ban
i also want when you edit the file of player, banned category
it will ban the ip too

Heres my code of Ban

pawn Код:
CMD:ban(playerid, params[])
{
    new pid;
    new ip[128];
    if(PlayerInfo[playerid][pAdmin] >= 3 || IsPlayerAdmin(playerid))
    {
        if(sscanf(params, "us[128]", pid, params[2])) return SendClientMessage(playerid,COLOR_RED, "USAGE: /ban <playerid/name> <reason>");
        if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player is not connected!");
        if(pid == playerid) return SendClientMessage(playerid,COLOR_RED, "ERROR: You cant ban yourself!");
        new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
        new year,month,day; getdate(year, month, day);
        new hour,minute,second; gettime(hour,minute,second);
        GetPlayerName(pid, paramname, sizeof(paramname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string, sizeof(string), "Administrator %s has ban %s <Reason: %s> <Date: %d/%d/%d> <Time: %d:%d>",adminname,paramname, params[2],month,day,year,hour,minute);
        SendClientMessageToAll(COLOR_RED, string);
        SaveIn("BanLog",string);
        format(string, sizeof(string), "You have been ban by Administrator %s <Reason: %s>", paramname, params[2]);
        SendClientMessage(pid,COLOR_RED, string);
        format(string, sizeof(string), ""red"Administrator Bans You: %s\nTime: %d:%d\nDate: %d/%d/%d\nReason: %n\nNote:"white"If you are mistakely get banned go to our forums at [url]www.server.com\nand[/url] make unban appeal", adminname, params[2],hour,minute,month,day,year,params[2]);
        ShowPlayerDialog(pid,453, DIALOG_STYLE_MSGBOX,""white"Banned Info:",string,"Ok","");
        SendClientMessage(pid,COLOR_WHITE, "==============================================");
        format(string, sizeof(string), "You have been ban by Administrator %s <Reason: %s>", paramname, params[2]);
        SendClientMessage(pid,COLOR_RED, string);
        SendClientMessage(pid,COLOR_RED, "Make unban appeal at our forums. www.server.com");
        SendClientMessage(pid,COLOR_WHITE, "==============================================");
        format(string, sizeof(string), "You ban %s <Reason: %s>", paramname, params[2]);
        SendClientMessage(playerid,COLOR_RED, string);
        Ban(pid);
        format(ip,128,"%s**",ip);
        format(ip,128,"banip %s",params[2]);
        SendRconCommand(ip);
        new INI:File = INI_Open(UserPath(playerid));
        PlayerInfo[pid][pBanned] = 1;
        INI_WriteInt(File,"Banned",1);
        INI_Close(File);
        format(string,sizeof(string),"Administrator %s has banned %s",adminname,paramname);
        SendToAdmins(COLOR_GREY,string);
        format(string, sizeof(string), "Administrator %s has banned %s <Reason:%s>",adminname,paramname,params[2]);
        printf(string);
    }
    else return SendClientMessage(playerid,COLOR_RED, "ERROR: You must be Administrator Level 3 to use this command");
    return 1;
}
then heres my player file stats:

Код:
[data]
Password = 187367946
Cash = 999999990
Score = 99810
Admin = 10
Banned = 1 //Heres the part i want to check the ip too
Kills = 5981
//the IP checking would be here if needed
Deaths = 8
Please help


Re: Ban Checking - Is this effective? - =WoR=G4M3Ov3r - 08.11.2011

https://sampwiki.blast.hk/wiki/GetPlayerIp

For example

PHP код:
new ip[128];
GetPlayerIp(giveplayerid,ip,128); 



Re: Ban Checking - Is this effective? - GAMER_PS2 - 08.11.2011

ok now i add IP on File Stats but now how can i check the ip onplayerconnect


Re: Ban Checking - Is this effective? - =WoR=G4M3Ov3r - 08.11.2011

PHP код:
CheckBan(ip[])
{
    new 
string[20];
    new 
Filefile fopen("ban.cfg"io_read);
    while(
fread(filestring))
    {
        if (
strcmp(ipstringtruestrlen(ip)) == 0)
        {
            
fclose(file);
            return 
1;
        }
    }
    
fclose(file);
    return 
0;

Under the OnPlayerConnect callback, use this.

PHP код:
if (CheckBan(playerIP) == 1)
    {
        
SetPlayerName(playerid"BannedPlayer");
        
SendClientMessage(playerid0xFFFFFFAA"You are banned from this server.");
        
Kick(playerid);
        return 
1;
    } 
Not tested, but try it.


Re: Ban Checking - Is this effective? - GAMER_PS2 - 08.11.2011

Dude can we talk on PM? i hate to talk about scripting on public anyway i need also help saving IP on File Stats (Answer it on PM if you want)

I'm just tried so forgive me


Re: Ban Checking - Is this effective? - =WoR=G4M3Ov3r - 08.11.2011

Quote:
Originally Posted by GAMER_PS2
Посмотреть сообщение
Dude can we talk on PM? i hate to talk about scripting on public anyway i need also help saving IP on File Stats (Answer it on PM if you want)

I'm just tried so forgive me
Which storage data are you using ?


Re: Ban Checking - Is this effective? - GAMER_PS2 - 08.11.2011

What you mean? if this is your asking for i will post the code:

pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pScore,
    pAdmin,
    pKills,
    pFreeze,
    pBanned,
    pDeaths,
    pGod,
    pMute,
    pWarn,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
if i'm not wrong


Re: Ban Checking - Is this effective? - =WoR=G4M3Ov3r - 08.11.2011

Quote:
Originally Posted by GAMER_PS2
Посмотреть сообщение
What you mean? if this is your asking for i will post the code:

pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pScore,
    pAdmin,
    pKills,
    pFreeze,
    pBanned,
    pDeaths,
    pGod,
    pMute,
    pWarn,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
if i'm not wrong
These are enums.. Anyways I'm assuming you're using ini

What I gave you earlier, saves in your scriptfiles, with a file named "ban.cfg".


Re: Ban Checking - Is this effective? - GAMER_PS2 - 08.11.2011

Thanks for Help Never Mind i will skip this part i will continue it later but you have still rep+ you respect me so much i hate other users they didnt respect me even i explain what to do


Re: Ban Checking - Is this effective? - =WoR=G4M3Ov3r - 08.11.2011

Quote:
Originally Posted by GAMER_PS2
Посмотреть сообщение
Thanks for Help Never Mind i will skip this part i will continue it later but you have still rep+ you respect me so much i hate other users they didnt respect me even i explain what to do
You asked for help, I only disrespect retards who don't try using the search button, but to post here and annoy + spam us for help.

So, if you still need help concerning this, feel free to PM me.