Jump to content

getIDFromEventName issue


Chaos

Recommended Posts

hi, i got problem with this code, i'm trying to get ID from event name but it seems not working and every time it gives random number and the event names is containing space any idea?

  
  
addEvent('nextEventVoteResult') 
addEventHandler('nextEventVoteResult', getRootElement(), 
    function(eventName) 
    local eventID = getIDFromEventName(eventName) 
    outputChatBox(eventID,root) 
    end 
) 
  
  
function getIDFromEventName(eventName) 
   for i,v in ipairs(events) do 
       if v.name == eventName then 
         return i 
      end 
   end 
   return false 
end 

Link to comment
I dont think you can do this, you need to define the function first, then use it

like function getIDFromEventName() ...

......

then

addEvent ......

Wrong. It is not like that. The server side script loads and then whenever that event is triggered, that function is already loaded so the function is triggered.

Also, may I see your events table? I guess that is the problem or do you sort the table using table.sort?

Link to comment

Wrong. It is not like that. The server side script loads and then whenever that event is triggered, that function is already loaded so the function is triggered.

Also, may I see your events table? I guess that is the problem or do you sort the table using table.sort?

Thanks for the correction

Link to comment

Wrong. It is not like that. The server side script loads and then whenever that event is triggered, that function is already loaded so the function is triggered.

Also, may I see your events table? I guess that is the problem or do you sort the table using table.sort?

Thanks for the correction

Welcome

Link to comment

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...