Jump to content

Script ajuda


Recommended Posts

Posted (edited)

Olá, Boa Noite 

Estou com um terrível problema com um script que encontrei na internet. Um script que é uma proteção de base quando chega perto e teleportado para um certo local. Porem ele por acl, Quando o GroupName esta com o Group Casa e o aclgroup esta no nome de casa, ele funciona perfeitamente, quando eu mudo, nao reconhece mesmo eu tando na acl.

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

--------------------------------------- CONFIGS --------------------------------------------
RestricLocation["location1"] = {1899.5703125,-1847.1195068359,35.016845703125}  --Local PARTE DE CIMA
RestricLocation["location2"] = {1955.8936767578,-1890.5413818359,13.546875}  --LOCAL PARTE DE BAIXO
TeleportLocation = {1969.4591064453,-1786.7172851563,13.546875} --LOCAL TO TELEPORT PLAYER
GroupName = "Milicia" 
GroupNameBy = 2 ----- 2 è pra quem ta na ACL  , 1 è pra quem ta no grupo
MsgInvasao = "Base privada! Você não pode entrar aqui!"
EnableVehicleGodMode = true 
HabilitarAdmin = false 
GodMode = false 
NaoAtirar = false 


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

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

function EnterPlace ( theElement )
local veh = getPedOccupiedVehicle(theElement)
local accName = getAccountName(getPlayerAccount(theElement))
  if HabilitarAdmin == true then
    if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( "Milicia" ) ) ) then
      return
    end
  end
  if (getElementType ( theElement ) == "player") and (PlayerHaveLevel (theElement) == false) then
    sendMsg(theElement,MsgInvasao)
    if veh then
      setElementPosition( veh, 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)
  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)

    local connectedPlayers = getElementsByType ( "player" )
    for i, aPlayer in ipairs(connectedPlayers) do
        if(PlayerHaveLevel (aPlayer) == true) then
            sendMsg(aPlayer," O Jogador " ..getPlayerName ( PlayerID ) .." esta tentando invadir a sua BASE !")
        end
    end
end

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

 

Edited by Lord Henry
Código formatado de texto para Lua.
  • Moderators
Posted

Da próxima vez, utilize a formatação de código clicando no botão <> em vez de colar o código direto no texto.

Na sua linha 29, troque "Milicia" por GroupName. Da mesma forma que foi feito na linha 79.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted (edited)
14 minutes ago, Lord Henry said:

Da próxima vez, utilize a formatação de código clicando no botão <> em vez de colar o código direto no texto.

Na sua linha 29, troque "Milicia" por GroupName. Da mesma forma que foi feito na linha 79.

Perdão, Não consegui troquei o nome por GroupName e não funcionou

Edited by Niick
  • Moderators
Posted

Mostre como ficou.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted

A linha 29 deve ficar assim:

if ( isObjectInACLGroup ("user."..accName, aclGetGroup( GroupName ) ) ) then

Sempre que for testar um script, deixei seu debug ativado com o comando /debugscript 3

  • Thanks 1

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
16 hours ago, DNL291 said:

A linha 29 deve ficar assim:


if ( isObjectInACLGroup ("user."..accName, aclGetGroup( GroupName ) ) ) then

Sempre que for testar um script, deixei seu debug ativado com o comando /debugscript 3

Muito Obrigado!!!

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