In trying to make a tow script. The problem i got right now is that i don't know if you can do that function ENT:Initialize() reads a vehicle script.
The code:
--Placed at lua/entities
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
function ENT:Initialize()
self.Entity:SetModel("models/statetrooper/ram_tow.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity=ents.Create("prop_vehicle_jeep")
end
function OyFekOff( ply, ent )
if ent:GetClass() == "entity_spikestrip" then return false end
end
hook.Add("EntityTakeDamage", "cnTireDamage","PhysgunPickup","OYFEKOFF=C",OyFekOff)
function ENT:StartTouch( ent )
if ent.cnWheelHealth then return end
if (ent:IsVehicle()) then
end
end
can you put it into [ LUA ] ?
I fixed that i won't spawn as a vehicle but now i got another problem.
Im trying to allow people to press on the buttonfortow to get health. anyone got any ideas how to do this?
[QUOTE]AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
function spawn( ply, key, activator, caller )
local prop = ents.Create("prop_vehicle_jeep")
prop:SetModel("models/statetrooper/ram_tow.mdl")
prop:SetKeyValue("vehiclescript","scripts/vehicles/statetrooper/ram3500_tow.txt" )
prop:Spawn()
prop:SetPos(Vector(-4769.285645, -5296.895020, 1081.730469))
local buttonfortow = ents.Create( "gmod_button" )
buttonfortow:SetModel( "models/dav0r/buttons/button.mdl" )
buttonfortow:SetPos(prop:GetPos()+Vector(50,-55,45))
buttonfortow:SetAngles(prop:GetAngles()+Angle(90,0,0))
buttonfortow:Spawn()
buttonfortow:SetUseType(ONOFF_USE)
constraint.Weld(buttonfortow,prop,0,0,0,0,true)
local test = ents.Create( "prop_physics" )
test:SetModel( "models/props_borealis/mooring_cleat01.mdl" )
test:SetPos(Vector(-4769.285645, -5296.895020, 1081.730469))
test:Spawn()
end
function ENT:Initialize()
spawn()
self.Entity:Remove()
end
function ENT:Use( activator, caller )
if IsValid( caller ) and caller:IsPlayer() then
caller:Kill()
end
end[/QUOTE]
[editline]19th November 2016[/editline]
Changed the code abit.
[QUOTE]AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
function ENT:Initialize( ply, key, activator, caller )
self.Entity:SetModel("models/maxofs2d/button_05.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
local prop = ents.Create("prop_vehicle_jeep")
prop:SetModel("models/statetrooper/ram_tow.mdl")
prop:SetKeyValue("vehiclescript","scripts/vehicles/statetrooper/ram3500_tow.txt" )
prop:Spawn()
prop:SetPos(Vector(-4769.285645, -5296.895020, 1081.730469))
local buttonfortow = ents.Create( "gmod_button" )
buttonfortow:SetModel( "models/dav0r/buttons/button.mdl" )
buttonfortow:SetPos(prop:GetPos()+Vector(50,-55,45))
buttonfortow:SetAngles(prop:GetAngles()+Angle(90,0,0))
buttonfortow:Spawn()
buttonfortow:SetUseType(ONOFF_USE)
constraint.Weld(buttonfortow,prop,0,0,0,0,true)
end
function ENT:Use( activator, caller )
if IsValid( caller ) and caller:IsPlayer() then
caller:Kill()
end
end[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.