Samp-Bans help
#1

I have this on OnPlayerConnect

PHP код:
CheckBan(playerid
Which checks the ban from here

PHP код:
stock CheckBan(playerid)
{
    
format(post_stringsizeof(post_string), "action=checkip&apikey="#APIKEY"&ban_ip=%s", ips[playerid]);
    
HTTP(playeridHTTP_POSTAPIPATHpost_string"OnCheckResponse");
    return 
1;

Then the check response from here
PHP код:
public OnCheckResponse(indexresponse_codedata[])
{
    if(
response_code == 200)
    {
        if(
sscanf(data"p?ss"errorcode)) printf("[SAMP-BANS]: Error,  API responded with: %s"data);
        else if(
strcmp(error"Success"true) == 0)
        {
             
SendClientMessage(index0xFFFFFFcode);
            
Kick(index);
            
printf("[SAMP-BANS]: %s"code);*/
            new 
playerid[MAX_PLAYERS], string[128];
            
SendClientMessage(playerid0xFFFFFFFF"You are banned from {FF9900}xxxxxx");
   
Kick(playerid); // Tried adding the above 2 lines and this line, but getting errors :/
   //return 1;
        
}
        else if(
strcmp(code"Ban not found")) printf("[SAMP-BANS]: Error,  API responded with: %s"code);
    }
    else 
printf("[SAMP-BANS]: Encountered an error, the page didn't respond");

The problem is, when I ban someone, he connects, but doesn't get kick, how do I apply kick(playerid) on the check response, so the player get kicked,
I also tried adding Kick(playerid) on the check response but says undefined symbol playerid
Reply
#2

playerid has no value and you are never define playerid in this function.

Print data to see what you can get more from this response.
Reply
#3

Quote:
Originally Posted by Azazelo
Посмотреть сообщение
playerid has no value and you are never define playerid in this function.
Yea I know it's not defined in the public function, but how do I kick a player in the response, once it detects if a player is banned
Reply
#4

You can go trow all player id to find mach for IP. For example or you can make a list of ip address when player connected and then go trow that.

and if you have a time print raw data from data array and copy/paste here.
Reply
#5

i'm using Samp-bans Fs, that means I don't have my own ban file, It bans only Ip addresses, and I just want to kick those players who connect that are IP banned
Reply
#6

The index variable in OnCheckResponse is the playerid, so therefore replace playerid with index whenever you want to specify the players ID.

pawn Код:
public OnCheckResponse(index, response_code, data[])
{
    if(response_code == 200)
    {
        if(sscanf(data, "p?ss", error, code)) printf("[SAMP-BANS]: Error,  API responded with: %s", data);
        else if(strcmp(error, "Success", true) == 0)
        {
            SendClientMessage(index, 0xFFFFFF, code);
            Kick(index);
            printf("[SAMP-BANS]: %s", code);
        }
        else if(strcmp(code, "Ban not found")) printf("[SAMP-BANS]: Error,  API responded with: %s", code);
    }
    else printf("[SAMP-BANS]: Encountered an error, the page didn't respond");
}
That should do it already, if it doesn't then it means that there is a configuration problem. You should look at the console to see what is printed when you join as someone who is banned.
Reply
#7

Yes I know that I have to use the index as playerid, but still, the player does not get kicked once it checks the ban, (He just reconnects and reconnects"

Here is the log:
PHP код:
Rj has connected to the server
Rj has left the server 
(kicked)
Rj has connected to the server
Rj has left the server
(kicked)
Rj has connected to the server
Rj has left the server 
(kicked
This goes on and on, The banned player will try to connect and connect but it fails so it just does that in the chatbox

Why does the response does not check if he is banned and then KICK him right away?
Reply
#8

Kick(playerid); is the reason why that is happening.
set a timer to 7000 milesecs or try 5000 milesecs then call CheckBan when the timer is called.

i have solve this by setting the timer and calling the CheckBan after the timer is called
Reply
#9

Quote:
Originally Posted by Romel
Посмотреть сообщение
Kick(playerid); is the reason why that is happening.
set a timer to 7000 milesecs or try 5000 milesecs then call CheckBan when the timer is called.

i have solve this by setting the timer and calling the CheckBan after the timer is called
Can you set an example please of how i'm going to use timer to call the CheckBan?
It's hard for a noob to do (well atleast for me though)
Reply
#10

You mean something like this?

PHP код:
SetTimer("CheckBan"7000false); 
Already added it, and once i ban someone, he can connect effortlessly, (the ban did not work, because of the timer?)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)