• 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 #30 on: July 28, 2015, 01:50:01 am »
Because there's quite a few point systems out there, I will not be adding this to the release. With the code you suggested, we'll leave out all the people that don't have the Pointshop addon by burt0n installed. Don't want that. ;_;

Like I said before, I encourage to edit the source of this addon and make it your own. Durations should be pretty easy to change. I prefer to just unstuck the player after the noclip effect finishes. It might indeed be better to kill/teleport the player if unstuck somehow fails, I will look into that.

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Roll the Dice module
« Reply #31 on: July 28, 2015, 02:46:54 pm »
Because there's quite a few point systems out there, I will not be adding this to the release. With the code you suggested, we'll leave out all the people that don't have the Pointshop addon by burt0n installed. Don't want that. ;_;

Like I said before, I encourage to edit the source of this addon and make it your own. Durations should be pretty easy to change. I prefer to just unstuck the player after the noclip effect finishes. It might indeed be better to kill/teleport the player if unstuck somehow fails, I will look into that.
Maybe do a search if the server has adam burtons pointshop installed, and if it's not then it will
Code: Lua
  1. end
the whole thing that takes points from you.

Anyways, I tryed something in your addon and changed some stuff, and added this in:
Code: Lua
  1.         if calling_ply:PS_HasPoints(50) and calling_ply.TRTD_Cooldown-0 and calling_ply:Alive() then
  2.                 calling_ply:PS_TakePoints(50)
  3.                 ULib.tsayError( calling_ply, "50 points have been reducted in exchange for a roll!" )
  4.         elseif calling_ply.TRTD_Cooldown-1 > CurTime() then
  5.         ULib.tsayError(calling_ply, "You have to wait " .. math.Round(calling_ply.TRTD_Cooldown - CurTime()) .. " more seconds before you can Roll the Dice again.")
  6.         else
  7.                 ULib.tsayError( calling_ply, "You do not have enough points!" )
  8.         end
But this doesn't seem to be working, the only thing I want it to do is take points whenever the command is ran, and check if the player is alive, has 50 points, and his cooldown is over, so it won't take the 50 points when the cooldown isn't over yet, but I get the following error:
Code: [Select]
addons/ulx-rtd/lua/ulx/modules/sh/trtd.lua:280: attempt to perform arithmetic on field 'TRTD_Cooldown' (a nil value)
Can you help me a bit out maybe?

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #32 on: July 28, 2015, 08:51:51 pm »
Lua is angry because you're making it do maths with Player.TRTD_Cooldown (the nil value) in your if-statement.
Code: Lua
  1. calling_ply.TRTD_Cooldown - 0

This fails because you try to use this variable before it is defined. You should add your check after that point.

You know a player respected the cooldown when: Player.TRTD_Cooldown < CurTime().

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Roll the Dice module
« Reply #33 on: July 29, 2015, 04:35:13 am »
Lua is angry because you're making it do maths with Player.TRTD_Cooldown (the nil value) in your if-statement.
Code: Lua
  1. calling_ply.TRTD_Cooldown - 0

This fails because you try to use this variable before it is defined. You should add your check after that point.

You know a player respected the cooldown when: Player.TRTD_Cooldown < CurTime().
I really have no idea how your cooldown system works so it checks if there's still a cooldown, or not, but I can't seem to get it to work.

addons/ulx-rtd/lua/ulx/modules/sh/trtd.lua:280: attempt to compare nil with number

*snip*

[EDIT] while making this post I fixed it myself, which was actually really easy to do.
Thanks anyway for the help, I hope to see you find a way to support adams pointshop :)

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #34 on: August 04, 2015, 06:52:39 am »
I have a sprint addon on my server, so I'm guessing its interfering with the faster/slower speed outcomes.

I've tried drastically changing the values in the config but that doesn't seem to help.

Any ideas?
"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 Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #35 on: August 04, 2015, 07:55:19 am »
I have a sprint addon on my server, so I'm guessing its interfering with the faster/slower speed outcomes.

I've tried drastically changing the values in the config but that doesn't seem to help.

Any ideas?

Ahh yes, that would interfere with the dice. Mhm... Open up the ulx-rtd/lua/ulx/modules/sh/trtd.lua file and replace the original code for faster speed and reduced speed with the following:

