..:D&G:.. Posted February 14, 2015 Share Posted February 14, 2015 Hello guys, I am making an economy system for my server. I made a coins system which I want to use in shops. For example I want to sell a Burger for $4.50, so I want the player to pay 4 dollars, (takePlayerMoney) and then the number after the decimal (.50) to be takem from the player as 50 coins (takePlayerCoins). I really don't know how to do this , the items from shops are in a table like this: local shops = { -- General [1] = { {"Mask", "A Mask", "$5.25"}, {"Cookies", "A packet of cookies", "$3.53"}, {"Water Bottle", "A bottle of water", "$1.99"}, {"Ice Cream", "A cold Ice Cream", "$3.56"}, {"Coca Cola", "A can of Coca Cola", "$1.10"}, {"Lighter", "A stylish Lighter", "$2.59"}, {"Cigarette", "A Cigarette", "$0.50"}, {"Card Deck", "A Card Deck", "$5.20"} }, } Also, the prices are taken from a row: local itemCost = guiGridListGetItemText(shopItemsList, row, 2):sub(2) Any idea how to do this guys? Thanks. Link to comment
Castillo Posted February 14, 2015 Share Posted February 14, 2015 Split the cost, if it has a decimal ( a dot ), take the first value of the splitted cost as the money to take, and the second as the coins. Example: local cost = 3.25 local splittedCost = split ( tostring ( cost ), "." ) if ( splittedCost ) then outputChatBox ( tostring ( splittedCost [ 1 ] ) ) outputChatBox ( tostring ( splittedCost [ 2 ] ) ) end Link to comment
..:D&G:.. Posted February 15, 2015 Author Share Posted February 15, 2015 It worked Thanks man, I owe you ;D 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