Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 13/03/20 in all areas

  1. Bom questionamento, porém acredito eu que não. Pois no if eu estou comparando a "data" da marker hitada, com a "data" salva na tabela. Quando o gaimo salva a marker na tabela acredito eu que seja algo mais ou menos assim: markers = { -- a tabela nomeada userdata = { -- uma segunda tabela(sub-tabela), que seria a userdata ([thePlayer]) ["StartData"] = markerData -- e por fim ele salva a "data" do marker. }, }; Seguindo a lógica acima, o que me importa é a markerData, então quando eu faço assim: if marker == markers[source]["StartMarker"] then Eu to querendo dizer: SE a data da marker hitada é equivalente a data que esta dentro da sub-tabela(source, que no caso é a userdata) com index de ["StartMarker"] então faça: Abaixo o código, testado: veh = {}; markers = {}; for i=1,6 do veh[createVehicle(459, 1700.75781 + 3*i, -1806.09680, 13.54688, 0,0,0)] = true; createBlip(1700.75781, -1806.09680, 13.54688); end addEventHandler ( "onVehicleEnter", getRootElement(), function(thePlayer, seat) if not markers[thePlayer] then markers[thePlayer] = {}; end if veh[getPedOccupiedVehicle(thePlayer)] then markers[thePlayer]["StartMarker"] = createMarker(1683.57776, -1811.70239, 13.54688 - 0.8, "cylinder", 3, 255, 0, 0, 255, thePlayer); createMarker(1683.57776, -1811.70239 + 5, 13.54688 - 0.8, "cylinder", 3, 0, 255, 0, 255, thePlayer); createBlipAttachedTo(markers[thePlayer]["StartMarker"]); outputChatBox("marker table: "..tostring(markers[thePlayer]), thePlayer, 255, 255, 0); -- debug outputChatBox("marker data: "..tostring(markers[thePlayer]["StartMarker"]), thePlayer, 255, 255, 0); -- debug end end) addEventHandler("onPlayerMarkerHit", getRootElement(), function(marker, dim) if dim then outputChatBox("onHit: "..tostring(marker), source, 0, 255, 0); -- debug if marker ~= markers[source]["StartMarker"] then -- se for diferente outputChatBox("o marker é diferente", source, 255, 0, 0); else -- se for igual outputChatBox("o marker é igual", source, 0, 255, 0); end end end) addCommandHandler("teste", function(player) for index, value in pairs(markers) do -- se fizer com ipairs não irá funcionar, por causa do "StartMarker" outputChatBox(" #ff0000indexado: #ffffff"..tostring(index).." #ff0000tabela: #ffffff"..tostring(value).." #ff0000valorReal: #ffffff"..tostring(value["StartMarker"]),player, 255, 0, 255, true); end end ) Abaixo mais uma "prova" dessa explicação, agora com tudo declarado: test = { -- tabela nomeada test2 = { -- "sub-tabela" ["value"] = 10, -- index contendo o valor desejado. }, }; for i, v in pairs(test) do outputChatBox(tostring(v["value"])); end OBS (muito importante): Eu tenho absoluta certeza do que estou falando? R: Nem um pouco, provavelmente posso estar falando groselha, e se estiver quem souber melhor por favor comente xD. Porém os códigos acima foram testados e funcionou! @Angelo Pereira
    1 point
  2. Basta verificar no evento onClientMarkerHit se o hitElement é igual a localPlayer addEventHandler( "onClientMarkerHit", getRootElement(), function (thePlayer, dim) -- Source = Marker que o player hitou if dim and thePlayer == localPlayer then if source == getJob and not isPedInVehicle(thePlayer) then showPanel(thePlayer) end if source == startMarker then -- Avisar se o jogador já tem as caixas e não pode pegar mais if aBoxes >= 10 then outputChatBox("Aviso, player ja tem as caixas") return end -- Roda alguma animacao frozen(thePlayer, 3000) -- Seta a quantidade de caixas pra 10 aBoxes = 3 -- Gera uma rota aleatoria setTimer(function() rota() end, 3000, 1) end -- Se o marker existe e eh o destino do player if target ~= nil and source == target then del() frozen(thePlayer, 3000) -- Paga o player setElementData(localPlayer, "dinheiro", math.random(100, 200)) -- Faz alguma animacao e para o carro -- Diminui uma caixa aBoxes = aBoxes - 1 -- Informa a quantidade de caixas outputChatBox("Caixas restantes: "..aBoxes) if aBoxes > 0 then -- Gera uma rota aleatoria setTimer(function() rota() end, 3000, 1) elseif aBoxes == 0 then outputChatBox("Retorne ao estoque para pegar mais caixas.") end end end end)
    1 point
  3. Na função createMarker(server-side) tem um argumento que você pode especificar para qual elemento o marker deve ser visível, e também há uma função chamada setElementVisibleTo que você pode usar para definir quem poderá ver o marker.
    1 point
  4. Acho, que fazendo dessa maneira markers[thePlayer]["StartMarker"], vai retorna em nil value.
    1 point
  5. Are you calling the function "collectgarbage" as XaskeL has suggested? I am not seeing it in your code that you posted above.
    1 point
  6. Set txd and dff to nil too after replace.
    1 point
  7. You must remove all references to the buffer variable and call "collectgarbage ()" after replacing the model, thereby freeing memory from unused data in the variables
    1 point
  8. السعر حرية شخصية يضعها صاحب السكربت حسب المجهود الذي بذله، اذا ما عجبك السعر ماهو مطلوب منك تنتقد وتطقطق
    1 point
×
×
  • Create New...