Sign in to follow this  
~Sr.Victor

take player money

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

Share this post


Link to post

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

Share this post


Link to post
11 hours ago, ~Sr.Victor said:

Can you put a delay to give the command?

You have to use setTimer

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.