Best-Killer1 Posted September 19, 2015 Share Posted September 19, 2015 [03:48:46] WARNING: SAEGAdministration\aManager\aServer.lua:103: Bad argument @ 'getPlayerAccount' [Expected element at argument 1] [03:48:46] WARNING: SAEGAdministration\aManager\aServer.lua:103: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] [03:48:46] ERROR: SAEGAdministration\aManager\aServer.lua:103: attempt to concatenate a boolean value This Is the Code : function amOpenWindow ( p ) if ( getPlayerStaffLevel ( p, 'string' ) == "Owner" ) then local query = exports.NGSQL:db_query ( "SELECT * FROM accountdata ORDER BY Username" ) local accounts = { valid = { }, invalid = { } } for i, v in ipairs ( query ) do if ( getAccount ( v.Username ) ) then accounts.valid[ tostring ( v.Username ) ] = v else accounts.invalid[ v.Username] = v accounts.invalid[ v.Username].reason = "Account doesn't exist in server database" end end for i, v in ipairs ( getAccounts ( ) ) do local n = getAccountName ( v ) if ( not accounts.valid [n] and not accounts.invalid[n] ) then accounts.invalid[n] = { } accounts.invalid[n].Username = n accounts.invalid[n].reason = "Account doesn't exist in MySQL database" end end triggerClientEvent ( p, "SAEGAdministration:AccountManager:onClientOpenWindow", p, accounts ) end end addCommandHandler ( "am", amOpenWindow ) local removeAccount_ = removeAccount -- remove account addEvent ( "SAEGAdmin:amManager:removeAccountFromHistory", true ) addEventHandler ( "SAEGAdmin:amManager:removeAccountFromHistory", root, function ( account ) for i, v in ipairs ( getElementsByType ( "player" ) ) do if ( getAccountName ( getPlayerAccount ( v ) ) == account ) then return exports.SAEGMessages:sendClientMessage ( "You need to kick "..tostring(getPlayerName(v)).." before you can delete this account.", source, 255, 255, 0 ) end removeAccount(account,source) end end ) function removeAccount ( account, source ) local user = "" if ( isElement ( source ) ) then user = getPlayerName ( source ).." ("..getAccountName(getPlayerAccount(source))..")" else user = "Console (Console)" end exports.NGSQL:db_exec ( "DELETE FROM accountdata WHERE Username=?", account ) exports.NGSQL:db_exec ( "DELETE FROM bank_accounts WHERE Account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM bank_transactions WHERE account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM jobdata WHERE Username=?", account ) exports.NGSQL:db_exec ( "DELETE FROM log_punish WHERE account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM user_shop WHERE seller_account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM vehicles WHERE Owner=?", account ) local acc = getAccount ( account ) if acc then removeAccount_ ( acc ) end exports.SAEGLogs:outputActionLog ( user.." deleted account "..tostring(account) ) if(isElement(source))then amOpenWindow ( source ) end end -- Execute server data saving addEvent ( "SAEGAdmin:aManager:ExecuteServerSave", true ) addEventHandler ( "SAEGAdmin:aManager:ExecuteServerSave", root, function ( ) exports.NGSQL:saveAllData ( true ) exports.SAEGLogs:outputActionLog ( getPlayerName(source).."("..getAccountName(getPlayerAccount(source))..") saved all server data" ) end ) addEvent ( "SAEGAdmin:Module->aManager:OpenPanelFromSource", true ) addEventHandler ( "SAEGAdmin:Module->aManager:OpenPanelFromSource", root, function ( ) amOpenWindow ( source ) end ) -- Ban accounts addEvent ( "SAEGAdmin:Modules->Banner:onAdminBanClient", true ) addEventHandler ( "SAEGAdmin:Modules->Banner:onAdminBanClient", root, function ( acc, day, month, year, reason, days ) local l = getPlayerName(source).." ("..getAccountName(getPlayerAccount(source)).." banned account "..tostring(acc).." for "..tostring(days).." days | reason: "..tostring(reason) outputDebugString ( l ) exports.SAEGLogs:outputServerLog ( l ) exports.SAEGLogs:outputActionLog ( l ) exports.SAEGBans:banAccount ( acc, day, month, year, reason, getPlayerName(source) ) end ) -- update account vip addEvent ( "SAEGAdmin->Modules->aManager->VIPManager->UpdateAccountVIP", true ) addEventHandler ( "SAEGAdmin->Modules->aManager->VIPManager->UpdateAccountVIP", root, function ( account, level, day, month, year ) for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( not isGuestAccount ( a ) and getAccountName ( a ) == account ) then kickPlayer ( v, "Server is giving you VIP... Please reconnect." ) break end end setTimer ( function ( account, level, day, month, year, source ) exports.ngsql:db_exec ( "UPDATE accountdata SET vip=?, vipexp=? WHERE Username=?", tostring ( level ), table.concat({year,month,day},"-"), account ) exports.saeglogs:outputActionLog ( getAccountName(getPlayerAccount(source)).." updated "..tostring(account).." VIP - Level: "..tostring(level).." | Exp. Date: "..table.concat({year,month,day},"-") ) end, 250, 1, account, level, day, month, year, source) end ) Link to comment
UserToDelete Posted September 19, 2015 Share Posted September 19, 2015 [03:48:46] WARNING: SAEGAdministration\aManager\aServer.lua:103: Bad argument @ 'getPlayerAccount' [Expected element at argument 1][03:48:46] WARNING: SAEGAdministration\aManager\aServer.lua:103: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] [03:48:46] ERROR: SAEGAdministration\aManager\aServer.lua:103: attempt to concatenate a boolean value This Is the Code : function amOpenWindow ( p ) if ( getPlayerStaffLevel ( p, 'string' ) == "Owner" ) then local query = exports.NGSQL:db_query ( "SELECT * FROM accountdata ORDER BY Username" ) local accounts = { valid = { }, invalid = { } } for i, v in ipairs ( query ) do if ( getAccount ( v.Username ) ) then accounts.valid[ tostring ( v.Username ) ] = v else accounts.invalid[ v.Username] = v accounts.invalid[ v.Username].reason = "Account doesn't exist in server database" end end for i, v in ipairs ( getAccounts ( ) ) do local n = getAccountName ( v ) if ( not accounts.valid [n] and not accounts.invalid[n] ) then accounts.invalid[n] = { } accounts.invalid[n].Username = n accounts.invalid[n].reason = "Account doesn't exist in MySQL database" end end triggerClientEvent ( p, "SAEGAdministration:AccountManager:onClientOpenWindow", p, accounts ) end end addCommandHandler ( "am", amOpenWindow ) local removeAccount_ = removeAccount -- remove account addEvent ( "SAEGAdmin:amManager:removeAccountFromHistory", true ) addEventHandler ( "SAEGAdmin:amManager:removeAccountFromHistory", root, function ( account ) for i, v in ipairs ( getElementsByType ( "player" ) ) do if ( getAccountName ( getPlayerAccount ( v ) ) == account ) then return exports.SAEGMessages:sendClientMessage ( "You need to kick "..tostring(getPlayerName(v)).." before you can delete this account.", source, 255, 255, 0 ) end removeAccount(account,source) end end ) function removeAccount ( account, source ) local user = "" if ( isElement ( source ) ) then user = getPlayerName ( source ).." ("..getAccountName(getPlayerAccount(source))..")" else user = "Console (Console)" end exports.NGSQL:db_exec ( "DELETE FROM accountdata WHERE Username=?", account ) exports.NGSQL:db_exec ( "DELETE FROM bank_accounts WHERE Account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM bank_transactions WHERE account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM jobdata WHERE Username=?", account ) exports.NGSQL:db_exec ( "DELETE FROM log_punish WHERE account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM user_shop WHERE seller_account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM vehicles WHERE Owner=?", account ) local acc = getAccount ( account ) if acc then removeAccount_ ( acc ) end exports.SAEGLogs:outputActionLog ( user.." deleted account "..tostring(account) ) if(isElement(source))then amOpenWindow ( source ) end end -- Execute server data saving addEvent ( "SAEGAdmin:aManager:ExecuteServerSave", true ) addEventHandler ( "SAEGAdmin:aManager:ExecuteServerSave", root, function ( ) exports.NGSQL:saveAllData ( true ) exports.SAEGLogs:outputActionLog ( getPlayerName(source).."("..getAccountName(getPlayerAccount(source))..") saved all server data" ) end ) addEvent ( "SAEGAdmin:Module->aManager:OpenPanelFromSource", true ) addEventHandler ( "SAEGAdmin:Module->aManager:OpenPanelFromSource", root, function ( ) amOpenWindow ( source ) end ) -- Ban accounts addEvent ( "SAEGAdmin:Modules->Banner:onAdminBanClient", true ) addEventHandler ( "SAEGAdmin:Modules->Banner:onAdminBanClient", root, function ( acc, day, month, year, reason, days ) local l = getPlayerName(source).." ("..getAccountName(getPlayerAccount(source)).." banned account "..tostring(acc).." for "..tostring(days).." days | reason: "..tostring(reason) outputDebugString ( l ) exports.SAEGLogs:outputServerLog ( l ) exports.SAEGLogs:outputActionLog ( l ) exports.SAEGBans:banAccount ( acc, day, month, year, reason, getPlayerName(source) ) end ) -- update account vip addEvent ( "SAEGAdmin->Modules->aManager->VIPManager->UpdateAccountVIP", true ) addEventHandler ( "SAEGAdmin->Modules->aManager->VIPManager->UpdateAccountVIP", root, function ( account, level, day, month, year ) for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( not isGuestAccount ( a ) and getAccountName ( a ) == account ) then kickPlayer ( v, "Server is giving you VIP... Please reconnect." ) break end end setTimer ( function ( account, level, day, month, year, source ) exports.ngsql:db_exec ( "UPDATE accountdata SET vip=?, vipexp=? WHERE Username=?", tostring ( level ), table.concat({year,month,day},"-"), account ) exports.saeglogs:outputActionLog ( getAccountName(getPlayerAccount(source)).." updated "..tostring(account).." VIP - Level: "..tostring(level).." | Exp. Date: "..table.concat({year,month,day},"-") ) end, 250, 1, account, level, day, month, year, source) end ) Because "Source" in triggered functions are not "players" at all function amOpenWindow ( p ) if ( getPlayerStaffLevel ( p, 'string' ) == "Owner" ) then local query = exports.NGSQL:db_query ( "SELECT * FROM accountdata ORDER BY Username" ) local accounts = { valid = { }, invalid = { } } for i, v in ipairs ( query ) do if ( getAccount ( v.Username ) ) then accounts.valid[ tostring ( v.Username ) ] = v else accounts.invalid[ v.Username] = v accounts.invalid[ v.Username].reason = "Account doesn't exist in server database" end end for i, v in ipairs ( getAccounts ( ) ) do local n = getAccountName ( v ) if ( not accounts.valid [n] and not accounts.invalid[n] ) then accounts.invalid[n] = { } accounts.invalid[n].Username = n accounts.invalid[n].reason = "Account doesn't exist in MySQL database" end end triggerClientEvent ( p, "SAEGAdministration:AccountManager:onClientOpenWindow", p, accounts ) end end addCommandHandler ( "am", amOpenWindow ) local removeAccount_ = removeAccount -- remove account addEvent ( "SAEGAdmin:amManager:removeAccountFromHistory", true ) addEventHandler ( "SAEGAdmin:amManager:removeAccountFromHistory", root, function ( account ) for i, v in ipairs ( getElementsByType ( "player" ) ) do if ( getAccountName ( getPlayerAccount ( v ) ) == account ) then return exports.SAEGMessages:sendClientMessage ( "You need to kick "..tostring(getPlayerName(v)).." before you can delete this account.", source, 255, 255, 0 ) end removeAccount(account,source) end end ) function removeAccount ( account, source ) local user = "" if ( isElement ( source ) ) then user = getPlayerName ( source ).." ("..getAccountName(getPlayerAccount(source))..")" else user = "Console (Console)" end exports.NGSQL:db_exec ( "DELETE FROM accountdata WHERE Username=?", account ) exports.NGSQL:db_exec ( "DELETE FROM bank_accounts WHERE Account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM bank_transactions WHERE account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM jobdata WHERE Username=?", account ) exports.NGSQL:db_exec ( "DELETE FROM log_punish WHERE account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM user_shop WHERE seller_account=?", account ) exports.NGSQL:db_exec ( "DELETE FROM vehicles WHERE Owner=?", account ) local acc = getAccount ( account ) if acc then removeAccount_ ( acc ) end exports.SAEGLogs:outputActionLog ( user.." deleted account "..tostring(account) ) if(isElement(source))then amOpenWindow ( source ) end end -- Execute server data saving addEvent ( "SAEGAdmin:aManager:ExecuteServerSave", true ) addEventHandler ( "SAEGAdmin:aManager:ExecuteServerSave", root, function ( ) exports.NGSQL:saveAllData ( true ) exports.SAEGLogs:outputActionLog ( getPlayerName(source).."("..getAccountName(getPlayerAccount(source))..") saved all server data" ) end ) addEvent ( "SAEGAdmin:Module->aManager:OpenPanelFromSource", true ) addEventHandler ( "SAEGAdmin:Module->aManager:OpenPanelFromSource", root, function ( ) amOpenWindow ( source ) end ) -- Ban accounts addEvent ( "SAEGAdmin:Modules->Banner:onAdminBanClient", true ) addEventHandler ( "SAEGAdmin:Modules->Banner:onAdminBanClient", root, function ( acc, day, month, year, reason, days ) local l = getPlayerName(source).." ("..getAccountName(getPlayerAccount(source)).." banned account "..tostring(acc).." for "..tostring(days).." days | reason: "..tostring(reason) outputDebugString ( l ) exports.SAEGLogs:outputServerLog ( l ) exports.SAEGLogs:outputActionLog ( l ) exports.SAEGBans:banAccount ( acc, day, month, year, reason, getPlayerName(source) ) end ) -- update account vip addEvent ( "SAEGAdmin->Modules->aManager->VIPManager->UpdateAccountVIP", true ) addEventHandler ( "SAEGAdmin->Modules->aManager->VIPManager->UpdateAccountVIP", root, function ( account, level, day, month, year ) for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( not isGuestAccount ( a ) and getAccountName ( a ) == account ) then kickPlayer ( v, "Server is giving you VIP... Please reconnect." ) break end end setTimer ( function ( account, level, day, month, year, client ) exports.ngsql:db_exec ( "UPDATE accountdata SET vip=?, vipexp=? WHERE Username=?", tostring ( level ), table.concat({year,month,day},"-"), account ) exports.saeglogs:outputActionLog ( getAccountName(getPlayerAccount(client)).." updated "..tostring(account).." VIP - Level: "..tostring(level).." | Exp. Date: "..table.concat({year,month,day},"-") ) end, 250, 1, account, level, day, month, year, client) end ) Link to comment
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