Jump to content

Timer


-.Paradox.-

Recommended Posts

Posted

Hello i want draw +1500 text every time a zombie get killed, and disappear after 3 seconds thanks for help.

addEvent( "onZombieWasted" ); 
addEventHandler( "onZombieWasted", getRootElement(), 
       function( killer ) 
           givePlayerMoney( killer, 1500 ); 
       end 
) 
  
addEventHandler("onZombieWasted", getRootElement(), 
function () 
        dxDrawText("+1500", 1211, 51, 1351, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
  
        dxDrawText("+1500", 1211, 49, 1351, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
  
        dxDrawText("+1500", 1209, 51, 1349, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
  
        dxDrawText("+1500", 1209, 49, 1349, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
  
        dxDrawText("+1500", 1210, 50, 1350, 76, tocolor(0, 100, 35, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
  
end 
) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

I know but i dont want use it

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Then you have to create an "onClientRender" event handler every time you want to display your text, and then create a timer to destroy the handler after 3 seconds.

Posted

not onClientRender because I want when zombie wasted, I guess I have to remove event handler after 3 secs after each kill

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

That's exactly what I said. You need to add event handler when a zombie gets killed, and then create a timer to remove that event handler. The dx functions are displayed only for one frame, that's why you have to display them "onClientRender".

Posted

Like that? I made this code in my iPhone but idk what I must put to show the text only when zombie get killed thanks for help

  
function onTest() 
dxDrawText("+1500", 1211, 51, 1351, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false)  
dxDrawText("+1500", 1211, 49, 1351, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false)  
dxDrawText("+1500", 1209, 51, 1349, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false)  
dxDrawText("+1500", 1209, 49, 1349, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false)  
dxDrawText("+1500", 1210, 50, 1350, 76, tocolor(0, 100, 35, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
end 
addEventHandler("onClientRender", getRootElement, onTest) 
  
setTimer( 
function () 
removeEventHandler("onClientRender", getRootElement, onTest) 
end 
, 3000, 1 
) 
  

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Yeah, just like that, except you have to do

addEventHandler("onClientRender", root, onTest) 
setTimer(removeEventHandler, 3000, 1, "onClientRender", root, onTest) 

whenever a zombie gets killed. So the proper code should look like this:

function onTest() 
dxDrawText("+1500", 1211, 51, 1351, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
dxDrawText("+1500", 1211, 49, 1351, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
dxDrawText("+1500", 1209, 51, 1349, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
dxDrawText("+1500", 1209, 49, 1349, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
dxDrawText("+1500", 1210, 50, 1350, 76, tocolor(0, 100, 35, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
end 
  
addEvent( "onZombieWasted" ); 
addEventHandler( "onZombieWasted", root, 
function( killer ) 
        givePlayerMoney( killer, 1500 ); 
        addEventHandler("onClientRender", root, onTest) 
        setTimer(removeEventHandler, 3000, 1, "onClientRender", root, onTest) 
end) 
  

You are probably still going to tweak this a bit, so it behaves properly when two zombies get killed in a period shorter than three seconds.

Posted

Not working :/

Error: Money/script.lua:14 Bad argument @ 'RemoveEventHandler' [Expected function at argument 3, got nil]

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
function onTest() 
dxDrawText("+1500", 1211, 51, 1351, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
dxDrawText("+1500", 1211, 49, 1351, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
dxDrawText("+1500", 1209, 51, 1349, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
dxDrawText("+1500", 1209, 49, 1349, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
dxDrawText("+1500", 1210, 50, 1350, 76, tocolor(0, 100, 35, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
end 
  
addEvent( "onZombieWasted" ); 
addEventHandler( "onZombieWasted", root, 
function( killer ) 
        givePlayerMoney( killer, 1500 ); 
        addEventHandler("onClientRender", root, onTest) 
        setTimer( function ( ) 
                removeEventHandler ( "onClientRender", root, onTest ) 
                end, 3000, 1 ) 
end) 

Posted

Not working too :/ no errors in debug

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

onZombieWasted is a server side event.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

So what I should do?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

I don't know what zombie gamemode do you use, so I don't know whether "onClientZombieWasted" exists. Assuming it does not, you could use this code serverside:

addEvent( "onZombieWasted" ) 
addEventHandler( "onZombieWasted", getRootElement(), 
function( killer ) 
        givePlayerMoney( killer, 1500 ) 
        triggerClientEvent(killer,"onClientZombieWasted", resourceRoot) 
end 

and this code clientside:

function onTest() 
        dxDrawText("+1500", 1211, 51, 1351, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("+1500", 1211, 49, 1351, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("+1500", 1209, 51, 1349, 77, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("+1500", 1209, 49, 1349, 75, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("+1500", 1210, 50, 1350, 76, tocolor(0, 100, 35, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
end 
      
addEvent( "onClientZombieWasted" ) 
addEventHandler( "onClientZombieWasted", root, 
function() 
        addEventHandler("onClientRender", root, onTest) 
        setTimer( 
        function () 
                removeEventHandler ( "onClientRender", root, onTest ) 
        end, 3000, 1) 
end) 

Again, I don't know what zombie resource do you use, so it may not work properly.

Posted

Eh, I forgot about that "remotely triggerable" thingy, my bad. Just replace

addEvent("onClientZombieWasted") 

by

addEvent("onClientZombieWasted", true) 

Posted

You would still need to check whether the "source" is a zombie using

isPedZombie() 

, which is a serverside function, so it would still require triggering server events and all that stuff. Or maybe there's some other way to check whether a ped is a zombie (eg. getElementData()), but I don't know of any other because I've never ran that zombie gamemode myself.

Posted

Thanks man working

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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