Jump to content

Vehicles killing players


Destiny

Recommended Posts

Posted
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

Posted

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) 

560x95_FFFFFF_FF9900_000000_000000.png

Posted

Check if your file is in client side in meta.xml

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Guest Guest4401
Posted
>    ="server.lua" type="client"/>>

Posted

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

    

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

Has to work.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Sorry.Does not work

Maybe explain what are you using this for? because that script will just cancel the damage if a vehicle crashes on you.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

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

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
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

CiTLh.png
Posted
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 ..

Please do not PM me with scripting related question nor support, use the forums instead.

  • MTA Team
Posted

SERVER SIDE:

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

TRY IT SERVER SIDED!

Posted

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 .

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted

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.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

Oh You'r Right Thank's for tell me

Server.lua

and meta.xml

server.lua type='server'

addEventHandler("onVehicleDamage", root, function() 
    cancelEvent() 
end) 

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted
Oh You'r Right Thank's for tell me

Server.lua

and meta.xml

server.lua type='server'

addEventHandler("onVehicleDamage", root, function() 
    cancelEvent() 
end) 

This will protect from anything, just like qais code.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

There's no attacker argument in that event.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

it's say on wiki

Source

The source of this event is the vehicle that got damaged.

and i put attacker so if worng what is the correct ?

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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