steadyfi Posted November 10, 2014 Share Posted November 10, 2014 (edited) Hi , i've got a little problem with my set teams script. I use this script to set the team for admins to Admins when they join. I try to use outputChatBox to say hello when a admin joins but I get a error. Script: (server side) --Create teams on resource start function createTeams(source, teamName) staff = createTeam("Admins", 128, 0, 0) end addEventHandler("onResourceStart", getRootElement(), createTeams) --Set admins from ACL to Admin team after logging in function setAdminTeam(thePlayer) local name = getPlayerName(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then --check if admin setPlayerTeam(source, staff) --set team outputChatBox("Greetings "..name.." ! Welcome back.", getRootElement(), 0, 255, 0) --greetings end end addEventHandler("onPlayerLogin", getRootElement(), setAdminTeam) Error: [2014-11-10 22:39:46] WARNING: [race]\[mods]\gc_players\teams.lua:9: Bad argument @ 'getPlayerName' [Expected element at argument 1] [2014-11-10 22:39:46] ERROR: [race]\[mods]\gc_players\teams.lua:12: attempt to concatenate local 'name' (a boolean value) Thanks. Edited November 10, 2014 by Guest Link to comment
Et-win Posted November 10, 2014 Share Posted November 10, 2014 https://wiki.multitheftauto.com/wiki/OnPlayerLogin Link to comment
steadyfi Posted November 10, 2014 Author Share Posted November 10, 2014 https://wiki.multitheftauto.com/wiki/OnPlayerLogin I think I got it. It means I gotta use the getPlayerName(source) inside the outputChatBox and not use it as a local variable, right ? Edit: It worked , thanks ! But how do I make it work with color codes ? Link to comment
Anubhav Posted November 10, 2014 Share Posted November 10, 2014 --Create teams on resource start function createTeams(source, teamName) staff = createTeam("Admins", 128, 0, 0) end addEventHandler("onResourceStart", getRootElement(), createTeams) --Set admins from ACL to Admin team after logging in function setAdminTeam(thePlayer) local name = getPlayerName(source) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then --check if admin setPlayerTeam(source, staff) --set team outputChatBox("#00FF00Greetings #FF0000"..name.." ! Welcome back.", source, 0, 255, 0, true) --greetings end end addEventHandler("onPlayerLogin", getRootElement(), setAdminTeam) Link to comment
steadyfi Posted November 11, 2014 Author Share Posted November 11, 2014 --Create teams on resource start function createTeams(source, teamName) staff = createTeam("Admins", 128, 0, 0) end addEventHandler("onResourceStart", getRootElement(), createTeams) --Set admins from ACL to Admin team after logging in function setAdminTeam(thePlayer) local name = getPlayerName(source) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then --check if admin setPlayerTeam(source, staff) --set team outputChatBox("#00FF00Greetings #FF0000"..name.." ! Welcome back.", source, 0, 255, 0, true) --greetings end end addEventHandler("onPlayerLogin", getRootElement(), setAdminTeam) I mean how do I make it work with name color codes. If a player has a color code show it, but I think it isn't possible. Anyway, I got my answer and I replaced ..name.. with ..getPlayerName(source)... This is the code if anyone needs it: --Create teams on resource start function createTeams(source, teamName) --function staff = createTeam("Admin", 128, 0, 0) --create team end addEventHandler("onResourceStart", getRootElement(), createTeams) --Event triggers createTeams function when the Resource Starts and creates the team --Set admins from ACL to Admin team after logging in function setAdminTeam(thePlayer) --function if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then --check if admin setPlayerTeam(source, staff) --set team outputChatBox("Greetings "..getPlayerName(source).." !", getRootElement(), 0, 255, 0) --greetings (will show player name with color code ex: #000000Test , I can't make it handle color codes) end end addEventHandler("onPlayerLogin", getRootElement(), setAdminTeam) --event handler so when a player joins ACL gives him Admin rights if account is added in admin group and triggers function Link to comment
WASSIm. Posted November 11, 2014 Share Posted November 11, 2014 --Create teams on resource start function createTeams( ) --function staff = createTeam("Admin", 128, 0, 0) --create team end addEventHandler("onResourceStart", getRootElement(), createTeams) --Set admins from ACL to Admin team after logging in function setAdminTeam(_, account) --function if isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("Admin")) then --check if admin setPlayerTeam(source, staff) --set team outputChatBox("Greetings "..getPlayerName(source).." !", root, 0, 255, 0, true) end end addEventHandler("onPlayerLogin", getRootElement(), setAdminTeam) Link to comment
steadyfi Posted November 11, 2014 Author Share Posted November 11, 2014 After a 2 min research on the wiki on the topic outputChatBox I found how to make the name color coded. I was a idiot , sorry. --Create teams on resource start function createTeams(source, teamName) staff = createTeam("Admins", 102, 0, 0) end addEventHandler("onResourceStart", getRootElement(), createTeams) --Set Admin team function setAdminTeam(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then setPlayerTeam(source, staff) local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour local name = getPlayerName ( source ) --get his name outputChatBox("#00FF00Greetings: "..name, getRootElement(), r, g, b, true) end end addEventHandler("onPlayerLogin", getRootElement(), setAdminTeam) #Solved Link to comment
Anubhav Posted November 11, 2014 Share Posted November 11, 2014 After a 2 min research on the wiki on the topic outputChatBox I found how to make the name color coded.I was a idiot , sorry. --Create teams on resource start function createTeams(source, teamName) staff = createTeam("Admins", 102, 0, 0) end addEventHandler("onResourceStart", getRootElement(), createTeams) --Set Admin team function setAdminTeam(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then setPlayerTeam(source, staff) local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour local name = getPlayerName ( source ) --get his name outputChatBox("#00FF00Greetings: "..name, getRootElement(), r, g, b, true) end end addEventHandler("onPlayerLogin", getRootElement(), setAdminTeam) #Solved I told the same thing. Sorry if this is counted as spam. I just told multi-code Link to comment
steadyfi Posted November 11, 2014 Author Share Posted November 11, 2014 After a 2 min research on the wiki on the topic outputChatBox I found how to make the name color coded.I was a idiot , sorry. --Create teams on resource start function createTeams(source, teamName) staff = createTeam("Admins", 102, 0, 0) end addEventHandler("onResourceStart", getRootElement(), createTeams) --Set Admin team function setAdminTeam(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then setPlayerTeam(source, staff) local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour local name = getPlayerName ( source ) --get his name outputChatBox("#00FF00Greetings: "..name, getRootElement(), r, g, b, true) end end addEventHandler("onPlayerLogin", getRootElement(), setAdminTeam) #Solved I told the same thing. Sorry if this is counted as spam. I just told multi-code You send it color coded but getPlayerName does not include color codes from the players name. Sorry if I didn't explain myself right. 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