[DMC] Posted October 14, 2010 Share Posted October 14, 2010 function findPlayerByName(playerPart) local pl = getPlayerFromName(playerPart) if isElement(pl) then return pl else for i,v in ipairs (getElementsByType ("player")) do if (string.find(getPlayerName(v),playerPart)) then return v end end end end function n1 (playerSource, command, arg1) if (arg1 == nil ) or arg1 == false then outputChatBox ("ERROR: You must insert a valid player name.", playerSource, 255, 0, 0, false) else local playerElement = findPlayerByName(arg1) if playerElement then local name = getPlayerName(playerElement) local sourceName = getPlayerName(playerElement) outputChatBox (getPlayerName(playerSource).." Says Nice One to "..getPlayerName((playerElement).."!", getRootElement(), 255, 255, 0, true) end end addCommandHandler("n1", n1) I made this with varez findplayerbyname and its saying 23: expected (to close '(' at line 22) near end' so i added 1 end and it didnt work because its still giving this error, can anyone tell me how to fix it Link to comment
12p Posted October 14, 2010 Share Posted October 14, 2010 function findPlayerByName(playerPart) local pl = getPlayerFromName(playerPart) if isElement(pl) then return pl else for i,v in ipairs (getElementsByType ("player")) do if (string.find(getPlayerName(v),playerPart)) then return v end end end end function n1 (playerSource, command, arg1) if (arg1 == nil ) or arg1 == false then outputChatBox ("ERROR: You must insert a valid player name.", playerSource, 255, 0, 0, false) else local playerElement = findPlayerByName(arg1) if playerElement then local name = getPlayerName(playerElement) local sourceName = getPlayerName(playerElement) outputChatBox (getPlayerName(playerSource).." Says Nice One to "..getPlayerName(playerElement).."!", getRootElement(), 255, 255, 0, true) end end addCommandHandler("n1", n1) Just you added an "extra" "(" on getPlayerName ((playerElement) Link to comment
dzek (varez) Posted October 14, 2010 Share Posted October 14, 2010 again - asking for syntax error help is just ridiculous.. Link to comment
[DMC] Posted October 14, 2010 Author Share Posted October 14, 2010 again - asking for syntax error help is just ridiculous.. why? is there a site for this because i searched wiki and i apriciate the help you guys have been giving me, i ones read a tiny bit in a manual somewere but im gonna try to script some scripts i wanted for a long time all by myself this time Link to comment
dzek (varez) Posted October 14, 2010 Share Posted October 14, 2010 because language syntax is very very very important but basic thing you should know. also when you are getting syntax error most times you are getting exact solution how to fix it (something expected on some line) Link to comment
12p Posted October 14, 2010 Share Posted October 14, 2010 And even easier, with MTA Unnoficial Script Editor you can find where are these syntax errors. Link to comment
[DMC] Posted October 15, 2010 Author Share Posted October 15, 2010 And even easier, with MTA Unnoficial Script Editor you can find where are these syntax errors. not working for me (win7) 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