Tando Posted July 26, 2018 Share Posted July 26, 2018 This are SpawnCarProtection but it's need SetTime Client: addEvent("Col", true) function enable(veh) for i, vehd in ipairs(getElementsByType("vehicle")) do for i, vehp in ipairs(getElementsByType("player")) do setElementCollidableWith( vehd,veh, false) setElementCollidableWith( vehp,veh, false) end end end addEventHandler("Col", root, enable) addEvent("Col2", true) function denable(veh) for i, vehd in ipairs(getElementsByType("vehicle")) do for i, vehp in ipairs(getElementsByType("player")) do setElementCollidableWith( vehd,veh,true) setElementCollidableWith( vehp,veh,true) end end end addEventHandler("Col2", root, denable) Server: addEventHandler("onPlayerSpawnVehicle", root, function (vms, _, veh) if getElementType (veh) == "vehicle" and (veh) then triggerClientEvent("Col",source,veh) setElementAlpha(veh, 150) setElementData(veh, "SpawnProtected", true) setTime(function() if not isElement (veh)then return end triggerClientEvent("Col2",veh,veh) setElementData(veh, "SpawnProtected",false) setElementAlpha(veh,255) end,10000,1) end end ) Link to comment
Erknneto Posted July 27, 2018 Share Posted July 27, 2018 It's not 'setTime', the correct function is setTimer. Read more about it : https://wiki.multitheftauto.com/wiki/SetTimer Link to comment
VenomOG Posted August 15, 2018 Share Posted August 15, 2018 CLIENT addEvent("Col", true) function enable(veh) for i, vehd in ipairs(getElementsByType("vehicle")) do for i, vehp in ipairs(getElementsByType("player")) do setElementCollidableWith( vehd,veh, false) setElementCollidableWith( vehp,veh, false) end end end addEventHandler("Col", root, enable) addEvent("Col2", true) function denable(veh) for i, vehd in ipairs(getElementsByType("vehicle")) do for i, vehp in ipairs(getElementsByType("player")) do setElementCollidableWith( vehd,veh,true) setElementCollidableWith( vehp,veh,true) end end end addEventHandler("Col2", root, denable) SERVER---- addEventHandler("onPlayerSpawnVehicle", root, function (vms, _, veh) if getElementType (veh) == "vehicle" and (veh) then triggerClientEvent("Col",source,veh) setElementAlpha(veh, 150) setElementData(veh, "SpawnProtected", true) setTimer(function() if not isElement (veh)then return end triggerClientEvent("Col2",veh,veh) setElementData(veh, "SpawnProtected",false) setElementAlpha(veh,255) end,10000,1) end end ) @(SAUG)Tando Link to comment
JeViCo Posted August 16, 2018 Share Posted August 16, 2018 (edited) i guess you missed something here setTimer(function() if not isElement (veh)then return end triggerClientEvent("Col2",veh,veh) setElementData(veh, "SpawnProtected",false) setElementAlpha(veh,255) end,10000,1) added veh arguments setTimer(function(veh) if not isElement (veh)then return end triggerClientEvent("Col2",veh,veh) setElementData(veh, "SpawnProtected",false) setElementAlpha(veh,255) end,10000,1,veh) @KnucklesSAEG Edited August 16, 2018 by JeViCo Link to comment
Tando Posted August 16, 2018 Author Share Posted August 16, 2018 16 hours ago, JeViCo said: i guess you missed something here setTimer(function() if not isElement (veh)then return end triggerClientEvent("Col2",veh,veh) setElementData(veh, "SpawnProtected",false) setElementAlpha(veh,255) end,10000,1) added veh arguments setTimer(function(veh) if not isElement (veh)then return end triggerClientEvent("Col2",veh,veh) setElementData(veh, "SpawnProtected",false) setElementAlpha(veh,255) end,10000,1,veh) @KnucklesSAEG On 8/15/2018 at 06:17, KnucklesSAEG said: CLIENT addEvent("Col", true) function enable(veh) for i, vehd in ipairs(getElementsByType("vehicle")) do for i, vehp in ipairs(getElementsByType("player")) do setElementCollidableWith( vehd,veh, false) setElementCollidableWith( vehp,veh, false) end end end addEventHandler("Col", root, enable) addEvent("Col2", true) function denable(veh) for i, vehd in ipairs(getElementsByType("vehicle")) do for i, vehp in ipairs(getElementsByType("player")) do setElementCollidableWith( vehd,veh,true) setElementCollidableWith( vehp,veh,true) end end end addEventHandler("Col2", root, denable) SERVER---- addEventHandler("onPlayerSpawnVehicle", root, function (vms, _, veh) if getElementType (veh) == "vehicle" and (veh) then triggerClientEvent("Col",source,veh) setElementAlpha(veh, 150) setElementData(veh, "SpawnProtected", true) setTimer(function() if not isElement (veh)then return end triggerClientEvent("Col2",veh,veh) setElementData(veh, "SpawnProtected",false) setElementAlpha(veh,255) end,10000,1) end end ) @(SAUG)Tando problem was in end !!! 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