Lergen Posted December 4, 2019 Share Posted December 4, 2019 Hello. I've been attempting to modify the scoreboard so that when a moderator/admin logs in, they're automatically assigned the region/flag of the country specified in the Lua script. addEventHandler("onPlayerLogin", root, function(thePlayer, command) local player_account = getPlayerAccount(thePlayer) if not player_account then return false end local account_name = getAccountName(player_account) if not isObjectInACLGroup("user."..account_name, aclGetGroup("Admin")) and isObjectInACLGroup("user."..account_name, aclGetGroup("Moderator")) then return false end local img = ":admin/client/images/flags/us.png" local country_code = "US" setElementData(thePlayer, "Country", {img, country_code}) return true end ) Unfortunately, I seem to be getting an error on the third line: "Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got account]. Can anyone offer any advice on what's going wrong here? Making it a command handler instead of an event handler seems to work, for some reason, but I need it to be on logon rather than through player command. Link to comment
WorthlessCynomys Posted December 4, 2019 Share Posted December 4, 2019 Hy! If you look at the Wiki page of onPlayerLogin, It shows that this gives you the current and previous account as arguments, meaning you don't have to getPlayerAccount, because you already get It from the event. Command handler works because It provides you a player instead of an account, so you have to get the account. 1 Link to comment
Lergen Posted December 4, 2019 Author Share Posted December 4, 2019 18 hours ago, WorthlessCynomys said: Hy! If you look at the Wiki page of onPlayerLogin, It shows that this gives you the current and previous account as arguments, meaning you don't have to getPlayerAccount, because you already get It from the event. Command handler works because It provides you a player instead of an account, so you have to get the account. Thanks so much for your help! I hate to ask again, but I'm still a bit confused as to where to go from here, as removing those lines still seems to present another error: addEventHandler("onPlayerLogin", root, function(thePlayer, command) local account_name = getAccountName(player_account) if not isObjectInACLGroup("user."..account_name, aclGetGroup("Admin")) and isObjectInACLGroup("user."..account_name, aclGetGroup("Moderator")) then return false end local img = ":admin/client/images/flags/us.png" local country_code = "US" setElementData(thePlayer, "Country", {img, country_code}) return true end ) This now gives me an error on the 4th line: "attempt to concatenate local 'account_name' (a boolean value). Any ideas? Link to comment
Scripting Moderators ds1-e Posted December 5, 2019 Scripting Moderators Share Posted December 5, 2019 4 hours ago, Lergen said: Thanks so much for your help! I hate to ask again, but I'm still a bit confused as to where to go from here, as removing those lines still seems to present another error: addEventHandler("onPlayerLogin", root, function(thePlayer, command) local account_name = getAccountName(player_account) if not isObjectInACLGroup("user."..account_name, aclGetGroup("Admin")) and isObjectInACLGroup("user."..account_name, aclGetGroup("Moderator")) then return false end local img = ":admin/client/images/flags/us.png" local country_code = "US" setElementData(thePlayer, "Country", {img, country_code}) return true end ) This now gives me an error on the 4th line: "attempt to concatenate local 'account_name' (a boolean value). Any ideas? Wrong parameters in function - read carefully - https://wiki.multitheftauto.com/wiki/OnPlayerLogin source is your player who logged in, replace thePlayer with previous_account and command with current_account Then on line 3, you need to pass current_account. Good luck. 1 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