Author Topic: Print message in all chat and make image unclosable  (Read 2139 times)

0 Members and 1 Guest are viewing this topic.

Offline BlitherLlama

  • Newbie
  • *
  • Posts: 8
  • Karma: -4
Print message in all chat and make image unclosable
« on: January 02, 2017, 08:06:28 AM »
I'm currently trying to create a ulx command that opens an image on a player when typing !meow {player}
Currently, my issues are:
- It wont say anything in chat (regardless if I use !meow or !smeow)
- I don't know how to make the 'meow' part of #A is making #T enjoy meow, a rainbow colour
- I've seen it done on another server where if they do this to you, the image pops up but you can't close it and it takes up your whole screen (instead of it just being in the steam browser tab)

Code: [Select]
function ulx.meow( calling_ply, target_plys, openedurl, should_silent )

for k,v in pairs( target_plys ) do

v:SendLua([[gui.OpenURL( "image.com" )]])

end

if should_silent then

ulx.fancyLogAdmin( calling_ply, true, "#A is making #T enjoy meow", openedurl, target_plys )

else

ulx.fancyLogAdmin( calling_ply, "#A is making #T enjoy meow", openedurl, target_plys )

end

end

local url = ulx.command( "Pixels' Addons", "ulx meow", ulx.meow, "!meow" )
url:addParam{ type=ULib.cmds.PlayersArg }
url:defaultAccess( ULib.ACCESS_ADMIN )
url:help( "Makes a user enjoy 'meow'" )
url:setOpposite( "ulx smeow", { _, _, _, true }, "!smeow" )

Any help is appreciated

Thanks,
BlitherLlama

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: Print message in all chat and make image unclosable
« Reply #1 on: January 02, 2017, 12:44:04 PM »
Well I worked around the first problem by just separating the commands. They'll still be !meow and !smeow though.

Code: [Select]
-----------------Meow---------------------------
function ulx.meow( calling_ply, target_plys )
    for k, v in pairs ( target_plys ) do
        v:SendLua([[gui.OpenURL("http://eskipaper.com/images/kitty-cat-1.jpg")]])
        ulx.fancyLogAdmin( calling_ply, "#A is making #T enjoy meow", target_plys )
    end   
end

local meow = ulx.command( CATEGORY_NAME, "ulx meow", ulx.meow, "!meow" )
meow:addParam{ type=ULib.cmds.PlayersArg }
meow:defaultAccess( ULib.ACCESS_ADMIN )
meow:help( "Makes a user enjoy meow" )

-------------------SMeow------------------------------
function ulx.smeow( calling_ply, target_plys )
    for k, v in pairs ( target_plys ) do
        v:SendLua([[gui.OpenURL("http://eskipaper.com/images/kitty-cat-1.jpg")]])
        ulx.fancyLogAdmin( calling_ply, true, "#A is making #T enjoy meow", target_plys )   
    end
end

local smeow = ulx.command( CATEGORY_NAME, "ulx smeow", ulx.smeow, "!smeow" )
smeow:addParam{ type=ULib.cmds.PlayersArg }
smeow:defaultAccess( ULib.ACCESS_ADMIN )
smeow:help( "Makes a user enjoy meow" )
« Last Edit: January 02, 2017, 03:14:19 PM by BlueNova »

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Print message in all chat and make image unclosable
« Reply #2 on: January 02, 2017, 12:49:24 PM »
I need to test the command first to get some insight as to why it isn't doing as you intend before answering your first two questions, but I highly suspect the reason is because you're passing openedurl (which I assume is a string) and target_plys to ulx.fancyLogAdmin() while you only have one thing for it to replace, #T.

not really an edit: Something I just realized is that you only have one argument set with cmd:addParam(), so openedurl will always be nil. This could also cause problems with fancyLog.

As for how to make the image pop up without you being able to close it, you'll most likely need to create your own custom menu.

And as a final aside, some unsolicited advice: making an image pop up on player's screens without them being able to close it is a good way to get them to leave your server and never come back. At least, that would be my reaction to this if I had recently joined.

edit 1:

I think BlueNova had a good idea with separating the commands, as setOpposite isn't really intended to be used for silencing commands, but at the same time that issue could be fixed (I'm 99.9% certain, at least) while keeping them combined.

edit 2:

I guess I didn't read your second question correctly the first time around. I don't believe fancyLogAdmin accepts color arguments, so you'll have to use ULib.tsayColor.
« Last Edit: January 02, 2017, 01:37:24 PM by roastchicken »
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline BlitherLlama

  • Newbie
  • *
  • Posts: 8
  • Karma: -4
Re: Print message in all chat and make image unclosable
« Reply #3 on: January 02, 2017, 07:47:07 PM »
Thanks all! Recently found out that theres a scriptfodder addon that does exactly this https://scriptfodder.com/scripts/view/1097

I planned to use this on minges before they get kicked/banned as a warning not to do it again.