Boat

Hello everyone, boys and girls. It’s a vehicle base, normal, pleasant. Somebody help me make the character to sit in it in the car? Now it disappears and just hanging in the air, and the boat floats by itself. With me a beer.


if(SERVER) then AddCSLuaFile() end
ENT = {}
ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.ClassName = "xmv_base"
function ENT:Initialize()
    if(SERVER) then
		self:SetModel("models/props_junk/cardboard_box001a.mdl")
		
		self:SetSolid(SOLID_VPHYSICS)
		self:SetMoveType(MOVETYPE_VPHYSICS)
		self:PhysicsInit(SOLID_VPHYSICS)
		self:DrawShadow(false)
		local phys = self:GetPhysicsObject()
		if (phys:IsValid()) then
			phys:Wake()
		end
		self:PhysWake()
		self:SetUseType(SIMPLE_USE)
    end	
end

function ENT:SetupDataTables()
	self:NetworkVar( "Entity", 0, "Driver")
	self:SetupDataTables2()
end

function ENT:SetupDataTables2()
	--Filler
end
function ENT:OnMove(ply, data)


end
function ENT:OnKeyPress(ply, key)

end

local t = {start=nil,endpos=nil,mask=MASK_PLAYERSOLID,filter=nil}
local function PlayerNotStuck(ply, pos)

	t.start = pos or ply:GetPos()
	t.endpos = t.start
	t.filter = ply
	return util.TraceEntity(t,ply).StartSolid == false
	
	
end

local function FindPassableSpace( ply, direction, step )
	local OldPos = ply:GetPos()
	local i = 0
	local origin = ply:GetPos()
	while ( i < 14 ) do
		

		origin = origin + step * direction
		if ( PlayerNotStuck( ply , origin) ) then
			return true, origin
		end
		i = i + 1
	end
	--ply:SetPos(OldPos)
	return false, OldPos
end

local function UnstuckPlayer( pl , ang)
	ply = pl

	NewPos = ply:GetPos()
	local OldPos = NewPos
	
	if ( !PlayerNotStuck( ply ) ) then
	
		local angle = ang or ply:GetAngles()
		
		local forward = angle:Forward()
		local right = angle:Right()
		local up = angle:Up()
		
		local SearchScale = 1
		local found
		found, NewPos = FindPassableSpace(  pl, forward, -SearchScale )
		if ( not found ) then
			found, NewPos = FindPassableSpace(  pl, right, SearchScale )
			if ( not found ) then
				found, NewPos = FindPassableSpace(  pl, right, -SearchScale )
				if ( not found ) then
					found, NewPos = FindPassableSpace(  pl, up, SearchScale )
					if ( not found ) then
						found, NewPos = FindPassableSpace(  pl, up, -SearchScale )
						if ( not found ) then
							found, NewPos = FindPassableSpace(  pl, forward, SearchScale )
							if ( not found ) then
								return false	
							end
						end
					end
				end
			end
		end
		
		if OldPos == NewPos then
			return true -- ???
		else
			ply:SetPos( NewPos )
			if SERVER and ply and ply:IsValid() and ply:GetPhysicsObject():IsValid() then
				if ply:IsPlayer() then
					ply:SetVelocity(vector_origin)
				end
				ply:GetPhysicsObject():SetVelocity(vector_origin) -- For some reason setting origin MAY apply some velocity so we're resetting it here.
			end
			return true
		end
		
	end
