Jump to content

[help] trigger


Death

Recommended Posts

hello I need help I am not able to pass the parameter result

follows an excerpt below

result = 0  
setTimer (function ()  
if result <= 25 then  
result = members_in_turf [team] [zone] + result  
triggerClientEvent ("OnTimer" theplayer, result)  
                 outputChatBox ("" .. tonumber (result) .. "") 
end 
  

Edited by Guest
Link to comment

you do not set the timer value after the function has been end (milliseconds,repeat). Try that.

result = 0 
setTimer (function () 
    if result <= 25 then 
        result = members_in_turf [team] [zone] + result 
        triggerClientEvent ("OnTimer" theplayer, result) 
        outputChatBox ("" .. tonumber (result) .. "") 
    end--you forgot 
end,1000,1)--value for set the timer after 'end' 

and I recommend reading: https://wiki.multitheftauto.com/wiki/SetTimer

Link to comment

well this is my full function however when passing the parameter and try recebelo the client file the result is null.

help me

function teste(thePlayer) 
        local gang = getPlayerTeam(thePlayer) 
        local team = getTeamName(gang) 
            local x, y, z = getElementPosition ( thePlayer ); 
            local zona = getZoneName ( x, y, z, false ); 
            resultado = 0 
            setTimer(function() 
            if resultado <= 25 then 
            resultado = members_in_turf[team][zona] + resultado 
            triggerClientEvent("onTimer", thePlayer, resultado) 
                    outputChatBox(""..tonumber(resultado).."") 
                        end 
            end,5000,0) 
end 
  

Link to comment

I think I did not explain right.

I'm having problems when passing a value as a parameter in the trigger,

and receive the value in the client file

below this codes

server--

function teste(thePlayer) 
        local gang = getPlayerTeam(thePlayer) 
        local team = getTeamName(gang) 
            local x, y, z = getElementPosition ( thePlayer ); 
            local zona = getZoneName ( x, y, z, false ); 
            resultado = 0 
            setTimer(function() 
            if resultado <= 25 then 
            resultado = members_in_turf[team][zona] + resultado 
            triggerClientEvent("onTimer", thePlayer, resultado) 
                    outputChatBox(""..tonumber(resultado).."") 
                        end 
            end,5000,0) 
end 

---client

function testee(thePlayer,resultado) 
     
    outputChatBox("Verme ="..tostring(resultado).."") 
    removeEventHandler("onClientRender", root, tempo) 
    addEventHandler("onClientRender", root, tempo) 
  
end 
addEvent("onTimer", true) 
addEventHandler("onTimer", getLocalPlayer(), testee) 

Link to comment
  
triggerClientEvent(thePlayer,"onTimer", thePlayer, resultado) 
  

--Client

  
function testee(resultado) 
    
    outputChatBox("Verme ="..tostring(resultado).."") 
    removeEventHandler("onClientRender", root, tempo) 
    addEventHandler("onClientRender", root, tempo) 
  
end 
addEvent("onTimer", true) 
addEventHandler("onTimer", getLocalPlayer(), testee) 

Read correctly how they work.

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