Jump to content

Elementos creados por un recurso


-Rex-

Recommended Posts

Posted

Quisiera saber, Si se puede obtener todos los elementos que han sido creado por X Script, Por ejemplo con X script hago que se creen X objetos en el Mapa y esos elementos que se crearon con ese Script usarlos para X Cosa.

Y Yo quiero hacer algo que obtenga todos los elementos que fueron creados con ese Script.

Posted

Puedes utilizar getElementsByType.

  
local resourceName = 'GTImaps' 
for k, v in ipairs ( getElementsByType('object', getResourceRootElement(getResourceFromName(resourceName))) ) do 
   if ( k == #getElementsByType('object', getResourceRootElement(getResourceFromName(resourceName))) ) then 
      outputChatBox('El recurso '..resourceName..' ha creado '..tostring(k)..' objetos.') 
   end 
end 
  

Posted
local myTable = {} 
  
function addElementToTable (theElement, theTable) 
        local dataReturn = false 
        if theElement then 
             if isElement(theElement) then 
                   if theTable then 
                         if type(theTable) == "table" then 
                              table.insert(theTable, theElement) 
                              dataReturn = true 
                         end 
                   end 
             end 
        end 
        return dataReturn 
end 

Y eso para que sirve?

Posted
Puedes utilizar getElementsByType.
  
local resourceName = 'GTImaps' 
for k, v in ipairs ( getElementsByType('object', getResourceRootElement(getResourceFromName(resourceName))) ) do 
   if ( k == #getElementsByType('object', getResourceRootElement(getResourceFromName(resourceName))) ) then 
      outputChatBox('El recurso '..resourceName..' ha creado '..tostring(k)..' objetos.') 
   end 
end 
  

Gracias, Intentaré con ese código

Posted

Lol tan simple con un...

La función getElementsByType tiene la opción "startat", en ese caso usamos resourceRoot, el cual nos daría los children siempre y cuando sean del tipo que queremos.

getElementsByType("player/object/etc",resourceRoot) 

Posted
Lol tan simple con un...

La función getElementsByType tiene la opción "startat", en ese caso usamos resourceRoot, el cual nos daría los children siempre y cuando sean del tipo que queremos.

getElementsByType("player/object/etc",resourceRoot) 

No conocia tal argumento :)

Posted

Yo lo hice de esta forma y funciona de forma compartida :P

  
tablaAlmacenamiento = { } 
  
function setData( element, dataName, value ) 
     
    if not tablaAlmacenamiento[element] then 
        tablaAlmacenamiento[element] = { } 
    end 
  
    if not tablaAlmacenamiento[element][dataName] then 
        tablaAlmacenamiento[element][dataName] = value 
        return true 
    else 
        tablaAlmacenamiento[element][dataName] = value 
        return true 
    end 
  
    return false 
  
end 
  

Posted
Hmmm, ¿almacenarlos en una tabla?

¿Y cuando no existan ya? ¿qué?

Es una opción pero bueno, busca la mejor manera.

Las puede guardar en SQL y luego al cargar el recurso lea todos los valores dentro de la db y se las asigne de nuevo a la tabla. Yo tenía un sistema parecido a ese.

  • Recently Browsing   0 members

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