Jump to content

Add command handler - help


ReGo

Recommended Posts

[center]function collectMoney(thePlayer, shopElement) 
    local pedName = getPedName(shopElement) 
    local playerName = getPlayerName(thePlayer):gsub("_", " ") 
    local sPendingWage = tonumber(getElementData(shopElement, "sPendingWage")) 
    local sIncome = tonumber(getElementData(shopElement, "sIncome")) 
    local profit = sIncome - sPendingWage 
    if profit >= 0 then 
        if sIncome > 0 then 
            if exports.global:giveMoney(thePlayer, sIncome) then 
                setTimer(function () 
                    exports.global:sendLocalText(thePlayer, "* "..pedName.." gives "..playerName.." a couple of dollar notes and a jar of coins.", 255, 51, 102, 30, {}, true) 
                    storeKeeperSay(thePlayer, "This is what we've got so far, boss. Keep it please.", pedName) 
                    setElementData(shopElement, "sIncome", 0, true) 
                    mysql:query_free("UPDATE `shops` SET `sIncome`='0' WHERE id='"..tostring(getElementData(shopElement, "dbid")).."' ") 
                    playCollectMoneySound(shopElement) 
                    --triggerClientEvent(thePlayer, "shop:toggleGuiElement:bCollectProfit", thePlayer, false, shopElement) 
                    return true 
                end, 3000, 1) 
            end 
        end 
         
        if sPendingWage > 0 then 
            if not solvePendingWage(thePlayer, shopElement) then 
                --triggerClientEvent(thePlayer, "shop:toggleGuiElement:bCollectProfit", thePlayer, true, shopElement) 
                return false 
            end 
        end 
    else 
        if sPendingWage > 0 then 
            if not solvePendingWage(thePlayer, shopElement) then 
                --triggerClientEvent(thePlayer, "shop:toggleGuiElement:bCollectProfit", thePlayer, true, shopElement) 
                return false 
            end 
        end 
         
        if sIncome > 0 then 
            if exports.global:giveMoney(thePlayer, sIncome) then 
                setTimer(function () 
                    exports.global:sendLocalText(thePlayer, "* "..pedName.." gives "..playerName.." a couple of dollar notes and a jar of coins.", 255, 51, 102, 30, {}, true) 
                    storeKeeperSay(thePlayer, "This is what we've got so far, boss. Keep it please.", pedName) 
                    setElementData(shopElement, "sIncome", 0, true) 
                    mysql:query_free("UPDATE `shops` SET `sIncome`='0' WHERE id='"..tostring(getElementData(shopElement, "dbid")).."' ") 
                    playCollectMoneySound(shopElement) 
                    --triggerClientEvent(thePlayer, "shop:toggleGuiElement:bCollectProfit", thePlayer, false, shopElement) 
                    return true 
                end, 3000, 1) 
            end 
        end 
    end 
    return false 
end 
addEvent("shop:collectMoney", true ) 
addEventHandler("shop:collectMoney", getRootElement(), collectMoney)[/center]
 

Please add command '/collectmoney' help me please

Link to comment
    function collectMoney(thePlayer, shopElement) 
        local pedName = getPedName(shopElement) 
        local playerName = getPlayerName(thePlayer):gsub("_", " ") 
        local sPendingWage = tonumber(getElementData(shopElement, "sPendingWage")) 
        local sIncome = tonumber(getElementData(shopElement, "sIncome")) 
        local profit = sIncome - sPendingWage 
        if profit >= 0 then 
            if sIncome > 0 then 
                if exports.global:giveMoney(thePlayer, sIncome) then 
                    setTimer(function () 
                        exports.global:sendLocalText(thePlayer, "* "..pedName.." gives "..playerName.." a couple of dollar notes and a jar of coins.", 255, 51, 102, 30, {}, true) 
                        storeKeeperSay(thePlayer, "This is what we've got so far, boss. Keep it please.", pedName) 
                        setElementData(shopElement, "sIncome", 0, true) 
                        mysql:query_free("UPDATE `shops` SET `sIncome`='0' WHERE id='"..tostring(getElementData(shopElement, "dbid")).."' ") 
                        playCollectMoneySound(shopElement) 
                        --triggerClientEvent(thePlayer, "shop:toggleGuiElement:bCollectProfit", thePlayer, false, shopElement) 
                        return true 
                    end, 3000, 1) 
                end 
            end 
            
            if sPendingWage > 0 then 
                if not solvePendingWage(thePlayer, shopElement) then 
                    --triggerClientEvent(thePlayer, "shop:toggleGuiElement:bCollectProfit", thePlayer, true, shopElement) 
                    return false 
                end 
            end 
        else 
            if sPendingWage > 0 then 
                if not solvePendingWage(thePlayer, shopElement) then 
                    --triggerClientEvent(thePlayer, "shop:toggleGuiElement:bCollectProfit", thePlayer, true, shopElement) 
                    return false 
                end 
            end 
            
            if sIncome > 0 then 
                if exports.global:giveMoney(thePlayer, sIncome) then 
                    setTimer(function () 
                        exports.global:sendLocalText(thePlayer, "* "..pedName.." gives "..playerName.." a couple of dollar notes and a jar of coins.", 255, 51, 102, 30, {}, true) 
                        storeKeeperSay(thePlayer, "This is what we've got so far, boss. Keep it please.", pedName) 
                        setElementData(shopElement, "sIncome", 0, true) 
                        mysql:query_free("UPDATE `shops` SET `sIncome`='0' WHERE id='"..tostring(getElementData(shopElement, "dbid")).."' ") 
                        playCollectMoneySound(shopElement) 
                        --triggerClientEvent(thePlayer, "shop:toggleGuiElement:bCollectProfit", thePlayer, false, shopElement) 
                        return true 
                    end, 3000, 1) 
                end 
            end 
        end 
        return false 
    end 
    addCommandHandler("collectmoney",collectMoney) 

addCommandHandler("collectmoney",collectMoney) 

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