end
function ENT:AssignPlayer(ply, driver)
	local rider = driver or self:GetDriver()
	if(self:GetDriver() and self:GetDriver():IsValid()) then
		rider:SetNWEntity("XMV_Vehicle", NULL)
		rider:UnSpectate()
		--self:GetDriver():SetParent()
		rider:Spawn()
		rider:SetPos(self:GetPos()+Vector(0,0,20))
		timer.Simple(0, function()
			if IsValid(self) then
				UnstuckPlayer(rider, self:GetAngles())
			end
		end)
		rider:GetViewModel():SetNoDraw(false)
		self:SetDriver(NULL)
		
		hook.Remove("Move", self)
		
		hook.Remove("KeyPress", self)
	end
	if(ply and ply:IsValid() and (not ply:XMVGetVehicle() or not ply:XMVGetVehicle():IsValid())) then
		ply:SetActiveWeapon("popcorn_bucket")
		self:SetDriver(ply)
		ply.prepos = ply:GetPos()
		ply:Spectate( OBS_MODE_CHASE )
		ply:SpectateEntity(self)
		ply:SetNWEntity("XMV_Vehicle", self)
		ply:GetViewModel():SetNoDraw(true)
		--ply:SetParent(self)
		hook.Add("Move",self,function(self, ply, data)
			if(not self:GetDriver() or not self:GetDriver():IsValid()) then
				self:Remove()	
			end
			if(ply == self:GetDriver()) then
				self:OnMove(ply, data)
			end
		end)
		hook.Add("KeyPress",self,function(self,ply,key)
			if(not self:GetDriver() or not self:GetDriver():IsValid()) then
				self:Remove()	
			elseif(ply == self:GetDriver() and key == IN_USE) then
				self:AssignPlayer()
			end
			self:OnKeyPress(ply, key)
		end)
	end
	self.LastEnter = CurTime()
end
function ENT:OnRemove()
	if CLIENT then return end
	self:AssignPlayer(nil, self:GetDriver())
end

if(CLIENT) then
	surface.CreateFont( "XMV_Player_Font", {
		font 		= "Default",
		size 		= 30,
		weight 		= 450,
		antialias 	= true,
		additive 	= false,
		shadow 		= false,
		outline 	= false
	} )
	function ENT:CreateModels()
		
	end
	
	function ENT:DrawPlayerName(vector, angle, scale)
		local pos,ang = LocalToWorld(vector, angle, self:GetPos(), self:GetAngles())
		self:DrawPlayerName2(pos, ang, scale)
	end
	function ENT:DrawPlayerName2(vector, angle, scale)
		local rider = self:GetDriver()
		local color = Color(255,0,0)
		local text = "No Driver"
		if(rider and rider:IsValid()) then
			color = team.GetColor(rider:Team())
			text = rider:Name()
		end
		cam.Start3D2D(vector, angle, scale)	
			draw.DrawText(text, "XMV_Player_Font", 0, 0, color, TEXT_ALIGN_CENTER )
		cam.End3D2D()
	end
	function ENT:Draw()
		self:DrawModel()
		
		self:DrawPlayerName(Vector(0, 0, 12.5), Angle(), 0.2)
	end
	
	hook.Add("Think","XMV_CAR_Think",function()
		for k,v in pairs(player.GetAll()) do
			local car = v:XMVGetVehicle()
			if(car and car:IsValid()) then -- Assume they are in a car
				v:SetNoDraw(true)
				v.washidden = true
			elseif((not car or not car:IsValid()) and v.washidden) then
				v:SetNoDraw(false)
				v.washidden = false
			elseif((not car or not car:IsValid())) then
				v.washidden = false
			end
		end
	end)
else
	function ENT:Think()
		local phys = self:GetPhysicsObject()
		if IsValid(phys) then
			phys:Wake()
		end
		if (self:GetDriver() and self:GetDriver():IsValid() and not self:GetDriver():Alive()) then
			self:AssignPlayer()
			
		end
	end
	function ENT:Use(ply, call)
		if ply:IsPlayer()  and (not self:GetDriver() or not self:GetDriver():IsValid()) then
			if not self.LastEnter or CurTime() - self.LastEnter > 1 then
				self:AssignPlayer(ply)
			end
		end
	end
	hook.Add("PlayerSpawn","XMV_CAR_REMOVE",function(ply)
		local car = ply:XMVGetVehicle()
		if(car and car:IsValid()) then -- Assume they are in a car
			car:AssignPlayer()
		end
	end)
end
scripted_ents.Register(ENT, ENT.ClassName, true)

local PMETA = FindMetaTable"Player"

function PMETA:XMVGetVehicle()
	return self:GetNWEntity("XMV_Vehicle")
end

function PMETA:XMVInVehicle()
	return self:XMVGetVehicle() and self:XMVGetVehicle():IsValid()
end

Huuuh…Bump! I know propblem is here


ply:Spectate( OBS_MODE_CHASE )
		ply:SpectateEntity(self)

please help me brothers!

Оп!

Huuuh…bump!

OUF!

If you would stop bumping your post and be patient, someone will reply. Anyway, that aside could you please explain more clearly? I am struggling to understand what you mean.

