Jump to content

give player random pay


Stevenn

Recommended Posts

Okay so, im trying to do a job, but i need to know can i give a player a random pay, should i use math.random or random from a table?

like

givePlayerMoney(math.random (200, 500)) 

would give the player a random pay from 200-500? and, if i use any of those alternative how can I output it in chatbox like

givePlayerMoney(math.random (200, 500)) 
outputChatBox("well done you have earned" ..what_to_pu_here.. "$") 

Link to comment
local randomMoney = math.random ( 200, 500 ) 
givePlayerMoney ( randomMoney ) 
outputChatBox ( "well done you have earned ".. randomMoney .."$" ) 

Oh, looks like I wasn't that gone after all, now, if I need to give the player a random location every time and then output in chatbox which location they got and create a marker at that

I have absolutely no idea how to do it, and I'd appreciate some help

like (i know this is obviously wrong)

  
outputChatBox("Now depart to" ..location.. "to get your next pay") -- where location will be randomly choosen from a table (x,y,x) and a name attached to it, like 
location = { [jefferson]=x,y,z, [allsaints]=x,y,z 

Link to comment
-- Create a table with coordinates. 
local locations = 
    { 
        { 0, 0, 5 }, 
        { 0, 0, 10 }, 
        { 0, 0, 15 }, 
        { 0, 0, 20 } 
    } 
     
function getRandomLocation ( ) 
    return unpack ( locations [ math.random ( #locations ) ] ) -- Unpack the random location, that'll give us 3 arguments: x, y, z. 
end 

Link to comment

Thank you for the really fast reply, as always.

But, if I'm gonna create a marker at one of those, how would I do that?

outputChatBox ( "my message" ..locations.. "hehe" ) 
mymarker = createMarker (locations, "cylinder", 1.5, 255, 255, 0, 170 ) 
  

I'm probably wrong but.. :)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...