Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function crearNPCsTiendas()
- local x, y, z, rx, ry, rz, int, dim, blipx, blipy, blipz = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
- local varNPC
- local varColision
- local varListaNPCs = exports["MR1_Inicio"]:query("SELECT * FROM NPCRobos")
- if not varListaNPCs then return end
- -- Iterar sobre cada interior y crear los pickups de entrada y salida
- for i, NPCs in ipairs(varListaNPCs) do
- --outputChatBox("Creando NPC en: " .. x .. ", " .. y .. ", " .. z .. " | Interior: " .. int .. " | Dimensión: " .. dim)
- varNPC = createPed(30, NPCs.posX, NPCs.posY, NPCs.posZ) -- ID del skin 30 (puedes cambiarlo)
- setElementRotation(varNPC, NPCs.rotX, NPCs.rotY, NPCs.rotZ)
- setElementInterior(varNPC, NPCs.Interior)
- setElementDimension(varNPC, NPCs.Dimension)
- setElementData(varNPC, "ID", i)
- -- Crear ColShape alrededor del NPC
- varColision = createColSphere(NPCs.posX, NPCs.posY, NPCs.posZ, 3) -- Radio de 2 metros
- setElementInterior(varColision, NPCs.Interior)
- setElementDimension(varColision, NPCs.Dimension)
- npcCols[varNPC] = varColision;
- npcData[varNPC] = {
- x = NPCs.blipx,
- y = NPCs.blipy,
- z = NPCs.blipz,
- int = NPCs.Interior,
- dim = NPCs.Dimension,
- col = varColision,
- robo = false,
- ladron = false,
- cooldown = false,
- maxRecompensa = 0,
- acumulado = 0
- }
- addEventHandler("onColShapeHit", varColision, function(source, Dimension)
- if not (getElementType(source) == "player") or isPedInVehicle(source) then
- return
- end
- local playerDim = getElementDimension(source)
- local colDim = getElementDimension(varColision)
- if playerDim == colDim then
- outputChatBox("#9AA498[#FF7800NPC#9AA498] #53B440Presiona #FFFFFFH #53B440 para robar la tienda.", source, 255, 255, 255, true)
- bindKey(source, "H", "down", function()
- iniciarRobo(source, varNPC)
- --outputChatBox("Has presionado H frente al NPC con ID: " .. getElementData(varNPC, "ID"), source, 255, 255, 255)
- end)
- end
- end)
- addEventHandler("onColShapeLeave", varColision, function(source)
- if getElementType(source) == "player" then
- if (npcData[varNPC].robo == true) then
- if npcData[varNPC].ladron == source then
- outputChatBox("Has dejado la zona del robo, el robo ha sido cancelado.", source, 255, 0, 0)
- finalizarRobo(source, varNPC)
- end
- end
- unbindKey(source, "H")
- end
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement