• Print

Author Topic: Forcing a picture on a screen?  (Read 4598 times)

0 Members and 1 Guest are viewing this topic.

Offline IncendiaryBlitz

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Forcing a picture on a screen?
« on: March 30, 2017, 06:17:42 pm »
Hi, I'm a bit new to Lua coding and want to make a ulx command that will show a picture on the screen of the target. Basically, I am making a jump scare command to play some pranks on the Owner of the server I develop. If someone could help me figure out the basis of making that command, it would be great!




Ps. My best guess is forcing a DFrame on the screen but at the same time, I don't know how to incorporate a pic into that.

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: Forcing a picture on a screen?
« Reply #1 on: March 30, 2017, 09:26:54 pm »
You could try something like this...

Code: Lua
  1. function ulx.scare( calling_ply, target_plys )
  2.  
  3.     for k, v in pairs ( target_plys ) do
  4.         v:SendLua([[gui.OpenURL("")]]) --URL to something goes here.
  5.     end
  6.  
  7. end
  8.  
  9. local scare = ulx.command( CATEGORY_NAME, "ulx scare", ulx.scare, "!scare", true )
  10. scare:addParam{ type=ULib.cmds.PlayersArg }
  11. scare:defaultAccess(ULib.ACCESS_ADMIN)
  12. scare:help("Have some fun why don't ya?")
  13.  

I'm almost 100% positive there's a better way to do this but this is just something I thought of that you could try. Been a while since I wrote glua, or anything in ULX for that matter, but nevertheless this has the basic concept in mind.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Forcing a picture on a screen?
« Reply #2 on: March 30, 2017, 10:28:49 pm »
Just use HUD elements. It's very easy to draw an image to a client using render textures.

http://wiki.garrysmod.com/page/render/DrawTextureToScreenRect

This would allow you to do that.

Here is some example clientside VGUI (This is obviously pseudo code)
If you are a developer, you should be able to read this and turn it into usable code no problem.

Code: [Select]
AddCSLuaFile()
myPicture = Material( "path/to/image.png" )
function MyJumpScare()
if not LocalPlayer().scared then return end
   
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetMaterial( myPicture )
surface.DrawTexturedRect(x, y, width, height )
end

you could then write your code/command to set the .scared = true to the local player using a net message or even
ply:SendLua("LocalPlayer().scared = true")

Offline IncendiaryBlitz

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Forcing a picture on a screen?
« Reply #3 on: March 31, 2017, 01:51:03 pm »
Awesome. Bothe of these will really help. Thanks!

  • Print