Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 20/07/23 in all areas

  1. Hola, buenas noches. Vale, para analizar, estás añadiendo estos eventos de onMarkerHit, a todos los markers (root) -- Asignar la función tomarMarker al evento onMarkerHit addEventHandler("onMarkerHit", root, function(hitElement, matchingDimension) if isElement(marker) and source == marker and getElementType(hitElement) == "player" then tomarMarker(hitElement) end end) -- Asignar la función avisarPolicial al evento onMarkerHit addEventHandler("onMarkerHit", root, function(hitElement, matchingDimension) if isElement(marker) and source == marker and getElementType(hitElement) == "player" then avisarPolicial() end end) Esto es una mala practica, ya que sería más óptimo sólo 'atachar' ese evento sólamente al elemento que haga falta y que nos sea necesario, un cierto marker por ejemplo. Pero dejemos de lado esto. Estás verificando bien, que el source, sea el marker en cuestión, sin embargo, acá está la falla, en ningun momento se crea el marker ese del que hablamos. Podes hacer que el marker se cree al inicio del script (funcion que se ejecuta con el onResourceStart) y ahí mismo, añadir los addEventHandlers de tomarMarker() y avisarPolicial(), 'atachado' a ese marker recién creado.
    1 point
  2. local comandos = {"login", "logout", "testando"} -- Lista de comandos que não podem ser bindados. function playerPressedKey(button, press) if (press) then -- Se o jogador apertou a tecla, então: local bindados = getCommandsBoundToKey(button, "down") -- Obtém uma lista de comandos bindados a essa tecla que o jogador acabou de apertar. O comando é o índice e o argumento é o valor. if table.size(bindados) == 0 then return end -- Se não há nada bindado nesta tecla (a função acima retornou uma tabela vazia), então nada acontece. for cmd,v in pairs(bindados) do -- Para cada comando bindado nesta tecla, faça: for _,cmds in pairs(comandos) do -- Para cada comando que não pode ser bindado, faça: if cmd == cmds then -- Se o comando bindado nesta tecla está na lista de comandos proibidos, então: outputChatBox("O comando '"..cmd.."' não pode ser bindado.") cancelEvent() return end end end end end addEventHandler("onClientKey", root, playerPressedKey) addCommandHandler("testando", function(cmd) -- Comando genérico só para saber se ele está sendo executado ou não. outputChatBox("Você está testando.") end) function table.size(theTable) -- Função útil que conta quantos elementos tem uma tabela. Quando usar #tabela não funcionaria. local size = 0 for _, v in pairs(theTable) do size = size + 1 end return size end Os comandos continuam funcionando fora da bind (digitados manualmente).
    1 point
×
×
  • Create New...