Swatrat Posted April 30, 2015 Posted April 30, 2015 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!
Dimos7 Posted April 30, 2015 Posted April 30, 2015 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
Olle Risk Posted April 30, 2015 Posted April 30, 2015 "account" will still be nil in this case. "thePlayer" holds the player element who used the command and source probably doesn't exist.
ALw7sH Posted April 30, 2015 Posted April 30, 2015 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
Walid Posted April 30, 2015 Posted April 30, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now