Hello, and thaks for the answer. I try making boat system for my server. Now the boat works fine, but the player goes into spectator’s mode and dont visible. I wanna make, that player sitting in the boat how in vehicle and be visible. This is the base for all boats, if need i can paste code of specific boat, but how player looks in boat - in this base. This is an entity - not vehicle. When player in boat on the boat drawing his name. Forgive me for bumping and bad english, guys.

BUMP!

ОП - Хуй. Заебал бампить. Сейчас я что-нибудь попытаюсь сделать с твоей лодкой.
English
OP is asshole. Stop bumping. Okay, I will try to fix your boat.

[editline]2nd June 2014[/editline]

Кидай стим и объясни получше причину.


(User was banned for this post ("This is still an English forum" - Gurant))

Хорошоий мой! Щас щас я домой то приду


(User was banned for this post ("This is an English forum" - Gurant))

This isn’t a Russian forum, if you don’t want get banned, speak in English.

Okay, dont kick me brother!

We try figured it out, but still dont working for me. There is console error

**[ERROR] addons/true boats/lua/entities/xmv_base.lua:265: Tried to use a NULL entity!

  1. EnterVehicle - [C]:-1
  2. unknown - addons/true boats/lua/entities/xmv_base.lua:265
    **

if(SERVER) then AddCSLuaFile() end
ENT = {}
ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.ClassName = "xmv_base"
function ENT:Initialize()
    if(SERVER) then
                self:SetModel("models/props_junk/cardboard_box001a.mdl")
               
                self:SetSolid(SOLID_VPHYSICS)
                self:SetMoveType(MOVETYPE_VPHYSICS)
                self:PhysicsInit(SOLID_VPHYSICS)
                self:DrawShadow(false)
                local phys = self:GetPhysicsObject()
                if (phys:IsValid()) then
                        phys:Wake()
                end
                self:PhysWake()
                self:SetUseType(SIMPLE_USE)
                local car = ents.Create("prop_vehicle_prisoner_pod")  
                                car:SetModel("models/nova/jeep_seat.mdl")  
                                car:SetKeyValue("vehiclescript","scripts/vehicles/prisoner_pod.txt")  
                                car:SetKeyValue("limitview", "0")
                                car:SetPos(self:GetPos())  
                                car:SetAngles(self:GetAngles())
                               
                                car:Spawn()
                                car:Activate()
                                car:SetNoDraw(true)
                                constraint.Weld(car, self, 0,0,0,0)
                                car:SetParent(self)
                                car:DeleteOnRemove(self)
                self:SetNetworkedEntity("PassSeat",car)
                               
    end
end
 
function ENT:SetupDataTables()
        self:NetworkVar( "Entity", 0, "Driver")
        self:SetupDataTables2()
end
 
function ENT:SetupDataTables2()
        --Filler
end
function ENT:OnMove(ply, data)
 
 
end
function ENT:OnKeyPress(ply, key)
 
end
 
local t = {start=nil,endpos=nil,mask=MASK_PLAYERSOLID,filter=nil}
local function PlayerNotStuck(ply, pos)
 
        t.start = pos or ply:GetPos()
        t.endpos = t.start
        t.filter = ply
        return util.TraceEntity(t,ply).StartSolid == false
       
       
end
 
local function FindPassableSpace( ply, direction, step )
        local OldPos = ply:GetPos()
        local i = 0
        local origin = ply:GetPos()
        while ( i < 14 ) do
               
 
                origin = origin + step * direction
                if ( PlayerNotStuck( ply , origin) ) then
                        return true, origin
                end
                i = i + 1
        end
        --ply:SetPos(OldPos)
        return false, OldPos
end
 
