Jump to content

Can't see what's actualy wrong


bartje01

Recommended Posts

Hey all.

I'm trying to make a deagle pickup where you need 500$ to pick it up.

I got some information from wiki.

this is what I've got now.

  
local aPickup = createPickup (420.14,-2537.42,32.30, 2, 24, 3000, 0 ) 
  
function pickedUpWeaponCheck ( player ) 
         local money = getElementMoney(source) 
  
        if (money > 499) then 
   outputChatBox ( "You have picked up a Deagle for $500", player ) --Display this message in the chat box 
   giveWeapon ( source, 24, 50 ) 
  
end 
    end 
addEventHandler ( "onPickupHit", aPickup, pickedUpWeaponCheck ) 
  

It has no effect. No message, no deagle.

I really can't see what's wrong.

please help.

Link to comment
local aPickup = createPickup (420.14,-2537.42,32.30, 2, 24, 3000, 0 ) 
  
function pickedUpWeaponCheck ( player ) 
        local money = getPlayerMoney(player) -- is getPlayerMoney not getElementMoney 
        if (money > 499) then 
   outputChatBox ( "You have picked up a Deagle for $500", player ) --Display this message in the chat box 
   giveWeapon ( source, 24, 50 ) 
end 
    end 
addEventHandler ( "onPickupHit", aPickup, pickedUpWeaponCheck ) 

Link to comment

wrong

  
local aPickup = createPickup (420.14,-2537.42,32.30, 2, 24, 3000, 0 ) 
  
function pickedUpWeaponCheck ( player ) 
        local money = getPlayerMoney(player) -- is getPlayerMoney not getElementMoney 
        if (money > 499) then 
   outputChatBox ( "You have picked up a Deagle for $500", player ) --Display this message in the chat box 
   giveWeapon ( player, 24, 50 ) 
end 
    end 
addEventHandler ( "onPickupHit", aPickup, pickedUpWeaponCheck ) 
  

but the coneption is wrong!

this will give you weapon when you pick it up already!

so just cancel availability of picking it up if player have < 500!

and your indentation = randomness!

  
local aPickup = createPickup (420.14,-2537.42,32.30, 2, 24, 3000, 0 ) 
addEventHandler("onPickupHit", aPickup, function(player) 
  local money = getPlayerMoney(player) 
  if (money<500) then cancelEvent() return false end -- cancel pickup picking up (cancelEvent) and stop the function (return false) if player dont have any money 
  -- this will be done when  player have enough money 
  outputChatBox("You have picked up a Deagle for $500", player) 
  takePlayerMoney(player, 500) -- you forgot to take money from player before!! 
  -- no need to give weapon - pickup is already doing this when picked up 
end) 
  

Link to comment

This is what i came up with:

  
local aPickup = createPickup(420.14,-2537.42,32.30,2,24,3000,50) 
  
function pickedUpWeaponCheck(player) 
     local money = getPlayerMoney(player) 
     if money < 499 then 
        takeWeaponAmmo(player, 24, 50) 
         outputChatBox ( "You can not afford this. You need".. 500 - money.. "more to pick this up.", player ) 
     else 
        outputChatBox ( "You picked up a Desert Eagle. It cost you $500.", player ) 
        takePlayerMoney(player, 500) 
    end 
end 
  
addEventHandler ( "onPickupHit", aPickup, pickedUpWeaponCheck ) 
  

Link to comment

i can buy with $499 with this.. result = having $-1 :P

btw: this is weird too.. why can't you just use the most proper way (the one i gave you?) - it's logical - you can't pickup (cancelEvent) if you dont have the money, not "you will get ammo and it will be immediately taken from you if you dont have the money"..

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