Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 17/12/22 in all areas

  1. You are correct that the string.match() function is not the best choice for parsing coordinates in this scenario. Splitting the string into tokens using string.split() and then converting each token to a number using tonumber() is a more robust solution. Here is an example of how you can use string.split() and tonumber() to parse the coordinates string entered in the edit box and store the x, y, and z values in separate variables: local xyz_str = guiGetText(edit_box) local xyz = split(xyz_str, ",") -- xyz is now a table of tokens if #xyz == 3 then -- check if there are exactly 3 coordinates local x, y, z = tonumber(xyz[1]), tonumber(xyz[2]), tonumber(xyz[3]) if x and y and z then -- check if each coordinate is a valid number -- code to execute if coordinates were parsed successfully else -- code to execute if not all coordinates are valid numbers end else -- code to execute if there aren't exactly 3 coordinates end This code will split the coordinates string entered in the edit box into separate tokens using string.split(), and then convert each token to a number using tonumber(). It also checks that there are exactly 3 coordinates and that each coordinate is a valid number before proceeding. You can then use the x, y, and z variables to teleport the player to the specified coordinates using setElementPosition(), as in the previous example. setElementPosition(player, x, y, z)
    1 point
  2. You can use split to split the string into tokens and convert each of them to numbers. local xyz_str = guiGetText(edit_box) local xyz = split(xyz_str, ",") -- xyz is now a table of tokens if #xyz == 3 then -- check if there are exactly 3 coordinates local x, y, z = tonumber(xyz[1]), tonumber(xyz[2]), tonumber(xyz[3]) if x and y and z then -- check if each coordinate is a valid number -- code to execute if coordinates were parsed successfully else -- code to execute if not all coordinates are valid numbers end else -- code to execute if there aren't exactly 3 coordinates end This is a good start, but the space characters have to match exactly, and the numbers can only be non-negative integers. I was going to improve the pattern to allow arbitrary number of spaces, but then I remembered non-integers and negative numbers and thought it would be too much hassle to get it right. With split, we allow tonumber to take care of all number formats and space characters.
    1 point
  3. function createPanel(commandName) local window = guiCreateWindow(532, 373, 232, 171, "TELEPORTER POSITION", false) guiWindowSetSizable(window, false) local button_1 = guiCreateButton(141, 99, 64, 25, "EXIT", false, window) -- guiSetAlpha(button_1, 0.42) -- local button_2 = guiCreateButton(32, 99, 64, 25, "TELEPORT", false, window) local edit_box = guiCreateEdit(42, 37, 153, 21, "0,0,0", false, window) showCursor(true) addEventHandler("onClientGUIClick", button_1, function() if isElement(window) then destroyElement(window) showCursor(false) end end) addEventHandler("onClientGUIClick", button_2, function(player) local x, y ,z = string.match(guiGetText(edit_box), "(%d+), (%d+), (%d+)") x, y, z = tonumber(x), tonumber(y), tonumber(z) setElementPosition(player, x, y, z) end) end addCommandHandler("tp", createPanel) To use this script, the player can enter the desired coordinates in the format "x, y, z" in the edit box and click the "TELEPORT" button. This will teleport the player to the specified coordinates.
    1 point
  4. @tunet26 Temporary bans cannot be appealed. And yes, the ban is correct
    1 point
  5. engineSetModelLODDistance setFogDistance setFarClipDistance Combining these functions should do the trick if you are trying to make the view distance higher. In some cases using setFarClipDistance should be enough. Also there are setVehiclesLODDistance and setPedsLODDistance Take a good look on these functions' wiki pages, high values for some of these could cause fps lag. Some of these functions' maximum values are also locked to a certain value.
    1 point
  6. I might be mistaken, but all that looks like is GetElementHealth coupled with math.percent to get the percentage of health from the player's current total. If you want it for the local player like in that screenshot, you can just display the value it returns via a dxDraw function from the client-side. EDIT: Just realized you might actually be talking about that damage points thing at the bottom left. It's a bit simplistic but you could probably calculate that by using a combination of OnPlayerDamage to see if the shot lands, then GetPedWeapon to adjust how many points to add depending on the weapon they're using. Or just use the loss argument from OnPlayerDamage to get how much damage they did.
    1 point
×
×
  • Create New...