So, basically i wanted to make an entity where a function should be excecuted whenever a player touches it. This function is to connect the player to another server.
What I've done so far is, that i created in (Steam\steamapps\common\GarrysMod\garrysmod\lua\entities)
a folder and created cl_init.lua, init.lua and shared.lua..
cl_init.lua:
include("shared.lua")
function ENT:Draw()
self:DrawModel()
end
init.lua:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
ENT:Initialize()
self:SetModel( "models/props_borealis/bluebarrel001.mdl" )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetTrigger( true )
end
function ENT:Touch( entity )
LocalPlayer():ConCommand("connect 89.163.221.238:27015")
end
shared.lua:
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Test"
ENT.Author = "MasterJasonYT"
ENT.Spawnable = true
ENT.Category = "Other"
After i wrote this script, i can't find this in my entity menu in-game...
Are you still able to spawn it with the ent_create console command?
Yes, but I‘m getting an error model. I‘ve tried multiple models for this, it just doesn‘t work..
Sorry, you need to Log In to post a reply to this thread.