Jump to content

[AYUDA] setTimer


Javier

Recommended Posts

Posted
No, ipairs se usa para las tablas con index.

Ahora cuando abro mi server con el resource me dice esto constantemente

 ERROR: infection\zombie.lua:65: bad argument #1 to 'pairs' (table expected, got nil) 

Alguna otra ayuda?

Posted

Solidsnake , Ahora si funciona es que lo habia copiado mal. Ahora el problema es que cuando el player muere y respawnea le sigue sumando armadura. alguna ayuda?

Posted
playersTouched = { } 
  
function incremento ( attacker, weapon, bodypart, loss ) 
    if ( attacker and getElementType ( attacker ) == "ped" and getElementData ( attacker, "zombie" ) ) then 
        playersTouched [ source ] = true 
    end 
end 
addEventHandler ( "onPlayerDamage", getRootElement(), incremento ) 
  
setTimer ( 
    function ( ) 
        for player, _ in pairs ( playersTouched ) do 
            setPedArmor ( player, ( getPedArmor ( player ) + 10 ) ) 
        end 
    end 
    ,120000, 0 
) 
  
addEventHandler( "onPlayerWasted", getRootElement( ), 
function() 
        playersTouched [ source ] = false 
end 
) 

Posted
playersTouched = { } 
  
function incremento ( attacker, weapon, bodypart, loss ) 
    if ( attacker and getElementType ( attacker ) == "ped" and getElementData ( attacker, "zombie" ) ) then 
        playersTouched [ source ] = true 
    end 
end 
addEventHandler ( "onPlayerDamage", getRootElement(), incremento ) 
  
setTimer ( 
    function ( ) 
        for player, _ in pairs ( playersTouched ) do 
            setPedArmor ( player, ( getPedArmor ( player ) + 10 ) ) 
        end 
    end 
    ,120000, 0 
) 
  
addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        playersTouched [ source ] = nil 
    end 
) 

El problema de pekio era que no quito al jugador de la tabla, nomas cambio el valor a 'false'.

  • Recently Browsing   0 members

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