SpoC^ Posted February 19, 2015 Posted February 19, 2015 I'm with this script, as I do for him not take all my money when I die, instead take only one value (500) of my money 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);
#RooTs Posted February 19, 2015 Posted February 19, 2015 I think you have tried it takePlayerMoney(player, getPlayerMoney(player) -500) most did not solve?
Banex Posted February 19, 2015 Posted February 19, 2015 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 = 500 -- 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);
#RooTs Posted February 19, 2015 Posted February 19, 2015 @Banex defines one time in seconds it to be destroyed the pickup setTimer(function() if (isElement(we)) then destroyElement(we) end end, 10000, 1)
Banex Posted February 19, 2015 Posted February 19, 2015 @Banex defines one time in seconds it to be destroyed the pickup setTimer(function() if (isElement(we)) then destroyElement(we) end end, 10000, 1) About What you are talking about?
#RooTs Posted February 19, 2015 Posted February 19, 2015 About What you are talking about? on your server you have this same script, only that they are never destroyed. and they are scattered all over the map, they just destroyed when someone passes them and capture. sets a time for them to be destroyed.
Banex Posted February 19, 2015 Posted February 19, 2015 About What you are talking about? on your server you have this same script, only that they are never destroyed. and they are scattered all over the map, they just destroyed when someone passes them and capture. sets a time for them to be destroyed. I do not use this on my server , and please do not go off topic, if you want to talk to me, just send me a PM
#RooTs Posted February 19, 2015 Posted February 19, 2015 @Banex, is as I expected you do not know anything at all, and also diverts the focus of the subject @Spoc ^, try this 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 valuemoney = 500 -- value take money local moneyAmmount = valuemoney local time = 15000 -- time in mile seconds moneyAmmount = math.floor(moneyAmmount/1) takePlayerMoney(player, moneyAmmount) moneyAmmount = math.floor(moneyAmmount/3) -- Create the pickups and times local pickup = createPickup(x1, y1, z, 3, 1212) setElementData(pickup, "amount1", math.random( 1, 25 ) ); setTimer(function() if (isElement(pickup)) then destroyElement(pickup) end end, time, 1) 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)
Banex Posted February 19, 2015 Posted February 19, 2015 It's funny, we all know you can not scripting anything. You learned how to use DestroyElement and now wants to show everyone knows how to use it. If he had asked how to destroy the pickup money after a few seconds, I could help you easily. Honestly, you said I do not know anything, but if I had so little knowledge in Lua like you, I would have left the MTA.
SpoC^ Posted February 20, 2015 Author Posted February 20, 2015 I think you have tried it takePlayerMoney(player, getPlayerMoney(player) -500) most did not solve? Yes #Roots I tried to work it out, but did not work
SpoC^ Posted February 20, 2015 Author Posted February 20, 2015 @Banex defines one time in seconds it to be destroyed the pickup setTimer(function() if (isElement(we)) then destroyElement(we) end end, 10000, 1) About What you are talking about? Thank Banex I will complete
SpoC^ Posted February 20, 2015 Author Posted February 20, 2015 @Banex, is as I expected you do not know anything at all, and also diverts the focus of the subject @Spoc ^, try this 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 valuemoney = 500 -- value take money local moneyAmmount = valuemoney local time = 15000 -- time in mile seconds moneyAmmount = math.floor(moneyAmmount/1) takePlayerMoney(player, moneyAmmount) moneyAmmount = math.floor(moneyAmmount/3) -- Create the pickups and times local pickup = createPickup(x1, y1, z, 3, 1212) setElementData(pickup, "amount1", math.random( 1, 25 ) ); setTimer(function() if (isElement(pickup)) then destroyElement(pickup) end end, time, 1) 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) Thanks #Roots Worked perfectly, good job
#RooTs Posted February 20, 2015 Posted February 20, 2015 Thanks #Roots Worked perfectly, good job It's nothing!,
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