Jump to content

Script no Work


xeon17

Recommended Posts

Posted

When i get in contact with the money pickup , i no get money of player who died. any help please

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(), play 

A unique GangWar gamemode waiting for you!
Click here for more information.

560x95_FFFFFF_FF9900_000000_000000.png

  • Moderators
Posted

Did you check if the script did started and error/warnings?

Did you tried to debug it with outputDebugString() ?

Did you checked all variables values while you output them?

The only thing I see is a cut of event handler:

addEventHandler("onPlayerWasted", getRootElement(),play--... 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

And if you want to attach the onPlayerWasted event to function "playerJustGotDied", just replace "play" with "playerJustGotDied".

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

All is working good , only one thing no.. when player get in contact with the money pickup of the died player he should get his money but that not happen.

When a player die then crate a pickup of money he has before died , when someone get in contact with pickup he get that money

A unique GangWar gamemode waiting for you!
Click here for more information.

560x95_FFFFFF_FF9900_000000_000000.png

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