Oh, sorry, i forgot to update the script in the OP with the one i tried to make.
if SERVER then
AddCSLuaFile( "rollthedice.lua" )
end
--The RTD function itself
function ulx.rollthedice( calling_ply )
--Because i'm lazy
local greencolor = Color( 25, 200, 25 )
local whitecolor = Color( 255, 255, 255 )
local ply = calling_ply
if( ply.NextRTD and ply.NextRTD > CurTime() ) then
ULib.tsayError( ply, false, "You have to wait before rolling the dice again!")
elseif ply:GetPoints() < 25 then
ULib.tsayError( ply, false, "You dont have enough points!" )
elseif ply:IsSpec() then
ULib.tsayError( ply, false, "You can not roll the dice while being a spectator!" )
else
ply.NextRTD = (CurTime + 300)
ply:TakePoints( 25 )
local Choice = math.random(1, 17)
--Make sure that the second number is the same as the highest choice that can happen. Otherwise it will do nothing but steal your points most of the time.
if Choice == 1 then
ply:Kill()
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " was hit by a truck!" )
elseif Choice == 2 then
local HitPoints = math.random(1, 5) * 10
ply:TakeDamage( HitPoints )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " caught a cold and lost "..HitPoints.." health!")
elseif Choice == 3 then
local HitPoints = ply:Health() + 25
ply:SetHealth( HitPoints )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " found a small health vial and got 25 health!")
elseif Choice == 4 then
local HitPoints = ply:Health() + 50
ply:SetHealth( HitPoints )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " found a medkit and got 50 health!")
elseif Choice == 5 then
local HitPoints = ( ply:Health() * 75 ) / 100
ply:TakeDamage( HitPoints )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " was hit by lightning!" )
elseif Choice == 6 then
local HitPoints = ( ply:Health() * 25 ) / 100
ply:TakeDamage( HitPoints )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " was hit by a crowbar!" )
elseif Choice == 7 then
ply:Give( "weapon_ttt_binoculars" )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " found a toilet roll and started using it as a pair of binoculars!" )
elseif Choice == 8 then
ply:GivePoints( 125 )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " won a moderate amount of points!" )
elseif Choice == 9 then
ply:GivePoints( 50 )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " won a small amount of points!" )
elseif Choice == 10 then
ply:GivePoints( 275 )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " won a huge amount of points!" )
elseif Choice == 11 then
ply:TakePoints( 75 )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " lost a moderate amount of points!" )
elseif Choice == 12 then
ply:TakePoints( 25 )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " lost a small amount of points!" )
elseif Choice == 13 then
ply:TakePoints( 225 )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " lost a huge amount of points!" )
elseif Choice == 14 then
ply:StripWeapons()
if not ply:IsSpec() then
ply:Give("weapon_zm_improvised")
ply:Give("weapon_zm_carry")
ply:Give("weapon_ttt_unarmed")
end
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " was robbed by a homeless guy!" )
elseif Choice == 15 then
ply:Ignite( 20, 0 )
if ply:IsSpec() then
ply:Extinguish()
end
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " spontaneously combusted!" )
elseif Choice == 16 then
ply:GodEnable()
timer.Simple( 30, ply:GodDisable, ply )
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " suddenly got Chuck Norris mode for 30 seconds!" )
elseif Choice == 17 then
ply:Lock()
ULib.tsayColor( nil, false, greencolor, ply:Nick(), whitecolor, " was frozen by a cold breeze!" )
timer.Simple( 30, ply:UnLock, ply )
end
end
end
local rtd = ulx.command("Fun", "ulx rtd", ulx.rollthedice, "!rtd" )
rtd:help( "Feeling lucky? Rolling the dice will run a random command on the user." )
ulx.addToMenu( ulx.ID_MCLIENT, "Roll The Dice", "ulx rtd" )
function ResetRTDPerRound()
for k, v in pairs( player.GetAll() ) do
v.NextRTD = nil
end
ULib.tsayError( nil, "DEBUG: Reset RTD delay for everyone." )
end
hook.Add( "TTTBeginRound", "ResetRTDPerRound", ResetRTDPerRound )