Jump to content

Bad argument @ 'getAccountName'


Swatrat

Recommended Posts

Posted

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! :)

Posted
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 

 

 

Posted

"account" will still be nil in this case. "thePlayer" holds the player element who used the command and source probably doesn't exist.

function be_remove() {

        printf("Too much gaming and too little sleep makes Olle wanna kill...");

        be_remove();

}

Posted
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 

Posted

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

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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