• Print

Author Topic: Roll the Dice module  (Read 46282 times)

0 Members and 1 Guest are viewing this topic.

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #15 on: March 26, 2015, 03:27:05 am »
1. Adding a ban (maybe kick) to the roll would be scary as <censor>, but I love it. I would fear that users wouldn't be so excited to use it though considering they'd risk losing their score and karma (not touching configs for these), so I don't plan on adding this effect.

2. Adding that explode option would be dope a.f. lol I'll read through this again to figure out how to add that. I'll also check out ulx jail to the mix, now that I think of it. Or even get whipped by the dice (ulx whip/slap). <censor>, options seem to be endless once you know what's going on lol

3. This shouldve been 1 but no ragrets, but I understand the purpose of it being random and not being able to choose the effect. I just think players would enjoy the option to some effects that aren't normally accessible at their own leisure. Similar to ulx Fun commands. I'm mainly talking about the drugged and confused effects. Giving users the option to do this to themselves has been a popular request. For now, I'll look into extending the time lengths for some effects.

Oh, I misunderstood you. Thought you said wanted banning as an effect or something. That would have taken the dice to the next level for suuure. xD

I only wanted 1 lethal effect considering there's not that many effects (yet). Rocket will actually explode the player in the air. You're obviously free to modify and/or add anything you want! I like the idea of ulx whip as a roll though...

I'll attach separate ulx commands for confused and drugged to this post. Code is kinda messy but it works. (:

Edit: updated versions
« Last Edit: March 28, 2015, 12:17:48 pm by Timmy »

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #16 on: March 26, 2015, 06:56:29 am »
Oh, I misunderstood you. Thought you said wanted banning as an effect or something. That would have taken the dice to the next level for suuure. xD

I only wanted 1 lethal effect considering there's not that many effects (yet). Rocket will actually explode the player in the air. You're obviously free to modify and/or add anything you want! I like the idea of ulx whip as a roll though...

I'll attach separate ulx commands for confused and drugged to this post. Code is kinda messy but it works. (:

Awesome! It took me a minute to find it (so many commands), but I got it up and running. I know my community will love using this (weridos lol). I just tried it for a minute and I'm about ready to give up technology for the day. My eyes... lol Oh well. Is there a way to somehow create a "Confirm" window for those who may be epileptic? I plan on releasing a video on how to use this, but some people will try to go for the full 256 seconds, forget how to get out of drugged, have a seizure, then I'm lol So when they go, say, for 30+ seconds, and they hit confirm (or when they do the chat command), have something say "This may cause nausea or epileptic episodes. Do you wish to continue?" or something to that matter. I'm sure this is asking more than needed, but I'm looking out for the fam.

Thanks again!

On a side note, I really do have a buttload of categories. Some commands come with their own as well as addons and whatnot. If I combined the code from one autorun into one lua file, and moves the lua/sh code into one lua/sh lua file, would that essentially combine whatever I just did into categories? I'll probably look more in depth into this and categorize them better. Here's half of them for instance http://puu.sh/gQkr0/fa6fa331b1.png and it would be a lot easier if I combined some of them. But I'll look into that. Just checking if anyone knows an easy or suggested way of doing this.
"Then Jesus said to his disciples, 'Whoever wants to be my disciple must deny themselves and take up their cross and follow me.'" - Matthew 16:24



MNWO: Steam | Discord | Website | Join Server

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Roll the Dice module
« Reply #17 on: March 26, 2015, 07:43:23 am »
On a side note, I really do have a buttload of categories. Some commands come with their own as well as addons and whatnot. If I combined the code from one autorun into one lua file, and moves the lua/sh code into one lua/sh lua file, would that essentially combine whatever I just did into categories? I'll probably look more in depth into this and categorize them better. Here's half of them for instance http://puu.sh/gQkr0/fa6fa331b1.png and it would be a lot easier if I combined some of them. But I'll look into that. Just checking if anyone knows an easy or suggested way of doing this.

