Jump to content

What event should i use ?


FuriouZ

Recommended Posts

Hello :)

I have question

What event should i use to check player data ?

I think theese are wrong ? I mean, will they lag ?

onClientRender

onClientPreRender

For example i got this function:

  
-- addEventHandler("onClientRender", root, 
addEventHandler("onClientPreRender", root, 
    function() 
        local Arena = getElementData(player,"Arena"); 
        if (Arena == "Stuntage" ) then 
            setPedCanBeKnockedOffBike(localPlayer, false) 
        else             
            setPedCanBeKnockedOffBike(localPlayer, true) 
        end 
    end) 

I found another way setTimer

But i thing it will lag, or not ?

or:

setTimer( 
    function() 
        local Arena = getElementData(player,"Arena"); 
        if (Arena == "Stuntage" ) then 
            setPedCanBeKnockedOffBike(localPlayer, false) 
        else             
            setPedCanBeKnockedOffBike(localPlayer, true) 
        end 
    end,5000,0) 

Wich one will be better ? Or should i use someting else ?

Link to comment
Hello :)

I have question

What event should i use to check player data ?

I think theese are wrong ? I mean, will they lag ?

onClientRender

onClientPreRender

For example i got this function:

  
-- addEventHandler("onClientRender", root, 
addEventHandler("onClientPreRender", root, 
    function() 
        local Arena = getElementData(player,"Arena"); 
        if (Arena == "Stuntage" ) then 
            setPedCanBeKnockedOffBike(localPlayer, false) 
        else             
            setPedCanBeKnockedOffBike(localPlayer, true) 
        end 
    end) 

I found another way setTimer

But i thing it will lag, or not ?

or:

setTimer( 
    function() 
        local Arena = getElementData(player,"Arena"); 
        if (Arena == "Stuntage" ) then 
            setPedCanBeKnockedOffBike(localPlayer, false) 
        else             
            setPedCanBeKnockedOffBike(localPlayer, true) 
        end 
    end,5000,0) 

Wich one will be better ? Or should i use someting else ?

This is very inefficient - You only need to call setPedCanBeKnockedOffBike once.

Link to comment
  • Moderators
This is very inefficient - You only need to call setPedCanBeKnockedOffBike once.

No. Because the player can switch between arenas. So put this code in a function and call it everytime the player choose/select an arena:

function updateCanBeKnockedOffBike() 
    local arena = getElementData(localPlayer, "Arena") 
    if arena == "Stuntage"  then 
        setPedCanBeKnockedOffBike(localPlayer, false) 
    else 
        setPedCanBeKnockedOffBike(localPlayer, true) 
    end 
end 

Has to be on the client side ofc.

Link to comment
  • Moderators
You just repeated what I said.?

Not at all, you wanted him to do this code only once (then with onClientResourceStart) but in fact, he surely want it to be executed as many times the player will select a first/new arena.

Link to comment
This is very inefficient - You only need to call setPedCanBeKnockedOffBike once.

No. Because the player can switch between arenas. So put this code in a function and call it everytime the player choose/select an arena:

function updateCanBeKnockedOffBike() 
    local arena = getElementData(localPlayer, "Arena") 
    if arena == "Stuntage"  then 
        setPedCanBeKnockedOffBike(localPlayer, false) 
    else 
        setPedCanBeKnockedOffBike(localPlayer, true) 
    end 
end 

Has to be on the client side ofc.

Thank you ! :)

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