Jump to content

Bad argument @ 'getAccountName'


Swatrat

Recommended Posts

I tried fixing a script that a friend of mine made for sound command but I'm new in lua and it's kinda hard for me. The script is giving that *Bad argument* and I can't figure it out how to fix.It's saying "Error: sound/gay_s.lua:4: Bad argument @ 'getAccountName' [Expected account at argument 1, got nil]"

local cmd = {} 
function gay(thePlayer) 
end 
if getAccountName(account) == "swatrat" then 
if (isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("Admin"))) and not isTimer(cmd[thePlayer]) then 
triggerClientEvent(getRootElement(), "gay", getRootElement()) 
local name = getPlayerName( thePlayer ) 
outputChatBox (tostring( name )..": #FF00FFHA GAY", getRootElement(), 255, 255, 255, true ) 
cmd[thePlayer] = setTimer(resetcmd,30000,1,thePlayer) 
else 
                    if isTimer(cmd[thePlayer]) then 
                    local remaining,execute = getTimerDetails(cmd[thePlayer]) 
                    outputChatBox("#FF0000[CMD] #ffffffWait "..math.floor(remaining/1000).." seconds.",thePlayer,255,255,255,true) 
                    else 
                    end 
end 
end 
addCommandHandler("gay", gay) 
  
function resetcmd(thePlayer) 
    if isTimer(cmd[thePlayer]) then killTimer(cmd[thePlayer]) end 
    cmd[thePlayer] = nil 
end 

Any help is accepted! :)

Link to comment
local cmd = {} 
function gay(thePlayer) 
end 
local account = getPlayerAccount(source) 
if getAccountName(account) == "swatrat" then 
if (isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("Admin"))) and not isTimer(cmd[thePlayer]) then 
triggerClientEvent(getRootElement(), "gay", getRootElement()) 
local name = getPlayerName( thePlayer ) 
outputChatBox (tostring( name )..": #FF00FFHA GAY", getRootElement(), 255, 255, 255, true ) 
cmd[thePlayer] = setTimer(resetcmd,30000,1,thePlayer) 
else 
                    if isTimer(cmd[thePlayer]) then 
                    local remaining,execute = getTimerDetails(cmd[thePlayer]) 
                    outputChatBox("#FF0000[CMD] #ffffffWait "..math.floor(remaining/1000).." seconds.",thePlayer,255,255,255,true) 
                    else 
                    end 
end 
end 
addCommandHandler("gay", gay) 
  
function resetcmd(thePlayer) 
    if isTimer(cmd[thePlayer]) then killTimer(cmd[thePlayer]) end 
    cmd[thePlayer] = nil 
end 

Link to comment
local cmd = {} 
function gay(thePlayer) 
local account = getPlayerAccount(thePlayer) 
    if getAccountName(account) == "swatrat" then 
        if (isObjectInACLGroup("user." ..getAccountName(account), aclGetGroup("Admin"))) and not isTimer(cmd[thePlayer]) then 
            local name = getPlayerName( thePlayer ) 
            outputChatBox (tostring( name )..": #FF00FFHA GAY", getRootElement(), 255, 255, 255, true ) 
            cmd[thePlayer] = setTimer(resetcmd,30000,1,thePlayer) 
            triggerClientEvent(getRootElement(), "gay", getRootElement()) 
        else 
            if isTimer(cmd[thePlayer]) then 
            local remaining,execute = getTimerDetails(cmd[thePlayer]) 
            outputChatBox("#FF0000[CMD] #ffffffWait "..math.floor(remaining/1000).." seconds.",thePlayer,255,255,255,true) 
            end 
        end 
    end 
end 
addCommandHandler("gay", gay) 
  
function resetcmd(thePlayer) 
    if isTimer(cmd[thePlayer]) then killTimer(cmd[thePlayer]) end 
    cmd[thePlayer] = nil 
end 

Link to comment

Done

local cmd = {} 
  
function gay(thePlayer)  
    if getAccountName(getPlayerAccount(thePlayer)) == "swatrat" then 
        if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin"))) then  
         if not isTimer(cmd[thePlayer]) then 
            local name = getPlayerName( thePlayer ) 
            outputChatBox (tostring( name )..": #FF00FFHA GAY", root, 255, 255, 255, true ) 
            cmd[thePlayer] = setTimer(resetcmd,30000,1,thePlayer) 
            triggerClientEvent(root, "gay", root) 
        else 
            if isTimer(cmd[thePlayer]) then 
                local remaining,execute = getTimerDetails(cmd[thePlayer]) 
                outputChatBox("#FF0000[CMD] #ffffffWait "..math.floor(remaining/1000).." seconds.",thePlayer,255,255,255,true) 
                end 
            end 
        end 
    end  
end 
addCommandHandler("gay", gay) 
  
function resetcmd(thePlayer) 
    if isTimer(cmd[thePlayer]) then  
    killTimer(cmd[thePlayer])  
    end 
    cmd[thePlayer] = nil 
end 

Edit : Sorry didn't see ALw7sH post

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