local function UnstuckPlayer( pl , ang)
        ply = pl
 
        NewPos = ply:GetPos()
        local OldPos = NewPos
       
        if ( !PlayerNotStuck( ply ) ) then
       
                local angle = ang or ply:GetAngles()
               
                local forward = angle:Forward()
                local right = angle:Right()
                local up = angle:Up()
               
                local SearchScale = 1
                local found
                found, NewPos = FindPassableSpace(  pl, forward, -SearchScale )
                if ( not found ) then
                        found, NewPos = FindPassableSpace(  pl, right, SearchScale )
                        if ( not found ) then
                                found, NewPos = FindPassableSpace(  pl, right, -SearchScale )
                                if ( not found ) then
                                        found, NewPos = FindPassableSpace(  pl, up, SearchScale )
                                        if ( not found ) then
                                                found, NewPos = FindPassableSpace(  pl, up, -SearchScale )
                                                if ( not found ) then
                                                        found, NewPos = FindPassableSpace(  pl, forward, SearchScale )
                                                        if ( not found ) then
                                                                return false   
                                                        end
                                                end
                                        end
                                end
                        end
                end
               
                if OldPos == NewPos then
                        return true -- ???
                else
                        ply:SetPos( NewPos )
                        if SERVER and ply and ply:IsValid() and ply:GetPhysicsObject():IsValid() then
                                if ply:IsPlayer() then
                                        ply:SetVelocity(vector_origin)
                                end
                                ply:GetPhysicsObject():SetVelocity(vector_origin) -- For some reason setting origin MAY apply some velocity so we're resetting it here.
                        end
                        return true
                end
               
        end
end
function ENT:AssignPlayer(ply, driver)
        local rider = driver or self:GetDriver()
        if(self:GetDriver() and self:GetDriver():IsValid()) then
                rider:SetNWEntity("XMV_Vehicle", NULL)
                //rider:UnSpectate()
                --self:GetDriver():SetParent()
                rider:Spawn()
                rider:SetPos(self:GetPos()+Vector(0,0,20))
                timer.Simple(0, function()
                        if IsValid(self) then
                                UnstuckPlayer(rider, self:GetAngles())
                        end
                end)
                rider:GetViewModel():SetNoDraw(false)
                self:SetDriver(NULL)
               
                hook.Remove("Move", self)
               
                hook.Remove("KeyPress", self)
        end
        if(ply and ply:IsValid() and (not ply:XMVGetVehicle() or not ply:XMVGetVehicle():IsValid())) then
                ply:SetActiveWeapon("popcorn_bucket")
                self:SetDriver(ply)
                ply.prepos = ply:GetPos()
                //ply:Spectate( OBS_MODE_CHASE )
                //ply:SpectateEntity(self)
                ply:SetNWEntity("XMV_Vehicle", self)
                ply:GetViewModel():SetNoDraw(true)
                --ply:SetParent(self)
                hook.Add("Move",self,function(self, ply, data)
                        if(not self:GetDriver() or not self:GetDriver():IsValid()) then
                                self:Remove()  
                        end
                        if(ply == self:GetDriver()) then
                                self:OnMove(ply, data)
                        end
                end)
                hook.Add("KeyPress",self,function(self,ply,key)
                        if(not self:GetDriver() or not self:GetDriver():IsValid()) then
                                self:Remove()  
                        elseif(ply == self:GetDriver() and key == IN_USE) then
                                self:AssignPlayer()
                        end
                        self:OnKeyPress(ply, key)
                end)
        end
        self.LastEnter = CurTime()
end
function ENT:OnRemove()
        if CLIENT then return end
        self:AssignPlayer(nil, self:GetDriver())
end
 
if(CLIENT) then
        surface.CreateFont( "XMV_Player_Font", {
                font            = "Default",
                size            = 30,
                weight          = 450,
                antialias       = true,
                additive        = false,
                shadow          = false,
                outline         = false
        } )
        function ENT:CreateModels()
               
        end
       
        function ENT:DrawPlayerName(vector, angle, scale)
                local pos,ang = LocalToWorld(vector, angle, self:GetPos(), self:GetAngles())
                self:DrawPlayerName2(pos, ang, scale)
        end
        function ENT:DrawPlayerName2(vector, angle, scale)
                local rider = self:GetDriver()
                //print(rider:Nick())
                local color = Color(255,0,0)
                local text = "No Driver"
                if(rider and rider:IsValid()) then
                        color = team.GetColor(rider:Team())
                        text = rider:Name()
                end
                /*if self.PassengerVehicle and self.PassengerVehicle:IsValid() then
                        text =
                end*/
                cam.Start3D2D(vector, angle, scale)    
                        draw.DrawText(text, "XMV_Player_Font", 0, 0, color, TEXT_ALIGN_CENTER )
                cam.End3D2D()
        end
        function ENT:Draw()
                self:DrawModel()
               
                self:DrawPlayerName(Vector(0, 0, 12.5), Angle(), 0.2)
        end
       
        hook.Add("Think","XMV_CAR_Think",function()
                for k,v in pairs(player.GetAll()) do
                        local car = v:XMVGetVehicle()
                        if(car and car:IsValid()) then -- Assume they are in a car
                                v:SetNoDraw(true)
                                v.washidden = true
                        elseif((not car or not car:IsValid()) and v.washidden) then
                                v:SetNoDraw(false)
                                v.washidden = false
                        elseif((not car or not car:IsValid())) then
                                v.washidden = false
                        end
                end
        end)
