Jump to content

Vehicles killing players


Destiny

Recommended Posts

function nodamage(attacker, bodypart) 
if getElementType(attacker) == 'vehicle' then 
cancelEvent() 
end 
addEventHandler("onClientPlayerDamage", getLocalPlayer (),nodamage) 

Error:

SCRIPT ERROR: antidamagecar\server.lua:5: 'end' expected near ''

WARNING: Loading script failed: antidamagecar\server.lua:5: 'end' expected near ''

What is the error I need help

Link to comment

Every function must be closed with an "end". I highly advice you to use tabulators giving you a better overview.

function nodamage(attacker, bodypart) 
    if getElementType(attacker) == 'vehicle' then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", getLocalPlayer (),nodamage) 

Link to comment

Does not work.No fault

Server.lua

function nodamage(attacker, bodypart) 
    if getElementType(attacker) == 'vehicle' then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", getLocalPlayer (),nodamage) 

Meta.xml

    

Link to comment
function nodamage ( attacker, bodypart ) 
    if ( attacker and getElementType ( attacker ) == "vehicle" ) then 
        cancelEvent ( ) 
    end 
end 
addEventHandler ( "onClientPlayerDamage", localPlayer, nodamage ) 

Has to work.

Link to comment

So it appears the script you have given us is to stop vehicles from killing players. Maybe you want players to stop attacking vehicles.

addEventHandler("onClientVehicleEnter",getRootElement(), 
function(player,seat) 
    setVehicleDamageProof(source,true) 
end ) 

exit the vehicle, then enter it. It will be indestructable.

Link to comment
  • Moderators
addEventHandler("onClientVehicleEnter",getRootElement(), 
function(player,seat) 
    setVehicleDamageProof(getPedOccupiedVehicle(player),true) 
end ) 

getPedOccupiedVehicle not needed if you read the wiki for event 'onClientVehicleEnter' you will find this

The source of the event is the vehicle that the player entered.

https://wiki.multitheftauto.com/wiki/OnC ... hicleEnter

My bad. I forgot that the source of the event is the vehicle that the player entered ..

Link to comment

SERVER SIDE:

  
function toggleDamageproof() 
    setVehicleDamageProof(source, eventName == "onVehicleStartEnter") 
end 
addEventHandler("onVehicleStartEnter", root, toggleDamageproof) 
addEventHandler("onVehicleStartExit", root, toggleDamageproof) 
  

TRY IT SERVER SIDED!

Link to comment

No !

i know what he want he want if player come with his vehicle and hit you you dont get any damage for the vehicle .

---------ClientSide

addEventHandler("onClientPlayerDamage",root, 
function(attacker) 
if getElementType(attacker) == "vehicle" then 
cancelEvent() 
end 
end) 

if dont work tell me i well make one with a trigger event .

Link to comment

Your code does not do what you said.

SERVER SIDE:
  
function toggleDamageproof() 
    setVehicleDamageProof(source, eventName == "onVehicleStartEnter") 
end 
addEventHandler("onVehicleStartEnter", root, toggleDamageproof) 
addEventHandler("onVehicleStartExit", root, toggleDamageproof) 
  

TRY IT SERVER SIDED!

This is what he want, X-SHADOW.

But this code will protect the car from everything, qais.

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