damien111 Posted August 18, 2012 Share Posted August 18, 2012 Im trying to make a gambling script here is a test i made, it makes the marker but it does not take money then randomly picks a number from a table, then determines if its more than 50. i cant get it to work If anyone can help thanks! SERVER local numbers = { { 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }, { 7 }, { 8 }, { 9 }, { 10 }, { 11 }, { 12 }, { 13 }, { 14 }, { 15 }, { 16 }, { 17 }, { 18 }, { 19 }, { 20 }, { 21 }, { 22 }, { 23 }, { 24 }, { 25 }, { 26 }, { 27 }, { 28 }, { 29 }, { 30 }, { 31 }, { 32 }, { 33 }, { 34 }, { 35 }, { 36 }, { 37 }, { 38 }, { 39 }, { 40 }, { 41 }, { 42 }, { 43 }, { 44 }, { 45 }, { 46 }, { 47 }, { 48 }, { 49 }, { 50 }, { 51 }, { 52 }, { 53 }, { 54 }, { 55 }, { 56 }, { 57 }, { 58 }, { 59 }, { 60 }, { 61 }, { 62 }, { 63 }, { 64 }, { 65 }, { 66 }, { 67 }, { 68 }, { 69 }, { 70 }, { 71 }, { 72 }, { 73 }, { 74 }, { 75 }, { 76 }, { 77 }, { 78 }, { 79 }, { 80 }, { 81 }, { 82 }, { 83 }, { 84 }, { 85 }, { 86 }, { 87 }, { 88 }, { 89 }, { 90 }, { 91 }, { 92 }, { 93 }, { 94 }, { 95 }, { 96 }, { 97 }, { 98 }, { 99 }, { 100 }, } function getRandomCoordinates ( ) return unpack (numbers [ math.random ( #numbers ) ] ) end number = getRandomCoordinates ( ) gambling = createMarker ( 2226.3559570313, 1838.3266601563, 10.8203125, "checkpoint", 2.0, 0, 255, 255, 255 ) function startgamble ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then takePlayerMoney ( source, 5000 ) triggerClientEvent ( "takeMoney", localPlayer ) if number < 50 then triggerClientEvent ( "giveMoney", localPlayer ) givePlayerMoney ( source , 10000 ) else triggerClientEvent ( "looseMoney", localPlayer ) end end end addEventHandler ( "onMarkerHit", gambling, startgamble ) CLIENT function greetingHandler ( message ) outputChatBox ( "You have bet 5000") end addEvent( "takeMoney", true ) addEventHandler( "takeMoney", getRootElement ) function greetingHandler ( message ) outputChatBox ( "You have won 10000") end addEvent( "giveMoney", true ) addEventHandler( "giveMoney", getRootElement ) function greetingHandler ( message ) outputChatBox ( "You lose 5000") end addEvent( "looseMoney", true ) addEventHandler( "looseMoney", getRootElement ) Meta <meta> <info author="Curt" version="3.0" type="script" name="Delivery Boyg Job" description="I just made a small medic job, just a gui for the job with marker" /> <script src = "script.lua" type = "server" /> <script src = "client.lua" type = "client" /> </meta> Link to comment
Cadu12 Posted August 18, 2012 Share Posted August 18, 2012 Why not use: math.random(100) ? Link to comment
sockz Posted August 18, 2012 Share Posted August 18, 2012 so many misstakes. Re-read your code. Link to comment
DNL291 Posted August 18, 2012 Share Posted August 18, 2012 As Cadu12 said, use math.random(). if you want to get a random number, of course. Link to comment
Guest Guest4401 Posted August 18, 2012 Share Posted August 18, 2012 local gambling = createMarker ( 2226.3559570313, 1838.3266601563, 10.8203125, "checkpoint", 2.0, 0, 255, 255, 255 ) addEventHandler("onMarkerHit",gambling, function(player) if getElementType(player) == "player" then if getPlayerMoney(player) >= 5000 then if math.random() < 1/2 then outputChatBox ("You have won 5000$.",player) givePlayerMoney(player,5000) else outputChatBox ("You have lost 5000$.",player) takePlayerMoney(player,5000) end else outputChatBox("You do not have enough money.",player) end end end ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now