• Problem using ply:Spectate()
    7 replies, posted
Hi there, I'm fairly new to Lua, and extremely new to GMod mod making. I've been looking into how to make a gamemode and I'm trying to make my own. Currently I'm trying to make a spectator mode (like the one in TTT or CS) where you can no-clip and fly through the world. I've got a separate team for spectators, and you are placed on it correctly. The spectator mode worked once for me correctly however, and since has caused the player to spawn normally with the exception that they violently vibrate when they try to move. I'm fairly certain this is most likely due to an error somewhere else in my code (as I said, I'm new to this stuff, so my code is all over the place and horribly messy!). If anyone would be kind enough to have a look through my project and tell me what's wrong with it that would be brilliant. Thanks Link to project: [url]https://www.dropbox.com/sh/r5xp0weo2otb3hu/AAAzcm4gTkDYNX8eUcrh73lma[/url]
This is essentially everything you need to make a player spectate: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/spectating_players_system.lua.html[/url] It'll make them spectator on first-join, and show you how to set as spectator and change to spawned player, etc.
Ok it worked the first time I selected the spectator team, but then I switched to blue and back to spectator and I was a player (not vibrating this time) who could run around. I'll upload my code to dropbox, then would you mind having a look please? :pwn:
[QUOTE=Roboguy99;44977439]Hi there, I'm fairly new to Lua, and extremely new to GMod mod making. I've been looking into how to make a gamemode and I'm trying to make my own. Currently I'm trying to make a spectator mode (like the one in TTT or CS) where you can no-clip and fly through the world. I've got a separate team for spectators, and you are placed on it correctly. The spectator mode worked once for me correctly however, and since has caused the player to spawn normally with the exception that they violently vibrate when they try to move. I'm fairly certain this is most likely due to an error somewhere else in my code (as I said, I'm new to this stuff, so my code is all over the place and horribly messy!). If anyone would be kind enough to have a look through my project and tell me what's wrong with it that would be brilliant. Thanks Link to project: [url]https://www.dropbox.com/sh/r5xp0weo2otb3hu/AAAzcm4gTkDYNX8eUcrh73lma[/url][/QUOTE] Bump. I'd really appreciate some help
Make sure when you choose spectator that you KillSilent after setting the Team to spectator, and returning false on PlayerDeathThink if spectator to stop respawns. Make sure each part is called in proper order. If you set spectator, then kill, then change team, it could happen that you respawn before the next line executes; so set it up in advance, then killsilent.
Erm...Now I'm even more confused. [code] function teamSpectator(ply) ply:PrintMessage(HUD_PRINTTALK, "You have joined the spectator team.") ply:SetGamemodeTeam(2) ply:KillSilent() end [/code] suggests to me that the team is being changed, then you are killed. What's different about setting spectator and changing team in my code? Also, I'm not using PlayerDeathThink currently because I have no use for it quite yet. I don't mean to be rude, but did you actually look at my code?
You may have a use for it if you are being spawned after joining spectator.
[QUOTE=Acecool;44979180]You may have a use for it if you are being spawned after joining spectator.[/QUOTE] Not following... Sorry I must seem really stupid to you. I think this might be what I want, but I really don't know at the moment.
Sorry, you need to Log In to post a reply to this thread.