Jump to content

SDK

Members
  • Posts

    635
  • Joined

  • Last visited

Everything posted by SDK

  1. This should be in scripting, but you need to change the gamemode in the meta for the mode and the maps so mapmanager recognizes them as different
  2. Some suggestions I came up with that would be a big improvement over the default debug console: + reload log on join so you can see what happened before you joined or what happens on /reconnect + view the debug of other clients + toggle to prevent spam like suggested earlier
  3. Looks interesting, hope you continue working on it
  4. Tried something, not tested but hoping to give you a general idea. Arenas = {} Arenas.selected = nil -- ... addEventHandler("onClientRender",root, function() local isAnyArenaSelected = false for i, arena in pairs(Arenas) do local r, g, b = getColorFromString(getElementData(arena.Element, "color")) arena.Color = tocolor(r, g, b, 255) dxDrawRectangle ( arena.x, arena.y, arena.size, arena.height, arena.Color, true) local mx, my = getCursorPosition() hover = mouseCheck(mx, my, arena.x, arena.x+arena.size, arena.mouseY, arena.mouseY+arena.height) if hover == true then isAnyArenaSelected = true if not Arenas.selected then -- preset animation when mouse is over arena selectArena(arena) end end end if not isAnyArenaSelected and Arenas.selected then -- preset animation when mouse isn't over any arena and there is still one selected selectArena( nil ) end end) function selectArena(arena) Arenas.selected = arena -- this function prepares all new positions and sizes when an arena is (de)selected for i, a in pairs(Arenas) do if arena == nil then -- no arena selected, move back to default size and position arena.next_y = ... arena.next_height = defaultArenaHeight elseif a == arena then -- this is the selected arena, maximum height arena.next_y = ... arena.next_height = MaxArenaHeight else -- this is an arena that needs to be minimized arena.next_y = ... arena.next_height = defaultArenaHeight * NumArenas - MaxArenaHeight end end end setTimer(function() -- this timer moves y and height up to their next_ value for i, arena in pairs(Arenas) do if (arena.next_y and arena.y ~= arena.next_y) then if arena.y < arena.next_y then arena.y += 1 else arena.y += -1 end end if (arena.next_height and arena.height ~= arena.next_height) then if arena.height < arena.next_height then arena.height += 1 else arena.height += -1 end end end end, 100, 0) -- 100 can be used to change the animation speed If you're still having trouble I would recommend adding one feature at the time to your script. Use GUI Images and use clicks (OnClientGUIClick) instead of hovering to keep it simple and have something that works. Afterwards you can modify that to use onClientMouseEnter/Leave for hover or back to dxDraw functions.
  5. MTA's login system is built-in, there are no .lua files.
  6. Car health ranges from a little above 1000 to 250, between 250 and 0 the car is burning. To ignore the under 250 part you can use math.max(). So to get it in a percentage: carHealth = ( math.max(getElementHealth(vehicle) - 250, 0) ) / 7.5 Slap some rounding function on that and you should be good to go.
  7. I think you don't need to split it if you use this function: https://wiki.multitheftauto.com/wiki/Tri ... lientEvent Not sure, since I never used it myself before
  8. Some small mistakes fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi(player, seat, jacked) if (source == fbi1 or source == fbi2 or source == fbi3) then local skin = getElementModel (player) if ( skin == 100 or skin == 255) then cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), lockfbi )
  9. You can delete all the files with fileDelete on onClientResourceStart or an other event.
  10. There's no real function for it yet, but there's an note here: https://wiki.multitheftauto.com/wiki/SetObjectStatic (replaced with setElementFrozen) So you could use onClientRender and isElementOnScreen to recreate the broken objects. As an extra you could run a timer which recreates every object every 5 seconds, depending on how important the objects are.
  11. SDK

    SQL question

    Yes, has been awhile since used sqlite im afraid The first query was wrong: "CREATE TABLE tempTable AS SELECT DISTINCT * FROM originalTable" "DROP TABLE originalTable" "ALTER TABLE tempTable RENAME TO originalTable" I tested it on a commandline and it worked, no duplicates.
  12. function killMe (thePlayer) if (thePlayer) then setTimer (killPed, 10000, 1, thePlayer) outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) end end addCommandHandler ("kill", killMe)
  13. while not setElementModel (localPlayer,newSkin) do newSkin = newSkin + 1 end triggerServerEvent ("skin", localPlayer, newSkin) This will first find a skin to the left/right, and then send it to the server Edit: ninja
  14. SDK

    SQL question

    Another way is using SELECT DISTINCT, which only selects unique rows and skips the duplicates, to create a (fixed) new db. "SELECT DISTINCT * INTO newtable FROM oldtable" Then drop (delete) the original table "DROP TABLE oldtable" and rename the new table to the old one. "ALTER TABLE newtable RENAME TO oldtable" (Found this after some googling, I'd expect it to work, but didn't test it so make sure you backup your database first)
  15. You need to use setElementModel serverside, use triggerServerEvent in the gui script to send the skin to the server.
  16. SDK

    Nametag script

    I can't see shit on that screenshot, but you're probably replacing in the wrong folder. MTA San Andreas 1.2\server\mods\deathmatch\resources\[gamemodes]\[race]\race
  17. setVehicleGravity ( vehicle, 0, 0, -0.5 ) That would make the vehicle's gravity twice as low
  18. Because you changed the indexes of the table, the table should be formatted this way local musics = { [1] = { 'David Guetta - Where Dem Girls At', 'http://199.167.195.194/wdga.mp3'}, [2] = { 'Coldplay - Paradise', 'http://199.167.195.194/pd.mp3'}, [3] = ... } local themusic = musics[math.random(#musics)] local file = themusic[2] local title = themusic[1]
  19. SDK

    God like car

    You mean an event? I don't think there's one that can be used here. Like I said, for a map it's easier to just disable damage for all vehicles all the time.
  20. SDK

    God like car

    My code was meant to replace the setVehicleDamageProof line in the solution by solidsnake. But since your making a map, it's easier to do this: addEventHandler("onVehicleDamage", root, function() cancelEvent() end) Root means all vehicles
  21. SDK

    God like car

    I've got experience with the race resource, so I already knew where to look. I searched the race script with n++'s "Search in files" feature for "setVehicleDamageProof". Found this in race\modes\base.lua: -------------------------------------- -- For use when starting or respawing -------------------------------------- function RaceMode.playerUnfreeze(player, bDontFix) if not isValidPlayer(player) then return end toggleAllControls(player,true) clientCall( player, "updateVehicleWeapons" ) local vehicle = RaceMode.getPlayerVehicle(player) if not bDontFix then fixVehicle(vehicle) end setVehicleDamageProof(vehicle, false) setVehicleEngineState(vehicle, true) setElementFrozen(vehicle, false) -- Remove things added for freeze only Override.setCollideWorld( "ForVehicleJudder", vehicle, nil ) Override.setCollideOthers( "ForVehicleSpawnFreeze", vehicle, nil ) Override.setAlpha( "ForRespawnEffect", {player, vehicle}, nil ) Override.flushAll() end It's easier to debug without other (not important) resources running. Make sure your script works, then test it out with other resources. The best way to find out if/which resource is interfering, is to stop them all (or the one's you think will give you problems) so you know there's nothing wrong with your script. Then enable them one by one and test to find it.
  22. SDK

    God like car

    Try testing the script with the default freeroam mode, it could be that race is messing with it. (Also, one small improvement, but it won't change your problem) addEventHandler ( "onVehicleEnter", root, function () setVehicleDamageProof ( source, true ) if ( isVehicleOnGround ( source ) ) then outputChatBox (getVehicleName ( source ) .. " is on the ground and made GOD-like") else outputChatBox (getVehicleName ( source ) .. " is in the air and made GOD-like") end end) Edit: I checked and race overrides your setVehicleDamageProof every time you get unfrozen after spawning, and there's no easy way to work around it. Better would be to cancel the onVehicleDamage event: addEventHandler("onVehicleDamage", source, function() cancelEvent() end)
  23. Use https://wiki.multitheftauto.com/wiki/StopSound This code is clientside, client code never affects other players but the local player.
  24. I just tried to decipher this topic, but I can't make sense of it. Is your problem fixed now? If not, what are you trying to do? Also important, is it client or serverside?
  25. Did you try searching? These seem to be all common questions for me. I'll give remove standard objects for free since it's a recent change: https://wiki.multitheftauto.com/wiki/RemoveWorldModel
×
×
  • Create New...