Jump to content

VehicleGodMode no script


Recommended Posts

O "VehicleGodMode" não está ativando, o carro ainda toma dano e explode no perímetro... O que falta?

RestricLocation = {}
TeleportLocation = {}
EnabledAlarm = true
ColCuboid = false

--------------------------------------- CONFIGS --------------------------------------------


RestricLocation["location1"] = {-454.89999389648, -1782, 36.900001525879}  --Local PARTE DE CIMA
RestricLocation["location2"] = {-395.29998779297, -1676.5999755859, 10}  --LOCAL PARTE DE BAIXO
TeleportLocation = {-384.079, -1678.615, 22.101} --LOCAL TO TELEPORT PLAYER
GroupName = "Snake" 
GroupNameBy = 2 -- 1 
MsgInvasao = "Não entre, base do Snake, propriedade privada!"
EnableVehicleGodMode = true
HabilitarAdmin = true 
GodMode = false 
NaoAtirar = false 

maxAutos = 5

--------------------------------------- CONFIGS --------------------------------------------

function sendMsg(iplayer,msg)
  outputChatBox(msg,iplayer,255,0,0,true)
end

function getVehicleType2(veh)
  vt = getVehicleType(veh)
  if vt == "Automobile" or vt == "Bike" or vt == "BMX" or vt == "Monster Truck" or vt == "Quad" or vt == "Plane" or vt == "Helicopter" then
    return "automobiles"
  end
end
function getVehiclesInsideBase(Colshape)
  automobiles,aircrafts = 1,1
  if isElement(Colshape) then
    for i,veh in pairs(getElementsWithinColShape(Colshape,"vehicle"))do
      if getVehicleType2(veh) == "automobiles" then
        automobiles = automobiles + 1
      end
    end
    setElementData(Colshape,"currentAutos",automobiles)
  end
  return automobiles
end

function EnterPlace(theElement)
  if getElementType(theElement)== "player" then
    local accName = getAccountName(getPlayerAccount(theElement))
    if HabilitarAdmin == true then
      if(isObjectInACLGroup("user."..accName,aclGetGroup("")))then
        return
      end
    end
  end
  if(getElementType(theElement)== "player")and(PlayerHaveLevel(theElement)== false)then
    sendMsg(theElement,MsgInvasao)
    if getPedOccupiedVehicle(theElement) then
      setElementPosition(getPedOccupiedVehicle(theElement),TeleportLocation[1],TeleportLocation[2],TeleportLocation[3])
    else
      setElementPosition(theElement,TeleportLocation[1],TeleportLocation[2],TeleportLocation[3])
    end
    sendMsgOwners(theElement)
  elseif getElementType(theElement)== "vehicle" then
    SetVehicleGodMode(theElement,true)
    currentAutos = getVehiclesInsideBase(source)
    local playerr = getVehicleController(theElement)
    if currentAutos > maxAutos then
      setElementPosition(theElement,TeleportLocation[1],TeleportLocation[2],TeleportLocation[3])
      setElementVelocity(theElement,0,0,0)
      if getVehicleController(theElement) then
        outputChatBox("#ffffffO limite de #ff00005 #ffffffveículos nesta base já foi atingido.",playerr,255,0,0, true)
      end
    elseif getVehicleController(theElement) then
      if getVehicleType2(theElement) == "automobiles" then
        outputChatBox("#ffffffLimite de veiculos na Base: #ff0000"..currentAutos.." / "..maxAutos,playerr, 255,255,255, true)
      end
    end
  end
end

function ExitPlace(theElement)
  if GodMode == true then
    setElementData(theElement,"blood",12000)
  end
  if NaoAtirar == true then
  toggleControl(theElement,"fire",true)
  toggleControl(theElement,"vehicle_fire",true)
  toggleControl(theElement,"vehicle_secondary_fire",true)
  toggleControl(theElement,"aim_weapon",true)
  end
  if getElementType(theElement)== "vehicle" then
    SetVehicleGodMode(theElement,false)
  end
end

