Jump to content

alex17"

Members
  • Posts

    163
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by alex17"

  1. local peds = [] addEventHandler( "onClientElementStreamIn", root, function () if getElementType(source) == "ped" and not peds[source] then peds[source] = source end end ) addEventHandler( "onClientElementStreamOut", root, function () if peds[source] then peds[source] = nil end end ) addEventHandler("onClientElementDestroy", root, function () if peds[source] then peds[source] = nil end end ) addEventHandler("onClientRender", root, function() for _, ped in ipairs(peds) do local x, y, z = getElementPosition(ped) dxDraw(...) ... end end ) Puedes usar onClientElementStreamIn para almacenar en una tabla los peds que empiezan a trasmitir y luego onClientElementStreamOut para eliminarlos de la tabla cuando ya no trasmitan, luego en la función para los dx solo dibuja los dx en los peds que esten en la tabla que en teoria son los que estan cerca a ti
  2. There are many ways to do it, I will leave you a small simple example. local path = "phone.png" local x, y, w, h = 969, 618, 220, 423 local isDraw = true showCursor(true) function drawImage() dxDrawImage(x, y, w, h, path, 0, 0, 0, tocolor(255, 255, 255, 255), true) -- draw image if isImage true end addEventHandler("onClientRender", root, drawImage) addEventHandler("onClientClick", root function() if isMouseInPosition ( x, y, w, h ) then path = "phone_main.png" end end ) bindKey("i", "down", function() if isDraw then isDraw = false showCursor(false) removeEventHandler("onClientRender", root, drawImage) end end ) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end
  3. local maxHealth = getElementData(localPlayer, "maxhealth") or 100 local health = getElementHealth(localPlayer) local percent = health / maxHealth dxDrawRectangle(x, y, w * percent, h, ...)
  4. Marker = createMarker( 1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0) function openwindow(thePlayer) triggerClientEvent(thePlayer,"opengui1window", thePlayer, thePlayer) end addEventHandler("onMarkerHit", Marker, openwindow)
  5. function comprarskin(id, valor) takePlayerMoney(client, valor) setElementModel(client, id) end addEvent("ponerskin", true) addEventHandler("ponerskin", root, comprarskin)
  6. addEventHandler( "onPlayerWasted", root, function() spawnpoints[source] = {getElementPosition(source)} end ) addCommanHandler("respawn", function(player) if isDead(player) then return end if spawnpoints[player] then setElementPosition(player, unpack(spawnpoints[player])) end end )
  7. addEventHandler("onPlayerLogin", root, function(_, account) setAccountData(account, "lastconnection", getRealTime().timestamp) end ) addCommandHandler("login", function(player, _, accountName) if accountName then local account = getAccount(accountName) if account then local lastconnection = getAccountData(account, "lastconnection") if lastconnection then outputChatBox("Last Connection "..formatDate(lastconnection), player) end end end end ) function formatDate ( timestamp ) if ( tonumber ( timestamp ) ) then local time = getRealTime ( timestamp ) return string.format ( "%02d.%02d.%02d", time.monthday, time.month + 1, time.year + 1900, time.hour, time.minute ) end end you can guide yourself from this example
  8. local marker = createMarker(...) addCommandHandler("teleport", function(player) local vehicle = getPedOccupiedVehicle(player) if vehicle and isElementWithinMarker(vehicle, marker) then setElementPosition(vehicle, ...) setElementPosition(player, ...) end end )
  9. addEventHandler('onPlayerChat', root, function(msg, type) -- blank message patch local firstCharacter = string.sub(msg, 1, 1) if ( string.byte(firstCharacter) == 32 ) then outputChatBox( "Invalid text input." ) return end if type == 0 then cancelEvent() if not hasObjectPermissionTo(source, "command.kick") and not hasObjectPermissionTo(source, "command.mute") then if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then outputChatBox("Stop spamming main chat!", source, 255, 0, 0) return else chatTime[source] = getTickCount() end if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then outputChatBox("Stop repeating yourself!", source, 255, 0, 0) return else lastChatMessage[source] = msg end end if isElement(source) then local r, g, b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source) .. ': #FFFFFF' .. stripHex(msg), root, r, g, b, true) outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg ) end end end )
  10. the radius is the size that the colshapere will have, then when a player enters that radius the store will be activated. For example, if you put radius = 3, the store will activate when the players enter from the creation point 3 meters around But you are using a marker I would recommend you stick with just the marker and use onMarkerHit instead of onColShapeHit On the other hand, I would recommend you read the mta wiki to familiarize yourself with the functions you work with and their arguments. https://wiki.multitheftauto.com/wiki/CreatePed https://wiki.multitheftauto.com/wiki/CreateColSphere
  11. change the restriction of the command to Acl Admin, use that as an example and change the rest is not complicated
  12. ----------------------------[GO TO PLAYER]--------------------------------------- function gotoPlayer(thePlayer, commandName, target) if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) then if commandName:lower() == "goto" then if not (target) then outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target) if targetPlayer then local logged = getElementData(targetPlayer, "loggedin") if (logged==0) then outputChatBox("Player is not logged in.", thePlayer, 255, 0 , 0) else detachElements(thePlayer) local x, y, z = getElementPosition(targetPlayer) local interior = getElementInterior(targetPlayer) local dimension = getElementDimension(targetPlayer) local r = getPedRotation(targetPlayer) -- Maths calculations to stop the player being stuck in the target x = x + ( ( math.cos ( math.rad ( r ) ) ) * 2 ) y = y + ( ( math.sin ( math.rad ( r ) ) ) * 2 ) setCameraInterior(thePlayer, interior) if (isPedInVehicle(thePlayer)) then local veh = getPedOccupiedVehicle(thePlayer) setElementAngularVelocity(veh, 0, 0, 0) setElementInterior(thePlayer, interior) setElementDimension(thePlayer, dimension) setElementInterior(veh, interior) setElementDimension(veh, dimension) setElementPosition(veh, x, y, z + 1) warpPedIntoVehicle ( thePlayer, veh ) setTimer(setElementAngularVelocity, 50, 20, veh, 0, 0, 0) else setElementPosition(thePlayer, x, y, z) setElementInterior(thePlayer, interior) setElementDimension(thePlayer, dimension) end outputChatBox(" You have teleported to player " .. targetPlayerName .. ".", thePlayer) triggerEvent ( "frames:loadInteriorTextures", thePlayer, dimension ) -- Adams if exports.integration:isPlayerSupporter(thePlayer) then outputChatBox(" Supporter " .. username .. " has teleported to you. ", targetPlayer) else local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") if hiddenAdmin == 0 then outputChatBox(" Admin " .. username .. " has teleported to you. ", targetPlayer) end end end end end else local username = getPlayerName(thePlayer) local logged = getElementData(target, "loggedin") if (logged==0) then outputChatBox("Player is not logged in.", thePlayer, 255, 0 , 0) else detachElements(thePlayer) local x, y, z = getElementPosition(target) local interior = getElementInterior(target) local dimension = getElementDimension(target) local r = getPedRotation(target) -- Maths calculations to stop the player being stuck in the target x = x + ( ( math.cos ( math.rad ( r ) ) ) * 2 ) y = y + ( ( math.sin ( math.rad ( r ) ) ) * 2 ) setCameraInterior(thePlayer, interior) if (isPedInVehicle(thePlayer)) then local veh = getPedOccupiedVehicle(thePlayer) setElementAngularVelocity(veh, 0, 0, 0) setElementInterior(thePlayer, interior) setElementDimension(thePlayer, dimension) setElementInterior(veh, interior) setElementDimension(veh, dimension) setElementPosition(veh, x, y, z + 1) warpPedIntoVehicle ( thePlayer, veh ) setTimer(setElementAngularVelocity, 50, 20, veh, 0, 0, 0) else setElementPosition(thePlayer, x, y, z) setElementInterior(thePlayer, interior) setElementDimension(thePlayer, dimension) end outputChatBox(" You have accepted teleport request from " .. getPlayerName(target):gsub("_", " ") .. ".", thePlayer) triggerEvent ( "frames:loadInteriorTextures", thePlayer, dimension ) -- Adams if exports.integration:isPlayerSupporter(thePlayer) then outputChatBox(" Supporter " .. username .. " has accepted your teleport request. ", target) else outputChatBox(" Admin " .. username .. " has accepted your teleport request.", target) end end end end end addCommandHandler("goto", gotoPlayer, false, false) function getPlayer(thePlayer, commandName, from, to) if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) then if(not from or not to) then outputChatBox("SYNTAX: /" .. commandName .. " [Sending Player] [To Player]", thePlayer, 255, 194, 14) else local admin = getPlayerName(thePlayer):gsub("_"," ") local fromplayer, targetPlayerName1 = exports.global:findPlayerByPartialNick(thePlayer, from) local toplayer, targetPlayerName2 = exports.global:findPlayerByPartialNick(thePlayer, to) if(fromplayer and toplayer) then local logged1 = getElementData(fromplayer, "loggedin") local logged2 = getElementData(toplayer, "loggedin") if(not logged1 or not logged2) then outputChatBox("At least one of the players is not logged in.", thePlayer, 255, 0 , 0) else detachElements(fromplayer) local x, y, z = getElementPosition(toplayer) local interior = getElementInterior(toplayer) local dimension = getElementDimension(toplayer) local r = getPedRotation(toplayer) -- Maths calculations to stop the target being stuck in the player x = x + ( ( math.cos ( math.rad ( r ) ) ) * 2 ) y = y + ( ( math.sin ( math.rad ( r ) ) ) * 2 ) if (isPedInVehicle(fromplayer)) then local veh = getPedOccupiedVehicle(fromplayer) setElementAngularVelocity(veh, 0, 0, 0) setElementPosition(veh, x, y, z + 1) setTimer(setElementAngularVelocity, 50, 20, veh, 0, 0, 0) setElementInterior(veh, interior) setElementDimension(veh, dimension) else setElementPosition(fromplayer, x, y, z) setElementInterior(fromplayer, interior) setElementDimension(fromplayer, dimension) end outputChatBox(" You have teleported player " .. targetPlayerName1:gsub("_"," ") .. " to " .. targetPlayerName2:gsub("_"," ") .. ".", thePlayer) triggerEvent ( "frames:loadInteriorTextures", fromplayer, dimension ) -- Adams local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") if hiddenAdmin == 0 then outputChatBox(" An admin " .. admin .. " has teleported you to " .. targetPlayerName2:gsub("_"," ") .. ". ", fromplayer) outputChatBox(" An admin " .. admin .. " has teleported " .. targetPlayerName1:gsub("_"," ") .. " to you.", toplayer) else outputChatBox(" An hidden admin has teleported you to " .. targetPlayerName2:gsub("_"," ") .. ". ", fromplayer) outputChatBox(" An hidden admin has teleported " .. targetPlayerName1:gsub("_"," ") .. " to you.", toplayer) end end end end end end addCommandHandler("sendto", getPlayer, false, false) ----------------------------[GET PLAYER HERE]--------------------------------------- function getPlayer(thePlayer, commandName, target) if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) then if not target then outputChatBox("SYNTAX: /" .. commandName .. " /gethere [Partial Player Nick]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target) if targetPlayer then local logged = getElementData(targetPlayer, "loggedin") if (logged==0) then outputChatBox("Player is not logged in.", thePlayer, 255, 0 , 0) else local playerAdmLvl = getElementData( thePlayer, "admin_level" ) or 0 local targetAdmLvl = getElementData( targetPlayer, "admin_level" ) or 0 if (playerAdmLvl < targetAdmLvl) then outputChatBox("Sending "..targetPlayerName.." teleporting request as they're higher rank than you.", thePlayer, 255, 194, 14) outputChatBox(getPlayerName(thePlayer):gsub("_", " ").." wants to teleport you to them. /atp to accept, /dtp to deny.", targetPlayer, 255, 194, 14) setElementData(targetPlayer, "teleport:targetPlayer", thePlayer) return end detachElements(targetPlayer) local x, y, z = getElementPosition(thePlayer) local interior = getElementInterior(thePlayer) local dimension = getElementDimension(thePlayer) local r = getPedRotation(thePlayer) setCameraInterior(targetPlayer, interior) -- Maths calculations to stop the target being stuck in the player x = x + ( ( math.cos ( math.rad ( r ) ) ) * 2 ) y = y + ( ( math.sin ( math.rad ( r ) ) ) * 2 ) if (isPedInVehicle(targetPlayer)) then local veh = getPedOccupiedVehicle(targetPlayer) setElementAngularVelocity(veh, 0, 0, 0) setElementPosition(veh, x, y, z + 1) setTimer(setElementAngularVelocity, 50, 20, veh, 0, 0, 0) setElementInterior(veh, interior) setElementDimension(veh, dimension) else setElementPosition(targetPlayer, x, y, z) setElementInterior(targetPlayer, interior) setElementDimension(targetPlayer, dimension) end outputChatBox(" You have teleported player " .. targetPlayerName .. " to you.", thePlayer) triggerEvent ( "frames:loadInteriorTextures", targetPlayer, dimension ) -- Adams if exports.integration:isPlayerSupporter(thePlayer) then outputChatBox(" Supporter " .. username .. " has teleported you to them. ", targetPlayer) else local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") if hiddenAdmin == 0 then outputChatBox(" Admin " .. username .. " has teleported you to them. ", targetPlayer) end end end end end end end addCommandHandler("gethere", getPlayer, false, false)
  13. you just want to remove the export or you want to replace it with something else like ACL ?
  14. ped = createPed("modelID", 413.712890625, 2537.95703125, 19.1484375, false) you did not put the ped model id
  15. my bad -- Client local boxes = { {2969, 2484.1240234375, -1519.0988769531, 23.9921875, 0, 0, 55.477935791016}, } -- //////////////////// LOAD BOXES //////////////////// -- for i,v in ipairs(boxes) do local r = math.random(1,270) if isElement(boxes[i][8]) then destroyElement(boxes[i][8]) end boxes[i][8]= createObject(v[1], v[2], v[3], v[4]-0.9, 0, 0, r) end -- Client function takeBox(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if element and getElementType(element) == "object" and button == "left" and state == "down" then local x, y, z = getElementPosition(localPlayer) local x1, y1, z1 = getElementPosition(element) local distance = getDistanceBetweenPoints3D(x,y,z,x1,y1,z1) if distance < 3 then if getElementModel(element) == 2969 then setElementData(localPlayer, "boxes", boxes+1) for index, v in ipairs(boxes) do if v[8] and isElement(v[8]) then if v[8] == element then triggerServerEvent("destroyBox", localP, index) break end end end end end end end end --- server -- addEvent("destroyBox", true) addEventHandler("destroyBox", root, function(index) triggerClientEvent(root, "destroyBox", root, index) end ) -- client --- addEvent("destroyBox", true) addEventHandler("destroyBox", root, function(index) if boxes[index] and boxes[index][8] and isElement( boxes[index][8]) then destroyElement( boxes[index][8] ) end end )
  16. -- Client local boxes = { {2969, 2484.1240234375, -1519.0988769531, 23.9921875, 0, 0, 55.477935791016}, } -- //////////////////// LOAD BOXES //////////////////// -- for i,v in ipairs(boxes) do local r = math.random(1,270) if isElement(boxes[i][8]) then destroyElement(boxes[i][8]) end boxes[i][8]= createObject(v[1], v[2], v[3], v[4]-0.9, 0, 0, r) end -- Client function takeBox(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if element and getElementType(element) == "object" and button == "left" and state == "down" then local x, y, z = getElementPosition(localPlayer) local x1, y1, z1 = getElementPosition(element) local distance = getDistanceBetweenPoints3D(x,y,z,x1,y1,z1) if distance < 3 then if getElementModel(element) == 2969 then setElementData(localPlayer, "boxes", boxes+1) for index, v in ipairs(boxes) do if v[8] and isElement(v[8]) then if v[8] == element then triggerClientEvent("destroyBox", localP, index) break end end end end end end end end --- server -- addEvent("destroyBox", true) addEventHandler("destroyBox", root, function(index) triggerClientEvent(root, "destroyBox", root, index) end ) -- client --- addEvent("destroyBox", true) addEventHandler("destroyBox", root, function(index) if boxes[index] and boxes[index][8] and isElement( boxes[index][8]) then destroyElement( boxes[index][8] ) end end )
  17. no acabe de entenderte muy bien, tal vez si muestras lo que estas haciendo pueda entenderte mejor Por otro lado Guarda las armas en una tabla y luego usa table.insert asi se ira añadiendo esa armas una debajo de otra
  18. local ped = createPed(...) setPedVoice(ped, "PED_TYPE_DISABLED", "nil")
  19. local players = {} local maxItems = 10 local scroll = 0 local open = false bindKey("tab", "down", function manageScoreboard() if not open then open = true players = nil players = {} for _, player in ipairs(getElementsByType("player") do table.insert(players, player) end bindKey("mouse_wheel_up", "down", mouseWheel) bindKey("mouse_wheel_down", "down", mouseWheel) addEventHandler("onClientRender", root, dxDrawScoreboard) else open = false unbindKey("mouse_wheel_up", "down", mouseWheel) unbindKey("mouse_wheel_down", "down", mouseWheel) removeEventHandler("onClientRender", root, dxDrawScoreboard) end end ) function mouseWheel(key) if key == "mouse_wheel_down" then if scroll < (players - maxItems) then scroll = scroll + 1 end else if scroll > 0 then scroll = scroll - 1 end end end function dxDrawScoreboard() local cache = 0 for i = 1 + scroll, maxItems + scroll do local player then yers[i] if player then dxDrawRectangle(0, cache, 400, 100, "0x96000000") dxDrawText(getPlayerName(player), 0, cache, 400, 100 + cache) cache = cache + 100 end end end I leave you a very basic example so you can guide yourself
  20. alex17"

    Table

    local model = Items.Five["vehicle"] createVehicle(model, ...) local objectID = Items.Four.Gate local first = Items.Four.Base["First"] local last = Items.Four.Base["Last"] createObject(ObjectID, ...)
  21. I managed to avoid the bug by using a timer before transporting the vehicle. First I remove the player from the vehicle and transport him to the position, then with a timer I transport the vehicle addCommandHandler("tp", function(player) local vehicle = player.vehicle if vehicle then player:removeFromVehicle() player:setPosition(1660.8480224609, -2629.8156738281, 13.54687) Timer(function() vehicle:setPosition(1660.8480224609, -2629.8156738281, 13.54687) player:warpIntoVehicle(vehicle) end, 50, 1) end end )
  22. alex17"

    Blip dimensions

    It would no longer be necessary to refresh by deleting the blips and recreating them, since you already created all the blips in their respective dimensions.
  23. onPlayerWeaponFire is a server event use onClientPlayerWeaponFire
  24. You are doing everything in the client, that will make the changes only affect the local player What you need is to send from the server to all the players/clients the information of the vehicle and the component client function sacarColinF() -- This function disappears the component local theVehicle = getPedOccupiedVehicle(localPlayer) if (theVehicle) then -- We send the information to the server and the server will send the information to all clients triggerServerEvent("setComponentVisible", localPlayer, theVehicle, "colin" , false) end end addEventHandler("onClientGUIClick", sacarColin, sacarColinF) function ponerColinF() -- This function returns the visibility to the previous component local theVehicle = getPedOccupiedVehicle(localPlayer) if (theVehicle) then -- We send the information to the server and the server will send the information to all clients triggerServerEvent("setComponentVisible", localPlayer, theVehicle, "colin" , true) end end addEventHandler("onClientGUIClick", ponerColin, ponerColinF) -- This event is what the server sends to all clients to make the component visible / invisible addEvent("setComponentVisible", true) addEventHandler("setComponentVisible", root, function(vehicle, component, visible) setVehicleComponentVisible(vehicle, component, visible) end ) -- This event is sent by the server to the player who has just connected so that he can see the changes in the vehicles addEvent("setVehicleComponentsVisible", true) addEventHandler("setVehicleComponentsVisible", root, function(vehicles) for vehicle, components in pairs(vehicles) do if isElement(vehicle) then for component, visible in pairs(components) do setVehicleComponentVisible(vehicle, component, visible) end end end end ) server local vehicles = {} --save changes to vehicles in this table for players joining the server addEvent("setComponentVisible", true) addEventHandler("setComponentVisible", root, function(vehicle, component, visible) if not vehicles[vehicle] then vehicles[vehicle] = {} end if not vehicles[vehicle][component] then vehicles[vehicle][component] = visible end triggerClientEvent(root, "setComponentVisible", root, vehicle, component, visible) end ) -- When a player enters the server they will not see the changes that were made before connecting. the server will send the information to that client so that it can see the changes addEventHandler("onPlayerJoin", root, function() triggerClientEvent(source, "setVehicleComponentsVisible", source, vehicles) end )
  25. function giveVehicle(player) local v = createVehicle(....) warpPedIntoVehicle(player, v) setElementPosition(v, ...) setTimer(function(player) destroyElement(v) if isElement(player) then setElementPosition(player, ...) end end, 120000, 1, player) end function test(player) giveVehicle(player) end addCommandHandler("testvehicle", test)
×
×
  • Create New...