Jump to content

simple problem


[DMC]

Recommended Posts

Posted
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

Posted
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) 

Posted
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 :P

Posted

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)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...