bartje01 Posted November 9, 2010 Share Posted November 9, 2010 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
Castillo Posted November 9, 2010 Share Posted November 9, 2010 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
dzek (varez) Posted November 9, 2010 Share Posted November 9, 2010 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
bartje01 Posted November 9, 2010 Author Share Posted November 9, 2010 With both of the codes if doesn't give me the weapon. the message does work though. This line probaly cause the problem. local aPickup = createPickup (420.14,-2537.42,32.30, 2, 24, 3000, 0 ) The last 0 is the ammo. Link to comment
Castillo Posted November 9, 2010 Share Posted November 9, 2010 try setting 0 to higher? or may be the time of respawn no idea, i don't use much pickups Link to comment
bartje01 Posted November 9, 2010 Author Share Posted November 9, 2010 ye. but if I set the 0 higher people will get 1 ammo without paying Link to comment
Castillo Posted November 9, 2010 Share Posted November 9, 2010 nop, this cancels the event if you don't have the $500. Link to comment
bartje01 Posted November 9, 2010 Author Share Posted November 9, 2010 ah yea I see. It works. Thankyou really muchj guys Link to comment
dzek (varez) Posted November 9, 2010 Share Posted November 9, 2010 that's why you have used giveWeapon.. weird way Link to comment
J.S. Posted November 9, 2010 Share Posted November 9, 2010 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
dzek (varez) Posted November 10, 2010 Share Posted November 10, 2010 i can buy with $499 with this.. result = having $-1 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
bartje01 Posted November 10, 2010 Author Share Posted November 10, 2010 ye varex. I'm using yours now Link to comment
dzek (varez) Posted November 10, 2010 Share Posted November 10, 2010 sry, i didnt see it was J.S. reply, not yours Link to comment
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