Jump to content

[Help] when you touch the object you will be blown


Recommended Posts

well i tried to do something but i started scripting yesterday

so the script can be not sensible..

Anyway it doesn't work.

  
Me = getLocalPlayer 
function Main (hitPlayer, matchingDimension) 
vehicle = getPedOccupiedVehicle ( hitPlayer ) 
if hitPlayer ~= Me then  
if source == getElementModel(hitElement)==3458) then 
    blowVehicle ( vehicle ) 
        end 
end 
end 
addEventHandler( "onClientVehicleCollision", getRootElement(), Main) 
  

Link to comment

I haven't tested it, but you could try this;

function blowOnCollisionWithModel_Handler(hitElement) 
    if(source ~= getPedOccupiedVehicle(localPlayer)) then 
        if(getElementModel(hitElement) == 3458) then 
            blowVehicle(source); 
        end 
    end 
end 
addEventHandler("onClientVehicleCollision", getRootElement(), blowOnCollisionWithModel_Handler); 

Link to comment

Try this and see what it outputs when you hit the model you want.

function blowOnCollisionWithModel_Handler(hitElement) 
    outputChatBox("You collided with Model: [#FF2626"..tostring(getElementModel(hitElement)).."#BB0000]", 187, 0, 0, true); 
end 
addEventHandler("onClientVehicleCollision", getRootElement(), blowOnCollisionWithModel_Handler); 

Do note that due to how onClientVehicleCollision works, chat may or may not be spammed with messages.

Link to comment

Try this. If it still doesn't work, try commenting out the first if statement(also remember the end that closes it!).

function blowOnCollisionWithModel_Handler(hitElement) 
    if(source ~= getPedOccupiedVehicle(localPlayer)) then 
        if(hitElement == 3458) then 
            blowVehicle(source); 
        end 
    end 
end 
addEventHandler("onClientVehicleCollision", getRootElement(), blowOnCollisionWithModel_Handler); 

Link to comment

The problem with Dealman's script is that he's checking if hitElement is equal to 3458, but it won't work, because hitElement is a element, not a number.

So, you must first check if the element is valid using isElement and then use getElementModel to obtain the element model.

function blowOnCollisionWithModel_Handler ( hitElement ) 
    if ( source ~= getPedOccupiedVehicle ( localPlayer ) ) then 
        if ( isElement ( hitElement ) and getElementModel ( hitElement ) == 3458 ) then 
            blowVehicle ( source ) 
        end 
    end 
end 
addEventHandler ( "onClientVehicleCollision", getRootElement(), blowOnCollisionWithModel_Handler ) 

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