PDA

View Full Version : Moving a player to spec



agribilos
13th February 2021, 12:01
Hi
I have a quick question.
I'm trying to improve an anticamp script i use on my server. What i want to add is that if the player gets for instance 2 camping penalties then move him to spectators. But i don't know what command to use to move player to spec. If someone knows please help.
Thanks

agribilos
13th February 2021, 16:08
moveplayer(team)
{
self.pers["team"] = team;
self.sessionteam = self.pers["team"];
self.pers["weapon"] = undefined;
self.pers["savedmodel"] = undefined;
self setClientCvar("ui_allow_weaponchange", "1");
if (self.sessionstate!="dead")
{
self.sessionstate = team;
self suicide();
}
self notify("joined_team");
self notify("end_respawn");
maps\mp\gametypes\dm::spawnSpectator();
}

Ok i managed to do it modifying a code i found on this forum. It does the job but it doesn't work 100% correctly. When the player is moved to spectator and then tries to rejoin the options "autoassing" and the previous team are grayed out. So i guess it is not moved properly to spectator. Any idea how to fix this?

voron00
13th February 2021, 17:40
self [[level.spectator]]();

agribilos
13th February 2021, 18:14
Thank you but the problem still exists. It shows me as spectator on the scoreboard but i can still see my score. So i guess it does not properly leave the team.

moveplayer(team)
{
self.pers["team"] = team;
self.sessionteam = self.pers["team"];
if (self.sessionstate!="dead")
{
self.sessionstate = team;
self suicide();
self [[level.spawnSpectator]]();
self [[level.spectator]]();
self notify("joined_spectators");
}

}

1646
1645

voron00
13th February 2021, 19:36
Not like this, self [[level.spectator]](); is all you need to move player to spec.


moveplayer()
{
self [[level.spectator]]();
}

agribilos
13th February 2021, 20:20
Not like this, self [[level.spectator]](); is all you need to move player to spec.


moveplayer()
{
self [[level.spectator]]();
}

Yes i tried it also but it didn't work.. If i remember correctly what it did was to move the player in spectators at the scoreboard only but the player itself was left ingame and invulnerable. I'll have a look again tomorrow because now i'm too tired to think.

agribilos
14th February 2021, 06:44
self [[level.spawnSpectator]]();
self [[level.spectator]]();
self notify("joined spectators");

Ok i finally got it to work. I also had to set the function pointer "level.spawnSpectator = ::spawnSpectator;" in my gametype gsc.