Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: rObInX on Feb 18, 2015, 06:39 PM

Title: Crash
Post by: rObInX on Feb 18, 2015, 06:39 PM
Server crashes when using a timer.
Codes:
if ( CheckBan( player ) == 1 ) NewTimer( "Kick", 5000, 1, player );
function Kick( player )
{
  EMessage( "** [" + player.ID + "] " + player.Name + " has left the server( KICKED )." );
  player.Kick();
}

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi62.tinypic.com%2F2vlli4y.jpg&hash=b26000d076577941224cfc59ed0f68b1f13d1ac8)
Title: Re: Crash
Post by: Thijn on Feb 18, 2015, 06:44 PM
Known bug: https://bitbucket.org/stormeus/0.4-squirrel/issue/9/some-types-of-data-crash-timers

Use a wrapper function and pass an player ID instead of instance.

Locked.
Title: Re: Crash
Post by: Stormeus on Feb 18, 2015, 07:08 PM
I just want to point out that this would crash your server anyway if the player left in the five seconds it takes to kick them.

You can check if a player is still online by using a timer with player.ID instead of player, then using this in your Kick function:
function Kick(playerID) {
    local player = FindPlayer(playerID);
    if (player == null) {
        return;
    }

    EMessage( [...]