PDA

View Full Version : [Tutorial] force a player to reconnect


JernejL
22/09/2010, 09:01 PM
This is fairly simple thing to achieve, so i did not include code.

Basically, sometimes you want a player to reconnect - say if a player pauses and you wish to kick him & have him reconnect when he returns, or for various other reasons, so this is how it works:

1. In code, rcon ban the ip, but DON'T KICK the player
2. The player will timeout, in onplayerdisconnect unban the ip that was banned for him - remember that getplayerip doesnt work in onplayerdisconnect, so store the value elsewhere.
3. Player's client will lose connection and attempt to auto-reconnect afterwards.

[L3th4l]
22/09/2010, 09:58 PM
Nice

Steven82
22/09/2010, 09:59 PM
Have you tested this to make sure? Or are you assuming it will work? 0.0

Jantjuh
23/09/2010, 05:23 AM
Have you tested this to make sure? Or are you assuming it will work? 0.0

ye, it sure works, i teted it and it is an awesome handy way ::D

Hiddos
23/09/2010, 12:36 PM
Looks nice, another "glitch". If I were still scripting, I'd use it hehe.

Mikkel_Pedersen
24/09/2010, 01:04 PM
Wauw thanks a lot for showing us this. I tried making a command to force players to reconnect. And i may say i had some problems, first transfering the ip in a timer. But i got that fixed. And then had to find the time until it should unban you. But now it works.

Kyosaur
24/09/2010, 01:28 PM
Nice, very clever thinking :D.

Hijolion
25/09/2010, 03:40 AM
Tested in my server, worked perfectly!

Kwarde
25/09/2010, 05:40 AM
Indeed. But I already used this in my server ;) (my OLD server)

MrDeath537
27/09/2010, 10:39 PM
Very nice, I'm sure I'll use it.

Calgon
27/09/2010, 11:09 PM
Nice one, I'll try to make use of this later.

cyber_punk
28/09/2010, 01:32 AM
Nice, I have a bit of an off topic question (could kinda be on topic) but I read in another thread that you have a way to detect the half connected bug. My question is are you simply just checking the time between player updates and if its over a certain time you know they missed some updates/timed out and are therefore in a desync'ed state? Just kinda curious because using your reconnect method with the half connected detection would be really really nice and very useful.

Tenshi
10/01/2011, 08:32 PM
not trying to be mean or selfish, but how is this listed as a Tutorial?
more like how to idea, not really tutorial, just saying...

cessil
11/01/2011, 04:52 AM
here's an example of what it may look like
OnPlayerConnect(playerid)
{
new IP[20];
GetPlayerIp(playerid,IP,sizeof(IP));
SetPVarString(playerid,"ip",IP);
}
OnPlayerBugged(playerid)
{
SetPVarInt(playerid,"bugban",1);
new IP[24];
GetPlayerIp(playerid,IP,sizeof(IP));
format(IP,sizeof(IP),"banip %s",IP);
SendRconCommand(IP);
}
OnPlayerDisconnect(playerid)
{
if(GetPVarInt(playerid,"bugban") == 1)
{
new string[24];
GetPVarString(playerid,"ip",string,sizeof(string));
format(string,sizeof(string),"unbanip %s",string);
SendRconCommand(string);
SendRconCommand("reloadbans");
}
}

JernejL
24/02/2011, 11:56 AM
You don't have to use reloadbans if you use rcon unbanip ingame.
reloadbans is only needed to reload samp.ban file if you changed it externally.

Biesmen
24/02/2011, 01:27 PM
not trying to be mean or selfish, but how is this listed as a Tutorial?
more like how to idea, not really tutorial, just saying...

How to and Tutorial is the same.

-- On topic:

Thanks. I'm gonna use this

black_dota
24/02/2011, 05:14 PM
Why to unban and all that shit, simply make command fakeban or fban and then in code just kick the player but add the message You have been banned from this server

Hiddos
24/02/2011, 05:41 PM
Why to unban and all that shit, simply make command fakeban or fban and then in code just kick the player but add the message You have been banned from this server

:picard:

If you actually would read the thread you might notice that it explains how to re-connect a player serversided, not a way to fake a ban.

Mean
24/02/2011, 06:04 PM
Thank you. Lovely.
EDIT: How do I unban an IP in RCON?

[03]Garsino
24/02/2011, 06:07 PM
Thank you. Lovely.
EDIT: How do I unban an IP in RCON?

SendRconCommand + unbanip IP

Mean
24/02/2011, 06:09 PM
Knew about SendRconCommand, but didn't know what is the cmd to unban da IP in RCON. Thank you.

DarkKillerWithPride<3
04/01/2012, 02:12 PM
EDIT:nvm ^^ says it all

aco_SRBIJA
29/01/2012, 06:39 PM
The cessil code doesen't work...It says You're banned, but you can re join and everything gonna be okay...

[BFK]MetalHead
30/01/2012, 10:27 AM
Thanks man.really thanks.i really needed this.

Konstantinos
30/01/2012, 11:03 AM
I had tested some months ago and all worked perfect on reconnect myself with '/recon'.
The only problem was that when my IP got unban when it was time to login OnPlayerConnect with Dialogs, my statistics mixed up.

Drebin
15/07/2012, 01:57 PM
Note: Since SA-MP 0.3e R2 this trick does not work anymore (due to the security update).

[MM]RoXoR[FS]
16/07/2012, 04:04 AM
Aint working for me
Code I used

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
new pIP[20];

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}


public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new tst[50];
format(tst,50,"unbanip %s",pIP);
SendRconCommand(tst);
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/ban", cmdtext, true, 10) == 0)
{
GetPlayerIp(playerid,pIP,20);
new tst[50];
format(tst,50,"banip %s",pIP);
SendRconCommand(tst);
return 1;
}
return 0;
}

It ban me when I type /ban.
When I disconnect it does unban me, but I have to quit GTA SAN AN and come back.
If i dont exit my game, it said You are banned .

Kirollos
20/07/2012, 08:54 PM
RoXoR[FS];1989935']Aint working for me
Code I used

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
new pIP[20];

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}


public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new tst[50];
format(tst,50,"unbanip %s",pIP);
SendRconCommand(tst);
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/ban", cmdtext, true, 10) == 0)
{
GetPlayerIp(playerid,pIP,20);
new tst[50];
format(tst,50,"banip %s",pIP);
SendRconCommand(tst);
return 1;
}
return 0;
}

It ban me when I type /ban.
When I disconnect it does unban me, but I have to quit GTA SAN AN and come back.
If i dont exit my game, it said You are banned .

look what drebin said:

Note: Since SA-MP 0.3e R2 this trick does not work anymore (due to the security update).

_Jake_
21/07/2012, 01:42 AM
Trick doesn't work anymore.
Due to new security updates.

Mr.R
24/07/2012, 03:34 PM
Any example in code? I don't understand this as well..

Kindred
24/07/2012, 04:16 PM
Any example in code? I don't understand this as well..

Doesn't even work anymore, don't bother.

Read the post above yours.

Lordz™
23/10/2012, 06:22 AM
Nice idea though, couldn't we set player's pos to unknown coordinate and then set skin to 9999 so that player will get crashed?

_Jake_
23/10/2012, 07:16 AM
^^

No you couldn't do that,
If you set player to unknown skin id, it will automatically crash the game.
Close the game, and show the report crash from SA-MP..

I already test this before.

And it went out like i just mention above.