Vice City: Multiplayer

Community Projects => SLC's Squirrel Plugin => Bug Reports => Topic started by: Luckshya on July 20th, 2017, 11:23 AM

Title: [Fixed] player.Spec and player.Spectate
Post by: Luckshya on July 20th, 2017, 11:23 AM
Well, I was trying to spectate a player.
I first used player.Spec = plr which worked.
then I wanted to stop the player from spectating plr
so, I tried player.Spec = null which crashed the server with an error: std::out_of_range 
then, I tried player.RestoreCamera() which gave no effect.
then, I used player.Spectate(plr) which worked and player was spectating plr and plr left and the server crashed with that same error.

I still didn't get a way to stop someone from spectating.
Title: Re: [BUG] player.Spec and player.Spectate
Post by: vito1 on July 20th, 2017, 11:58 AM
player.SpectateTarget = player
Title: Re: [BUG] player.Spec and player.Spectate
Post by: EK.IceFlake on July 20th, 2017, 12:12 PM
Quote from vito1 on July 20th, 2017, 11:58 AM
player.SpectateTarget = player
What?
Title: Re: [BUG] player.Spec and player.Spectate
Post by: vito1 on July 20th, 2017, 01:11 PM
Quote from EK.IceFlake on July 20th, 2017, 12:12 PM
Quote from vito1 on July 20th, 2017, 11:58 AM
player.SpectateTarget = player
What?
That.
Quote
way to stop someone from spectating.
It's equal to player.SpectateTarget = null
Title: Re: [BUG] player.Spec and player.Spectate
Post by: EK.IceFlake on July 20th, 2017, 04:14 PM
Quote from vito1 on July 20th, 2017, 01:11 PM
Quote from EK.IceFlake on July 20th, 2017, 12:12 PM
Quote from vito1 on July 20th, 2017, 11:58 AM
player.SpectateTarget = player
What?
That.
Quote
way to stop someone from spectating.
It's equal to player.SpectateTarget = null
player.SpectateTarget doesn't exist in SLC's plugin.
Title: Re: [BUG] player.Spec and player.Spectate
Post by: vito1 on July 20th, 2017, 04:32 PM
Quote from EK.IceFlake on July 20th, 2017, 04:14 PM
Quote from vito1 on July 20th, 2017, 01:11 PM
Quote from EK.IceFlake on July 20th, 2017, 12:12 PM
Quote from vito1 on July 20th, 2017, 11:58 AM
player.SpectateTarget = player
What?
That.
Quote
way to stop someone from spectating.
It's equal to player.SpectateTarget = null
player.SpectateTarget doesn't exist in SLC's plugin.
Ah I did not noticed this section, sorry.
Title: Re: [BUG] player.Spec and player.Spectate
Post by: . on July 24th, 2017, 04:10 PM
Entities have something called null entities. Like: SqPlayer.NullInst(); Which you can use to specify an entity which doesn't exist. Which you can use with player.Spectate(...);

This spectating crash has been reported several times an tbh I have no idea wtf is causing it. Could be an event fired when the player is spectated. Which corrupts the stack or something.

I'm not home for another week or so. Therefore I can' t look into it.
Title: Re: [BUG] player.Spec and player.Spectate
Post by: . on August 6th, 2017, 02:01 PM
An attempt to fix this behavior was made here(http://forum.vc-mp.org/?topic=3607.msg36257#msg36257). Let me know if it does anything. And if it doesn't. I honestly have no idea what can cause the crash. Because I'm doing nothing but forward the call to the server function. So I'll assume that the server is the one to cause the crash.
Title: Re: [BUG] player.Spec and player.Spectate
Post by: Luckshya on August 6th, 2017, 02:55 PM
The bug is still not yet fixed, it's still crashing the server, here's what I'm using
Code: [Select]
g_Cmd <- SqCmd.Manager();

SqCore.On().PlayerCommand.Connect(this, function(player, command)
{
    g_Cmd.Run(player, command);
});

Spectate <- g_Cmd.Create("spec", "s", ["player"], 1, 1, -1, false, true);
Spectate.Help = "It is a command used to spectate a player.";
Spectate.BindExec(Spectate, function(player, args)
{
local plr = ( (SqStr.AreAllDigit(args.player)) ? SqFind.Player.WithID(args.player.tointeger()) : SqFind.Player.NameContains(false, false, args.player) )
player.Message(plr)
if ( plr == SqPlayer.NullInst() ) return player.Message("[#FF7F50]Error: [#ffffff]Unknown player [#FF7F50]%s[#ffffff].", args.player);
else if ( player.ID == plr.ID ) return player.Message("[#FF7F50]Error: [#ffffff]You cannot spectate yourself.");
else if ( !plr.Spawned ) return player.Message("[#FF7F50]Error: [#FF7F50]%s [#ffffff]is not yet spawned.", plr.Name)
else if ( player.Spectating() != null ) return player.Message("[#FF7F50]Error: [#ffffff]You're already spectating: [#FF7F50]%s[#ffffff].", player.Spec.Name);
player.SpecID = plr.ID;
player.Message("[#ffcc00]Information: [#ffffff]You're now spectating: %s.", plr.Name);
return true;
});

Unspec <- g_Cmd.Create("unspec", "s", [""], 0, 0, -1, false, true);
Unspec.Help = "It is a command used to stop spectating a player.";
Unspec.BindExec(Unspec, function(player, args)
{
if ( player.Spectating() == null ) return player.Message("[#FF7F50]Error: [#ffffff]You're not spectating anyone.");
player.Message("[#ffcc00]Information: [#ffffff]You've stopped spectating: [#FF7F50]%s[#ffffff].", player.Spectating().Name);
player.SpecID = -1; //player.Spectate(SqPlayer.NullInst()), player.SpectateNone();
return true;
});

Commands: /spec <player> and /unspec
Let's see if I'm doing something wrong.

Here's the error log
(http://i.imgur.com/joL6MBR.jpg)
Title: Re: [BUG] player.Spec and player.Spectate
Post by: Luckshya on August 7th, 2017, 09:49 AM
Fixed after the latest binary update.
Locked.