• Make prop_vehicle_jeep disappear when player disconnects
    4 replies, posted
So I've got this so far... [lua]function fPlayerDisconnect( ply ) // Remove the prop_vehicle_jeep... end hook.Add( "PlayerDisconnected", "playerdisconnected", fPlayerDisconnect )[/lua] But what I am trying to do, is to get it to remove the prop_vehicle_jeep when player disconnects. I was searching from the garrysmod wiki for this, but I couldn't really find anything and since I am new to Lua I don't know exactly what to look for.
[url]http://wiki.garrysmod.com/?title=Entity.Remove[/url]
[QUOTE=Aitsihia;30805476]So I've got this so far... [lua]function fPlayerDisconnect( ply ) // Remove the prop_vehicle_jeep... end hook.Add( "PlayerDisconnected", "playerdisconnected", fPlayerDisconnect )[/lua] But what I am trying to do, is to get it to remove the prop_vehicle_jeep when player disconnects. I was searching from the garrysmod wiki for this, but I couldn't really find anything and since I am new to Lua I don't know exactly what to look for.[/QUOTE] [lua] function fPlayerDisconnect( ply ) // Remove the prop_vehicle_jeep... if ply:GetVehicle():GetClass() == "prop_vehicle_jeep" then ply:GetVehicle():Remove() end end hook.Add( "PlayerDisconnected", "playerdisconnected", fPlayerDisconnect )[/lua]
Not sure but hey, here's a go. [lua] function fPlayerDisconnect( ply ) for _,car in pairs(ents.FindByClass("prop_vehicle_jeep")) do if car:GetOwner == ply then car:Remove() end end end hook.Add( "PlayerDisconnected", "playerdisconnected", fPlayerDisconnect ) [/lua] [QUOTE=RetTurtl3;30809264] crap [/QUOTE] :frog:
[QUOTE=jrj996;30813149]Not sure but hey, here's a go. [lua] function fPlayerDisconnect( ply ) for _,car in pairs(ents.FindByClass("prop_vehicle_jeep")) do if car:GetOwner == ply then car:Remove() end end end hook.Add( "PlayerDisconnected", "playerdisconnected", fPlayerDisconnect ) [/lua] :frog:[/QUOTE] oh hey don't forget the parentheses on GetOwner() [lua] function fPlayerDisconnect( ply ) for _,car in pairs(ents.FindByClass("prop_vehicle_jeep")) do if car:GetOwner() == ply then car:Remove() end end end hook.Add( "PlayerDisconnected", "playerdisconnected", fPlayerDisconnect ) [/lua]
Sorry, you need to Log In to post a reply to this thread.