-Doc- Posted May 3, 2015 Posted May 3, 2015 Hi I'd like to know how i can make a rhino get damage from projectile 21 this its type of projectile. Help?
WhoAmI Posted May 3, 2015 Posted May 3, 2015 onVehicleDamage getElementType getProjectileType destroyElement
WhoAmI Posted May 3, 2015 Posted May 3, 2015 client.lua addEventHandler ( "onClientVehicleDamage", root, -- creating an event function ( attackerElement ) -- attaching funciton to it if ( getElementModel ( source ) ~= 432 ) then -- checking if vehicle is rhino return; -- if not canceling function end local attackerElementType = getElementType ( attackerElement ); -- getting type of attacker element if ( attackerElementType == "projectile" ) then -- checking if it is projectile local projectileType = getProjectileType ( attackerElement ); -- getting type of projectile if ( projectileType == 21 ) then -- checking if projectile has 21 id triggerServerEvent ( "destroy", source ); -- triggering serverside event which will destroy rhino end end end ); server.lua addEvent ( "destroy", true ); -- adding custom event addEventHandler ( "destroy", root, -- attaching it function ( ) -- to this function destroyElement ( source ); -- destroying rhino end ); meta.xml > ="client.lua" type="client" /> ="server.lua" type="server" />>
-Doc- Posted May 3, 2015 Author Posted May 3, 2015 but one thing i dnot need to destroy i need to get damage 250
WhoAmI Posted May 3, 2015 Posted May 3, 2015 addEvent ( "destroy", true ); -- adding custom event addEventHandler ( "destroy", root, -- attaching it function ( ) -- to this function setElementHealth ( source, getElementHealth ( source ) - 250 ); end );
WhoAmI Posted May 3, 2015 Posted May 3, 2015 You sure that projectile ID is 21? Because 21 is "Air Bomb".
-Doc- Posted May 3, 2015 Author Posted May 3, 2015 setElementVelocity (veh, vx+(((velX/3)*(-1))/50), vy+(((velY/3)*(-1))/50), vz+(((velZ/3)*(-1))/50) ) bullet = createProjectile(veh, 21, muzzleX, muzzleY, muzzleZ, 1, nil, 255,255,255, velX, velY, velZ) im using tank projectile and projectile id its 21
WhoAmI Posted May 3, 2015 Posted May 3, 2015 client addEventHandler ( "onClientVehicleDamage", root, function ( attackerElement ) if ( getElementModel ( source ) ~= 432 ) then return; end cancelEvent ( ); if ( attackerElement and getElementType ( attackerElement ) == "projectile" ) then outputChatBox ( "It's projectile!" ); if ( getProjectileType ( attackerElement ) == 21 ) then triggerServerEvent ( "destroy", localPlayer, source ); end end end ); server addEvent ( "destroy", true ); addEventHandler ( "destroy", root, function ( vehicle ) setElementHealth ( vehicle, getElementHealth ( vehicle ) - 250 ); end ); Tell me if 'It's projectile!' appears on chatbox if you shot rhino.
WhoAmI Posted May 3, 2015 Posted May 3, 2015 addEventHandler ( "onClientVehicleDamage", root, function ( attackerElement ) outputChatBox ( getElementModel ( source ) .. ": " .. getElementType ( attackerElement ) ); if ( getElementModel ( source ) ~= 432 ) then return; end cancelEvent ( ); if ( attackerElement and getElementType ( attackerElement ) == "projectile" ) then if ( getProjectileType ( attackerElement ) == 21 ) then triggerServerEvent ( "destroy", localPlayer, source ); end end end ); Tell me what chatbox outputs now.
-Doc- Posted May 3, 2015 Author Posted May 3, 2015 appears only when i shot in tank but tank doesnt get damage
WhoAmI Posted May 3, 2015 Posted May 3, 2015 client addEventHandler ( "onClientVehicleDamage", root, function ( attackerElement, weapon ) outputChatBox ( getElementModel ( source ) .. ": " .. weapon ); if ( getElementModel ( source ) ~= 432 ) then return; end cancelEvent ( ); if ( attackerElement and getElementType ( attackerElement ) == "projectile" ) then if ( getProjectileType ( attackerElement ) == 21 ) then triggerServerEvent ( "destroy", localPlayer, source ); end end end ); And now? Strange, because it's not projectile.
-Doc- Posted May 3, 2015 Author Posted May 3, 2015 No effects and no chatbox + 21 its a projectile https://wiki.multitheftauto.com/wiki/Projectiles
WhoAmI Posted May 3, 2015 Posted May 3, 2015 I know. But, it outputs 'object' or 'vehicle', I can't see 'projectile' on your chatbox while using code below, can you? addEventHandler ( "onClientVehicleDamage", root, function ( attackerElement ) outputChatBox ( getElementModel ( source ) .. ": " .. getElementType ( attackerElement ) ); if ( getElementModel ( source ) ~= 432 ) then return; end cancelEvent ( ); if ( attackerElement and getElementType ( attackerElement ) == "projectile" ) then if ( getProjectileType ( attackerElement ) == 21 ) then triggerServerEvent ( "destroy", localPlayer, source ); end end end );
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now