Jump to content

Math Money


Klesh

Recommended Posts

Posted

Here is my script but i dont know what i have tu put now, only i need when someones win get random money. thanks

  
resourceRoot = getResourceRootElement() 
  
function onPlayerDestructionDerbyWin () 
end 
  
addEventHandler ("onResourceStart", resourceRoot, chooserandom) 
function give () 
  local Player = getPlayerDestructionDerbyWin ( ) 
  randomMoney = math.random ( 1, 1000 ) 
  givePlayerMoney ( randomPlayer, randomMoney ) 
  outputChatBox ( '*' .. getPlayerName ( randomPlayer ) .. ' Has Won $' .. randomMoney .. ' !', getRootElement(), 255, 255, 0 ) 
end 
  

Posted

You can use this way.

  
local money ={} 
money[0] = { "10"} -- amount of money 
money[1] = { "20"} 
money[2] = {"100"} 
  
  
  

Posted
addEventHandler ("onPlayerJoin", getRootElement(), giveRandomMoney) 
function giveRandomMoney () 
  local randomPlayer = getRandomPlayer ( ) 
  randomMoney = math.random ( 1, 1000 ) 
  givePlayerMoney ( randomPlayer, randomMoney ) 
  outputChatBox ( '*' .. getPlayerName ( randomPlayer ) .. ' Has Won $' .. randomMoney .. ' !', getRootElement(), 255, 255, 0 ) 
end 

Just an a example for to give random money on every player who joins.I didn't tested so I'm not completely sure it's correct.

But I think the main base is like that.

Posted

I just gave him an example how it looks like.Because I don't know for what he wants to use 'givePlayerMoney'

EDIT: I have a sense I have written a stupid non-explanatary code.

Posted
I just gave him an example how it looks like.Because I don't know for what he wants to use 'givePlayerMoney'

EDIT: I have a sense I have written a stupid non-explanatary code.

well your code wont work, because giveRandomMoney is nil when you call addEventHandler. :3

Posted (edited)

Could this work maybe :roll:

function giveRandomMoney() 
local randomPlayer = getRandomPlayer() 
local randomMoney = math.random(1,1000) 
givePlayerMoney (randomPlayer, randomMoney) 
outputChatBox("*" ..randomPlayer.. "has won $" ..randomMoney.. "*", getRootElement(), 255,140,0) 
end 
addEventHandler("onResourceStart", getResourceRootElement, giveRandomMoney) 
setTimer(giveRandomMoney, 60000, 0) 

Edited by Guest
Posted

It's not very clear, but I think the TS wants to give a player a random amount of money when he wins a DD/DM.

He should explain himself better

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...