Jump to content

take player money


~Sr.Victor

Recommended Posts

Hello, I have a script for making weapons. However, if the person has no money, he can manufacture it anyway.

I want that if the person has no money a warning appears in the chat

function progressodeagle(thePlayer)
	if isElementWithinMarker (thePlayer, deagle2) then
	takePlayerMoney(thePlayer, 2500) 
	giveWeapon(thePlayer, 24, 2)
	setPedFrozen(thePlayer, true)
	setPedAnimation(thePlayer, "ped", "bomber", 16000, true, false, false, false)
	setTimer(setPedFrozen, 16000, 1, thePlayer, false)
	setTimer(giveWeapon,16000, 1, thePlayer, 24, 450)
	
	end
end
addCommandHandler("fabricar", progressodeagle)

 

Edited by ~Sr.Victor
Link to comment
  • ~Sr.Victor changed the title to take player money
  • Moderators

You can get player's money with getPlayerMoney.

And this is just a simple IF statement:
 

function progressodeagle(thePlayer)
    if isElementWithinMarker(thePlayer, deagle2) then
    	local currentMoney = getPlayerMoney(thePlayer)
    
        if currentMoney >= 2500 then
            takePlayerMoney(thePlayer, 2500) 
            giveWeapon(thePlayer, 24, 2)
            setPedFrozen(thePlayer, true)
            setPedAnimation(thePlayer, "ped", "bomber", 16000, true, false, false, false)
            setTimer(setPedFrozen, 16000, 1, thePlayer, false)
            setTimer(giveWeapon,16000, 1, thePlayer, 24, 450)
        else
            outputChatBox("You don't have enough money! ($2500)", thePlayer)
        end
    end
end
addCommandHandler("fabricar", progressodeagle)

 

Edited by Patrick
  • Thanks 1
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...