else
        function ENT:Think()
                local phys = self:GetPhysicsObject()
                if IsValid(phys) then
                        phys:Wake()
                end
                if (self:GetDriver() and self:GetDriver():IsValid() and not self:GetDriver():Alive()) then
                        self:AssignPlayer()
                       
                end
                if self:GetNWEntity("PassSeat"):GetDriver() != self:GetNWEntity("PassSeat"):GetNWEntity("Driver") then
                        self:GetNWEntity("PassSeat"):SetNWEntity("Driver", self:GetNWEntity("PassSeat"):GetDriver())
                        //print(self:GetNWEntity("PassSeat"):GetNWEntity("Driver"):Nick())
                end
                if self:GetDriver() != self:GetNWEntity("PassSeat"):GetNWEntity("Driver") then
                        self:SetDriver(self:GetNWEntity("PassSeat"):GetNWEntity("Driver"))
                end
        end
        function ENT:Use(ply, call)
                /*if ply:IsPlayer()  and (not self:GetDriver() or not self:GetDriver():IsValid()) then
                        if not self.LastEnter or CurTime() - self.LastEnter > 1 then
                                self:AssignPlayer(ply)
                        end
                end*/
                if self:GetNWEntity("PassSeat") == NULL then
                ply:EnterVehicle(self:GetNWEntity("PassSeat"))
                end
        end
        hook.Add("PlayerSpawn","XMV_CAR_REMOVE",function(ply)
                local car = ply:XMVGetVehicle()
                if(car and car:IsValid()) then -- Assume they are in a car
                        car:AssignPlayer()
                end
        end)
end
scripted_ents.Register(ENT, ENT.ClassName, true)
 
local PMETA = FindMetaTable"Player"
 
function PMETA:XMVGetVehicle()
        return self:GetNWEntity("XMV_Vehicle")
end
 
function PMETA:XMVInVehicle()
        return self:XMVGetVehicle() and self:XMVGetVehicle():IsValid()
end

self:GetNWEntity(“PassSeat”) returns NULL entity ( Invalid entity ). Add IsValid() checks and make sure you actually set that NWEntity somewhere.

Thanks, error has gone, but player cant use the boat now.

Here’s the code that should work:



AddCSLuaFile()

