• 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
Roll the Dice module
« on: February 28, 2015, 03:36:30 am »
Helloo everyone ^-^

I'm pretty new to Lua programming and I just wrote my first semi-useful ULX module. (Yay!) I'd love to get some feedback on it. I hope it's okay if I post it here? :)

I bet most people already know Roll the Dice! You type rtd in the chatbox and you'll receive a random effect from "the dice".

I'm aware that not all effects will work in each gamemode but it's easy to add/delete effects in lua/ulx/modules/sh/trtd.lua.

Console variables
trtd_cooldown - (Default: 90) - Time (in seconds) before a player can roll the dice again
trtd_notifications - (Default: 1) - Broadcast notification to all players when a player rolls the dice

List of effects
Code: [Select]
**Good effects**
* double health
* faster speed
* godmode
* increased armor
* invisibility
* low gravity
* noclip
* nothing
* tiny player

**Bad effects**
* blindness
* confusion
* corporal punishment
* decreased armor
* drugged
* earthquake
* reduced health
* reduced speed
* respawn
* rocket
* spontaneous combustion

Changelog
Code: [Select]
## 1.4.0 (23 Jun 2020) - rewrite

Features:

- New effects: nothing, corporal punishment, increased/decreased armor, respawn

## 1.4.0 (19 Dec 2015) - lost

Features:

- New effects: nothing, corporal punishment, increased/decreased armor, respawn

## 1.3.1 (2 Apr 2015)

Bugfixes:

- Fix invisibility not hiding the players weapon

## 1.3.0 (2 Apr 2015)

Features:

- Improved "randomness" for the Dice

Bugfixes:

- Fix earthquake effect affecting nearby players
- Update blindness effect to use gLua's ScreenFade

## 1.2.1 (24 Mar 2015)

Bugfixes:

- Fix effects getting disabled twice
- Fixed effects giving unexpected results when ran simultaneously

## 1.2.0 (14 Mar 2015)

Features:

- New effects: noclip, confused, drugged

## 1.1.0 (3 Mar 2015)

Features:

- Improved update script

Bugfixes:

- Fix effect notifications not being sent to all players

## 1.0.0 (27 Feb 2015)

Features:

- Roll the dice
- Update checker

Thanks!
« Last Edit: June 23, 2020, 11:13:04 am by Timmy »

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Roll the Dice module
« Reply #1 on: February 28, 2015, 09:54:22 am »
Looks interesting and I took a look at some of the code and it's well done too.
Nice work!

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Roll the Dice module
« Reply #2 on: March 01, 2015, 02:39:22 pm »
I was working on one and i see this is done! Love to look at it!

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Roll the Dice module
« Reply #3 on: March 01, 2015, 04:39:30 pm »
So that's how identify version differences...
Code: Lua
  1. local version = "v1.0"
  2. local version_url = "http://users.silenceisdefeat.com/timmy/gmod/trtd.txt"
  3. local update_url = "github.com/Killua13/ULX-RTD"

I never knew that, I've done it like this, thought at the same time I never cared really about updates, seeing as most of my addons aren't really complicated that could break and need updates.
Code: Lua
  1. hook.Add('PlayerInitialSpawn','PlayerInitialSpawn'..ADDON_NAME, function(ply)
  2. if ply:IsSuperAdmin() == false then return end
  3. http.Fetch( "http://www.f4egaming.com/gmod_development/"..ADDON_NAME..".txt", function( body, len, headers, code )
  4. if body == nil then return end
  5. local body = string.Explode(" ",body)
  6.         if body[1] != "Version" then return end
  7.         if body[2] != YOUR_VERSION then
  8.         if ply:GetPData(ADDON_NAME..""..PLY2) != nil then
  9.                 if ply:GetPData(ADDON_NAME..""..PLY2) != "1" then
  10.                         umsg.Start(ADDON_NAME, ply)
  11.                                 umsg.String(YOUR_VERSION)
  12.                                 umsg.String(body[2])
  13.                                 umsg.String(ADDON_ACTUAL_NAME)
  14.                                 umsg.String(DOWNLOAD_LINK)
  15.                         umsg.End()
  16.                 end
  17.                         MsgN("~"..MESSAGE_TO_SERVER.."~")
  18.                         MsgC(Color(255,255,255,255),"Your Version: ",Color(255,0,0,255),YOUR_VERSION,"\n")
  19.                         MsgC(Color(255,255,255,255),"Online Version: ",Color(255,0,0,255),body[2],"\n")
  20.                         MsgC(Color(255,0,0,255),"OUT OF DATE","\n")
  21.                         MsgN("We here at Apple Inc. strongly suggest that you keep this addon updated")
  22.                         MsgN("Please go here and update: "..DOWNLOAD_LINK)
  23.                 end
  24.         end
  25. end,
  26. function( error )
  27.         MsgN("DOESNOT WORK")
  28. end)
  29. end)
  30. net.Receive( ADDON_NAME, function( length, client )
  31.         net.ReadEntity():SetPData(ADDON_NAME..""..PLY2,"1")
  32. end )
  33. util.AddNetworkString( ADDON_NAME )
  34. end
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #4 on: March 01, 2015, 11:36:16 pm »
Looks interesting and I took a look at some of the code and it's well done too.
Nice work!

Thanks for the feedback! That's great to hear. :)

I was working on one and i see this is done! Love to look at it!

