Jump to content

Money Drop


#Paper

Recommended Posts

Posted
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); 
   moneyAmmount = math.floor(moneyAmmount/2); 
   takePlayerMoney(player, moneyAmmount); 
   moneyAmmount = math.floor(moneyAmmount/2); 
   setElementData(createPickup(x1, y1, 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) 
if (isElement(attacker)) then 
    createMoney(source) 
    end 
end 
addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); 
addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); 

I didn't fully made this script, it was in the forums and I just searched for it for you and fixed some bugs.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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); 
   moneyAmmount = math.floor(moneyAmmount/2); 
   takePlayerMoney(player, moneyAmmount); 
   moneyAmmount = math.floor(moneyAmmount/2); 
   setElementData(createPickup(x1, y1, 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) 
if (isElement(attacker)) then 
    createMoney(source) 
    end 
end 
addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); 
addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); 

I didn't fully made this script, it was in the forums and I just searched for it for you and fixed some bugs.

the money doesn't drop (bad argumnets the setElementData(createPickup...))

and from where i must trigger the moneyPickupHit?

mtaubluascripter.png

My skype: skiper964

I helped you? Help me! ^^

Help me bro! ^^

Posted

Strange, I tested it and worked fine o_O.

P.S: There's a "onPickupUse" event for "moneyPickupHit".

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Strange, I tested it and worked fine o_O.

P.S: There's a "onPickupUse" event for "moneyPickupHit".

I edited a little bit the code, whit "test" cmd the pickup is created but i can't drop it :S

function createMoney(killed) 
   local x, y, z = getElementPosition(killed) 
   local x1, y1, x2, y2 
   x1 = (x-2)+(math.random()*2) 
   y1 = (y-2)+(math.random()*2) 
   x2 = (x-2)+(math.random()*2) 
   y2 = (y-2)+(math.random()*2) 
   local moneyAmmount = getPlayerCount() * 4 
   addStat(getPlayerAccount(killed), "cash", -moneyAmmount) 
   setElementData(createPickup(x1, y1, z, 3, 1212), "ammount", moneyAmmount) 
end 
addCommandHandler("test", createMoney) 
  
function moneyPickupHit(player) 
if isGuestAccount(getPlayerAccount(player)) == false then 
   local money = getElementData(source, "ammount") 
   if money then 
      addStat(getPlayerAccount(player), "cash", money) 
      destroyElement(source) 
   end 
end 
end 
addEventHandler("onPickupUse", getRootElement(), moneyPickupHit) 

mtaubluascripter.png

My skype: skiper964

I helped you? Help me! ^^

Help me bro! ^^

Posted
Strange, I tested it and worked fine o_O.

P.S: There's a "onPickupUse" event for "moneyPickupHit".

I edited a little bit the code, whit "test" cmd the pickup is created but i can't drop it :S

function createMoney(killed) 
   local x, y, z = getElementPosition(killed) 
   local x1, y1, x2, y2 
   x1 = (x-2)+(math.random()*2) 
   y1 = (y-2)+(math.random()*2) 
   x2 = (x-2)+(math.random()*2) 
   y2 = (y-2)+(math.random()*2) 
   local moneyAmmount = getPlayerCount() * 4 
   addStat(getPlayerAccount(killed), "cash", -moneyAmmount) 
   setElementData(createPickup(x1, y1, z, 3, 1212), "ammount", moneyAmmount) 
end 
addCommandHandler("test", createMoney) 
  
function moneyPickupHit(player) 
if isGuestAccount(getPlayerAccount(player)) == false then 
   local money = getElementData(source, "ammount") 
   if money then 
      addStat(getPlayerAccount(player), "cash", money) 
      destroyElement(source) 
   end 
end 
end 
addEventHandler("onPickupUse", getRootElement(), moneyPickupHit) 

P.S: I didn't see the events xD

mtaubluascripter.png

My skype: skiper964

I helped you? Help me! ^^

Help me bro! ^^

Posted

DON'T DOUBLE POST, EVEN WORST FOR SOMETHING LIKE THAT.

What are you trying to achieve?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
DON'T DOUBLE POST, EVEN WORST FOR SOMETHING LIKE THAT.

What are you trying to achieve?

So, when a players die, the server creates the money pickup and when a player get it get the amount of pickup, just this :D

P.S: OMFG T_T sry for double post

mtaubluascripter.png

My skype: skiper964

I helped you? Help me! ^^

Help me bro! ^^

Posted

I tested the code I gave you and works fine.

Note: This will work if someone kills you, not when you die with some command.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Why not just use CreateElement("foo", createPickup(...)) when the player dies?

I don't understand you either... createPickup returns a pickup element already.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Why not just use CreateElement("foo", createPickup(...)) when the player dies?

I don't understand you either... createPickup returns a pickup element already.

Infact, but think that i'll use the classic method of money getting:

function onWasted (killer) 
   givePlayerMoney(killer, 500) 
end 

mtaubluascripter.png

My skype: skiper964

I helped you? Help me! ^^

Help me bro! ^^

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