Jump to content

botder

MTA Team
  • Posts

    524
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by botder

  1. You need a serverside solution: Everytime a map resources starts you take it's resource root element (parent of 'map' element) and set the element data with the key type to resource-type -- resourceRoot is the root element of the resource -- resource is the pointer to the resource, which started setElementData(resourceRoot, "type", getResourceInfo(resource, "type")) Then you can use that information clientside to differentiate between maps/gamemodes/etc by getting the element data from the resource root element -- resourceRoot is the parent of the parent (= map) of the sound local resourceType = getElementData(resourceRoot, "type") Maybe that will help.
  2. Try the latest admin resource ==> https://code.google.com/p/mtasa-resources/source/detail?r=1024
  3. You should try the math functions. local nHealth = getElementHealth(veh) or 0 local nProgress = math.max(0, (nHealth - 250) / 750) OR local nHealth = math.max(0, (getElementHealth(veh) or 0) - 250) local nProgress = nHealth / 750
  4. Maybe your code to load the data from XML is bad and loads nothing OR your code to load the data from the table is bad.
  5. I only tested the code alone on my server. This is an ugly hack and I don't recommend it. It probably won't put the player into spectator mode (requires more changes). File: race_server.lua Search the line addEventHandler('onPlayerQuit', g_Root and move the anonymous function out and give it a name. function handlePlayerQuit() destroyBlipsAttachedTo(source) table.removevalue(g_Players, source) -- ... end Don't forget to add the handler in onPlayerQuit and add a new event onPlayerLogout for it. addEventHandler('onPlayerQuit', g_Root, handlePlayerQuit) addEventHandler('onPlayerLogout', g_Root, handlePlayerQuit) Search for addEventHandler('onPlayerJoin', g_Root, joinHandlerByEvent) and add below that line: addEventHandler('onPlayerLogin', g_Root, joinHandlerByEvent) Search for function joinHandlerByEvent() and extend the function: function joinHandlerByEvent() if getAccountName(getPlayerAccount(source)) == 'guest' then return end setPlayerNotReady(source) joinHandlerBoth() end Search for if not table.find(g_Players, p) then and extend the code block: if not table.find(g_Players, p) then if getAccountName(getPlayerAccount(p)) ~= 'guest' then player = p break end end
  6. No compilation errors, but I am not sure if it works. In one sentence: It takes the angle from the player to the colshape, turns it around (negative) and then applies the velocity (before the impact) to push the player away. function handleShapeHit(contactElement, matchingDimension) if not matchingDimension then return end if getElementType(contactElement) ~= "player" then return end local x, y = getElementPosition(source) local px, py, pz = getElementPosition(contactElement) local vx, vy, vz = getElementVelocity(contactElement) local speed = math.sqrt(math.pow(vx, 2) + math.pow(vy, 2) + math.pow(vz, 2)) + 0.25 local angle = -math.atan2(px - x, py - y) setElementVelocity(contactElement, speed * math.cos(angle), speed * math.sin(angle), vz + 0.1) end local col = createColRectangle(-150, -150, 300, 300) addEventHandler("onColShapeHit", col, handleShapeHit)
  7. Download the latest .csv file, enable debug mode in admin resource, execute the command via console and you will get the latest ip2country compact file.
  8. botder

    Connect COL?

    Use isElementWithinColShape for both colshapes in an AND-statement (a and b)
  9. Your memo has to show some lines with text. That means you have to store, which memo is visible including the text for each memo. gMemo = { { messages = {}, visible = true }, { messages = {}, visible = true } } -- each index is one line Each memo has it's own size. That means you have to store the size of the memo. gMemo = { { messages = {}, visible = true, width = 300, height = 300 }, { messages = {}, visible = true, width = 400, height = 400 } } Your memo can only show a part of the text. That means you have to store the position, where the text starts and how many lines it can show. gMemo = { { messages = {}, visible = true, width = 300, height = 300, position = 0, linecount = 8 }, { messages = {}, visible = true, width = 400, height = 400, position = 15, linecount = 10 } } You can add more of course, but that should give you a small help for the beginning. Possible functions: dxCreateMemo dxMemoSetSize dxMemoGetSize dxMemoClear dxMemoSetText dxMemoGetText dxMemoRender dxMemoSetLine dxMemoGetLine dxMemoSetVisible dxMemoGetVisible dxMemoDestroy
  10. You could actually copy the scrolling from my debugconsole resource
  11. You can't save a lua table, but you can convert it to a string with toJSON and convert it back with fromJSON
  12. Create a new one, copy the data from the last account and delete the last account. Do you need something else? getAccount addAccount getAllAccountData setAccountData removeAccount
  13. It should work like this (not sure) local player = Player.getRandom() -- Mute the player player:setMuted(true) player.muted = true setPlayerMuted(player, true) -- Unmute the player player:setMuted(false) player.muted = false setPlayerMuted(player, false) -- Is the player muted? if player.muted then --[[ ... ]] end if player:isMuted() then --[[ ... ]] end if isPlayerMuted(player) then --[[ ... ]] end
  14. He changed the last screenshot where you could see the cursor on the same position. Another fun fact: Picture A: http://i.imgur.com/cfRmnEi.png Picture B: http://i.imgur.com/qDysPT7.png The "MTA:SA 1.4" text is moved by 1 pixel up
  15. botder

    Table

    The client didn't create the ped yet. When you create a ped serverside then it will take some ticks until the ped will be created clientside and that's why setting the animation may not work.
  16. Notice how the cursor never changes the position in the first and last "screenshot"
  17. botder

    edit box DX

    How to jump with the cursor? Using the position, iterate through the visible text and checking if the delta position is greater or lower than the cursor position. How to make a blinking caret? Use that piece of code when drawing the caret line: tocolor(0, 0, 0, math.abs(math.sin(getTickCount() / 300)) * 200)
  18. blocked = { ["FiveForty"] = true, ["Querty"] = true } addEventHandler("onPlayerChat", root, function (_, type) if (type == 2) then -- team message local team = getPlayerTeam(source) if (team and blocked[ getTeamName(team) ]) then return cancelEvent() end end end )
  19. The serverside resource starts faster than the clientside > Pointless clientside event triggering @ onResourceStart The players are probably already logged in > onPlayerLogin doesn't get triggered Problem: When the player logs out and then logs in the clock will be rendered multiple times because you don't check if the event is already added.
  20. Add 'race' gamemode in the map settings / definitions (you can find those using the bottoms on top of your screen) and then go bottom/left to the other buttons and use your mouse_wheel to switch to race.
  21. botder

    scratch ?

    http://en.wikipedia.org/wiki/Rewrite_%28programming%29 maybe that will help
  22. The easiest way to do is to disable physical impact on the vehicle (setElementCollisionsEnabled) and then change the setVehicleTurnVelocity to some value (not too high! >> 0.5 - 2.0). Freeze the vehicle after some small time (because it may disappear and respawn on land).
  23. Which driver version do you use? I had problems with newer drivers in MTA and that problem may affect you now.
×
×
  • Create New...