Jump to content

help with triggerEvent


swag_k_dog

Recommended Posts

I wanted to script a ped, and negate the damage he takes, but I got it wrong..

server:

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),
	function()
        local batped = createPed(30, 2767.5, -1617, 11)
        setElementRotation(batped, 0, 0, -45)
        setTimer(setPedAnimation,500,1,batped, "dildo", "dildo_idle")
        setTimer(giveWeapon,500,1,batped, 5, 1, true)
		triggerClientEvent("onClientPedDamage", resourceRoot)
	end
) 

and client:

addEvent("onClientPedDamage", true)
addEventHandler("onClientPedDamage", getRootElement(),
function()
cancelEvent()
end
)

whats the problem?

Edited by swag_k_dog
Link to comment

use this client side

addEventHandler("onClientResourceStart", resourceRoot,
    function()
        batped = createPed(30,  2767.5, -1617, 11)
        setElementRotation(batped, 0, 0, -45)
        setTimer(setPedAnimation,500,1,batped, "dildo", "dildo_idle")
        setTimer(givePedWeapon,500,1,batped, 5, 1, true)
        addEventHandler ( "onClientPedDamage", batped, cancelPedDamage)
    end
) 

function cancelPedDamage ()
    if source == batped then 
        cancelEvent() 
    end
end 

 

  • Like 1
Link to comment
  On 10/10/2016 at 19:12, Walid said:

use this client side


addEventHandler("onClientResourceStart", resourceRoot,
    function()
        batped = createPed(30,  2767.5, -1617, 11)
        setElementRotation(batped, 0, 0, -45)
        setTimer(setPedAnimation,500,1,batped, "dildo", "dildo_idle")
        setTimer(givePedWeapon,500,1,batped, 5, 1, true)
        addEventHandler ( "onClientPedDamage", batped, cancelPedDamage)
    end
) 

function cancelPedDamage ()
    if source == batped then 
        cancelEvent() 
    end
end 

 

Expand  

Thanks for all the help. you're always here when I need you :D damn, scripting is getting more interesting now

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