function PlayerHaveLevel(PlayerID)
  if GroupNameBy == 1 then
    if(getElementData(PlayerID ,"gang")== GroupName)then
      if GodMode == true then
        setElementData(PlayerID,"blood",999999999999999)
      end
      if NaoAtirar == true then
        toggleControl(PlayerID,"fire",false)
        toggleControl(PlayerID,"vehicle_fire",false)
        toggleControl(PlayerID,"vehicle_secondary_fire",false)
        toggleControl(PlayerID,"aim_weapon",false)
      end
      return true
    else
      return false
    end
  else
    local accName = getAccountName(getPlayerAccount(PlayerID))
    if(isObjectInACLGroup("user."..accName,aclGetGroup(GroupName)))then
      if GodMode == true then
        setElementData(PlayerID,"blood",999999999999999)
      end
      if NaoAtirar == true then
        toggleControl(PlayerID,"fire",false)
        toggleControl(PlayerID,"vehicle_fire",false)
        toggleControl(PlayerID,"vehicle_secondary_fire",false)
        toggleControl(PlayerID,"aim_weapon",false)
      end
      return true
    else
      return false
    end
  end
end

function ResourceStart()
  LoadLocations()
  CreateCollision()
end
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),ResourceStart)

function LoadLocations()
  local RX,RY,RZ,WRX,WRX,WRX
  if(RestricLocation["location1"][1] > RestricLocation["location2"][1])then
    RestricLocation["maxx"] = RestricLocation["location1"][1]
    RestricLocation["minx"] = RestricLocation["location2"][1]
  else
    RestricLocation["maxx"] = RestricLocation["location2"][1]
    RestricLocation["minx"] = RestricLocation["location1"][1]
  end
  if(RestricLocation["location1"][2] > RestricLocation["location2"][2])then
    RestricLocation["maxy"] = RestricLocation["location1"][2]
    RestricLocation["miny"] = RestricLocation["location2"][2]
  else
    RestricLocation["maxy"] = RestricLocation["location2"][2]
    RestricLocation["miny"] = RestricLocation["location1"][2]
  end
  if(RestricLocation["location1"][3] > RestricLocation["location2"][3])then
    RestricLocation["maxz"] = RestricLocation["location1"][3]
    RestricLocation["minz"] = RestricLocation["location2"][3]
  else
    RestricLocation["maxz"] = RestricLocation["location2"][3]
    RestricLocation["minz"] = RestricLocation["location1"][3]
  end
end

function CreateCollision()
  RX = RestricLocation["minx"]
  WRX = RestricLocation["maxx"] - RestricLocation["minx"]
  RY = RestricLocation["miny"]
  WRY = RestricLocation["maxy"] - RestricLocation["miny"]
  RZ = RestricLocation["minz"]
  WRZ = RestricLocation["maxz"] - RestricLocation["minz"]
  ColCuboid = createColCuboid(RX,RY,RZ,WRX,WRY,WRZ)
  if ColCuboid then
    addEventHandler("onColShapeHit",ColCuboid,EnterPlace)
    addEventHandler("onColShapeLeave",ColCuboid,ExitPlace)
  else
    outputDebugString("Erro,verifique: location1 e location2")
  end
end

function ResourceStop()
  destroyElement(ColCuboid)
end
addEventHandler("onResourceStop",getResourceRootElement(getThisResource()),ResourceStop)

function sendMsgOwners(PlayerID)
  local connectedPlayers = getElementsByType("player")
  for i,aPlayer in ipairs(connectedPlayers)do
    if(PlayerHaveLevel(aPlayer)== true)then
      sendMsg(aPlayer,"O Jogador #ff0000" ..getPlayerName(PlayerID).." #FFFFFFesta tentando invadir a #FF0000BASE 4!")
    end
  end
end

function SetVehicleGodMode(VehicleID,godEoD)
  if EnableVehicleGodMode == true then
     setElementData(VehicleID, "godmode", godEoD)
    setVehicleDamageProof(VehicleID,godEoD)
  end
end

 

Edited by xLive
format
Link to comment

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