Jump to content

Problema con Timer


Destroyer.-

Recommended Posts

Hola, tengo un problema con un timer me tira warnings :/

  
function player_Wasted ( ammo, attacker, weapon, bodypart ) 
 if attacker and getElementType(attacker) == "player" then 
local arrestado = getElementData(source, "arrestado") or 0 
local level = getPlayerWantedLevel(source) 
local acc = getPlayerAccount(source) 
  
      if skins[getElementModel(attacker)] and level > 0  then 
    setElementData(source,"arrestado", arrestado+1) 
    local arresto = setAccountData(acc,"arresto",1) 
    if arresto==0 then return end 
  
                setTimer (fadeCamera, 2000, 1, source, false) 
                setTimer (setCameraTarget, 4000, 1, source, source) 
                setTimer (fadeCamera, 6000, 1, source, true) 
                setTimer (spawnPlayer, 6000, 1,  source, 4076.3999023438, -1788.5, 3.511967, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
  
                outputChatBox ( "Fuiste Arrestado Por "..getPlayerName ( attacker ).." por 50 segundos.", source,255,0,0 ) 
                givePlayerMoney (attacker, 4000)  
                outputChatBox ( "Arrestaste a "..getPlayerName(source), attacker,255,255,0 ) 
                theTimer = setTimer ( function() 
                 
        setElementPosition ( source, 1544.4332275391, -1674.7698974609, 13.688399200439 ) 
    setPlayerWantedLevel ( source,0) 
         
    end, 50000, 1 ) 
  
             
                end 
            end 
        end 
addEventHandler ("onPlayerWasted", getRootElement(), player_Wasted) 
  
  

tira warnings:

  
[2016-01-15 15:06:02] WARNING: PoliciaxD\server.lua:65: Bad argument @ 'setElementPosition' [Expected element at argument 1, got nil] 
[2016-01-15 15:06:02] WARNING: PoliciaxD\server.lua:66: Bad argument @ 'setPlayerWantedLevel' [Expected element at argument 1, got nil] 
  

Espero me puedan ayudar, gracias :/

Link to comment
  
timers = {} -- si usas una simple variable despues de usarla mas de dos veces ya no funcionara usa una tabla. 
function player_Wasted ( ammo, attacker, weapon, bodypart ) 
 if attacker and getElementType(attacker) == "player" then 
local arrestado = getElementData(source, "arrestado") or 0 
local level = getPlayerWantedLevel(source) 
local acc = getPlayerAccount(source) 
  
      if skins[getElementModel(attacker)] and level > 0  then 
    setElementData(source,"arrestado", arrestado+1) 
    local arresto = setAccountData(acc,"arresto",1) 
    if arresto==0 then return end 
  
                setTimer (fadeCamera, 2000, 1, source, false) 
                setTimer (setCameraTarget, 4000, 1, source, source) 
                setTimer (fadeCamera, 6000, 1, source, true) 
                setTimer (spawnPlayer, 6000, 1,  source, 4076.3999023438, -1788.5, 3.511967, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
  
                outputChatBox ( "Fuiste Arrestado Por "..getPlayerName ( attacker ).." por 50 segundos.", source,255,0,0 ) 
                givePlayerMoney (attacker, 4000)  
                outputChatBox ( "Arrestaste a "..getPlayerName(source), attacker,255,255,0 ) 
                timers[source] = setTimer ( function() 
                 
        setElementPosition ( source, 1544.4332275391, -1674.7698974609, 13.688399200439 ) 
    setPlayerWantedLevel ( source,0) 
         
    end, 50000, 1,source ) --agregas El elemento a quien va el timer osea 'source' despues del 3 argumento. 
  
             
                end 
            end 
        end 
addEventHandler ("onPlayerWasted", getRootElement(), player_Wasted) 
  
  

Es por que en server side funciona de forma diferente el setTimer asi que tendras que añadir en los argumentos para que jugador va este timer, hay te deje indicado

Link to comment
  
timers = {} -- si usas una simple variable despues de usarla mas de dos veces ya no funcionara usa una tabla. 
function player_Wasted ( ammo, attacker, weapon, bodypart ) 
 if attacker and getElementType(attacker) == "player" then 
local arrestado = getElementData(source, "arrestado") or 0 
local level = getPlayerWantedLevel(source) 
local acc = getPlayerAccount(source) 
  
      if skins[getElementModel(attacker)] and level > 0  then 
    setElementData(source,"arrestado", arrestado+1) 
    local arresto = setAccountData(acc,"arresto",1) 
    if arresto==0 then return end 
  
                setTimer (fadeCamera, 2000, 1, source, false) 
                setTimer (setCameraTarget, 4000, 1, source, source) 
                setTimer (fadeCamera, 6000, 1, source, true) 
                setTimer (spawnPlayer, 6000, 1,  source, 4076.3999023438, -1788.5, 3.511967, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
  
                outputChatBox ( "Fuiste Arrestado Por "..getPlayerName ( attacker ).." por 50 segundos.", source,255,0,0 ) 
                givePlayerMoney (attacker, 4000)  
                outputChatBox ( "Arrestaste a "..getPlayerName(source), attacker,255,255,0 ) 
                timers[source] = setTimer ( function() 
                 
        setElementPosition ( source, 1544.4332275391, -1674.7698974609, 13.688399200439 ) 
    setPlayerWantedLevel ( source,0) 
         
    end, 50000, 1,source ) --agregas El elemento a quien va el timer osea 'source' despues del 3 argumento. 
  
             
                end 
            end 
        end 
addEventHandler ("onPlayerWasted", getRootElement(), player_Wasted) 
  
  

Es por que en server side funciona de forma diferente el setTimer asi que tendras que añadir en los argumentos para que jugador va este timer, hay te deje indicado

Sigue tirando los mismos errores en los mismos argumentos :S

  
  
function player_Wasted ( ammo, attacker, weapon, bodypart ) 
 if attacker and getElementType(attacker) == "player" then 
local arrestado = getElementData(source, "arrestado") or 0 
local level = getPlayerWantedLevel(source) 
local acc = getPlayerAccount(source) 
  
      if skins[getElementModel(attacker)] and level > 0  then 
    setElementData(source,"arrestado", arrestado+1) 
    local arresto = setAccountData(acc,"arresto",1) 
    if arresto==0 then return end 
  
                setTimer (fadeCamera, 2000, 1, source, false) 
                setTimer (setCameraTarget, 4000, 1, source, source) 
                setTimer (fadeCamera, 6000, 1, source, true) 
                setTimer (spawnPlayer, 6000, 1,  source, 4076.3999023438, -1788.5, 3.511967, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
  
                outputChatBox ( "Fuiste Arrestado Por "..getPlayerName ( attacker ).." por 50 segundos.", source,255,0,0 ) 
                givePlayerMoney (attacker, 4000)  
                outputChatBox ( "Arrestaste a "..getPlayerName(source), attacker,255,255,0 ) 
                 timers[source] = setTimer ( function() 
                 
        setElementPosition ( source, 1544.4332275391, -1674.7698974609, 13.688399200439 ) 
    setPlayerWantedLevel ( source,0) 
         
    end, 50000, 1,source ) 
  
             
                end 
            end 
        end 
addEventHandler ("onPlayerWasted", getRootElement(), player_Wasted) 
  

Link to comment
function player_Wasted ( ammo, attacker, weapon, bodypart ) 
    if attacker and getElementType(attacker) == "player" then 
    local arrestado = getElementData(source, "arrestado") or 0 
    local level = getPlayerWantedLevel(source) 
    local acc = getPlayerAccount(source) 
  
    if skins[getElementModel(attacker)] and level > 0  then 
        setElementData(source,"arrestado", arrestado+1) 
        local arresto = setAccountData(acc,"arresto",1) 
        if arresto==0 then return end 
  
        setTimer (fadeCamera, 2000, 1, source, false) 
        setTimer (setCameraTarget, 4000, 1, source, source) 
        setTimer (fadeCamera, 6000, 1, source, true) 
        setTimer (spawnPlayer, 6000, 1,  source, 4076.3999023438, -1788.5, 3.511967, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
  
        outputChatBox ( "Fuiste Arrestado Por "..getPlayerName ( attacker ).." por 50 segundos.", source,255,0,0 ) 
        givePlayerMoney (attacker, 4000) 
        outputChatBox ( "Arrestaste a "..getPlayerName(source), attacker,255,255,0 ) 
  
            local player = source 
            theTimer = setTimer ( function(p) 
                local p = player 
                while type(p) == "userdata" do -- uso while para hacer un ciclo que me indique si 'p' es un dato de usuario. 
                setElementPosition ( p, 1544.4332275391, -1674.7698974609, 13.688399200439 ) 
                setPlayerWantedLevel ( p,0)  
                p = nil -- retorno la variable 'p' a nula. De otra manera al no hacer esto la función entra en un ciclo infinito. 
            end 
        
            end, 3000, 1 ) 
           
        end 
                 
    end 
end 
addEventHandler ("onPlayerWasted", getRootElement(), player_Wasted) 
  

Link to comment
function player_Wasted ( ammo, attacker, weapon, bodypart ) 
    if attacker and getElementType(attacker) == "player" then 
    local arrestado = getElementData(source, "arrestado") or 0 
    local level = getPlayerWantedLevel(source) 
    local acc = getPlayerAccount(source) 
  
    if skins[getElementModel(attacker)] and level > 0  then 
        setElementData(source,"arrestado", arrestado+1) 
        local arresto = setAccountData(acc,"arresto",1) 
        if arresto==0 then return end 
  
        setTimer (fadeCamera, 2000, 1, source, false) 
        setTimer (setCameraTarget, 4000, 1, source, source) 
        setTimer (fadeCamera, 6000, 1, source, true) 
        setTimer (spawnPlayer, 6000, 1,  source, 4076.3999023438, -1788.5, 3.511967, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
  
        outputChatBox ( "Fuiste Arrestado Por "..getPlayerName ( attacker ).." por 50 segundos.", source,255,0,0 ) 
        givePlayerMoney (attacker, 4000) 
        outputChatBox ( "Arrestaste a "..getPlayerName(source), attacker,255,255,0 ) 
  
            local player = source 
            theTimer = setTimer ( function(p) 
                local p = player 
                while type(p) == "userdata" do -- uso while para hacer un ciclo que me indique si 'p' es un dato de usuario. 
                setElementPosition ( p, 1544.4332275391, -1674.7698974609, 13.688399200439 ) 
                setPlayerWantedLevel ( p,0)  
                p = nil -- retorno la variable 'p' a nula. De otra manera al no hacer esto la función entra en un ciclo infinito. 
            end 
        
            end, 3000, 1 ) 
           
        end 
                 
    end 
end 
addEventHandler ("onPlayerWasted", getRootElement(), player_Wasted) 
  

Funciona de lujo, gracias :wink:

Link to comment
  • Recently Browsing   0 members

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