I'm trying to get multiple seats with my gamemode. As much as I hate to ask for help, I feel I'm running out of either options or time... So here is my code; (All the relevant code anyways)
init.lua
[code]
function vehicleEntry(ply,car)
-- This has been getting called... As has the motorist:SitNearest() :v
if(car:GetNWFloat("Lock") <= 0 || car:GetNWFloat("Lock") == nil) then
local driving=car:GetDriver()
if(driving:IsPlayer()) then
ply:SitNearest(car)
end
end
end
hook.Add("PlayerUse","vehicleSeating",vehicleEntry)
[/code]
vehicles.lua ((Contains the player function))
[code]
local motorist=FindMetaTable("Player")
function motorist:SitNearest(automobile)
local nearestSeat
local lastDistance=5000
self:ChatPrint("Checking!")
for k,v in pairs(ents.FindInSphere(automobile:GetPos(),256)) do
if(v:GetParent() == automobile && v:IsVehicle()) then
local myDriver=v:GetDriver()
if(myDriver:IsPlayer() == false) then
self:EnterVehicle(v)
end
end
end
end
[/code]
I've already found and know that both functions are called... I've also properly parented them before you ask...
Exit the main vehicle first if you are calling it while the player is in drivers position.
I don't think the vehicle will return a driver when the PlayerUse hook is called.
use PlayerEnteredVehicle
[url]http://wiki.garrysmod.com/?title=Gamemode.PlayerEnteredVehicle[/url]
[QUOTE=thegrb93;32699772]I don't think the vehicle will return a driver when the PlayerUse hook is called.
use PlayerEnteredVehicle
[url]http://wiki.garrysmod.com/?title=Gamemode.PlayerEnteredVehicle[/url][/QUOTE]
It cant be hooked if someone drives the car.
You muse use the "PlayerUse" hook.
Any other ideas why it might not be working?
[QUOTE=Gustavgr16;32701370]It cant be hooked if someone drives the car.
You muse use the "PlayerUse" hook.[/QUOTE]
Ah. Didn't completely know the function of this script. Have you checked that ents.FindInSphere is finding your chair or whatever?
Sorry, you need to Log In to post a reply to this thread.