Jump to content

Ped's Don't die and how to pass arguements in eventhandler


Fabio(GNR)

Recommended Posts

First, my ped's won't die. I spawn a car, spawn a ped, warp ped in vehicle, bind a blip to it. When i shoot the vehicle it just stays in flames explodes and stays in flames unlimited. Why are my ped's invulnerable?

Server Side:

function convoy( number) 
if number == 1 then 
car1 = createVehicle(470, 1839.328125,281.9150390625,23.716369628906,0,0,94.788726806641) 
car2 = createVehicle(433, 1810.673828125,278.4248046875,21.178592681885,0,0,94.865631103516) 
car3 = createVehicle(470, 1777.3564453125,276.9091796875,19.094444274902,0,0,86.532409667969) 
ped1 = createPed(287, 0,0,0,0,0,0, true) 
ped2 = createPed(287, 1,1,1,0,0,0, true) 
ped3 = createPed(287, 2,2,2,0,0,0, true) 
setTimer(warpPeds,250,1) 
triggerClientEvent(source,"createBlips", source, car1, car2, car3, ped1, ped2, ped3 ) 
elseif number == 2 then 
  
else 
outputChatBox("Error...") 
end 
end 
function warpPeds() 
warpPedIntoVehicle(ped1,car1) 
warpPedIntoVehicle(ped3,car3) 
warpPedIntoVehicle(ped2,car2) 
end 

How they are created, then client-side:

function createTheBlips(car1,car2,car3,ped1,ped2,ped3) 
blipPed1 = createBlipAttachedTo(ped1,0,4) 
blipPed2 = createBlipAttachedTo(ped2,0,4) 
blipPed3 = createBlipAttachedTo(ped3,0,4) 
addEventHandler("onClientRender", getRootElement(),  
function() 
triggerEvent("drawStatusEvent",localPlayer,ped1,ped2,ped3) 
end) 
end 

Then to my next question, i have function which creates a eventhandler on "onClientRender", but it has to pass arguements to a other function. Function 1: Has the good arguements, has the eventhandler.

Function 2: gets triggered every render, doesn't have arguements but needs it.

Link to comment

Maybe you have a script cancelling the damage done to ped(s)?

By pass arguments you mean something like this:

addEventHandler ( "onClientRender", root, 
    function ( arg1, arg2, arg3 ) 
  
    end 
) 

If so, then is not possible to do that as far as I know.

Link to comment

Will try that, i will look around for those but i dont think i have any canceling scrips unless it's enabled by default.

EDIT: Oh misread you but yeah that is what i meant, maybe there is a other solution:

I create my ped's server side and warp them into a vehicle. Then i send a clientevent which creates blips for the peds and creates a onClientRender for dxDrawText. But, i want it to draw only when the ped is alive. Any idea?

Also, if you create a blip on a ped will it be deleted when it dies?

EDIT2: Something is very wrong :S, i did stopall

then started runcode which also started ajax, i do run ped = createPed(287,1,1,1)

But it can't be damaged...

Peds do die now, i changed some things and something prevented them from getting damaged.

Link to comment

Thanks, problem is now: I found out that the Ped's do die when not being warped. When they get warped to their vehicle to cant be killed anymore. The vehicle can be blown when not occupied, the ped's can be killed when they are not in vehicle.

But if i warp them, they get invincible.

function convoy( number ) 
if number == 1 then 
car1 = createVehicle(470, 1839.328125,281.9150390625,23.716369628906,0,0,94.788726806641) 
car2 = createVehicle(433, 1810.673828125,278.4248046875,21.178592681885,0,0,94.865631103516) 
car3 = createVehicle(470, 1777.3564453125,276.9091796875,19.094444274902,0,0,86.532409667969) 
ped1 = createPed(287, 0,0,3,0,0,0, true) 
ped2 = createPed(287, 1,1,4,0,0,0, true) 
ped3 = createPed(287, 2,2,3,0,0,0, true) 
triggerClientEvent(source,"createBlips", source, car1, car2, car3, ped1, ped2, ped3 ) 
setTimer(warpPeds, 500,1,car1,car2,car3,ped1,ped2,ped3) 
elseif number == 2 then 
  
else 
outputChatBox("Error...") 
end 
end 
function warpPeds(car1,car2,car3,ped1,ped2,ped3) 
warp1 = warpPedIntoVehicle(ped1,car1) 
warp2 = warpPedIntoVehicle(ped3,car3) 
warp3 = warpPedIntoVehicle(ped2,car2) 
setVehicleDamageProof(car1,false) 
setVehicleDamageProof(car2,false) 
setVehicleDamageProof(car3,false) 
end 

Why?!

Link to comment

I tinhk it is possible.

Example code (Untested):

 local number = 0 
local numberB = false 
  
function onRenderCustomEvent() 
    number = number + 1 
    if number <= 150 then 
        numberB = true 
        number = 0 
    end 
    triggerEvent("onCustomRender", getRootElement(), number, numberB) -- and so 
end 
addEventHandler("onClientRender", getRootElement(), onRenderCustomEvent) 
  
  
function onCustomRender(arg, arg2) 
    outputChatBox(tostring(arg .. " : " .. arg2)) 
    -- PS: It will spammer chat, just for example 
end 
addEvent("onCustomRender", true) 
addEventHandler("onCustomRender", getRootElement(), onCustomRender) 

Link to comment

I tried something like that but it didn't work. That probably does, although that problem is somewhat solved i really want to know why the ped's don't die. Thanks though!

EDIT: The ped's didnt die because i spawned them at 0,0,0 then warped them to a vehicle far away. Which caused them to be desynced. But now the ped's die but the car's keep exploding, sort of. The onVehicleExlode doesn't get called after once though.

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