Destiny Posted July 2, 2012 Share Posted July 2, 2012 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
-ffs-Sniper Posted July 2, 2012 Share Posted July 2, 2012 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
Destiny Posted July 2, 2012 Author Share Posted July 2, 2012 error, this time at ERROR: antidamagecar\server.lua:6: attempt to call global 'getLocalPlayer' < a nill value> Link to comment
Anderl Posted July 2, 2012 Share Posted July 2, 2012 Check if your file is in client side in meta.xml Link to comment
Guest Guest4401 Posted July 2, 2012 Share Posted July 2, 2012 > ="server.lua" type="client"/>> Link to comment
Destiny Posted July 2, 2012 Author Share Posted July 2, 2012 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
Castillo Posted July 2, 2012 Share Posted July 2, 2012 function nodamage ( attacker, bodypart ) if ( attacker and getElementType ( attacker ) == "vehicle" ) then cancelEvent ( ) end end addEventHandler ( "onClientPlayerDamage", localPlayer, nodamage ) Has to work. Link to comment
Castillo Posted July 3, 2012 Share Posted July 3, 2012 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. Link to comment
Destiny Posted July 4, 2012 Author Share Posted July 4, 2012 Players not to damage vehicles Link to comment
codeluaeveryday Posted July 4, 2012 Share Posted July 4, 2012 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
DNL291 Posted July 4, 2012 Share Posted July 4, 2012 addEventHandler("onClientVehicleEnter",getRootElement(), function(player,seat) setVehicleDamageProof(getPedOccupiedVehicle(player),true) end ) Link to comment
TAPL Posted July 4, 2012 Share Posted July 4, 2012 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 Link to comment
DNL291 Posted July 4, 2012 Share Posted July 4, 2012 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
Destiny Posted July 4, 2012 Author Share Posted July 4, 2012 Cars will not be damaged by weapons.Separated from the car will be canceled Link to comment
qaisjp Posted July 5, 2012 Share Posted July 5, 2012 SERVER SIDE: function toggleDamageproof() setVehicleDamageProof(source, eventName == "onVehicleStartEnter") end addEventHandler("onVehicleStartEnter", root, toggleDamageproof) addEventHandler("onVehicleStartExit", root, toggleDamageproof) TRY IT SERVER SIDED! Link to comment
X-SHADOW Posted July 5, 2012 Share Posted July 5, 2012 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
Anderl Posted July 5, 2012 Share Posted July 5, 2012 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
X-SHADOW Posted July 5, 2012 Share Posted July 5, 2012 Oh You'r Right Thank's for tell me Server.lua and meta.xml server.lua type='server' addEventHandler("onVehicleDamage", root, function() cancelEvent() end) Link to comment
Anderl Posted July 5, 2012 Share Posted July 5, 2012 Oh You'r Right Thank's for tell meServer.lua and meta.xml server.lua type='server' addEventHandler("onVehicleDamage", root, function() cancelEvent() end) This will protect from anything, just like qais code. Link to comment
Anderl Posted July 5, 2012 Share Posted July 5, 2012 There's no attacker argument in that event. Link to comment
X-SHADOW Posted July 5, 2012 Share Posted July 5, 2012 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 ? Link to comment
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