Jorgito'Molina Posted March 24, 2013 Share Posted March 24, 2013 function createMoney(player) local x, y, z = getElementPosition(player); local x1, y1, x2, y2; x1 = (x-2)+(math.random()*4); y1 = (y-2)+(math.random()*4); x2 = (x-2)+(math.random()*4); y2 = (y-2)+(math.random()*4); local moneyAmmount = getPlayerMoney(player); -- it is not fair too get all the player money. moneyAmmount = math.floor(moneyAmmount/1); takePlayerMoney(player, moneyAmmount); -- We are going to create 3 pickups, zo we are just cut the ammount in half moneyAmmount = math.floor(moneyAmmount/3); -- Create the pickups setElementData(createPickup(x1, y1, z, 3, 1212), "ammount", moneyAmmount); setElementData(createPickup(x2, y2, z, 3, 1212), "ammount", moneyAmmount); setElementData(createPickup(x2, y2, z, 3, 1212), "ammount", moneyAmmount); end function moneyPickupHit(player) local money = getElementData(source, "ammount"); if money then givePlayerMoney(player, money); destroyElement(source); end end function playerJustGotDied(ammo, attacker, weapon, bodypart) createMoney(source); end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); help money in interior, latter killed Link to comment
MIKI785 Posted March 24, 2013 Share Posted March 24, 2013 I don't understand, what's the problem, what are you trying to achieve? Link to comment
Castillo Posted March 24, 2013 Share Posted March 24, 2013 He wants the pickups to also work on interiors. function createMoney(player) local x, y, z = getElementPosition(player); local x1, y1, x2, y2; local x1 = (x-2)+(math.random()*4); local y1 = (y-2)+(math.random()*4); local x2 = (x-2)+(math.random()*4); local y2 = (y-2)+(math.random()*4); local moneyAmmount = getPlayerMoney(player); -- it is not fair too get all the player money. local moneyAmmount = math.floor(moneyAmmount/1); takePlayerMoney(player, moneyAmmount); -- We are going to create 3 pickups, zo we are just cut the ammount in half local moneyAmmount = math.floor(moneyAmmount/3); local interior = getElementInterior ( player ) local dimension = getElementDimension ( player ) -- Create the pickups local pickups = { createPickup(x1, y1, z, 3, 1212), createPickup(x2, y2, z, 3, 1212), createPickup(x2, y2, z, 3, 1212) } for _, pickup in ipairs ( pickups ) do setElementData ( pickup, "ammount", moneyAmmount ) setElementInterior ( pickup, interior ) setElementDimension ( pickup, dimension ) end end function moneyPickupHit(player) local money = getElementData(source, "ammount"); if money then givePlayerMoney(player, money); destroyElement(source); end end function playerJustGotDied(ammo, attacker, weapon, bodypart) createMoney(source); end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); Link to comment
Jorgito'Molina Posted March 24, 2013 Author Share Posted March 24, 2013 (edited) Who, thanks Solidsnake14 Edited March 24, 2013 by Guest 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