The online racing simulator
Server IP Kick
(9 posts, closed, started )
Server IP Kick
Hello

I found a code when I was browsing the forum. We will create a new text document, If you have IP in the list if a direct kick. For this can you help?


Code :

Event OnNewPlayerJoin( $userName )
IF (GetCurrentPlayerVar($userName,"IPAdress") == "127.0.0.1")
THEN
cmdLFS("/kick " . GetCurrentPlayerVar("userName") );
ENDIF
EndEvent

There are many functions in Lapper to add a player to a file or check if the player exits in the current file. And ofcourse you can remove the player from that file.

See the functions below. If you use the searchfunction of this forum.
You will see many many examples.

moveusertogroup();
getlistofusersgroup();
usergroupfromfile();
usergrouptofile();
removeuserfromgroup();
useringroup();
I did something like this , where is the error ?



<?php 
Event OnNewPlayerJoin
$userName 
UserInGroup"IPAdress""./Blacklist.txt" );

IF (
UserInGroupGetCurrentPlayerVar($userName,"IPAdress") == 1
THEN
cmdLFS
("/kick " GetCurrentPlayerVar("userName") );
ENDIF
EndEvent
?>


I think it must be like this:

Event OnNewPlayerJoin( $userName )
UserInGroup( "IPAdress", "./Blacklist.txt" );

IF (UserInGroup( GetCurrentPlayerVar("IPAdress") == 1)
THEN
cmdLFS("/kick " . GetCurrentPlayerVar("userName") );
ENDIF
EndEvent

I tried, unfortunately did not work . I think the problem , Can not pull ip address from list
Quote from Stakikety :I tried, unfortunately did not work . I think the problem , Can not pull ip address from list

Sorry, I did the code from the head and hadn't tested it.
This should work:


Event OnNewPlayerJoin( $userName )
$userName = GetCurrentPlayerVar( "UserName" );
UserGroupFromFile( "IPAddress", "./Blacklist.txt" );

IF ( UserInGroup( "IPAddress",$userName ) == 1 )
THEN
cmdLFS("/kick " . GetCurrentPlayerVar("userName") );
ENDIF
EndEvent

I just realised that above code will check if the userName is in the Blacklist.txt , while you want to check the IPAdress.
So here's another piece of code to do just that:


Event OnNewPlayerJoin( $userName )
$IPAddress = GetCurrentPlayerVar( "IPAdress" );
UserGroupFromFile( "IPAddress", "./Blacklist.txt" );

IF ( UserInGroup( "IPAdress",$IPAddress ) == 1 )
THEN
cmdLFS("/kick " . GetCurrentPlayerVar("userName") );
ENDIF
EndEvent

Thank you , I tried to kick myself , no kick . Ip address 127.0.0.1 I did. I guess that throws another player ?
Being a localhost, you can't kick or ban your self.
I have tried the code to block the IP connection but it does not work, putting the IP in the .txt file does not throw the user who connects with that IP
This thread is closed

Server IP Kick
(9 posts, closed, started )
FGED GREDG RDFGDR GSFDG