ULX

Author Topic: Kittens overlay (ULX 2)  (Read 7177 times)

0 Members and 1 Guest are viewing this topic.

Offline mblunk

  • Newbie
  • *
  • Posts: 4
  • Karma: 1
Kittens overlay (ULX 2)
« on: November 11, 2006, 04:23:13 PM »
While my friend (DeltaOps101) and I were messing around on my server, we had an idea. Instead of the normal blind, the ability to place the kitten overlay on someone's screen. Simply add the following code to the bottom of ulx/fun.lua, then use these commands:

say !kittens <user> [time]  -- Puts the overlay on the user for [time] seconds (If no time, default is 10)
console ulx kittens <user> [time] -- Same args as above

And for the code:
Code: [Select]
function ulx.cc_kittens( userid, args, argv, argc )
if argc < 1 then
ULib.tsay( userid, ulx.LOW_ARGS )
return
end

local amt
if not argv[ 2 ] then
amt = 10
else
amt = tonumber( argv[ 2 ] )
end

if not amt then
ULib.tsay( userid, "\"" .. argv[ 2 ] .. "\" is an invalid amount!" )
return
end

local targets, err = ULib.getUsers( argv[ 1 ], _, true, ulx.ucl, userid ) -- Enable keywords
if not targets then
ULib.tsay( userid, err )
return
end

for _, v in ipairs( targets ) do
ULib.sendRect( v, 301, 0, 0, 1, 1, amt, 255, 255, 255, 255, "matsys_regressiontest/background.vmt")
end
end
ulx.CONCOMMAND( "kittens", ulx.cc_kittens, "<user> [<time> - LOL KITTIES", ACCESS_SLAY, "!kittens" )

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Kittens overlay (ULX 2)
« Reply #1 on: November 11, 2006, 09:06:16 PM »
Mblunk, nice addition, though I've not ever used/seen this before.

One suggestion for the future for anyone coding addons (and until we make a modules folder)...
Try not to modify any of the original ULib/ULX files.
This way, when we have released newer versions, your code changes will not have gotten overwritten because you modified an original file. :)

To create your own, create your code in a separate .lua file in your \gmod9\lua\init folder
(Ulib_kitties.lua perhaps),
and at the top of your code, add the following...

Code: [Select]
assert( _file.Exists( "lua/ULib/init.lua" ), "ULX needs ULib to run!" )
_OpenScript( "ULib/init.lua" )
assert( ULib.ULIB_VERSION >= 1.1, "ULX requires ULib version 1.1 or higher to run!" )


You can change that version check if needed.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline mblunk

  • Newbie
  • *
  • Posts: 4
  • Karma: 1
Re: Kittens overlay (ULX 2)
« Reply #2 on: November 13, 2006, 03:34:48 AM »
Ah yes, that makes more sense. I see how an update would cause loss of this feature. Thanks for the heads-up.