Destiny Posted July 2, 2012 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
-ffs-Sniper Posted July 2, 2012 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)
Destiny Posted July 2, 2012 Author Posted July 2, 2012 error, this time at ERROR: antidamagecar\server.lua:6: attempt to call global 'getLocalPlayer' < a nill value>
Anderl Posted July 2, 2012 Posted July 2, 2012 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
Destiny Posted July 2, 2012 Author 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
Castillo Posted July 2, 2012 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted July 3, 2012 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
codeluaeveryday Posted July 4, 2012 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. Tutorials: => getOnlineAdmins() => [TUT] Better Join Country => [TUT] Updating admin countries => [TUT] Updating admin flags Server: K@N Zombies / Freeroam
DNL291 Posted July 4, 2012 Posted July 4, 2012 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.
TAPL Posted July 4, 2012 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
DNL291 Posted July 4, 2012 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 .. Please do not PM me with scripting related question nor support, use the forums instead.
Destiny Posted July 4, 2012 Author Posted July 4, 2012 Cars will not be damaged by weapons.Separated from the car will be canceled
MTA Team qaisjp Posted July 5, 2012 MTA Team 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!
X-SHADOW Posted July 5, 2012 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 . My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Anderl Posted July 5, 2012 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. "[...] 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
X-SHADOW Posted July 5, 2012 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) My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Anderl Posted July 5, 2012 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. "[...] 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
Anderl Posted July 5, 2012 Posted July 5, 2012 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
X-SHADOW Posted July 5, 2012 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 ? My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
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