Jump to content

ExMohmD

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by ExMohmD

  1. First, you need to create a table that stores the information about each road and its barriers. Each road will have an associated number of barriers and a flag indicating whether it should be blocked initially or not. During the map load or initialization, you'll check the flags and add barriers to the roads accordingly. After each map reload, you'll remove a barrier randomly from the initially blocked roads. Here's a basic implementation of the concept: -- Define the roads and barriers data table local roadsData = { { name = "Doherty", numBarriers = 3, blockedInitially = true }, { name = "ExampleRoad1", numBarriers = 2, blockedInitially = false }, { name = "ExampleRoad2", numBarriers = 1, blockedInitially = false }, -- Add more roads here as needed } -- Function to add barriers to a road function addBarriersToRoad(roadData) local roadName = roadData.name local numBarriers = roadData.numBarriers for i = 1, numBarriers do -- Add code to create barriers on the road (e.g., createObject) -- The exact code depends on your map and barrier objects -- Example: createObject(x, y, z, model) end end -- Function to remove a random barrier from a road function removeRandomBarrierFromRoad(roadData) local roadName = roadData.name local numBarriers = roadData.numBarriers if numBarriers > 0 then local barrierIndex = math.random(1, numBarriers) -- Remove code to destroy the barrier (e.g., destroyElement) -- The exact code depends on how you created the barriers -- Example: destroyElement(barrierObjects[roadName][barrierIndex]) -- Make sure to keep track of the barrier objects using a table if needed. end end -- Function to initialize roads and barriers function initializeRoadsAndBarriers() for _, roadData in ipairs(roadsData) do if roadData.blockedInitially then addBarriersToRoad(roadData) end end end -- Initialize the roads and barriers when the resource starts addEventHandler("onResourceStart", resourceRoot, initializeRoadsAndBarriers) -- Function to handle map reload event function onMapReload() for _, roadData in ipairs(roadsData) do if roadData.blockedInitially then removeRandomBarrierFromRoad(roadData) end end end -- Register the map reload event addEventHandler("onMapLoad", root, onMapReload) In this example, we defined the roads and barriers in the roadsData table. The initializeRoadsAndBarriers function checks the blockedInitially flag for each road and adds barriers accordingly during the resource start. The onMapReload function removes one random barrier from the initially blocked roads after each map reload. Remember that you may need to adapt the code depending on your specific map and barrier objects. Additionally, you should handle errors and edge cases to ensure the script works correctly in various scenarios.
  2. The issue in your code is that you are passing the "root" element to the server-side function as the argument and trying to use it as a player (ped). The "root" element is typically used on the client-side to refer to the root element of the resource, and it does not represent a player or ped on the server-side. To fix this, you need to pass the correct player (ped) element from the client-side to the server-side. You can do this by using the "source" keyword on the server-side, which represents the player who triggered the event. Here's the modified code: Client-side code: lua addEventHandler("onClientKey", root, function (button, press) if button == "j" then triggerServerEvent("jetpackClicked", localPlayer) -- Pass localPlayer as an argument end end) Server-side code: addEvent("jetpackClicked", true) addEventHandler('jetpackClicked', root, function () local player = source -- Use the "source" keyword to get the player element if player and isElement(player) and getElementType(player) == "player" then setPedWearingJetpack(player, not isPedWearingJetpack(player)) end end) Now, when the client triggers the "jetpackClicked" event, it will pass the localPlayer (the player who pressed the "j" key) as the argument to the server-side function. The server-side function will then use the "source" keyword to get the correct player element and toggle their jetpack accordingly.
  3. To achieve the functionality you described, you can modify the code to include a check to ensure that only one person with the same skin can see the marker, and the marker only flashes once when it is on the wrong skin. We will create a system that ensures the marker is visible only to the correct player and flashes only once for the incorrect player. First, let's create a table to keep track of players and their associated markers: local skinMarkers = {} Now, modify the unit1 function as follows: function unit1() local playerskin = getElementModel(source) local x, y, z = getElementPosition(source) if (validSkin[playerskin]) then if not (status2) then status = false status3 = false -- Check if the player already has a marker if skinMarkers[source] then -- If the player already has a marker, destroy it destroyElement(skinMarkers[source].marker) end -- Create the blip and marker for the correct skin local statusB2 = createBlipAttachedTo(source, 0, 4, 0, 0, 255) local statusMarker1 = createMarker(x, y, z, "checkpoint", 4, 255, 0, 0) destroyElement(statusMarker) -- Store the marker and blip in the table for later use skinMarkers[source] = { marker = statusMarker1, blip = statusB2, skin = playerskin, flashing = false, -- Add a flashing flag } attachElements(statusMarker1, source) outputChatBox("#898c8f<<#2c469cNeXoN Roleplay#898c8f>> #0f5720Sikeressen megváltoztatad az egységed állapotát: #ffffff||Üldözés||", source, 255, 255, 255, true) status2 = true else outputChatBox("#898c8f<<#2c469cNeXoN Roleplay#898c8f>> #0f5720Már ez az egységed állapota.", source, 255, 255, 255, true) end end end Now, let's modify the checkSkin function to handle visibility and flashing: function checkSkin() local playerskin = getElementModel(source) local markerData = skinMarkers[source] if (validSkin[playerskin]) then setElementAlpha(markerData.marker, 255) -- If the player has the wrong marker and it hasn't flashed yet, make it flash once if markerData.skin ~= playerskin and not markerData.flashing then markerData.flashing = true setTimer(function() setElementAlpha(markerData.marker, 0) end, 1000, 1) -- Flash for 1 second (adjust the duration as needed) end else setElementAlpha(markerData.marker, 0) end end addEventHandler("onElementModelChange", root, checkSkin) This code should now provide the functionality you described. The marker will be visible only to the player with the correct skin, and it will flash once for the player with the incorrect skin. Additionally, the flashing will occur only once for the player with the wrong skin.
  4. It seems like you have encountered an issue with the ped lighting after disabling collisions for the peds. You are correct that disabling collisions with the setElementCollisionsEnabled function could potentially affect the lighting as well, as lighting in games often relies on collision information to calculate shadows and other visual effects. To maintain the normal lighting for the peds while still disabling collisions with objects, you can try a different approach: Collision Groups: In many game engines, including Grand Theft Auto (GTA) modding, there are collision groups that define how objects interact with each other. You can assign the peds to a separate collision group that does not collide with objects like tables. This way, the peds won't be blocked by tables, but their lighting should remain unaffected. Alternate Collision Shapes: Instead of disabling the entire collision, you can try using simplified collision shapes for the peds. For example, you can use a cylinder or a capsule as the collision shape for the ped instead of the full complex shape. This will allow the ped to move freely without getting stuck on objects, while still providing some basic collision for lighting calculations. Lighting Tweaks: If the lighting issue persists, you may need to tweak the lighting settings or add additional lights to the scene to compensate for the lack of collision data. For instance, you could add ambient or fill lights to brighten up the area where the peds are located. Remember that the specifics of implementing these solutions may depend on the game engine or modding framework you are using. Make sure to refer to the documentation or community resources for the specific modding tools you are working with. Lastly, it's always a good idea to test each change you make in isolation, so you can identify the exact cause of the issue and better understand how different settings affect the game environment.
  5. It seems like the issue is with the event handler for resetting the gate. The onClientClick event handler is triggering the gate to open but not closing it. The Reset event is supposed to close the gate, but there's a problem with its implementation. To fix this, you should modify the Reset event handler to close the gate when it is triggered. Also, it's better to use a single event handler for both opening and closing the gate. Here's the revised code: local sx, sy = guiGetScreenSize(); local relx, rely = sx / 1920, sy / 1080; local GateMenu = false local GateStatus = false local TheGate = createObject(1468, 51.62455, -1524.62549, 5.05399, 0, 0, 90); local TheSensor = createColSphere(55.60476, -1524.89941, 5.00539, 3); color = tocolor(10, 20, 30, 255) color1 = tocolor(5, 10, 15, 255) addCommandHandler("devmode", function() setDevelopmentMode(true); end ) addEventHandler("onClientRender", root, function() if (GateMenu) then dxDrawRectangle(sx * .35, sy * .4, sx * .3, sy * .05, tocolor(10, 20, 10, 255)) -- fejléc dxDrawRectangle(sx * .35, sy * .4, sx * .3, sy * .40, tocolor(20, 30, 40, 200)) -- Alap dxDrawRectangle(sx * .42, sy * .6, sx * .15, sy * .08, color1) -- Gomb(Megvásárlás) dxDrawText('Határ rendszer', sx * .70, sy * .8, sx * .3, sy * .05, relx2, rely * 2, "default-bold", "center", "center", false, false, false) dxDrawText('Fizesd ki a határt ára: 5000 FT', sx * .70, sy * .9, sx * .3, sy * .05, relx2, rely * 2, "default-bold", "center", "center", false, false, false) dxDrawText('Ki fizetés', sx * .84, sy * .9, sx * .15, sy * .380, relx2, rely * 2, "default-bold", "center", "center", false, false, false) GlowedButton(); end end ) bindKey("m", "down", function() showCursor(not isCursorShowing()) end ) function isMouseInPosition(x, y, width, height) -- Kurzor lekérése 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 function GlowedButton() if (GateMenu) then if (isMouseInPosition(sx * .42, sy * .6, sx * .15, sy * .08)) then color1 = color else color1 = tocolor(5, 10, 15, 255) end end end addEventHandler("onClientElementColShapeHit", root, function(hitElement, matchingDimension) if matchingDimension then if hitElement == TheSensor then GateMenu = true end end end) addEventHandler("onClientElementColShapeLeave", root, function(hitElement, matchingDimension) if matchingDimension then if hitElement == TheSensor then GateMenu = false end end end) addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if GateMenu and button == "left" and state == "down" then if isMouseInPosition(sx * .42, sy * .6, sx * .15, sy * .08) then GateMenu = false if GateStatus then moveObject(TheGate, 5000, 51.62455, -1524.62549, 0) GateStatus = false else moveObject(TheGate, 5000, 1468, 51.62455, -1524.62549, 5.05399) GateStatus = true end end end end) Now the gate should open when you click the button and close again when you click it again. The Reset event is not needed in this case, as we can handle the gate's opening and closing in the same event handler.
  6. To make the player's ID heal when hit instead of the player's name, you need to modify the curarPlayer function to receive the player's ID as an argument instead of their name. Here's the updated version of the function: function curarPlayer(thePlayer, command, playerID) if playerID then local targetPlayer = tonumber(playerID) local targetPlayerElement = nil for _, player in ipairs(getElementsByType("player")) do if getElementData(player, "data.playerID") == targetPlayer then targetPlayerElement = player break end end if targetPlayerElement then local conta = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user."..conta, aclGetGroup("SAMU")) then local nameR = getPlayerName(targetPlayerElement) local wanted = getPlayerWantedLevel(targetPlayerElement) local px, py, pz = getElementPosition(thePlayer) local rx, ry, rz = getElementPosition(targetPlayerElement) local distancia = getDistanceBetweenPoints3D(px, py, pz, rx, ry, rz) local medKit = getElementData(thePlayer, "KitMedico") or 10000000 if distancia > 3 then outputDxBox(thePlayer, "Você precisa chegar mais perto do jogador para curá-lo.", "error") elseif distancia < 2 then if getElementData(targetPlayerElement, "playerFallen") then setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", 1000, false) if isElement(blip[targetPlayerElement]) then destroyElement(blip[targetPlayerElement]) end outputDxBox(thePlayer, "Curando jogador...", "info") setTimer(function() setPedAnimation(thePlayer, "ped", "facanger") setPedAnimation(targetPlayerElement, "ped", "facanger") end, 5000, 1) setTimer(outputDxBox, 5000, 1, thePlayer, "Você curou o jogador "..nameR, "success") setTimer(outputDxBox, 5000, 1, targetPlayerElement, "Você foi curado por um médico!", "success") setTimer(givePlayerMoney, 5000, 1, thePlayer, 3000) setTimer(setPlayerFallen, 5000, 1, targetPlayerElement, false) setTimer(function() setElementData(thePlayer, "AirNewSCR_LiberarXP", "Sim") setPedAnimation(thePlayer) setPedAnimation(targetPlayerElement) end, 6000, 1) else outputDxBox(thePlayer, "O jogador não precisa ser curado.", "error") end end else outputDxBox(thePlayer, "Permissão negada para usar o comando!", "error") end else outputDxBox(thePlayer, "ID do jogador inválido. Use /curar <ID>", "error") end else outputDxBox(thePlayer, "Erro! O correto é /curar <ID>", "error") end end addCommandHandler("curar", curarPlayer) Now, you can use the command /curar <ID> to heal the player with the specified ID. Replace <ID> with the actual ID of the player you want to heal.
  7. It seems that you want to modify the first line of code to check if the player's account name is one of the specified names ("wilmertrobert," "joan26," or "papotico02") instead of checking if the player belongs to the "Console" ACL group. The code snippet provided is in Lua (used in some game frameworks like MTA:SA). To achieve the desired change, you can modify the first line like this: if getPlayerAccount(player) == "wilmertrobert" or getPlayerAccount(player) == "joan26" or getPlayerAccount(player) == "papotico02" then This line will now check if the player's account name is one of the specified names, and if it matches, the following code block will be executed. Here's the complete code with the change: local player = -- the player object you want to check local data = -- some data you might want to use for the ban reason local additional = -- additional information (maybe ban duration) local additional2 = -- additional information (maybe use serial) if getPlayerAccount(player) == "wilmertrobert" or getPlayerAccount(player) == "joan26" or getPlayerAccount(player) == "papotico02" then outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." tried to ban you.", player, 255, 0, 0) local banner = getPlayerSerial(source) outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has been banned. [Reason: attempting to ban a staff member]", root, 255, 0, 0) setTimer ( function () addBan ( nil, nil, banner , root, "You were banned for attempting to ban a staff member") end, 500, 1) return false end local reason = data or "" local seconds = tonumber(additional) and tonumber(additional) > 0 and tonumber(additional) local bUseSerial = additional2 local isAnonAdmin = getElementData(source, "AnonAdmin") Remember to replace the player, data, additional, and additional2 variables with appropriate values depending on your context.
  8. It seems like you have implemented most of the functionality correctly. However, the issue lies in how you are saving the time settings. Currently, you are overwriting the "times.json" file every time the "/night" or "/mor" command is used. Instead, you should be updating the values in the file rather than recreating it every time. To achieve this, you can modify the server.lua file as follows: server.lua: local filename = "times.json" function saveTimeSettings(t) local file = fileCreate(filename) if file then local json = toJSON(t) fileWrite(file, json) fileClose(file) outputDebugString("Successfully saved: " .. json) else outputDebugString("Failed to save time settings.") end end function loadTimeSettings() local file = fileOpen(filename) if file then local json = fileRead(file, fileGetSize(file)) local savedSettings = fromJSON(json) if savedSettings then for i, v in pairs(savedSettings) do setTime(unpack(v)) end end fileClose(file) end end addEvent("saveTimeSettings", true) addEventHandler("saveTimeSettings", root, function(t) saveTimeSettings(t) end) addEventHandler('onResourceStart', resourceRoot, function() loadTimeSettings() end) Now, you need to modify the client.lua file to only trigger the server event when the settings change, instead of doing it every time the command is used: client.lua: local t = { ['night'] = {5, 0}, ['mor'] = {12, 0}, } addEvent("loadTimeSettings", true) addEventHandler("loadTimeSettings", resourceRoot, function() loadTimeSettings() end) addEventHandler('onClientResourceStart', resourceRoot, function() for i, v in pairs(t) do addCommandHandler(i, function() setTime(unpack(v)) triggerServerEvent("saveTimeSettings", resourceRoot, t) end) end triggerServerEvent("loadTimeSettings", resourceRoot) end) function loadTimeSettings() local file = fileOpen("times.json") if file then local json = fileRead(file, fileGetSize(file)) local savedSettings = fromJSON(json) if savedSettings then for i, v in pairs(savedSettings) do setTime(unpack(v)) end end fileClose(file) end end With these changes, the time settings should now persist between map changes and script restarts. The time settings will be saved to "times.json" and loaded back when the script starts or when a new map is loaded.
  9. The error you're encountering is due to the fact that the convertNumber function is returning a string instead of a number. In Lua, when you perform arithmetic operations on strings, you'll get this error. The convertNumber function seems to add commas as thousand separators to the input number. However, it doesn't actually convert the number to a numeric type. To fix this, you need to remove the commas from the string before using it in arithmetic operations. Here's an updated version of the convertNumber function that should solve the issue: function convertNumber(number) -- Remove commas from the number local cleanedNumber = string.gsub(number, ",", "") local formatted = cleanedNumber while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", "%1,%2") if k == 0 then break end end return formatted end Now, your deanimated function should work as expected without the error. The convertNumber function will clean the input number, remove any commas, and then add commas as thousand separators before returning the formatted string. Just replace the existing convertNumber function with the updated version provided above.
  10. Sure, I'd be happy to help you understand the script and explain how it works. This script appears to be a part of a game server work system. The main function addCommandHandler is used to handle the command "trabajar" (which means "work" in Spanish) that players can execute in the game. Here's a step-by-step explanation of how the script works: The script checks if the player executing the command is not currently in a vehicle (if not player:isInVehicle() then). This is probably to prevent players from starting work while in a vehicle. It then loops through a list of "MarkersCarpintero". These markers might represent locations or areas in the game world where the player can work as a "Carpintero" (carpenter). For each marker, the script checks if the player is within the range of the marker (if player:isWithinMarker(marker) then). If the player is within the marker, it checks if the player's current job is "Carpintero" (if mjob == "Carpintero" then). If the player's current job is "Carpintero," the script checks if the player already has the job ("Carpintero") as data (if currentJob == "Carpintero" then). If yes, it means the player is already working as a carpenter, and it displays an output message telling the player that they are already working there. If the player does not have the job of "Carpintero," it checks if the player has no job at all (if currentJob == "" then). If the player has no job, it assigns the job "Carpintero" to the player as data (player:setData("Roleplay:trabajo", "Carpintero")) and updates the marker's data to indicate it's a carpenter job marker (marker:setData("MarkerJob", "Carpintero")). If the player has a job other than "Carpintero," it displays an output message telling the player what their current job is. The script also has some removeElementData lines to remove any previous job-related data ("objeto" and "silla") from the player, probably to avoid conflicts or errors when assigning a new job. In summary, the script allows players to work as a carpenter if they are near a carpenter job marker and meet the specified conditions. If they are already working as a carpenter, it tells them they are already working there. If they have a different job, it informs them of their current job. It's important to note that this script only handles the "trabajar" command and the carpenter job. Depending on the entire game server setup, there might be other commands and jobs implemented separately. Also, it's crucial to ensure that the variables MarkersCarpintero and the functions like player:isWithinMarker() and player:setData() are correctly defined and implemented elsewhere in the script or resource. If they are not defined or implemented correctly, the script might not work as expected.
  11. Sure, I'll help you fix your code. I noticed a couple of issues in your code. Here's the corrected version: local prefix = "[Server] " local database = -- your database connection here local money = { -- your vipType to money mapping here } function AirNewSCR_EnviarServidor(thePlayer, commandName, key) if key then if existsKey(key) then local keyInfo = getKeyInfos(key) local vipType = keyInfo[1]["vipType"] local days = tonumber(keyInfo[1]["days"]) or 0 -- Initialize days to 0 if the value is not numeric local expires = os.time() dbExec(database, "DELETE FROM keys WHERE key = ?", key) outputChatBox(prefix .. "VIP " .. vipType .. " ativado com sucesso.", thePlayer, 255, 255, 255, true) local moneyAchieved = money[vipType] if days > 0 then if isVIP(getAccountID(getPlayerAccount(thePlayer)), vipType) then local vipInfo = getVIPInfos(getAccountID(getPlayerAccount(thePlayer)), vipType) if vipInfo[1]["expires"] ~= "Permanente" then expires = tonumber(vipInfo[1]["expires"]) + (days * 24 * 60 * 60) end else local accountId = getAccountID(getPlayerAccount(thePlayer)) dbExec(database, "INSERT INTO vips (accountId, vipType, expires) VALUES (?, ?, ?)", accountId, vipType, expires) end outputChatBox(prefix .. "O teu VIP expira dia: " .. os.date("%c", expires), thePlayer, 255, 255, 255, true) end end end end Changes made: Added prefix and database variables as placeholders. Please replace them with appropriate values. Checked if days is numeric by using tonumber, and initialized it to 0 if it's not. Replaced if not vipInfo[1]["expires"] == "Permanente" then with if vipInfo[1]["expires"] ~= "Permanente" then. Added an else block for when the player is not already VIP, to insert the new VIP entry into the database. Please make sure to replace prefix, database, and money variables with the correct values for your script. Additionally, ensure that the functions existsKey, getKeyInfos, isVIP, and getVIPInfos are defined correctly in your script.
×
×
  • Create New...