Awesome! Thanks. :)

So that's how identify version differences...
It's just the way I did it, very simplistic.

As I understand it, you're using PData to make sure a notification only appears once? That's cool! I'm basically notifying admins over and over again... I should probably fix that!

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Roll the Dice module
« Reply #5 on: March 02, 2015, 10:37:34 am »
I understand it, you're using PData to make sure a notification only appears once? That's cool! I'm basically notifying admins over and over again... I should probably fix that!

I had a feeling that if a message poped up every time, it would become very annoying, in which I had made an option to allow the superadmin to "never see this message again". for themselves. Though, when I update the addon, I change a number, then if there is an update they will get the message once more.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Canne

  • Newbie
  • *
  • Posts: 41
  • Karma: -9
Re: Roll the Dice module
« Reply #6 on: March 03, 2015, 01:11:45 pm »
So how do you make it like others can see what you get because i'm the only one that can see what i get i can't see what other people get out of the dice how you make it like everyone can see who wat get from the dice?

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #7 on: March 03, 2015, 03:01:29 pm »
I had a feeling that if a message poped up every time, it would become very annoying, in which I had made an option to allow the superadmin to "never see this message again". for themselves. Though, when I update the addon, I change a number, then if there is an update they will get the message once more.

That's a great approach! I updated mine and made it a little bit more user-friendly by limiting how many x the message shows. Not the best, but Derma scares me a bit. :c

So how do you make it like others can see what you get because i'm the only one that can see what i get i can't see what other people get out of the dice how you make it like everyone can see who wat get from the dice?

Thanks for reporting that! This issue should be fixed now. Please download the updated version. ^-^

Offline Canne

  • Newbie
  • *
  • Posts: 41
  • Karma: -9
Re: Roll the Dice module
« Reply #8 on: March 04, 2015, 12:06:01 pm »
That's a great approach! I updated mine and made it a little bit more user-friendly by limiting how many x the message shows. Not the best, but Derma scares me a bit. :c

Thanks for reporting that! This issue should be fixed now. Please download the updated version. ^-^


Hey bro i added you on steam mind accepting it i would appreciate it :)

Offline Canne

  • Newbie
  • *
  • Posts: 41
  • Karma: -9
Re: Roll the Dice module
« Reply #9 on: March 05, 2015, 01:44:03 pm »
Also timmy i would like to add more effects where is the site with all the effects that you can put in?

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #10 on: March 05, 2015, 11:18:46 pm »
Accepted ya. Everything you can do is on the Garry's Mod Wiki.

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #11 on: March 23, 2015, 05:25:32 pm »
Hey Timmy! Awesome addon. Lightweight. Unique. And easy to use.

I've been having some issues since the recent GMod update, but I finally got everything running normally (front end wise) and adding this addon definitely made it up to my community for the lack of server uptime. So everyone loves it!

I do have a couple of questions. Is there a way to allow users to choose their rtd (specifically negatives ones). I understand the concept of randomly getting an effect, but I'm curious if we could (a) force an effect upon someone, and (b) allow that user to select their own effects? They obviously wouldnt get the OP options, so it only negatively effects themselves, but I recently gave my members the power to ban themselves and rocket themselves. Some are hesitant to try banning themselves (as you would assume), but the rocket command is great. And being able to add these effects to the list wouldn't be half bad either.
"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 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 #12 on: March 23, 2015, 08:27:28 pm »
Could find MrPresident's old ulx explode release and bring it up to date inside here too.
KABOOM!
Damage bystanders with 1-2 damage just for being nearby.
Muhahaha...!
"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 #13 on: March 24, 2015, 06:23:31 am »
Is there a way to allow users to choose their rtd (specifically negatives ones). I understand the concept of randomly getting an effect, but I'm curious if we could (a) force an effect upon someone, and (b) allow that user to select their own effects? They obviously wouldnt get the OP options, so it only negatively effects themselves, but I recently gave my members the power to ban themselves and rocket themselves. Some are hesitant to try banning themselves (as you would assume), but the rocket command is great. And being able to add these effects to the list wouldn't be half bad either.

I will make all the effects available as ULX commands in the next release.

I feel like if users could select their own effects, that would defeat the purpose of the addon a little though. :)

A rocket effect is already included since I first released this addon. You can add this snippet of code to add 'banning' as an effect. ^-^

Could find MrPresident's old ulx explode release and bring it up to date inside here too.
KABOOM!
Damage bystanders with 1-2 damage just for being nearby.
Muhahaha...!

Ohhh. An explode effect would be very evil! But... the dice is evil. :P
« Last Edit: April 15, 2016, 10:43:09 am by Timmy »

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #14 on: March 25, 2015, 08:38:54 am »
I will make all the effects available as ULX commands in the next release.

I feel like if users could select their own effects, that would defeat the purpose of the addon a little though. :)

A rocket effect is already included since I first released this addon. You can add this snippet of code to add 'banning' as an effect. ^-^

Ohhh. An explode effect would be very evil! But... the dice is evil. :P

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.

UPDATE: Also, is there a way to move the timer configs for all effects in the RTD to the top of the file? I don't mind scrolling down changing values, but for the sake of convenience have a line for each effect and selecting the value at the top of the code. Just a suggestion.
« Last Edit: March 27, 2015, 08:05:45 am by allofmywutsteam »
"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

  • Print