Jump to content

Script fail :S


Eshtiz

Recommended Posts

For some reason, I failed two scripts.

giveallmoney

givemoney

one is for a specific player, one is global.

This is what I did,

I added the 'hiddenadmin' things to it so it hide my admin status if I used it.

Now if I'm on hidden admin duty, I don't receive money ( no one does ) if I use the command, but if I'm not hidden, they / I do.

Here's the giveallmoney function

function giveAllMoney(thePlayer, commandName, money) 
    if (exports.global:isPlayerLeadAdmin(thePlayer)) then 
        if (not money) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Money]", thePlayer, 255, 194, 14) 
      else 
local username = getPlayerName(thePlayer) 
        end 
                local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") 
            if (hiddenAdmin==0) then 
            local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
            exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.") 
            outputChatBox("You have given  $" .. money .. " to all players ", thePlayer) 
            outputChatBox("" .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.", getRootElement(), 255, 255, 255)     
                else 
            outputChatBox("Hidden Admin gave all players online " .. money .. " dollars.", getRootElement(), 255, 255, 255)  
        end 
    end 
end 
addCommandHandler("giveallmoney", giveAllMoney, false, false) 

Here's the givemoney function

function giveMoney(thePlayer, commandName, target, money) 
    if (exports.global:isPlayerLeadAdmin(thePlayer)) then 
        if not (target) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [money]", thePlayer, 255, 194, 14) 
        else 
            local username = getPlayerName(thePlayer) 
            local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target) 
             
            if targetPlayer then 
                                local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") 
            if (hiddenAdmin==0) then 
                        local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
                exports.logs:logMessage("[GIVE] " .. getPlayerName(thePlayer):gsub("_", " ") .. " gave " .. targetPlayerName .. " to $" .. money, 23) 
                exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.") 
                exports.global:giveMoney(targetPlayer, money) 
                outputChatBox("You have given " .. targetPlayerName .. " $" .. money .. ".", thePlayer) 
                outputChatBox("Admin " .. username .. " has given you $" .. money .. ".", targetPlayer) 
                    outputChatBox("" .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.", getRootElement(), 255, 255, 255) 
else 
            outputChatBox("Hidden Admin gave " .. targetPlayerName .. " " .. money .. " dollars.", getRootElement(), 255, 255, 255)  
            end 
                    end 
        end 
    end 
end 
addCommandHandler("givemoney", giveMoney, false, false) 

Would appreciate help, I messed it up somewhere.

Link to comment

-- giveAllMoney function:

function giveAllMoney(thePlayer, commandName, money) 
    if (exports.global:isPlayerLeadAdmin(thePlayer)) then 
        if (not money) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Money]", thePlayer, 255, 194, 14) 
        else 
            local username = getPlayerName(thePlayer) 
            local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") 
            if (hiddenAdmin==0) then 
                local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
                exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.") 
                outputChatBox("" .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.", getRootElement(), 255, 255, 255) 
            else 
                outputChatBox("Hidden Admin gave all players online " .. money .. " dollars.", getRootElement(), 255, 255, 255)  
            end 
            for index, player in ipairs(getElementsByType("player")) do 
                exports.global:giveMoney(player, tonumber(money)) 
            end 
            outputChatBox("You have given  $" .. money .. " to all players ", thePlayer) 
        end 
    end 
end 
addCommandHandler("giveallmoney", giveAllMoney, false, false) 

-- giveMoney function:

function giveMoney(thePlayer, commandName, target, money) 
    if (exports.global:isPlayerLeadAdmin(thePlayer)) then 
        if not (target) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [money]", thePlayer, 255, 194, 14) 
        else 
            local username = getPlayerName(thePlayer) 
            local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target) 
            if targetPlayer then 
                local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") 
                if (hiddenAdmin==0) then 
                    local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
                    exports.logs:logMessage("[GIVE] " .. getPlayerName(thePlayer):gsub("_", " ") .. " gave " .. targetPlayerName .. " to $" .. money, 23) 
                    exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.") 
                    outputChatBox("Admin " .. username .. " has given you $" .. money .. ".", targetPlayer) 
                    outputChatBox("" .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.", getRootElement(), 255, 255, 255) 
                else 
                    outputChatBox("Hidden Admin gave " .. targetPlayerName .. " " .. money .. " dollars.", getRootElement(), 255, 255, 255) 
                end 
                exports.global:giveMoney(targetPlayer, money) 
                outputChatBox("You have given " .. targetPlayerName .. " $" .. money .. ".", thePlayer)             
            end 
        end 
    end 
end 
addCommandHandler("givemoney", giveMoney, false, false) 

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