Jump to content

MTA Deduct Money From Command


Recommended Posts

addCommandHandler( "mend",

function( thePlayer, commandName, who )

if exports.players:isLoggedIn( thePlayer ) then

local inPD, factionID, factionName, factionTag = exports.factions:isPlayerInFactionType( thePlayer, 7 )

if inPD and factionTag then

fixVehicle(getPedOccupiedVehicle(getPlayerFromName(who)))

else

outputChatBox( "(( You are not in a Government faction. ))", thePlayer, 255, 0, 0 )

end

end

end

)

Im abit clueless with money. Id like the player who uses the command to lose 100$ from the command. Please Help

Link to comment
addCommandHandler( "mend", 
function( thePlayer, commandName, who ) 
if exports.players:isLoggedIn( thePlayer ) then 
          local inPD, factionID, factionName, factionTag = exports.factions:isPlayerInFactionType( thePlayer, 7 ) 
          if inPD and factionTag then 
          fixVehicle(getPedOccupiedVehicle(getPlayerFromName(who))) 
          if getPlayerMoney(thePlayer) >= 100 then takePlayerMoney(thePlayer, 100) end 
     else 
          outputChatBox( "(( You are not in a Government faction. ))", thePlayer, 255, 0, 0 ) 
          end 
     end 
end 
) 

Should check if the player has more than $100 or $100 and take it.

Link to comment

You should ensure the player has the cash before fixing the vehicle:

  
addCommandHandler( "mend", 
    function( thePlayer, commandName, who ) 
    if exports.players:isLoggedIn( thePlayer ) then 
        local inPD, factionID, factionName, factionTag = exports.factions:isPlayerInFactionType( thePlayer, 7 ) 
        if inPD and factionTag then 
            if getPlayerMoney(thePlayer) >= 100 then  
                takePlayerMoney(thePlayer, 100) 
                fixVehicle(getPedOccupiedVehicle(getPlayerFromName(who))) 
            else 
                outputChatBox( "(( You don't have enough cash! ))", thePlayer, 255, 0, 0 ) 
            end 
        else 
            outputChatBox( "(( You are not in a Government faction. ))", thePlayer, 255, 0, 0 ) 
        end 
    else 
        outputChatBox( "(( You are not logged in! ))", thePlayer, 255, 0, 0 ) 
    end 
end 
) 
  

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