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.
player.SpectateTarget = player
Quote from: EK.IceFlake on Jul 20, 2017, 11:12 AMQuote from: vito1 on Jul 20, 2017, 10:58 AMplayer.SpectateTarget = player
What?
That.
Quoteway to stop someone from spectating.
It's equal to player.SpectateTarget = null
Quote from: vito1 on Jul 20, 2017, 12:11 PMQuote from: EK.IceFlake on Jul 20, 2017, 11:12 AMQuote from: vito1 on Jul 20, 2017, 10:58 AMplayer.SpectateTarget = player
What?
That.
Quoteway to stop someone from spectating.
It's equal to player.SpectateTarget = null
player.SpectateTarget doesn't exist in SLC's plugin.
Quote from: EK.IceFlake on Jul 20, 2017, 03:14 PMQuote from: vito1 on Jul 20, 2017, 12:11 PMQuote from: EK.IceFlake on Jul 20, 2017, 11:12 AMQuote from: vito1 on Jul 20, 2017, 10:58 AMplayer.SpectateTarget = player
What?
That.
Quoteway 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.
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.
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.
The bug is still not yet fixed, it's still crashing the server, here's what I'm using
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)
Fixed after the latest binary update.
Locked.