Jump to content

Help with understand.


nowofresh

Recommended Posts

function callServerFunction(funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do arg[key] = tonumber(value) or value end 
    end 
    loadstring("return "..funcname)()(unpack(arg)) 
end 
addEvent("onClientCallsServerFunction", true) 
addEventHandler("onClientCallsServerFunction", resourceRoot , callServerFunction) 

What do this script ??

Link to comment

ipairs() is for tables where the keys are type 'number', start at 1 and increase by 1 on the next element

the elements don't have to be added to the table in key order

local Table = { 'a', 'b', 'c' } 
  
local Table = { [1]='a', [2]='b', [3]='c' } 
  
local Table = {} 
Table[1] = 'a' 
Table[2] = 'b' 
Table[3] = 'c' 
  
local String = table.concat(Table, " ") 
  
local Table = { unpack(Table) } 
  
for i,v in ipairs(Table) do 
end 

pairs() is for when the above doesn't apply, the keys can be any type lua supports, it will loop around all the elements in the table, but they are in a random order

local Table = { 'key'='a', 'key2'='b', 'key3'='c' } 
  
local Table = {} 
Table['key'] = 'a' 
Table['key2'] = 'b' 
Table['key3'] = 'c' 
  
local Table = {} 
Table[2] = 'a' 
Table[8] = 'b' 
Table[0] = 'c' 
  
for k,v in pairs(Table) do 
end 

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