^Dev-PoinT^ Posted November 11, 2011 Posted November 11, 2011 Hey i make This how To Make 2 thing 1- outputChatBox To The Player Your are Now in team .. 2- RedTeam Kill Blue Team Onley and Blue Team dont kill Red Team Only function team () teamRed = createTeam ("Red", 255, 0, 0 ) teamBlue = createTeam ("Blue", 0, 0, 255) end addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), team ) function count (thePlayer) local teamRed = getTeamFromName ( "Red" ) local teamBlue = getTeamFromName( "Blue" ) local RedCount = countPlayersInTeam ( teamRed ) local BlueCount = countPlayersInTeam( teamBlue ) if Redcount == Bluecount then setPlayerTeam (thePlayer, teamRed ) elseif Redcount < Bluecount then setPlayerTeam (thePlayer, teamBlue ) else if Redcount < Bluecount then setPlayerTeam (thePlayer,teamRed ) end end addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), count ) just This
Charlie_Jefferson Posted November 11, 2011 Posted November 11, 2011 who is thePlayer ? No idea, . I think that thePlayer is a strange name. It's not specified who thePlayer is either! How strange!
TAPL Posted November 11, 2011 Posted November 11, 2011 1- outputChatBox To The Player Your are Now in team ..2- RedTeam Kill Blue Team Onley you want us script this for you? LoL!
^Dev-PoinT^ Posted November 12, 2011 Author Posted November 12, 2011 idont say script For Me i say how to fix it so i can learn
TAPL Posted November 12, 2011 Posted November 12, 2011 you can learn by yourself and fix it by yourself this what you need, not put a random codes and say fix!
^Dev-PoinT^ Posted November 12, 2011 Author Posted November 12, 2011 TAPL if you are good scripter then iam noob scripter iam new on script we shuold ask for help
Charlie_Jefferson Posted November 12, 2011 Posted November 12, 2011 You've been new to scripting for 1 month. I've learnt lua in 2 days and now I don't really need help from others.
Blaawee Posted November 12, 2011 Posted November 12, 2011 mybe this Work: For #2 function team () teamRed = createTeam ("Red", 255, 0, 0 ) teamBlue = createTeam ("Blue", 0, 0, 255) end addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), team ) function count (thePlayer) local teamRed = getTeamFromName ( "Red" ) local teamBlue = getTeamFromName( "Blue" ) local RedCount = countPlayersInTeam ( teamRed ) local BlueCount = countPlayersInTeam( teamBlue ) if Redcount == Bluecount then setPlayerTeam (thePlayer, teamRed ) elseif Redcount < Bluecount then setPlayerTeam (thePlayer, teamBlue ) else if Redcount > Bluecount then setPlayerTeam (thePlayer,teamRed ) setTeamFriendlyFire ( teamBlue, false ) setTeamFriendlyFire ( teamRed, false ) end end addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), count )
Charlie_Jefferson Posted November 12, 2011 Posted November 12, 2011 For god's sake, don't help him. It's EASY. If you'll keep helping him, he will "script" a whole server. Stop it!
^Dev-PoinT^ Posted November 12, 2011 Author Posted November 12, 2011 its say teams.lua 'end' expected (to close 'if' at line 16 near '' function x () teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), x ) function count (thePlayer) local teamRed = getTeamFromName ( "Red" ) local teamBlue = getTeamFromName( "Blue" ) local RedCount = countPlayersInTeam ( teamRed ) local BlueCount = countPlayersInTeam( teamBlue ) if Redcount == Bluecount then setPlayerTeam (thePlayer, teamRed ) elseif Redcount < Bluecount then setPlayerTeam (thePlayer, teamBlue ) else if Redcount > Bluecount then setPlayerTeam (thePlayer,teamRed ) setTeamFriendlyFire ( teamBlue, false ) setTeamFriendlyFire ( teamRed, false )
Blaawee Posted November 12, 2011 Posted November 12, 2011 function x () teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), x ) function count (thePlayer) local teamRed = getTeamFromName ( "Red" ) local teamBlue = getTeamFromName( "Blue" ) local RedCount = countPlayersInTeam ( teamRed ) local BlueCount = countPlayersInTeam( teamBlue ) if Redcount == Bluecount then setPlayerTeam (thePlayer, teamRed ) elseif Redcount < Bluecount then setPlayerTeam (thePlayer, teamBlue ) elseif Redcount > Bluecount then setPlayerTeam (thePlayer,teamRed ) setTeamFriendlyFire ( teamBlue, false ) setTeamFriendlyFire ( teamRed, false )
unknooooown Posted November 12, 2011 Posted November 12, 2011 (edited) @ ^Dev-PoinT^ I could give you the answer.. But I wont.. But I am gonna tell you this, as a hint: Remember that you should always close, function, if, for. Example: function something() if(something == something)then for i,k in ipairs(something)do --something end elseif(something == somethingElse)then --something else end end If that doesn't help you, then you should really start reading the Wiki from the beginning again. I know that scripting can be hard when you are learning.. ( I started 6 months ago, so I know ) But you also need to learn how to solve problems on your own. Good luck EDIT: Also, as -=I Blaawee I=- said: It should be "elseif" not "else if". I would really recommend that you start reading everything you can on the wiki and the Lua documentation. You have some basic understanding of how scripting for Mta works, but it seems that you have no idea how Lua works. Do some reading and you will get better over time Edited November 12, 2011 by Guest
^Dev-PoinT^ Posted November 12, 2011 Author Posted November 12, 2011 i fix it but its dont set me in any team function createTeamsOnStart () teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) function balanceTeams ( thePlayer ) local RedTeam = getTeamFromName ( "Red" ) local BlueTeam = getTeamFromName ( "Blue" ) local RedCount = countPlayersInTeam ( RedTeam ) local BlueCount = countPlayersInTeam ( BlueTeam ) if RedCount == BlueCount then setPlayerTeam ( thePlayer , RedTeam ) elseif RedCount > BlueCount then setPlayerTeam ( thePlayer , BlueTeam ) elseif RedCount < BlueCount then setPlayerTeam ( thePlayer , RedTeam ) end end
Blaawee Posted November 12, 2011 Posted November 12, 2011 how you will do it , i mean is it a window or what
TAPL Posted November 12, 2011 Posted November 12, 2011 who is thePlayer ? Dev PoinT, this is question for you, you can't answer this?
^Dev-PoinT^ Posted November 12, 2011 Author Posted November 12, 2011 i see this on mta wiki Teams functions its say (thePlayer) i made this and did not work function createTeamsOnStart () teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) function balanceTeams ( source ) local RedTeam = getTeamFromName ( "Red" ) local BlueTeam = getTeamFromName ( "Blue" ) local RedCount = countPlayersInTeam ( RedTeam ) local BlueCount = countPlayersInTeam ( BlueTeam ) local source = getLocalPlayer() if RedCount == BlueCount then setPlayerTeam ( source , RedTeam ) elseif RedCount > BlueCount then setPlayerTeam ( source , BlueTeam ) elseif RedCount < BlueCount then setPlayerTeam ( source , RedTeam ) end end addEventHandler ( "onPlayerJoin", getRootElement(), balanceTeams )
Charlie_Jefferson Posted November 12, 2011 Posted November 12, 2011 function createTeamsOnStart () teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) function balanceTeams ( thePlayer, source ) local RedTeam = getTeamFromName ( "Red" ) local BlueTeam = getTeamFromName ( "Blue" ) local RedCount = countPlayersInTeam ( RedTeam ) local BlueCount = countPlayersInTeam ( BlueTeam ) if not RedCount == BlueCount then if RedCount > BlueCount then setPlayerTeam ( source , teamBlue ) outputChatBox("You've been moved to the blue team!", thePlayer) elseif RedCount < BlueCount then setPlayerTeam ( source , teamRed ) outputChatBox("You've been moved to the red team!", thePlayer) end end addEventHandler ( "onPlayerJoin", getRootElement(), balanceTeams ) This should work. Learn from this. Study what I've changed. You have potential, but your lazy, honestly. Good luck!
^Dev-PoinT^ Posted November 12, 2011 Author Posted November 12, 2011 thx its say 'end' expected(to close 'function' at line 7 near '' function createTeamsOnStart () teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) function balanceTeams ( thePlayer, source ) local RedTeam = getTeamFromName ( "Red" ) local BlueTeam = getTeamFromName ( "Blue" ) local RedCount = countPlayersInTeam ( RedTeam ) local BlueCount = countPlayersInTeam ( BlueTeam ) if not RedCount == BlueCount then if RedCount > BlueCount then setPlayerTeam ( source , teamBlue ) outputChatBox("You've been moved to the blue team!", thePlayer) elseif RedCount < BlueCount then setPlayerTeam ( source , teamRed ) outputChatBox("You've been moved to the red team!", thePlayer) end end addEventHandler ( "onPlayerJoin", getRootElement(), balanceTeams )
Charlie_Jefferson Posted November 12, 2011 Posted November 12, 2011 function createTeamsOnStart () teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) function balanceTeams ( thePlayer, source ) local RedTeam = getTeamFromName ( "Red" ) local BlueTeam = getTeamFromName ( "Blue" ) local RedCount = countPlayersInTeam ( RedTeam ) local BlueCount = countPlayersInTeam ( BlueTeam ) if not RedCount == BlueCount then if RedCount > BlueCount then setPlayerTeam ( source , teamBlue ) outputChatBox("You've been moved to the blue team!", thePlayer) elseif RedCount < BlueCount then setPlayerTeam ( source , teamRed ) outputChatBox("You've been moved to the red team!", thePlayer) end end end addEventHandler ( "onPlayerJoin", getRootElement(), balanceTeams ) Forgot to add an end.
TAPL Posted November 12, 2011 Posted November 12, 2011 open wiki and read just read! is reading difficult? https://wiki.multitheftauto.com/wiki/OnPlayerJoin there are no parameters with event onPlayerJoin so this function balanceTeams ( thePlayer, source ) should be function balanceTeams ()
BinSlayer1 Posted November 12, 2011 Posted November 12, 2011 and outputChatBox should be visible to the source not thePlayer also, never use 'source' as function parameter because source is an internal variable passed from an event that is attached to it and you should never define source yourself; it's what you can call a 'hidden variable'
^Dev-PoinT^ Posted November 12, 2011 Author Posted November 12, 2011 you mean like this ? function createTeamsOnStart () teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) function balanceTeams () local RedTeam = getTeamFromName ( "Red" ) local BlueTeam = getTeamFromName ( "Blue" ) local RedCount = countPlayersInTeam ( RedTeam ) local BlueCount = countPlayersInTeam ( BlueTeam ) if not RedCount == BlueCount then if RedCount > BlueCount then setPlayerTeam ( source , teamBlue ) outputChatBox("You've been moved to the blue team!", source) elseif RedCount < BlueCount then setPlayerTeam ( source , teamRed ) outputChatBox("You've been moved to the red team!", source) end end end addEventHandler ( "onPlayerJoin", getRootElement(), balanceTeams )
12p Posted November 12, 2011 Posted November 12, 2011 Improved code: teamRed = createTeam ( "Red", 255, 0, 0 ) teamBlue = createTeam ( "Blue", 0, 0, 255 ) function balanceTeams ( ) local RedCount = countPlayersInTeam ( teamBlue ) local BlueCount = countPlayersInTeam ( teamRed ) if RedCount ~= BlueCount then if RedCount > BlueCount then setPlayerTeam ( source , teamBlue ) elseif RedCount < BlueCount then setPlayerTeam ( source , teamRed ) end outputChatBox ( "You've been moved to the "..getTeamName ( getPlayerTeam ( source ) ):lower ( ).." team!", source ) end end addEventHandler ( "onPlayerJoin", getRootElement ( ), balanceTeams )
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