Jump to content

Shady1

Members
  • Posts

    766
  • Joined

  • Last visited

  • Days Won

    47

Everything posted by Shady1

  1. https://nightly.multitheftauto.com/ https://forum.multitheftauto.com/topic/80449-verdanatff-problem/
  2. To use it you need a modded panel and export it to your F1 panel.
  3. Shady1

    F1 panel sorunu

    büyük ihtimalle exports etmeniz gerekecektir
  4. I saw that you already mentioned this issue in your previous thread, you can have a look if you wish.
  5. Shady1

    [HELP]

    -- Client-side script addCommandHandler("setunit", function(command, unitNumber) -- Check if the unit number is valid (must be a number) if not tonumber(unitNumber) then outputChatBox("Invalid unit number! Please enter a valid number.", 255, 0, 0) return end unitNumber = math.floor(tonumber(unitNumber)) outputChatBox("You have set your unit number to: " .. unitNumber, 0, 255, 0) end)
  6. Shady1

    [HELP]

    Do you want to always show the player or do something like a trace so it can't know its original position but it knows its previous position use https://wiki.multitheftauto.com/wiki/CreateBlipAttachedTo
  7. Shady1

    [HELP]

    i don't understand what you are trying to do in the code, but i did as you asked, i didn't test it, try it and message back. local sanyi function Reset() destroyElement(sanyi) end setTimer( function() local x, y, z = getElementPosition(localPlayer) sanyi = createBlip(x, y, z, 0) end, 2000, 0) setTimer(Reset, 3000, 0)
  8. Shady1

    [HELP]

    tell me exactly what the problem is, or tell me what you want it to be
  9. Shady1

    [HELP]

    if it worked and you liked my help, you can give a like in the comment.
  10. Shady1

    [HELP]

    use https://wiki.multitheftauto.com/wiki/GetElementModel and source addEventHandler("onClientVehicleEnter", root, function(thePed, seat) local vehid = getElementModel(source) local playerskin = getElementModel(localPlayer) if (vehid ~= 596) then return end if (playerskin == 280) then playSound("beep.mp3") outputChatBox("#898c8f<<#2c469cNeXoN Roleplay#898c8f>> #0f5720Sikeress belépés", 255, 255, 255, true) PDMenu = true else playSound("beep.mp3") outputChatBox("#898c8f<<#2c469cNeXoN Roleplay#898c8f>> #0f5720Sikertelen belépés", 255, 255, 255, true) end end)
  11. Shady1

    MTA no sound

    hello, I will give a few suggestions about your problem, firstly delete the GTA:SA file and install it cleanly again, then update your Audio card driver if the problem still persists,While reinstalling your GTA:SA file, install it on your C disk
  12. i will tell you in a simple way,this is a simple code, you can continue through this code according to your game mode and you can set the dimensions side as you want. function onMarkerHit(hitElement, matchingDimension) if hitElement and getElementType(hitElement) == "player" and matchingDimension then setElementDimension(hitElement, 1) -- Change the dimension for the player setElementData(hitElement, "game_mode", "tdm") -- Change the gamemode for the player end end lobbyMarker = createMarker(x, y, z, "cylinder", 2, 255, 0, 0, 100) -- Create the marker addEventHandler("onMarkerHit", lobbyMarker, onMarkerHit) -- Attach the event handler to the marker
  13. use getWeaponProperty function setWeaponFireRate(weaponID, fireRate) local weapon = getWeaponProperty(weaponID, "poor", "maximum_clip_ammo") setWeaponProperty(weaponID, "pro", "maximum_clip_ammo", weapon/fireRate) end setWeaponFireRate(22, 3) -- Changes the fire rate of the pistol to shoot 3 rounds per second.
  14. Thank you for your comment but I just posted an example code, if the player expects more code support from me, just let me know and I'm ready to give more support to the players.
  15. Bună, băieți, am vrut să contribui la această problemă și vreau să împărtășesc un cod pe care l-am pregătit cu voi, scopul acestui cod este 6 pe care le vor genera numere și litere aleatorii, permiteți-mi să vă spun unde puteți utiliza acest cod, pt. exemplu: verificare e-mail, parola uitată, misiuni, evenimente function timeNeedsPlural(theNumber) if not (type(tonumber(theNumber)) == "number") then return "" end if (tonumber(theNumber) == 1) then return "" end return "" end function shuffleTable(tbl) local size = #tbl for i = size, 1, -1 do local rand = math.random(size) tbl[i], tbl[rand] = tbl[rand], tbl[i] end return tbl end function generateCode(codeSize) local code = {} local charset = {} for i = 48,57 do charset[#charset+1] = string.char(i) end for i = 97,122 do charset[#charset+1] = string.char(i) end for i=1,codeSize do code[#code+1] = charset[math.random(1,#charset)] end return code end
  16. To make it so that only the player who executed the command can see the message, you can replace the root parameter in the outputChatBox function with thePlayer. This will make the message appear only in the chatbox of the player who executed the command. example code for the client-side client.lua file: function onCommand(command, commandType) if string.find(command, 'vskins') then outputChatBox("#F4E607[VIP] #FFFFFF/vskin 1, /vskin 2, /vskin 3, /vskin 4", thePlayer, 244, 230, 7, true) end end addEventHandler("onClientPlayerCommand", getLocalPlayer(), onCommand) Note that the onClientPlayerCommand event is used instead of onPlayerCommand, since this code is running on the client-side. Also, the thePlayer parameter is replaced with getLocalPlayer() which returns the player who executed the command on their local machine. Finally, the last parameter of outputChatBox is set to true, which means that the message will be visible only to the player who executed the command.
  17. Hello my name is : Shady,I will show you some examples and tutorials that can be done with the math method. Lua provides a set of built-in math functions that can be used to perform various mathematical operations. Here are some of the most commonly used functions: math.abs(x) This function returns the absolute value of a given number x. Example cd: local x = -10 local abs_x = math.abs(x) -- abs_x is 10 math.ceil(x) This function rounds up a given number x to the nearest integer. Example cd: local x = 3.5 local ceil_x = math.ceil(x) -- ceil_x is 4 math.floor(x) This function rounds down a given number x to the nearest integer. Example cd: local x = 3.5 local floor_x = math.floor(x) -- floor_x is 3 math.max(x1, x2, ...) This function returns the maximum value among the given numbers. Example cd: local max_value = math.max(10, 20, 30) -- max_value is 30 math.min(x1,x2, ...) This function returns the minimum value among the given numbers. Example cd: local min_value = math.min(10, 20, 30) -- min_value is 10 math.random([m [, n]]) This function returns a random number between m and n. If m and n are not provided, it returns a random number between 0 and 1. Example cd: local random_value = math.random(1, 100) -- random_value is a random number between 1 and 100 math.sqrt(x) This function returns the square root of a given number x. Example cd: local x = 16 local sqrt_x = math.sqrt(x) -- sqrt_x is 4 In Lua, math.huge is a special value that represents positive infinity. It is often used in mathematical calculations where a number needs to be compared or used as a placeholder for a very large number. For example, let's say you want to find the maximum value in an array of numbers. You could start by initializing a variable max to -math.huge, which is the smallest possible number in Lua. Then you could loop through the array and compare each element to max, updating max if the element is larger. By starting with -math.huge, you can be sure that the first element in the array will always be larger than max, allowing you to update max with the first element. Here's an example code snippet that demonstrates the use of math.huge: local numbers = {5, 10, 2, 7, 15} local max = -math.huge for _, number in ipairs(numbers) do if number > max then max = number end end print("The maximum value is:", max) In this code, we start by defining an array of numbers. Then we initialize max to -math.huge before looping through the array using ipairs. For each number in the array, we check if it is greater than the current value of max. If it is, we update max with the new value. Finally, we print out the maximum value. Here are some examples of how these functions can be used in MTA scripts: Example 1: Calculating the distance between two points. getDistanceBetweenPoints2D function getDistanceBetweenPoints2D(x1, y1, x2, y2) local dx = x2 - x1 local dy = y2 - y1 return math.sqrt(dx*dx + dy*dy) end local distance = getDistanceBetweenPoints2D(10, 20, 30, 40) -- distance is the distance between the two points (10,20) and (30,40) Example 2: Generating a random number outputChatBox local random_value = math.random(1, 100) outputChatBox("The random number is: " .. random_value) Here I will show you 5 script sample codes with MTA Lua math function. In this direction, you can find some methods and information on how to create scripts with the math function. 1-) Generating Random Colors: string-methods function generateRandomColor() -- Generate random numbers from 0 to 255 local r = math.random(0, 255) local g = math.random(0, 255) local b = math.random(0, 255) -- return color code return string.format("#%02X%02X%02X", r, g, b) end 2-) Calculating the Distance Between Players: getElementPosition getDistanceBetweenPoints3D function getPlayerDistance(player1, player2) -- get the positions of the players local x1, y1, z1 = getElementPosition(player1) local x2, y2, z2 = getElementPosition(player2) -- calculate the distance local distance = getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) -- return the distance return distance end 3-) Calculating Vehicle Speed: getElementVelocity function getVehicleSpeed(vehicle) -- get the speed of the vehicle local speedX, speedY, speedZ = getElementVelocity(vehicle) -- Calculate the magnitude of the velocity vector local speed = math.sqrt(speedX^2 + speedY^2 + speedZ^2) -- return speed return speed end 4-) Showing Player's Health in Percentage: getElementHealth function getPlayerHealthPercentage(player) -- get player's health value local health = getElementHealth(player) -- Calculate percentage of health value local healthPercent = math.floor((health / 100) * 100) -- return health percentage return healthPercent end 5-) Calculating the Two-Dimensional Distance of Players: getElementPosition function getPlayer2DDistance(player1, player2) -- get the positions of the players local x1, y1, _ = getElementPosition(player1) local x2, y2, _ = getElementPosition(player2) -- calculate the distance local distance = math.sqrt((x2 - x1)^2 + (y2 - y1)^2) -- return the distance return distance end As you can see, here are 5 script examples with the MTA Lua math function
  18. Hello dear MTA players,My name is Eren(Shady) ,today I will show you String and Strings types in a simple and short way with examples, this string formula, which I needed very much at the time, is very useful for me today, so I decided to use it and make this tutorial to learn more, I hope I was able to explain it well. Strings and String Methods In Lua, a string is a sequence of characters that represents text data. Strings are used extensively in programming for storing and manipulating text-based information. In this tutorial, we will explore the different string types in Lua and how to manipulate them. Single Quoted Strings A single-quoted string is created by enclosing a sequence of characters between two single quotes. For example: local str = 'Hello, world!' Single-quoted strings are useful for creating short, simple strings that do not contain any special characters. If you need to include a single quote character within a single-quoted string, you can escape it using a backslash: local str = 'It\'s a beautiful day!' Double Quoted Strings A double-quoted string is created by enclosing a sequence of characters between two double quotes. For example: local str = "Hello, world!" Double-quoted strings are useful for creating more complex strings that may contain special characters such as escape sequences or variables. If you need to include a double quote character within a double-quoted string, you can escape it using a backslash: local str = "She said, \"Hello!\"" Long Strings A long string is created by enclosing a sequence of characters between two square brackets. For example: local str = [[This is a long string that spans multiple lines]] Long strings are useful for creating strings that contain multiple lines of text, such as paragraphs or blocks of code. They can also be used to create strings that contain special characters without the need for escape sequences. String Concatenation You can concatenate two or more strings together using the .. operator. For example: local str1 = "Hello" local str2 = "world" local str3 = str1 .. ", " .. str2 .. "!" In this example, str3 would contain the string "Hello, world!". String Manipulation Lua provides a number of built-in functions for manipulating strings. Some of the most commonly used string functions include: string.sub(str, start, end): Returns a substring of str starting at start and ending at end. string.len(str): Returns the length of str. string.lower(str): Returns str with all letters in lowercase. string.upper(str): Returns str with all letters in uppercase. string.rep(str, n): Returns str repeated n times. Pattern Matching Lua also provides a powerful pattern matching library that can be used to search and manipulate strings based on a pattern. The string.gsub() function is particularly useful for replacing parts of a string that match a pattern with another string. Here is an example of using string.gsub() to replace all occurrences of the word "dog" with the word "cat" in a string: local str = "I have a dog, but my neighbor has two dogs." local newStr = string.gsub(str, "dog", "cat") In this example, newStr would contain the string "I have a cat, but my neighbor has two cats.". The string we are working with is "My name is John_Smith". We want to swap the order of the two names in the string, so that it becomes "My name is Smith_John". str = "My name is John_Smith" new_str = string.gsub(str, "(John)_(Smith)", "%2_%1") Here's how the code achieves this: string.gsub() is called with the original string str, and two patterns to match: (John) and (Smith). The parenthesis around "John" and "Smith" indicates that they are capture groups, which means that any match to these patterns will be stored as a variable. The replacement string "%2_%1" is passed as the third argument to gsub(). This string contains the % modifier, which is used to reference the captured groups. In this case, %2 refers to the second captured group ("Smith"), and %1 refers to the first captured group ("John"). gsub() performs the substitution on the original string, replacing the matched pattern (John)_(Smith) with the replacement string "%2_%1". The resulting string, "My name is Smith_John", is stored in the new_str variable. So essentially, this code swaps the order of two captured groups in a string using the gsub() function and the % modifier. But how to make it dynamic and so it matches even if it's another First and Lastname (like Bruce_Willis) ? Well, we can use what we call character classes. They are special "codes" to match a specific type of thing in your string. For example, %a means "any letter", %d means "any digit". Here is the full list those character classes: . all characters %a letters %c control characters %d digits %l lower case letters %p punctuation characters %s space characters %u upper case letters %w alphanumeric characters %x hexadecimal digits %z the character with representation 0 So in our previous example we can replace the pattern like so: str1 = "My name is John_Smith" str2 = "My name is Bruce_Willis" new_str1 = string.gsub(str1, "(%a+)_(%a+)", "%2_%1") new_str2 = string.gsub(str2, "(%a+)_(%a+)", "%2_%1") new_str will contain "My name is Smith_John" and new_str2 will contain "My name is Willis_Bruce". So it works as long as it finds one or more letters followed by an underscore followed by one or more letters. Here I also used a modifier (+) to tell the matcher he has to look for 1 or more repetition of a letter. Here are the list of the possible modifiers: + 1 or more repetitions * 0 or more repetitions - also 0 or more repetitions ? optional (0 or 1 occurrence) More infos here In Lua, "\n" is known as a newline character. It is used to represent a new line of text in a string. When a newline character is encountered in a string, it tells the computer to move the cursor to the beginning of the next line. For example : local myString = "Hello\nworld" print(myString) In this example, the string "Hello" is followed by "\n" which tells Lua to add a new line. The string "world" is then printed on the next line. Output : Hello world You can also use multiple "\n" characters in a row to add multiple new lines: local myString = "This is the first line.\n\nThis is the third line." print(myString) In this example, two "\n" characters are used to add two new lines between the first and third lines. Output : This is the first line. This is the third line. You can use newline characters to format your text in a more readable way. For example, if you want to print a list of items, you can use a newline character to separate each item: local myString = "List of items:\n- Item 1\n- Item 2\n- Item 3" print(myString) In this example, the string "List of items:" is followed by "\n" to add a new line, then each item is listed on a new line with a hyphen (-) to indicate a bullet point. Output : List of items: - Item 1 - Item 2 - Item 3 In summary, "\n" is a newline character in Lua that is used to add a new line in a string. It is a useful tool for formatting text and making it more readable. string.sub(str, start, end): This function returns a substring of the input string, str, starting at the start index and ending at the end index. For example: local str = "Hello, World!" local subStr = string.sub(str, 7, 12) -- This will return "World!" string.len(str): This function returns the length of the input string, str. For example: local str = "Hello, World!" local len = string.len(str) -- This will return 13 string.lower(str): This function returns a new string with all letters in the input string, str, converted to lowercase. For example: local str = "HeLLo, WoRLd!" local lowerStr = string.lower(str) -- This will return "hello, world!" string.upper(str): This function returns a new string with all letters in the input string, str, converted to uppercase. For example: local str = "HeLLo, WoRLd!" local upperStr = string.upper(str) -- This will return "HELLO, WORLD!" string.rep(str, n): This function returns a new string that is n copies of the input string, str. For example: local str = "Hello" local repStr = string.rep(str, 3) -- This will return "HelloHelloHello" string.format string.format is a Lua function that is used to format strings based on a pattern. The basic syntax of string.format is: string.format(formatstring, ...) Here, formatstring is a string that contains placeholders for values that you want to include in the formatted string. The placeholders are indicated by % symbols followed by a letter that indicates the type of value to be included. The ... is a variable argument list that contains the values to be formatted. Here are some of the most commonly used placeholders in string.format: %s: Inserts a string value %d or %i: Inserts an integer value %f: Inserts a floating-point value %%: Inserts a literal % symbol Let's see some example codes that use string.format: -- Example 1: Formatting a simple string local name = "John" local age = 25 local formattedString = string.format("My name is %s and I am %d years old.", name, age) print(formattedString) -- Output: My name is John and I am 25 years old. -- Example 2: Formatting a floating-point value with a specific precision local pi = math.pi local formattedString = string.format("The value of pi is approximately %.2f.", pi) print(formattedString) -- Output: The value of pi is approximately 3.14. -- Example 3: Formatting an integer value with leading zeros local number = 42 local formattedString = string.format("The answer is %04d.", number) print(formattedString) -- Output: The answer is 0042. In Example 1, we format a simple string with placeholders for name and age. In Example 2, we format a floating-point value for pi with a precision of two decimal places. In Example 3, we format an integer value with leading zeros to make it four digits long. Hope this helps!
  19. Shady1

    inv

    hello, welcome to the forum, I prepared a simple code upon your request, this code is an example code, you can continue through this code or you can see what I've done through this code and make 1 new one yourself. local inventoryOpen = false local inventoryTab = guiCreateTab("Inventory") local inventoryGrid = guiCreateGridList(0.01, 0.05, 0.98, 0.9, true, inventoryTab) for i = 1, 8 do guiGridListAddColumn(inventoryGrid, "Slot " .. i, 0.125) end guiSetVisible(inventoryTab, false) function toggleInventory() if inventoryOpen then guiSetVisible(inventoryTab, false) showCursor(false) inventoryOpen = false else guiSetVisible(inventoryTab, true) showCursor(true) inventoryOpen = true end end addCommandHandler("i", toggleInventory)
  20. Shady1

    weapon

    this was just a sample code, you can do it using bone attach.
  21. Shady1

    teleporter

    Please, if it worked, you can give a like to my comment.
  22. Please, if it worked, you can give a like to my comment.
  23. Para fazer com que a imagem exemplo2 possa ser movida para a imagem exemplo1, você precisa adicionar algumas linhas de código no evento "onClientClick" que verifica se a imagem exemplo2 está sobre a imagem exemplo1 e, em caso afirmativo, coloca a imagem exemplo2 no primeiro slot livre na imagem exemplo1. Aqui está um exemplo de como você pode fazer isso: addEventHandler("onClientClick", root, function(b, s) if b == "left" then if s == "down" then if isMouseInPosition(x,y,w,h) then movendo = true addEventHandler("onClientRender", root, Mover) end else if movendo then movendo = false local inSlot = false for i,v in ipairs(slots) do if isMouseInPosition(v[1], v[2], v[3], v[4]) then inSlot = true x,y = v.imgx, v.imgy break end end if isMouseInPosition(1067, 381, 281, 281) and not inSlot then -- procura o primeiro slot livre for i,v in ipairs(slots) do if not v.weapon then v.weapon = true x,y = v.imgx, v.imgy break end end end temp = {} difx, dify = nil,nil removeEventHandler("onClientRender", root, Mover) end end end end)
×
×
  • Create New...