1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Help

Discussion in 'Discussion' started by Ron Tim, Aug 20, 2014.

  1. Ron Tim

    Ron Tim Clockwork Customer

    I am fairly new to LUA and I am trying to make a command that will give the player who typed it a random event to do. Like if they type the command (/pevent is what I made it) It would give them a random event out of a list I made. I tried different things and googled basic LUA tutorials but I cant figure out how to make this. I would post the code, but I have a feeling it is completely wrong, any help is greatly appreciated.
     
  2. Sophia

    Sophia Guest

    Didn't you already make this thread?
     
  3. Lev

    Lev certified honorable guy

  4. trurascalz

    trurascalz C16 Developer Legend

    Code:
    local table = {"event a", "event b", "event c", "event d"}
    
    local random = table.Random(table)
    print(random)
    
    Is the basic stuff.
     
  5. Ron Tim

    Ron Tim Clockwork Customer

    I did that and it said attempt to call field 'Random' < a nil value> ( Yes, I set it up in the command format)
     
  6. duck

    duck Phant0m Legend

    Tru used a bad example. The variable should not be called "table" as it will conflict with the global variable with the same name.
     
  7. Ron Tim

    Ron Tim Clockwork Customer

    Thanks a ton, I changed the variable to table2 and now it works like a charm :D (Thanks tru as well for the original set-up)
     

Previous Readers (Total: 0)