vanishSHC Posted November 15, 2010 Share Posted November 15, 2010 Okay so... Heres my schpele, ive been programming LUA for a little bit now, pretty basic nothing too fancy... I am having a problem assigning players to a team (based off a command handler) I have three parts to my script. 1. Obviously the Meta 2. Team.lua On Resource start creates the team 3. Team2.lua - For Purpose of Assigning based off A command Team1LUA Source function createTeamsOnStart () teamHoods = createTeam ( "Hoods", 0, 255, 0 ) teamMedical = createTeam ( "Medical", 255, 0, 0 ) teamPolice = createTeam ( "Police", 0, 0, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) ^works just how i wanted it to... Now for the erroneous script... Heres Team 2 Team2 LUA Source: function assignteamP setPlayerTeam (thePlayer, Police) if teamPolice = getPlayerTeam ( source ) -- get the player's team outputChatBox ( getPlayerName ( source ).."has joined the Police Force" ) else outputChatBox ( getPlayerName ( source ) .. " Was not successfully assigned to Police Force" ) end addCommandHandler ( "Team P", assignteamP ) function assignteamM setPlayerTeam (thePlayer, Medical) if teamMedical = getPlayerTeam ( source ) -- get the player's team outputChatBox ( getPlayerName ( source ).."has joined the sHc Doctors Coalition" ) else outputChatBox (getPlayerName ( source ) .. " Was not successfully assigned to sHc Doctors Coalition" ) end addCommandHandler ( "Team M", assignteamM ) function assignteamH (setPlayerTeam( thePlayer, Hoods) if teamHoods = getPlayerTeam ( source ) -- get the player's team outputChatBox (getPlayerName ( source ).."has joined the Hoodrats Team" ) else outputChatBox (getPlayerName ( source ) .. " Was not successfully assigned to Hoodrats Team" ) end addCommandHandler ("Team H", assignteamH ) function quitteam local theTeam = getPlayerTeam ( source ) if theTeam then setPlayerTeam ( source, nil ) -- remove the player from the current team end addCommandHandler ( "quitteam", quitteam) My Server is outputting that I have an error in team2lua line2 Teams\team2.lua:2: '('expected near 'setPlayerTeam' WARNING: Loading Script failed: Teams\Team2.lua:2: '(' expected near 'setPlayerTeam' start Resource "teams" started Perhaps i'm a bit daft and went about this the entirely wrong way... but i hope you can see what I am trying to do at least haha. Now this is just for an understanding on how to assign teams on server startup based off command handlers and shit like that. However, the real goal is to port this into GUI and not really use the commands (NOT what im trying to accomplish now though)... Thats a stretch when it doesnt quite work based off LUA Obviously I need to revamp my code. haha Any Takers? So... theres my issue heh. I would love for it to work. Link to comment
dzek (varez) Posted November 15, 2010 Share Posted November 15, 2010 Wut? Syntax error? Install anything better than Notepad - it should show you syntax errors (check Stickies on this forum - you can use Notepad++, 50p's Unofficial Script Editor, whatever). Also - syntax errors are telling you WHAT and WHERE something is wrong. -- error: -- '('expected near 'setPlayerTeam' function assignteamM setPlayerTeam (thePlayer, Medical) -- ( is expected before this line, so quick look - oh yea - you forgot the brackets () on function definition line! was it so hard? Link to comment
vanishSHC Posted November 15, 2010 Author Share Posted November 15, 2010 HAHA wow i am blind! thank you dzek I guess it was just confusion seeing as I figured all this code would work (which now it does thanks to you giving me an eye exam). Syntax just threw me off Feel free to close Link to comment
Recommended Posts