ENT = {}
ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.ClassName = "xmv_base"
function ENT:Initialize()
	if ( !SERVER ) then return end

	self:SetModel("models/props_junk/cardboard_box001a.mdl")

	self:SetSolid(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:PhysicsInit(SOLID_VPHYSICS)
	self:DrawShadow(false)
	local phys = self:GetPhysicsObject()
	if (IsValid(phys)) then
		phys:Wake()
	end
	self:PhysWake()
	self:SetUseType(SIMPLE_USE)

	local car = ents.Create("prop_vehicle_prisoner_pod")  
	car:SetModel("models/nova/jeep_seat.mdl")  
	car:SetKeyValue("vehiclescript","scripts/vehicles/prisoner_pod.txt")  
	car:SetKeyValue("limitview", "0")
	car:SetPos(self:GetPos())  
	car:SetAngles(self:GetAngles())
   
	car:Spawn()
	car:Activate()
	//car:SetNoDraw(true)
	car:SetColor(Color(0,0,0,0))
	car:SetRenderMode( RENDERMODE_TRANSALPHA )
	car:SetParent(self)
	car:DeleteOnRemove(self)
	self:DeleteOnRemove(car)

	self.Seat = car
	self:SetNetworkedEntity("PassSeat",car)

end
 
function ENT:SetupDataTables()
	self:NetworkVar( "Entity", 0, "Driver")
	self:SetupDataTables2()
end
 
function ENT:SetupDataTables2()
	--Filler
end
function ENT:OnMove(ply, data)
end
function ENT:OnKeyPress(ply, key)
end
 
local t = {start=nil,endpos=nil,mask=MASK_PLAYERSOLID,filter=nil}
local function PlayerNotStuck(ply, pos)

	t.start = pos or ply:GetPos()
	t.endpos = t.start
	t.filter = ply
	return util.TraceEntity(t,ply).StartSolid == false

end
 
local function FindPassableSpace( ply, direction, step )
	local OldPos = ply:GetPos()
	local i = 0
	local origin = ply:GetPos()
	while ( i < 14 ) do

		origin = origin + step * direction
		if ( PlayerNotStuck( ply , origin) ) then
			return true, origin
		end
		i = i + 1
	end
	--ply:SetPos(OldPos)
	return false, OldPos
end
 
local function UnstuckPlayer( pl , ang)
	ply = pl

	NewPos = ply:GetPos()
	local OldPos = NewPos
   
	if ( !PlayerNotStuck( ply ) ) then
   
		local angle = ang or ply:GetAngles()
	   
		local forward = angle:Forward()
		local right = angle:Right()
		local up = angle:Up()
	   
		local SearchScale = 1
		local found
		found, NewPos = FindPassableSpace(  pl, forward, -SearchScale )
		if ( not found ) then
			found, NewPos = FindPassableSpace(  pl, right, SearchScale )
			if ( not found ) then
				found, NewPos = FindPassableSpace(  pl, right, -SearchScale )
				if ( not found ) then
					found, NewPos = FindPassableSpace(  pl, up, SearchScale )
					if ( not found ) then
						found, NewPos = FindPassableSpace(  pl, up, -SearchScale )
						if ( not found ) then
							found, NewPos = FindPassableSpace(  pl, forward, SearchScale )
							if ( not found ) then
									return false   
							end
						end
					end
				end
			end
		end
	   
		if OldPos == NewPos then
				return true -- ???
		else
			ply:SetPos( NewPos )
			if SERVER and ply and ply:IsValid() and ply:GetPhysicsObject():IsValid() then
				if ply:IsPlayer() then
						ply:SetVelocity(vector_origin)
				end
				ply:GetPhysicsObject():SetVelocity(vector_origin) -- For some reason setting origin MAY apply some velocity so we're resetting it here.
			end
			return true
		end
		   
	end
end
function ENT:AssignPlayer(ply, driver)
	local rider = driver or self:GetDriver()
	if ( IsValid( self:GetDriver() ) ) then
		rider:SetNWEntity("XMV_Vehicle", NULL)
		//rider:UnSpectate()
		--self:GetDriver():SetParent()
		rider:Spawn()
		rider:SetPos(self:GetPos()+Vector(0,0,20))
		timer.Simple(0, function()
			if IsValid(self) then
				UnstuckPlayer(rider, self:GetAngles())
			end
		end)
		rider:GetViewModel():SetNoDraw(false)
		self:SetDriver(NULL)
	   
		hook.Remove("Move", self)
	   
		hook.Remove("KeyPress", self)
	end
        if(ply and ply:IsValid() and (not ply:XMVGetVehicle() or not ply:XMVGetVehicle():IsValid())) then
			ply:SetActiveWeapon("popcorn_bucket")
			self:SetDriver(ply)
			ply.prepos = ply:GetPos()
			//ply:Spectate( OBS_MODE_CHASE )
			//ply:SpectateEntity(self)
			ply:SetNWEntity("XMV_Vehicle", self)
			ply:GetViewModel():SetNoDraw(true)
			--ply:SetParent(self)
			hook.Add("Move",self,function(self, ply, data)
					if(not self:GetDriver() or not self:GetDriver():IsValid()) then
							self:Remove()  
					end
					if(ply == self:GetDriver()) then
							self:OnMove(ply, data)
					end
			end)
			hook.Add("KeyPress",self,function(self,ply,key)
					if(not self:GetDriver() or not self:GetDriver():IsValid()) then
							self:Remove()  
					elseif(ply == self:GetDriver() and key == IN_USE) then
							self:AssignPlayer()
					end
					self:OnKeyPress(ply, key)
			end)
        end
        self.LastEnter = CurTime()
end
function ENT:OnRemove()
	if CLIENT then return end
	self:AssignPlayer(nil, self:GetDriver())
end
 
if(CLIENT) then
	surface.CreateFont( "XMV_Player_Font", {
		font            = "Default",
		size            = 30,
		weight          = 450,
		antialias       = true,
		additive        = false,
		shadow          = false,
		outline         = false
	} )
	function ENT:CreateModels()
		   
	end
   
	function ENT:DrawPlayerName(vector, angle, scale)
		local pos,ang = LocalToWorld(vector, angle, self:GetPos(), self:GetAngles())
		self:DrawPlayerName2(pos, ang, scale)
	end
	function ENT:DrawPlayerName2(vector, angle, scale)
		local rider = self:GetDriver()
		//print(rider:Nick())
		local color = Color(255,0,0)
		local text = "No Driver"
		if(rider and rider:IsValid()) then
				color = team.GetColor(rider:Team())
				text = rider:Name()
		end
		/*if self.PassengerVehicle and self.PassengerVehicle:IsValid() then
				text =
		end*/
		cam.Start3D2D(vector, angle, scale)    
				draw.DrawText(text, "XMV_Player_Font", 0, 0, color, TEXT_ALIGN_CENTER )
		cam.End3D2D()
	end
	function ENT:Draw()
		self:DrawModel()
	   
		self:DrawPlayerName(Vector(0, 0, 12.5), Angle(), 0.2)
	end
   
	hook.Add("Think","XMV_CAR_Think",function()
		for k,v in pairs(player.GetAll()) do
			local car = v:XMVGetVehicle()
			if(car and car:IsValid()) then -- Assume they are in a car
					v:SetNoDraw(true)
					v.washidden = true
			elseif((not car or not car:IsValid()) and v.washidden) then
					v:SetNoDraw(false)
					v.washidden = false
			elseif((not car or not car:IsValid())) then
					v.washidden = false
			end
		end
	end)
else
	function ENT:Think()
		local phys = self:GetPhysicsObject()
		if IsValid(phys) then
			phys:Wake()
		end
		if (self:GetDriver() and self:GetDriver():IsValid() and not self:GetDriver():Alive()) then
			self:AssignPlayer()
		end
		if self:GetNWEntity("PassSeat"):GetDriver() != self:GetNWEntity("PassSeat"):GetNWEntity("Driver") then
			self:GetNWEntity("PassSeat"):SetNWEntity("Driver", self:GetNWEntity("PassSeat"):GetDriver())
			//print(self:GetNWEntity("PassSeat"):GetNWEntity("Driver"):Nick())
		end
		if self:GetDriver() != self:GetNWEntity("PassSeat"):GetNWEntity("Driver") then
			self:SetDriver(self:GetNWEntity("PassSeat"):GetNWEntity("Driver"))
		end
	end
	function ENT:Use(ply, call)
		/*if ply:IsPlayer()  and (not self:GetDriver() or not self:GetDriver():IsValid()) then
			if not self.LastEnter or CurTime() - self.LastEnter > 1 then
				self:AssignPlayer(ply)
			end
		end*/
		if IsValid( self.Seat ) then
			ply:EnterVehicle( self.Seat )
		end
	end
	hook.Add("PlayerSpawn","XMV_CAR_REMOVE",function(ply)
		local car = ply:XMVGetVehicle()
		if(car and car:IsValid()) then -- Assume they are in a car
			car:AssignPlayer()
		end
	end)
end
scripted_ents.Register(ENT, ENT.ClassName, true)
 
local PMETA = FindMetaTable"Player"
 
function PMETA:XMVGetVehicle()
   return self:GetNWEntity("XMV_Vehicle")
end
 
function PMETA:XMVInVehicle()
	return self:XMVGetVehicle() and self:XMVGetVehicle():IsValid()
end

Still nothing, when use the boat

It works for me, so it something wrong on your side, with your other entities and whatnot.

Oh sorry iforget about this spam in console, when i spawn the boat
**
[ERROR] addons/true boats/lua/entities/xmv_base.lua:251: attempt to call method ‘GetDriver’ (a nil value)

  1. unknown - addons/true boats/lua/entities/xmv_base.lua:251**

It works perfectly for me with the code I posted, so I can’t help you.