Code: Lua
  1. TRTD.AddEffect({name="faster speed", duration=20, enable=function(ply)
  2.     ply:SetWalkSpeed(ply:GetWalkSpeed() * 2)
  3.     ply:SetRunSpeed(ply:GetRunSpeed() * 2)
  4. end, disable=function(ply)
  5.     ply:SetWalkSpeed(ply:GetWalkSpeed() / 2)
  6.     ply:SetRunSpeed(ply:GetRunSpeed() / 2)
  7. end})
  8.  
  9. TRTD.AddEffect({name="reduced speed", duration=15, enable=function(ply)
  10.     ply:SetWalkSpeed(ply:GetWalkSpeed() * 0.25)
  11.     ply:SetRunSpeed(ply:GetRunSpeed() * 0.25)
  12. end, disable=function(ply)
  13.     ply:SetWalkSpeed(ply:GetWalkSpeed() * 4)
  14.     ply:SetRunSpeed(ply:GetRunSpeed() * 4)
  15. end})
« Last Edit: August 04, 2015, 08:01:19 am by Timmy »

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: Roll the Dice module
« Reply #36 on: August 04, 2015, 08:16:45 am »
Didn't seem to work.

Again, I tried drastically changing config to see if anything change, and nothing

Code: [Select]
TRTD.AddEffect({name="faster speed", duration=20, enable=function(ply)
    ply:SetWalkSpeed(ply:GetWalkSpeed() * 6)
    ply:SetRunSpeed(ply:GetRunSpeed() * 6)
end, disable=function(ply)
    ply:SetWalkSpeed(ply:GetWalkSpeed() / 6)
    ply:SetRunSpeed(ply:GetRunSpeed() / 6)
end})
 
TRTD.AddEffect({name="reduced speed", duration=15, enable=function(ply)
    ply:SetWalkSpeed(ply:GetWalkSpeed() * 0.10)
    ply:SetRunSpeed(ply:GetRunSpeed() * 0.10)
end, disable=function(ply)
    ply:SetWalkSpeed(ply:GetWalkSpeed() * 10)
    ply:SetRunSpeed(ply:GetRunSpeed() * 10)
end})
"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 Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #37 on: August 04, 2015, 09:01:41 am »
Didn't seem to work.

Again, I tried drastically changing config to see if anything change, and nothing
Nothing happens when the dice tries to modify speeds?

If that's the case, I'm guessing that addon is constantly overriding the walk and runspeeds or something. I'm afraid it would be hard to make these two play together. :/

Offline bobo0044

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
Re: Roll the Dice module
« Reply #38 on: December 06, 2015, 07:11:57 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

Source on GitHub

View the changelog or list of effects.

Thanks!

can someone help remove NOCLIP ? cus when I open the rtd list I cant find noclip but I find everything else?

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #39 on: December 06, 2015, 07:15:52 am »
can someone help remove NOCLIP ? cus when I open the rtd list I cant find noclip but I find everything else?

Delete lines 103-108 in lua/ulx/modules/sh/trtd.lua.

https://github.com/timmyws/ULX-RTD/blob/master/lua/ulx/modules/sh/trtd.lua#L103-L108

Offline bobo0044

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
Re: Roll the Dice module
« Reply #40 on: December 06, 2015, 07:19:18 am »

Offline bobo0044

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
Re: Roll the Dice module
« Reply #41 on: December 06, 2015, 07:39:45 am »

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #42 on: December 06, 2015, 07:43:02 am »
doesn't work I did it but no work
Have you tried restarting your server after you made those changes? :)
« Last Edit: December 06, 2015, 07:50:23 am by Timmy »

Offline bobo0044

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
Re: Roll the Dice module
« Reply #43 on: December 07, 2015, 09:10:50 am »
Have you tried restarting your server after you made those changes? :)

did so

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Roll the Dice module
« Reply #44 on: December 07, 2015, 10:25:58 am »
did so

- Confirm that you removed the noclip effect:
Code: [Select]
TRTD.AddEffect({name="noclip", duration=20, enable=function(ply)
    ply:SetMoveType(MOVETYPE_NOCLIP)
end, disable=function(ply)
    ply:SetMoveType(MOVETYPE_WALK)
    ply:UnTrap()
end})
The code above should be removed from the original file!

- Confirm that the changes were saved correctly.
- Make sure that the server did, in fact, restart.

If you're still having issues after you tried these things, you'll have to show me the contents of your trtd.lua file.

  • Print