AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Boolean Reset Only Disconnect (https://forums.alliedmods.net/showthread.php?t=293999)

siriusmd99 02-17-2017 07:33

Boolean Reset Only Disconnect
 
I have an array g_canJoin[33]

So i reset the value after client disconnect:
g_canJoin[id]= false;

Do i need to reset it also on client_connect?

I heard that sometimes when client crashes or looses internet connection there is a chance that player_disconnect event doesnt trigger after player disconnection.

This means that after one player's disconnect without player_disconnect event then boolean will stay true on connection instead of false.

Is this true? And is it safe to reset boolean value only on disconnect?

edon1337 02-17-2017 07:58

Re: Boolean Reset Only Disconnect
 
Depends the situation, example in Ice Cube plugin, you must reset it on disconnect either if player is frozen and disconnects the ice cube will remain. It's not necessary to reset on both forwards, reset it just on client_disconnect or just client_connect , just put some logic into it.

HamletEagle 02-17-2017 08:13

Re: Boolean Reset Only Disconnect
 
For amxx < 183, there is a chance that client_disconnect won't be fired. A new forward was added in 1.8.3 to fix this problem. Depending on what amxx version you use, decide when to reset.

siriusmd99 02-17-2017 08:22

Re: Boolean Reset Only Disconnect
 
Quote:

Originally Posted by edon1337 (Post 2496075)
Depends the situation, example in Ice Cube plugin, you must reset it on disconnect either if player is frozen and disconnects the ice cube will remain. It's not necessary to reset on both forwards, reset it just on client_disconnect or just client_connect , just put some logic into it.

You want logic? Ok.
For example I check users for inconsistent files (such as client side .dll files which can be fake cvar spoofer or different cheats) and if it doesn't find such file (incosistent file) it sets boolean allowed to true, else it sets boolean to false.
After that i check in putinserver boolean and if it's false then i kick player.

The problem is that I can't set allowed to false on connect because plugin_precache is triggered before client_connect. And imagine that case when client_disconnect is not triggered. It means that even if player has that file then boolean still remains true from previous disconnected player.

edon1337 02-17-2017 08:40

Re: Boolean Reset Only Disconnect
 
Then, use both.

PRoSToTeM@ 02-17-2017 09:42

Re: Boolean Reset Only Disconnect
 
If client is between connect and putinserver then client_disconnect is not called. If client is after putinserver then client_disconnect must be called always.

What is the problem to use client_connect for resetting?

siriusmd99 02-17-2017 10:18

Re: Boolean Reset Only Disconnect
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2496116)
If client is between connect and putinserver then client_disconnect is not called. If client is after putinserver then client_disconnect must be called always.

What is the problem to use client_connect for resetting?

Because value is set on precache. g_allowed= true is set on precache.
But precache is called before client_connect.

PRoSToTeM@ 02-17-2017 10:58

Re: Boolean Reset Only Disconnect
 
Quote:

Originally Posted by siriusmd99 (Post 2496137)
Because value is set on precache. g_allowed= true is set on precache.
But precache is called before client_connect.

What is g_allowed? Why u need precache?
Just set g_canJoin[x] = true in client_connect and reset it if something goes wrong.

EFFx 02-17-2017 11:53

Re: Boolean Reset Only Disconnect
 
In 183 isn't client_disconnected()?

georgik57 02-18-2017 10:43

Re: Boolean Reset Only Disconnect
 
Quote:

Originally Posted by HamletEagle (Post 2496081)
For amxx < 183, there is a chance that client_disconnect won't be fired. A new forward was added in 1.8.3 to fix this problem. Depending on what amxx version you use, decide when to reset.

But does FM's FM_ClientDisconnect for example work properly and cover all the cases?


All times are GMT -4. The time now is 20:45.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.