The command categories are manually specified in with each ulx.command call- you'd have to manually go through the code and change the category name yourself. As an example, with Timmy's confuse code he just posted, you'd look at the ulx-confused\lua\ulx\modules\sh\confuse.lua file, then find the line that has "ulx.command(" (line 51), then the first argument is "Fun". You can change that to whatever value you like. For other commands/addons, you'll just have to find where "ulx.command" is called. The files containing this SHOULD be in <whichever addon>\lua\ulx\modules\sh, though, so they shouldn't be hard to find.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #18 on: March 26, 2015, 08:02:05 am »
The command categories are manually specified in with each ulx.command call- you'd have to manually go through the code and change the category name yourself. As an example, with Timmy's confuse code he just posted, you'd look at the ulx-confused\lua\ulx\modules\sh\confuse.lua file, then find the line that has "ulx.command(" (line 51), then the first argument is "Fun". You can change that to whatever value you like. For other commands/addons, you'll just have to find where "ulx.command" is called. The files containing this SHOULD be in <whichever addon>\lua\ulx\modules\sh, though, so they shouldn't be hard to find.

Great! So I just have to find the "ulx.command" line in all the sh/*lua files and then I can rename the first argument. Now, I've seen commands that you can change the Category name via CATEGORY_NAME. Perfect example would be the "Restart Timer Command" by syst3M4TiK where he uses "local CATEGORY_NAME = "_Restart"" and changing works fine. Is there a difference between local CATEGORY_NAME = "_Restart" and ulx.command?
"Then Jesus said to his disciples, 'Whoever wants to be my disciple must deny themselves and take up their cross and follow me.'" - Matthew 16:24



MNWO: Steam | Discord | Website | Join Server

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Roll the Dice module
« Reply #19 on: March 26, 2015, 08:07:29 am »
CATEGORY_NAME is just a variable used within a file that's called in ulx.command later:
Code: Lua
  1. ulx.command( CATEGORY_NAME, ... )

So yeah, if a particular file has a CATEGORY_NAME defined, it'd be easier to change that instead of going to each instance of ulx.command and changing it.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #20 on: March 26, 2015, 12:32:56 pm »
CATEGORY_NAME is just a variable used within a file that's called in ulx.command later:
Code: Lua
  1. ulx.command( CATEGORY_NAME, ... )

So yeah, if a particular file has a CATEGORY_NAME defined, it'd be easier to change that instead of going to each instance of ulx.command and changing it.

Step 1. Change any available CATEGORY_NAME lines
Syep 2. If no CATEGORY_NAME available, change 1st parameter (out of 4?) in ulx.command

Sound right?
"Then Jesus said to his disciples, 'Whoever wants to be my disciple must deny themselves and take up their cross and follow me.'" - Matthew 16:24



MNWO: Steam | Discord | Website | Join Server

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #21 on: March 26, 2015, 06:15:26 pm »
I noticed that the stand alone drugged (not sure about the confusion yet) addon keeps a player alive (while spectating) after they die.

So, they drug themselves, die, and they're name remains active and they can communicate with the living still. The game seems to end normally when T's or Innos win, so I don't think that is affected, but I'll keep a look out.
"Then Jesus said to his disciples, 'Whoever wants to be my disciple must deny themselves and take up their cross and follow me.'" - Matthew 16:24



MNWO: Steam | Discord | Website | Join Server

Offline H-0-R-I-Z-0-N

  • Newbie
  • *
  • Posts: 3
  • Karma: -1
Re: Roll the Dice module
« Reply #22 on: March 26, 2015, 08:37:44 pm »
I can't find anywhere what the command to type in chat is? What is it?  :-\
I take back everything I've said. You wore those words on your lips, as if they meant anything anyway.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Roll the Dice module
« Reply #23 on: March 26, 2015, 09:35:52 pm »
I can't find anywhere what the command to type in chat is? What is it?  :-\

You type rtd in the chatbox and you'll receive a random effect from "the dice".
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #24 on: March 27, 2015, 01:05:43 am »
I noticed that the stand alone drugged (not sure about the confusion yet) addon keeps a player alive (while spectating) after they die.

So, they drug themselves, die, and they're name remains active and they can communicate with the living still. The game seems to end normally when T's or Innos win, so I don't think that is affected, but I'll keep a look out.

Sorry, I messed that up. See if the updated commands work for you. :)

Btw; I read up on photosensitivity and the likelihood for it to cause seizures, very small but I guess it could happen. I wanna fiddle with Derma a little before I try to write some confirmation gui. I changed the default duration to 30 seconds in this version though.

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #25 on: March 27, 2015, 08:01:18 am »
Sorry, I messed that up. See if the updated commands work for you. :)

Btw; I read up on photosensitivity and the likelihood for it to cause seizures, very small but I guess it could happen. I wanna fiddle with Derma a little before I try to write some confirmation gui. I changed the default duration to 30 seconds in this version though.

Alright cool I'll give it a try after work. And yeah I increased the time for drugged/confusion in the RTD to 30 or something higher than previously defaulted. But for the standalone I want to make it clear that doing it for a long time (longer than a short 30 sec) may do some dmg whether perma or not lol I just don't want liability to the very few who may be affected. It is a game, I understand that. And I could simply NOT add this, but that isn't fun now is it. But yeah, I figured a simple heads up would be beneficial one way or another.
"Then Jesus said to his disciples, 'Whoever wants to be my disciple must deny themselves and take up their cross and follow me.'" - Matthew 16:24



MNWO: Steam | Discord | Website | Join Server

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #26 on: April 07, 2015, 08:19:33 pm »
Sorry, I messed that up. See if the updated commands work for you. :)

Btw; I read up on photosensitivity and the likelihood for it to cause seizures, very small but I guess it could happen. I wanna fiddle with Derma a little before I try to write some confirmation gui. I changed the default duration to 30 seconds in this version though.

Update works great. Thanks!
"Then Jesus said to his disciples, 'Whoever wants to be my disciple must deny themselves and take up their cross and follow me.'" - Matthew 16:24



MNWO: Steam | Discord | Website | Join Server

Offline Ethan Jones

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: Roll the Dice module
« Reply #27 on: June 01, 2015, 08:21:44 pm »
Hey Timmy
I like your addon.
I kind of want to get into addon making with Ulx now that I have a prophunt server and you can't always get what you want. (lol)
I have an idea of adding pointshop integration
(!rtd player looses points/credits)
If you would like I could *try to* do this!
But I would like your permission first.
Or if you wanted to do this yourself i didn't want to take this from you.

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #28 on: June 01, 2015, 09:41:54 pm »
Hey Timmy
I like your addon.
I kind of want to get into addon making with Ulx now that I have a prophunt server and you can't always get what you want. (lol)
I have an idea of adding pointshop integration
(!rtd player looses points/credits)
If you would like I could *try to* do this!
But I would like your permission first.
Or if you wanted to do this yourself i didn't want to take this from you.

Absolutely! You're free to modify to the source of the addon.

You will need to make changes to the trtd.lua file, located in the lua/ulx/modules/sh folder of my addon. There's a comment somewhere that will tell you where the effect should be added.

All effects are added using the TRTD:AddEffect function. The function takes a lua table as an argument. The table holds information about the effect.

You'd probably want to do something similar to this:
Code: Lua
  1. TRTD.AddEffect({name="extra points", enable=function(ply)
  2.     ply:SetPoints( ply:GetPoints() + 100 ) -- Just an example. Change to use PS functions.
  3. end})

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Roll the Dice module
« Reply #29 on: July 27, 2015, 05:25:06 am »
Hey timmy! I love your addon, I have a few suggestions for you to add:
Make the rtd command cost pointshop points
TRTD.Settings.BuyRtd = 600 (this is just an example, 600 stands for the amount of points reducted from your points, set -1 to disable )
Make the duration of noclip less, maybe like 2 seconds, because this is just way too overpowered when all my players got noclip from it, also if a player is stuck it when going out of noclip, they should be randomly teleported to the person closest to them, or get automatically killed, or get teleported back to were they where if they are stuck.

[EDIT] I've found out an easy way if you know a bit of lua to make it reduct your pointshop points when running the command.
here's what I have:

Code: Lua
  1. function ulx.rtd(calling_ply)
  2.     if (!IsValid(calling_ply)) then return end
  3.        
  4.         calling_ply:PS_TakePoints(50)
  5.  
  6.     if (calling_ply.TRTD_Cooldown == nil) then
  7.         calling_ply.TRTD_Cooldown = 0
  8.     end
  9.  
  10.     if (calling_ply.TRTD_Cooldown-1 > CurTime()) then
  11.         ULib.tsayError(calling_ply, "You have to wait " .. math.Round(calling_ply.TRTD_Cooldown - CurTime()) .. " more seconds before you can Roll the Dice again.")
  12.         return
  13.     end
  14.  
  15.     if (!calling_ply:Alive()) then
  16.         ULib.tsayError(calling_ply, "You can't Roll the Dice when you're dead.")
  17.         return
  18.     end
  19.  
  20.     calling_ply.TRTD_Cooldown = CurTime() + TRTD.Settings.Cooldown:GetInt()
  21.  
  22.     local effect = randomEffect(calling_ply)
  23.  
  24.     MsgN("[".. TRTD.Settings.Tag:GetString() .."] " .. calling_ply:Nick() .. " has rolled " .. effect.name)
  25.  
  26.     effect.enable(calling_ply)
  27.  
  28.     if (effect.disable ~= nil && effect.duration ~= nil) then
  29.         -- Trigger the client-side countdown
  30.         net.Start("TRTD_EffectCountdown")
  31.         net.WriteInt(effect.duration, 6) -- Bit count of 6 allows any int between 0 and 63
  32.         net.Send(calling_ply)
  33.  
  34.         -- Make sure all hook IDs are unique...
  35.         local session = util.CRC(SysTime())
  36.         local hookId = "TRTD_EffectTimer_" .. calling_ply:SteamID64() .. session
  37.         local timerId = "TRTD_DeathListener_" .. calling_ply:SteamID64() .. session
  38.  
  39.         -- If the player dies during an effect, we want to stop it as well as the countdown
  40.         hook.Add("PlayerDeath", hookId, function(victim)
  41.             if (victim == calling_ply) then
  42.                 net.Start("TRTD_EffectCountdownStop")
  43.                 net.Send(calling_ply)
  44.                 effect.disable(calling_ply)
  45.                 timer.Destroy(timerId)
  46.             end
  47.         end)
  48.  
  49.         -- Disable the effect
  50.         timer.Create(timerId, effect.duration, 1, function()
  51.             if (!IsValid(calling_ply)) then return end
  52.             effect.disable(calling_ply)
  53.             hook.Remove("PlayerDeath", hookId)
  54.         end)
  55.     end
  56.  
  57.     local notification = {}
  58.     table.insert(notification, TRTD.Colors.Tag)
  59.     table.insert(notification, "[" .. TRTD.Settings.Tag:GetString() .. "] ")
  60.     table.insert(notification, team.GetColor(calling_ply:Team()))
  61.     table.insert(notification, calling_ply:Nick())
  62.     table.insert(notification, TRTD.Colors.Default)
  63.     table.insert(notification, " has received ")
  64.     table.insert(notification, TRTD.Colors.Effect)
  65.     table.insert(notification, effect.name)
  66.     table.insert(notification, TRTD.Colors.Default)
  67.     table.insert(notification, " from the dice.")
  68.  
  69.     local effectNotifications = nil -- nil will send to all players
  70.     if (TRTD.Settings.Notifications:GetBool() == false) then
  71.         effectNotifications = calling_ply
  72.     end
  73.  
  74.     ULib.tsayColor(effectNotifications, false, unpack(notification))
  75. end
  76. local rtd = ulx.command(TRTD.Settings.Category:GetString(), "ulx rtd", ulx.rtd, "!rtd", true)
  77. rtd:defaultAccess(ULib.ACCESS_ALL)
  78. rtd:help("Roll the Dice and receive a random, temporary effect.")
  79.  

But maybe make it so people can easily configure on how much it should cost, like I suggested above. (Maybe also support DarkRP and Pointshop 2)
« Last Edit: July 27, 2015, 11:43:56 am by Janjakob2000 »

  • Print