• ENT:Use and gui.OpenURL
    3 replies, posted
Hey there everyone! I'm currently working on a Clockwork HL2RP plugin, and I need to figure out how to make it so when you press Use on the entity, it opens the steam browser. Here is the code; [CODE] -- Called when the entity is used. function ENT:Use(activator, caller) activator:SendLua("gui.OpenURL('www.google.com')") end; [/CODE] I have added a command to spawn the entity, that all works just fine, but I can't get this to open a webpage.
Last I heard, it needs http:// in the URL. Try gui.OpenURL('http://www.google.com')
Wow, that was it lol. Thanks!
Hello, I have a Question, how did you get function ENT:Use work? I trying to make it work for my next bot project but when I Use " E " on entity it's never get called. [CODE] AddCSLuaFile() AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) DEFINE_BASECLASS("base_nextbot") models = {"models/mossman.mdl", "models/odessa.mdl", "models/breen.mdl", "models/alyx.mdl", "models/monk.mdl", "models/barney.mdl", "models/Kleiner.mdl" } function ENT:Initialize() --self:SetModel( "models/props_halloween/ghost_no_hat.mdl" ); --self:SetModel( "models/props_wasteland/controlroom_filecabinet002a.mdl" ); rand = math.random(1,7) print("!!!!!!!!!ALIVE!!!!!!!!!!!!!!!!!!!!!!") print(rand) self:SetModel( models[rand]) self:SetSolid( SOLID_BBOX ) self:SetUseType( SIMPLE_USE ) self:SetVar( "stop", false ) self:SetVar( "comeToPlayer", false ) self:SetVar( "FirstPlayer" , player.GetByID( 1 ) ) print(player.GetByID( 1 ).Name) self:SetVar( "PlayerPosition" , player.GetByID( 1 ):GetPos() ) self:SetVar( "Position", self:GetPos()) end ----------- -- Think -- ----------- function ENT:Think() self.PlayerPosition = self.FirstPlayer:GetPos() self.Position = self:GetPos() if(!self.comeToPlayer and self.Position:Distance(self.PlayerPosition) < 170) then self.loco:SetDesiredSpeed( 80 ) self:StartActivity( ACT_WALK ) local path = Path( "Follow" ) self.comeToPlayer = true elseif( self.Position:Distance(self.PlayerPosition) < 80 and !self.stop) then print("trorlorlorlo") self.stop = true self:StartActivity(ACT_IDLE) elseif(self.stop and self.Position:Distance(self.PlayerPosition) > 205) then self.comeToPlayer = false self.stop = false self:DropToFloor() end end function ENT:Use( activator, caller ) umsg.Start( "Talk", activator ) umsg.End( ) return true end function ENT:AcceptInput( name, activator, caller ) if ( name == "Use") then umsg.Start( "Talk", activator ) umsg.End( ) end return true end function ENT:BehaveAct() end function ENT:AcceptInput( name, activator, caller ) print("TOTOTOOTTO") if ( name == "Use" && ValidEntity( activator ) && activator:IsPlayer( ) ) then umsg.Start( "PurchaseStuff", activator ) umsg.End( ) end return true end function ENT:RunBehaviour() while ( true ) do -- walk somewhere random -- walk anims if(!self.stop) then speed = math.Rand( 50, 200 ) if(speed > 200 and self:GetActivity() ~= ACT_RUN) then self.loco:SetDesiredSpeed( speed ) self:StartActivity( ACT_RUN ) else self.loco:SetDesiredSpeed( speed * 0.5 ) self:StartActivity( ACT_WALK ) print("Run !") end -- walk speeds self:MoveToPos( Vector( math.Rand( -4000, 800 ), math.Rand( -3500, 3000 ), 200 )) coroutine.yield() else // Or any player self:PointAtEntity(self.FirstPlayer) self.loco:FaceTowards( self.PlayerPosition ) coroutine.yield() end end end function ENT:MoveToPos( pos, options ) local options = options or {} local path = Path( "Follow" ) path:SetMinLookAheadDistance( options.lookahead or 300 ) path:SetGoalTolerance( options.tolerance or 20 ) path:Compute( self, pos ) if ( !path:IsValid() ) then return "failed" end while ( path:IsValid()) do if (self.stop) then return "stopped" elseif(self.comeToPlayer) then path:Compute( self, self.PlayerPosition ) path:Update( self ) else path:Update( self ) end -- Draw the path (only visible on listen servers or single player) if ( options.draw ) then path:Draw() end -- If we're stuck then call the HandleStuck function and abandon if ( self.loco:IsStuck() ) then self:HandleStuck(); return "stuck" end -- -- If they set maxage on options then make sure the path is younger than it -- if ( options.maxage ) then if ( path:GetAge() > options.maxage ) then return "timeout" end end -- -- If they set repath then rebuild the path every x seconds -- if ( options.repath ) then if ( path:GetAge() > options.repath ) then path:Compute( self, pos ) end end coroutine.yield() end return "ok" end -- -- List the NPC as spawnable -- list.Set( "NPC", "gregs_npc", { Name = "Greg's NPC 2 ", Class = "gregs_npc", Category = "NPC" })[/CODE]
Sorry, you need to Log In to post a reply to this thread.