ErF Posted May 18, 2009 Posted May 18, 2009 Hi. It is spoken in the LUA MTA, and I have a problem because I want to write own gamemode - a simple TDM. I have a problem with setPlayerTeam. Code: -- TDM by ErF -- r,g,b = 208,21,73 r2,g2,b2 = 36,26,255 function CreateTeams() local red_team = createTeam("Czerwoni",r,g,b) local blue_team = createTeam("Niebiescy",r2,g2,b2) if(red_team and blue_team) then setTeamName(red_team, "Czerwoni") setTeamName(blue_team, "Niebiescy") setTeamColor(red_team, r,g,b) setTeamColor(blue_team, r2,g2,b2) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), CreateTeams) function Radom_Team( source ) local red_team = getTeamFromName("Czerwoni") local blue_team = getTeamFromName("Niebiescy") local rt_count = countPlayersInTeam(red_team) local bt_count = countPlayersInTeam(blue_team) if rt_count == bt_count then setPlayerTeam(source, "BlueTeam") outputChatBox("Twoja druzyna to: Niebiescy",source,r2,g2,b2) elseif rt_count > bt_count then setPlayerTeam(source, "BlueTeam") outputChatBox("Twoja druzyna to: Niebiescy",source,r2,g2,b2) elseif bt_count > rt_count then setPlayerTeam(source, "RedTeam") outputChatBox("Twoja druzyna to: Czerwoni",source,r,g,b) end end addEventHandler("onPlayerJoin",getRootElement(),Radom_Team) Error: [11:03:58] WARNING: core.lua: Bad argument @ 'setPlayerTeam' - Line: 22 Line 22: setPlayerTeam(source, "BlueTeam") Thanks.
robhol Posted May 18, 2009 Posted May 18, 2009 Teams are elements, not strings. You can't do setPlayerTeam(player, "Nameoftheteamhere"). Instead, you do myTeam = createTeam ( blah blah) setPlayerTeam( aPlayer, myTeam)
ErF Posted May 18, 2009 Author Posted May 18, 2009 I have this: -- TDM by ErF -- r,g,b = 208,21,73 r2,g2,b2 = 36,26,255 red_team = createTeam("Czerwoni",r,g,b) blue_team = createTeam("Niebiescy",r2,g2,b2) function CreateTeams() if(red_team and blue_team) then setTeamName(red_team, "Czerwoni") setTeamName(blue_team, "Niebiescy") setTeamColor(red_team, r,g,b) setTeamColor(blue_team, r2,g2,b2) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), CreateTeams) function Radom_Team( source ) local red_name = getTeamFromName("Czerwoni") local blue_name = getTeamFromName("Niebiescy") local rt_count = countPlayersInTeam(red_name) local bt_count = countPlayersInTeam(blue_name) if rt_count == bt_count then setPlayerTeam(source, blue_team) outputChatBox("Twoja druzyna to: Niebiescy",source,r2,g2,b2) elseif rt_count > bt_count then setPlayerTeam(source, blue_team) outputChatBox("Twoja druzyna to: Niebiescy",source,r2,g2,b2) elseif bt_count > rt_count then setPlayerTeam(source, red_team) outputChatBox("Twoja druzyna to: Czerwoni",source,r,g,b) end end addEventHandler("onPlayerJoin",getRootElement(),Radom_Team) I continue to be a error!
robhol Posted May 18, 2009 Posted May 18, 2009 Try moving the createTeam lines into the handler for onResourceStart.
ErF Posted May 18, 2009 Author Posted May 18, 2009 I did so... and... Errors: [19:00:09] WARNING: core.lua: Bad argument @ 'countPlayersInTeam' - Line: 18 [19:00:09] WARNING: core.lua: Bad argument @ 'countPlayersInTeam' - Line: 19 [19:00:09] WARNING: core.lua: Bad argument @ 'setPlayerTeam' - Line: 22 You can fix it?
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