• Making a bacta tank entity model issue
    22 replies, posted
Hello dear facepunch users, im currently working on a bacta tank entity. I use as base the playable piano code to get the vehicle chair into the prop.. with my code (for now) i can move the prop around. but i have a ugly issue here you can see what i mean: https://i.imgur.com/bgcARE7.jpg And this is my code for the entity: function ENT:Initialize() self:SetModel( self.ChairModel ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) self:SetUseType( SIMPLE_USE ) self:DrawShadow( false ) local phys = self:GetPhysicsObject() if IsValid( phys ) then phys:EnableMotion(false) phys:Sleep() end --self:SetOwner( self.Owner ) self:InitializeAfter() self:SetKeyValue( "minhealthdmg", "999999" ) end function ENT:InitializeAfter() self:SetupChair(  Vector( 0, 0, 30 ), Angle( 0, 90, 0 ) // actual chair vehicleclass ) end local function StandAnimation( vehicle, player ) return player:SelectWeightedSequence( ACT_GMOD_NOCLIP_LAYER ) end function ENT:SetupChair( vecvehicle, angvehicle ) self.Chair = ents.Create( "prop_vehicle_prisoner_pod" ) self.Chair:SetModel( "models/nova/airboat_seat.mdl" ) self.Chair:SetKeyValue( "vehiclescript","scripts/vehicles/prisoner_pod.txt" ) self.Chair:SetPos( self:GetPos() + vecvehicle ) self.Chair:SetParent( self ) self.Chair:SetMoveType( MOVETYPE_VPHYSICS ) self.Chair:SetAngles( angvehicle ) self.Chair:SetNotSolid( true ) -- self.Chair:SetNoDraw( true ) self.Chair:DrawShadow( false ) self.Chair:SetCollisionGroup( COLLISION_GROUP_DEBRIS_TRIGGER ) self.Chair.HandleAnimation = StandAnimation self.Chair:SetVehicleClass("bactacg_seat") self.Chair:SetOwner( self ) self.Chair:Spawn() self.Chair:Activate() local phys = self.Chair:GetPhysicsObject() if IsValid(phys) then phys:EnableMotion(false) phys:Sleep() end end if i use the original function i cannot move the parent thing anymore.. i use this cuz i need to make a function when a user is in this vehicle he gets healed over time till his MaxHealth is reached. thanks alot.. i want that it looks normal so not the weird view.. i need the seat into the model so it looks like its outside but its in.. you know what i mean i guess.
If you're trying to hide the chair you should try setting the Color to Color(255, 255, 255, 0) as well
Oh i mean not the chair.. if i make nodraw it works the issue i mean is the chair or the player sitting on the vehicle it looks lik the chair is outside from the color.. so the player is not in the bacta tank prop he is definetly in but the playermodel/chair is looking like its outside.. thats why i put the screenshot... i mean the second code is working wih parenting and the chair is hovered by the bacta tank prop... but im ot able to physgun move the whole thing with second code.. with the first i can move but the chair or player looks so weird.. i made the chair appear cuz i forget to make a screenshot with the camera tool.. i hope you understand what i mean
local phys = self.Chair:GetPhysicsObject() if IsValid(phys) then phys:EnableMotion(false) phys:Sleep() This may be why you can't move the entity, what is the purpose of this code?
If i change that it dont work either... (with code 2)
Maybe i should try to make a function for the ent.. just make the normal ent.. and make a for k.v in pairs ents.gettall() do and adding the chair in post to fix the clipping issue?...
It looks like an issue with the glass material of your tank, sometimes stuff like that happens, try messing with ENT.RenderGroup, I had an issue like this once.
thanks alot the rendergroup_both made the trick.. now i can work on the check function.. i mean if a player is in the vehicleclass he gets healed... must i use a changeowner function? and i must call the heal function in a ent:think() hook or?
Just for testing purpose i use this: is there ab etter way for me to do it? hook.Add("Think","Bactaheal",function() for k,v in pairs (player.GetAll()) do  if v:InVehicle() and  v:GetVehicle():GetVehicleClass() == "bactacg_seat" then  local maxhealth =  9900 if v:Health() < maxhealth then v:SetHealth(v:Health() + 1) end end end end)
Ok new Issue appears. I want to store the position where the Player press Use on my Entity to Enter the vehicle. And if he leave the vehicle he get the stored position.. i have this code: local function SetVehiclePositions(ply) ply.EntryPoint = ply:GetPos() ply.EntryAngles = ply:EyeAngles() end local function GetVehiclePositions(ply,veh) if ply:GetVehicle():GetVehicleClass() == "bactacg_seat" then ply:SetPos( ply.EntryPoint ) ply:SetEyeAngles( ply.EntryAngles ) end end hook.Add("CanPlayerEntryVehicle", "PlayerSaveBactaPos", SetVehiclePositions) hook.Add("PlayerLeaveVehicle", "PlayerLeaveBactaTank", GetVehiclePositions) the leavevehicle hook should work.. i just need the setting function when i start to enter the vehicle
You can use GM/PlayerEnteredVehicle to set the positions
Ok ill give it a try.. the leave hook is almost done.. idk playerenteredvehicle just runs after can... i need to cache it before the player is in the vehicle.. so i need to call the storing earlier
Forget what I said before, however, in your GetVehiclePositions function, you should use the supplied 'veh' param instead of using ply:GetVehicle(), the rest of the code should work nicely.
This is what i got from far now. still not work if i enter my vehicle seat and leav it he spawns at normal position.. so i need to use another hook for setting the variables-- local function SetVehiclePositions(ply) ply.EntryPoint = ply:GetPos() ply.EntryAngles = ply:EyeAngles() end local function GetVehiclePositions(ply,veh) if veh:GetVehicleClass() == "bactacg_seat" then ply:SetPos( ply.EntryPoint ) ply:SetEyeAngles( ply.EntryAngles ) end end hook.Add("CanPlayerEnterVehicle", "PlayerSaveBactaPos", SetVehiclePositions) hook.Add("PlayerLeaveVehicle", "PlayerLeaveBactaTank", GetVehiclePositions)
Make sure that the SetVehiclePositions function is running
ah i see the canplayerentervehicle hook is just for returning true or false... i need to get my ent code and maybe Ent:use() to get this function run..
Ok i dont understand.. On single Player it works.. but on multiplayer it dont work... here is the full code: function SetVehiclePositions(ply, veh) if veh:GetVehicleClass() == "bactacg_seat" then ply.EntryPoint = ply:GetPos() ply.EntryAngles = ply:EyeAngles() return true end end function GetVehiclePositions(ply,veh) if veh:GetVehicleClass() == "bactacg_seat"  then ply:SetPos( ply.EntryPoint ) ply:SetEyeAngles( ply.EntryAngles ) end end hook.Add("CanPlayerEnterVehicle", "PlayerSaveBactaPos", SetVehiclePositions) hook.Add("PlayerLeaveVehicle", "PlayerLeaveBactaTank", GetVehiclePositions) hook.Add("Think","Bactaheal",function() for k,v in pairs (player.GetAll()) do  if v:InVehicle() and  v:GetVehicle():GetVehicleClass() == "bactacg_seat" then  local maxhealth =  v:GetMaxHealth() or 100 if (v.NextHeal || 0 ) < CurTime() then if v:Health() < maxhealth then v.NextHeal = CurTime() + 0.2 v:SetHealth(v:Health() + 1) end end end end end) and here the entity itself AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( "shared.lua" ) function ENT:Initialize() self:SetModel( self.ChairModel ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) self:SetUseType( SIMPLE_USE ) self:DrawShadow( false ) local phys = self:GetPhysicsObject() if IsValid( phys ) then phys:EnableMotion(false) phys:Sleep() end self:InitializeAfter() self:SetKeyValue( "minhealthdmg", "999999" ) end function ENT:InitializeAfter() self:SetupChair(  Vector( 0, 0, 30 ), Angle( 0, 180, 0 ) // actual chair vehicleclass ) end local function StandAnimation( vehicle, player ) return player:SelectWeightedSequence( ACT_GMOD_NOCLIP_LAYER ) end function ENT:SetupChair( vecvehicle, angvehicle ) self.Chair = ents.Create( "prop_vehicle_prisoner_pod" ) self.Chair:SetModel( "models/nova/airboat_seat.mdl" ) self.Chair:SetKeyValue( "vehiclescript","scripts/vehicles/prisoner_pod.txt" ) self.Chair:SetPos( self:GetPos() + vecvehicle ) self.Chair:SetParent( self ) self.Chair:SetAngles( angvehicle ) self.Chair:SetNotSolid( true ) --self.Chair:SetNoDraw( true ) self.Chair:DrawShadow( false ) self.Chair:SetCollisionGroup( COLLISION_GROUP_DEBRIS_TRIGGER ) self.Chair.HandleAnimation = StandAnimation self.Chair:SetVehicleClass("bactacg_seat") self.Chair:SetOwner( self ) self.Chair:Spawn() self.Chair:Activate() local phys = self.Chair:GetPhysicsObject() if IsValid(phys) then phys:EnableMotion(false) phys:Sleep() end end
Ok i guess i should using net.messages to store the positions
Why? You dont need to know the position on the client, everything related to positioning the player is serverside.
yeah but idk how to get it to work.. maybe i do that when the client presses Use on the ent itself.. he gets into and the pos gets stored... im to dumb to get it normal working so i would do a client to server. otherwise i dont get it to work.. on singleplayer it wporks.
Ok i dont know how to get this to work.. here is my code: function ENT:Use( ply ) ply.EntryPoint = ply:GetPos() ply.EntryAngles = ply:EyeAngles() self.Chair:SetOwner( ply ) ply:EnterVehicle( self.Chair ) end local function GetVehiclePositions(ply,ent) if ply:GetVehicle():GetVehicleClass() == "bactacg_seat" then ply:SetPos( ply.EntryPoint ) ply:SetEyeAngles( ply.EntryAngles ) end end hook.Add("PlayerLeaveVehicle", "PlayerLeaveBactaTank", GetVehiclePositions)
You call AddOwner(ply,veh) But never define veh in your function AddOwner() What do you want your AddOwner function to do exactly? Right now you are only editing the player's value inside of it.
i forget to remove the veh variable... i made the hooks working with the canplayerenter and playerleave hook... its now work like it should.. and i changed a little bit of the code and removed the VEh part cuz just the ply is important for me.
Sorry, you need to Log In to post a reply to this thread.