Jump to content

Dead take Money pickup


SpoC^

Recommended Posts

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); 

Link to comment
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); 

Link to comment
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. :wink:

I do not use this on my server :roll:, and please do not go off topic, if you want to talk to me, just send me a PM

Link to comment

@Banex, is as I expected you do not know anything at all, and also diverts the focus of the subject :lol::lol:

@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) 

Link to comment

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.

Link to comment
@Banex, is as I expected you do not know anything at all, and also diverts the focus of the subject :lol::lol:

@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 :)

Link to comment

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