SpoC^ Posted April 9, 2015 Share Posted April 9, 2015 (edited) Hi friends, I created this function when the player puts your vehicle in the protected area, is indestructible, but when the player pushes the vehicle out of the protected area without being inside it, remains indestructible ... I do not want it Please help, and complete the function Server.lua -- CRIATE BY *SpoC^ for TWD -- local PraiaProtegidax = createMarker (191, -1797, 4, "cylinder", 25, 255,0,0,0) function Protect1 (source) local carro = getPedOccupiedVehicle (source) outputChatBox ('#00bfff* Entrou na Área de Proteção: #ffffffSeu veículo ficou indestrutível!',source,255,255,255,true) setVehicleDamageProof (carro,true) toggleControl (source, "fire", true) toggleControl (source, "aim_weapon", true) triggerClientEvent (source, "enableGodMode",source) end addEventHandler ("onMarkerHit", PraiaProtegidax, Protect1) function Protect21 (source) local carro = getPedOccupiedVehicle (source) outputChatBox ('#00bfff* Saiu da Área de Proteção: #ffffffSeu veículo não esta mais indestrutível!',source,255,255,255,true) setVehicleDamageProof (carro,false) toggleControl (source, "fire", true) toggleControl (source, "aim_weapon", true) triggerClientEvent (source, "disableGodMode",source) setTimer (triggerClientEvent, 1000, 3, source, "disableGodMode", source) end addEventHandler ("onMarkerLeave", PraiaProtegidax, Protect21) Edited April 10, 2015 by Guest Link to comment
#RooTs Posted April 9, 2015 Share Posted April 9, 2015 try this -- CRIATE BY *SpoC^ for TWD -- local PraiaProtegidax = createMarker (191, -1797, 4, "cylinder", 25, 255,0,0,0) function Protect1 (source, theVehicle) local carro = getPedOccupiedVehicle (source) outputChatBox ('#00bfff* Entrou na Área de Proteção: #ffffffSeu veículo ficou indestrutível!',source,255,255,255,true) setVehicleDamageProof (theVehicle, true) toggleControl (source, "fire", true) toggleControl (source, "aim_weapon", true) triggerClientEvent (source, "enableGodMode",source) end addEventHandler ("onMarkerHit", PraiaProtegidax, Protect1) function Protect21 (source, theVehicle) local carro = getPedOccupiedVehicle (source) outputChatBox ('#00bfff* Saiu da Área de Proteção: #ffffffSeu veículo não esta mais indestrutível!',source,255,255,255,true) setVehicleDamageProof (theVehicle, false) toggleControl (source, "fire", true) toggleControl (source, "aim_weapon", true) triggerClientEvent (source, "disableGodMode",source) setTimer (triggerClientEvent, 1000, 3, source, "disableGodMode", source) end addEventHandler ("onMarkerLeave", PraiaProtegidax, Protect21) Link to comment
SpoC^ Posted April 9, 2015 Author Share Posted April 9, 2015 (edited) "#RooTs" no work Edited April 10, 2015 by Guest Link to comment
#RooTs Posted April 9, 2015 Share Posted April 9, 2015 (edited) .. Edited April 10, 2015 by Guest Link to comment
SpoC^ Posted April 9, 2015 Author Share Posted April 9, 2015 (edited) "#RooTs" Worked protection, but when push the vehicle out of the area without being inside the vehicle, remains shielded ... only removes protection while I'm at it ... I just want to protect the vehicle being within the marker, and unprotect if outside the marker without being occupying the vehicle Edited April 10, 2015 by Guest Link to comment
neves768 Posted April 9, 2015 Share Posted April 9, 2015 Here is the solution: Only one file by server-side -- CRIATE BY *SpoC^ for TWD -- local PraiaProtegidax = createMarker (191, -1797, 4, "cylinder", 25, 255,0,0,0) function Protect1(source,dimens) local veh = getPedOccupiedVehicle(source) outputChatBox('#00bfff* Entrou na Área de Proteção: #ffffffSeu veículo ficou indestrutível!',source,255,255,255,true) setElementData(veh,"godmode",true) toggleControl(source,"fire",true) toggleControl(source,"aim_weapon",true) end addEventHandler("onMarkerHit",PraiaProtegidax,Protect1) function godmodeveh() godvar = getElementData(source,"godmode") if godvar and godvar == true then setVehicleDamageProof(source,true) setElementHealth(source,1000) cancelEvent() end end addEventHandler("onPlayerDamage",getRootElement(),godmodeveh) function Protect21(source,dimens) local veh = getPedOccupiedVehicle(source) outputChatBox ('#00bfff* Saiu da Área de Proteção: #ffffffSeu veículo não esta mais indestrutível!',source,255,255,255,true) setVehicleDamageProof (veh,false) setElementData(veh,"godmode",false) toggleControl(source, "fire", true) toggleControl(source, "aim_weapon", true) end addEventHandler("onMarkerLeave",PraiaProtegidax,Protect21) Link to comment
SpoC^ Posted April 9, 2015 Author Share Posted April 9, 2015 (edited) Neves768 not work less protection of the vehicle within the marking not working Edited April 10, 2015 by Guest Link to comment
neves768 Posted April 9, 2015 Share Posted April 9, 2015 Try it(now with colshape): -- CRIATE BY *SpoC^ for TWD -- local PraiaProtegidax = createColCuboid(163.32458, -1840.56104, 2, 55, 65, 60) function Protect1(source,dimens) if getElementType(source) == "vehicle" then setElementData(source,"godmode",true) else outputChatBox('#00bfff* Entrou na Área de Proteção: #ffffffSeu veículo ficou indestrutível!',source,255,255,255,true) toggleControl(source,"fire",true) toggleControl(source,"aim_weapon",true) end end addEventHandler("onColShapeHit",PraiaProtegidax,Protect1) function godmodeveh() godvar = getElementData(source,"godmode") if godvar then setVehicleDamageProof(source,true) setElementHealth(source,1000) cancelEvent() end end addEventHandler("onPlayerDamage",getRootElement(),godmodeveh) function Protect21(source,dimens) if getElementType(source) == "vehicle" then setVehicleDamageProof(source,false) setElementData(source,"godmode",false) else outputChatBox ('#00bfff* Saiu da Área de Proteção: #ffffffSeu veículo não esta mais indestrutível!',source,255,255,255,true) toggleControl(source, "fire", true) toggleControl(source, "aim_weapon", true) end end addEventHandler("onColShapeLeave",PraiaProtegidax,Protect21) Link to comment
maky55 Posted April 9, 2015 Share Posted April 9, 2015 Here is the solution:Only one file by server-side -- CRIATE BY *SpoC^ for TWD -- local PraiaProtegidax = createMarker (191, -1797, 4, "cylinder", 25, 255,0,0,0) function Protect1(source,dimens) local veh = getPedOccupiedVehicle(source) outputChatBox('#00bfff* Entrou na Área de Proteção: #ffffffSeu veículo ficou indestrutível!',source,255,255,255,true) setElementData(veh,"godmode",true) toggleControl(source,"fire",true) toggleControl(source,"aim_weapon",true) end addEventHandler("onMarkerHit",PraiaProtegidax,Protect1) function godmodeveh() godvar = getElementData(source,"godmode") if godvar and godvar == true then setVehicleDamageProof(source,true) setElementHealth(source,1000) cancelEvent() end end addEventHandler("onPlayerDamage",getRootElement(),godmodeveh) function Protect21(source,dimens) local veh = getPedOccupiedVehicle(source) outputChatBox ('#00bfff* Saiu da Área de Proteção: #ffffffSeu veículo não esta mais indestrutível!',source,255,255,255,true) setVehicleDamageProof (veh,false) setElementData(veh,"godmode",false) toggleControl(source, "fire", true) toggleControl(source, "aim_weapon", true) end addEventHandler("onMarkerLeave",PraiaProtegidax,Protect21) Neves768 no work Instaid of saying no work, give us the problem that happens.. Link to comment
ALw7sH Posted April 9, 2015 Share Posted April 9, 2015 You cant do cancelEvent for onPlayerDamge, read the wiki https://wiki.multitheftauto.com/wiki/OnPlayerDamage Canceling this event has no effect. Cancel the client-side event onClientPlayerDamage instead. Link to comment
SpoC^ Posted April 9, 2015 Author Share Posted April 9, 2015 (edited) Yes marky55, outputChatBox worked, less protection of the vehicle within the marking not working Edited April 10, 2015 by Guest Link to comment
SpoC^ Posted April 9, 2015 Author Share Posted April 9, 2015 (edited) Neves768 , outputChatBox worked, less protection of the vehicle within the marking not working Edited April 10, 2015 by Guest Link to comment
SpoC^ Posted April 9, 2015 Author Share Posted April 9, 2015 I need help, Can somebody help me friends? Link to comment
ALw7sH Posted April 10, 2015 Share Posted April 10, 2015 -- CRIATE BY *SpoC^ for TWD -- local PraiaProtegidax = createMarker (191, -1797, 4, "cylinder", 25, 255,0,0,0) function Protect1(element,dimens) if getElementType(element) == "vehicle" then setVehicleDamageProof(element,true) elseif getElementType(element) == "player" then outputChatBox('#00bfff* Entrou na Área de Proteção: #ffffffSeu veículo ficou indestrutível!',element,255,255,255,true) toggleControl(element,"fire",true) toggleControl(element,"aim_weapon",true) end end addEventHandler("onMarkerHit",PraiaProtegidax,Protect1) function Protect21(element,dimens) if getElementType(element) == "vehicle" then setVehicleDamageProof (element,false) elseif getElementType(element) == "player" then outputChatBox ('#00bfff* Saiu da Área de Proteção: #ffffffSeu veículo não esta mais indestrutível!',element,255,255,255,true) toggleControl(element,"fire",true) toggleControl(element,"aim_weapon",true) end end addEventHandler("onMarkerLeave",PraiaProtegidax,Protect21) Link to comment
SpoC^ Posted April 10, 2015 Author Share Posted April 10, 2015 ALw7sH, worked perfectly !! function Protect1(element,dimens) "bug" tidy !! Note 10 for you my Friend 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