Author Topic: Unsure how to make my code a module(+command) for ULX  (Read 6335 times)

0 Members and 1 Guest are viewing this topic.

Offline RandomGamer342

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Unsure how to make my code a module(+command) for ULX
« on: December 17, 2011, 05:09:58 AM »
I've been trying to find out how i do it for a while now, but i havent found a detailed explanation. Sorry if it's already been posted.

Essentially, i need the following  to be a console command that is registered by ULX(in the same way as for example ulx slap)

Help would be really appreciated.

Code: [Select]
--The RTD function itself
function RollTheDice( ply, cmd, args)
    --Because i'm lazy
    local greencolor = Color( 25, 200, 25 )
    local whitecolor = Color( 255, 255, 255 )

    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

There really isn't a lot more than the above, only a failed attempt at making it a command, AddCSLuaFile and a "reset" function for the delay.
« Last Edit: December 17, 2011, 05:21:56 AM by RandomGamer342 »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Unsure how to make my code a module(+command) for ULX
« Reply #1 on: December 17, 2011, 09:45:43 AM »
Re: Module
See http://forums.ulyssesmod.net/index.php/topic,5432.msg24508.html#msg24508
Re: Command
See http://forums.ulyssesmod.net/index.php/topic,4464.0.html

Start and Read those, ask questions from there
See also http://www.ulyssesmod.net/docs for ULib documentation.
ULX has a little documentation, but it's mostly notes/comments within the lua files themselves.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline RandomGamer342

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Unsure how to make my code a module(+command) for ULX
« Reply #2 on: December 19, 2011, 10:46:44 AM »
It doesnt seem to load the script when i put it into modules/sh in the ulx addon

Tried adding a message that should've been printed in regular intervals(when a TTT round starts) yet it doesn't actually do it.

Any tips? Is there anything special i have to do to get it to load the script?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Unsure how to make my code a module(+command) for ULX
« Reply #3 on: December 19, 2011, 02:11:52 PM »
So, its a bit vague to me... you asked in original post about 1) making that function a ULX addon module, and 2) making it (apparently) a ULX command.
I see you added some ULib tsay commands to it ~12/17/2011, but, I see nowhere (at least in your example) an attempt to make it a ULX command.
It won't 'register' as a command without the ULX command setup structure.
And what do you mean intervals? Right now, your code example has nothing that would start it as an interval, and no way for it to start/be run.
As it stands now, it would load in server memory as a function with no way to run it.
Am I missing code?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline RandomGamer342

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Unsure how to make my code a module(+command) for ULX
« Reply #4 on: December 20, 2011, 08:16:33 AM »
Oh, sorry, i forgot to update the script in the OP with the one i tried to make.

Code: [Select]
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 )

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Unsure how to make my code a module(+command) for ULX
« Reply #5 on: December 20, 2011, 08:29:22 AM »
Code: [Select]
if SERVER then
    AddCSLuaFile( "rollthedice.lua" )
end

This bit of code is not needed-- ULX will automatically add the file since you put it in the /modules/sh folder.


Code: [Select]
ulx.addToMenu( ulx.ID_MCLIENT, "Roll The Dice", "ulx rtd" )
Unless I'm mistaken, this line of code is no longer needed now that we're using XGUI. (XGUI gets the registered commands automatically)



And lastly, to test if the script is actually loading, try putting a print statement before the hook.add, and see if you can see the message in your server/client console:
Code: [Select]
print("Is it working!!?/1!?1?1?")
hook.Add( "TTTBeginRound", "ResetRTDPerRound", ResetRTDPerRound )



EDIT: Also, you may need to add this line of code to make sure that everyone has access to your ULX command by default:

Code: [Select]
rtd:defaultAccess( ULib.ACCESS_ALL )

You can always look at our lua files to see examples of how ULX commands work, slap and psay are examples I've been looking at for reference:
http://ulyssesmod.net/ulx/trunk/lua/ulx/modules/sh/chat.lua
http://ulyssesmod.net/ulx/trunk/lua/ulx/modules/sh/fun.lua
« Last Edit: December 20, 2011, 08:34:07 AM by Stickly Man! »
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Unsure how to make my code a module(+command) for ULX
« Reply #6 on: December 20, 2011, 04:43:15 PM »
Code: [Select]
ulx.addToMenu( ulx.ID_MCLIENT, "Roll The Dice", "ulx rtd" )Unless I'm mistaken, this line of code is no longer needed now that we're using XGUI. (XGUI gets the registered commands automatically)

Indeed. That code bit is left over from pre ULX 3.5 days.
Setting up the object with ulx.command, along with the <object>:help sets it in menus, both text/console (ulx help) and in XGUI.

By the way, this is looking quite fun. Good 'first' project for a conversion. Good way to learn Lua, and ULX/ULib structures.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline RandomGamer342

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Unsure how to make my code a module(+command) for ULX
« Reply #7 on: December 21, 2011, 10:39:54 AM »
And lastly, to test if the script is actually loading, try putting a print statement before the hook.add, and see if you can see the message in your server/client console:
Code: [Select]
print("Is it working!!?/1!?1?1?")
hook.Add( "TTTBeginRound", "ResetRTDPerRound", ResetRTDPerRound )

I did that, but it doesn't actually print anything(so it isn't being loaded)

Offline RandomGamer342

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Unsure how to make my code a module(+command) for ULX
« Reply #8 on: January 05, 2012, 10:19:41 AM »
Bump, would there be any reason for the following code not to get loaded as a module when it's in the modules/sh folder?

Code: [Select]
--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." )
rtd:defaultAccess( ULib.ACCESS_ALL )

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 )

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Unsure how to make my code a module(+command) for ULX
« Reply #9 on: January 05, 2012, 02:19:48 PM »
Code: [Select]
--The RTD function itself
function ulx.rollthedice( ply )
    --Because i'm lazy
    local greencolor = Color( 25, 200, 25 )
    local whitecolor = Color( 255, 255, 255 )

    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." )
rtd:defaultAccess( ULib.ACCESS_ALL )

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 )
I believe I got it into a working state.

« Last Edit: January 05, 2012, 02:22:31 PM by Aaron113 »