Jump to content

LabiVila

Members
  • Posts

    272
  • Joined

  • Last visited

Everything posted by LabiVila

  1. Hello, its me again. I wanted to know if there was a way to delete an object from a specific dimension since destroyElement destroys in all dimensions. If there is not, how would it be the most effective way to simulate one? Thank you!
  2. Hello, I need some help finding a specific angle. So let me start, I want this: I need to get local player's rotation and display the rotation he has to do in order to be looking on the direction of the object. Like: 'you have to turn `degrees` to face the object'. I can't seem to do the right math, thank you in advance!
  3. I just solved that by setting a timer to warpPedIntoVehicle (100 ms). I don't know why but somehow it's solved. Does it matter that I call the functions with: function () without event handlers? Maybe that messed me up earlier. I'll definitely change it to the style your style tho
  4. Hello, can you help me fix this part? It's the 'warpPedIntoVehicle', every time I use this I get 'Network Trouble' and I don't know why, for a, b in ipairs (getElementsByType ("player")) do local mySpawn = math.random (1, #mapSpawns) for c, d in ipairs (mapSpawns) do if (c == mySpawn) then local veh = createVehicle (d.id, d.x, d.y, d.z) if veh then outputDebugString ("created veh") end warpPedIntoVehicle (b, veh) setCameraTarget (b, b) fadeCamera (b, true) end end end mapSpawns is fine, I can output any value of it. And I as well get the 'created veh' from outputDebugString. Dunno what's wrong...
  5. I just got into the same problem some times ago, I used this and it helped me a lot: http://stackoverflow.com/questions/9291 ... ning-ratio NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin NewValue is gonna be your value, OldValue is gonna be your 300 for Cheetah, 500 for Infernus (depends on the car), NewMax is gonna be as much as your rectangle's length is, NewMin is gonna be 0. Good luck
  6. Also, you don't need an infinite loop to run above. It's pointless doing such, since it'll only use quite some CPU and not do much. You can set the timer once inside the 'onVehicleExplode', would be better
  7. for _,v in ipairs (getElementsByType ("team")) do guiGridListAddRow (rankinggrid, getTeamName (v)) end Replace all your lines above with these ones, should work. So you literally don't need to 'unpack' the table when loops like this above exist. EDIT: I had the page open for like 30 minutes than I replied, didn't see your comment (the guy above) x)
  8. Is it a GUI scrollbar? If yes, then Wiki provides the best example: https://wiki.multitheftauto.com/wiki/GuiCreateScrollBar otherwise post your script so we can have a clue what you talkin' about
  9. local kills = {} addEventHandler ("onResourceStart", getRootElement(), function () for _,player in ipairs (getElementsByType ("player")) do local account = getPlayerAccount (player) local playerKills = getAccountData (account, "player.kills") table.insert (kills, playerKills) end end ) addCommandHandler ("ranking", function () table.sort (kills, function (a, b) return a > b end ) for _,v in ipairs (kills) do outputChatBox (v) --is gonna output kills from highest to lowest end end ) So firstly, you put all the players in a table (actually player's account) when the resource starts (you can change that as you wish, just an example). Once you do that, when you write /ranking the table is gonna sort and then the output with all the row as you want.
  10. triggerClientEvent(source,"mapRunningServer",source) Source is not defined. Try changing it to: triggerClientEvent("mapRunningServer", root)
  11. So, I'll try to sum it up quickly, the advantage of OOP is that you don't have to rewrite the whole thing over and over like "normal" scripts do. Even tho OOP is much harder, once you get used to it you won't ever script in the "normal" way again. In the script you posted, if you turn it into OOP nothing would change but the syntax. It's the same stuff literary, but I have a very good example that progressed me very much. https://forum.mtasa.com/viewtopic.php?f ... le#p753385 a cool example of metatables and OOPs.
  12. LabiVila

    Bounty

    You can use element data to determine the player with a bounty. setElementData and getElementData you can get all players in the server allPlayers = getPlayersCount () and assign a random number with randomplayer = math.random (1, allPlayers) then you can do this to assign the player as bounty for k, player in ipairs (getElementsByType ("player")) do if (k == randomplayer) then setElementData (player, "bounty", true) -- or anything you like end end Let me know for any problem
  13. What does debugscript say? It seems fine to me
  14. LabiVila

    Lock System

    local players = {cars = {}, unlockedFor = {}} addCommandHandler ("vehUser", function (player) players [player] = {} end ) addCommandHandler ("addVehicle", function (player, _, car) for name, v in pairs (players) do if (name == player) then table.insert (v.cars, car) end ) addCommandHandler ("lockFor", function (player, _, otherPlayer) local otherPlayer = getPlayerFromName (otherPlayer) for name, v in pairs (players) do if (name == player) then table.insert (v.unlockedFor, otherPlayer) end end end ) It looks a lot like this. Now you can do the 'unlockCarFor' command, opposite of the one above. and when a player enters the car as passager, you can loop through v.unlockedFor, see if there's a name similiar to the one that wants to enter, if yes let him enter, if no then cancelEvent
  15. LabiVila

    Lock System

    You can use something like this: players [player] = {cars = {}} now you can insert cars and 'carLock' like this: table.insert (v.cars, {car, sharable = true / false }}
  16. LabiVila

    ComboBox

    https://wiki.multitheftauto.com/wiki/Gu ... lectedItem this example provides you with almost all the stuff you need. You just have to change the names and add grid columns manually not with a loop ( `for id, playeritem in ipairs(getElementsByType("player")) do` ) and let us know what you do so we can help you.
  17. LabiVila

    Lock System

    How do you want to save the tables to vehicle? Could you explain more?
  18. This should work: addCommandHandler("startup", function(p, cmd, suf) if suf == "job" then if scripter[getAccountName(getPlayerAccount(p))] then for i, res in ipairs(getResources()) do local resName = getResourceName(res) if resName:find("Job_") then local finalRes = getResourceFromName (res) startResource(finalRes, true) end end end end end)
  19. By the way, I don't think you would want to use that, since there are 12 weapon slots and just 9 numbers (or 10)
  20. LabiVila

    [HELP] dxEdit

    or you can use this: addEventHandler ("onClientRender", root, function () dxDrawText(table.maxn (text), 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) end )
  21. If you count "onClientPlayerJoin should be totally wrong here", font-sized and quoted as a detailed explanation, then I agree I'm wrong.
  22. I'm not telling anyone whether if onClientPlayerJoin is wrong or not. I'm just telling him how it works. Not up to me to decide which events to use, so instead of replying me whether it's right or wrong, post the solution
  23. Try this one: addEventHandler ("onClientPlayerJoin", root, function () setTimer (checkTimer, 2000, 1) end ) function checkTimer () if not isTransferBoxActive() then outputDebugString("Not visible, proceed") else setTimer(checkTransferBox, 2000, 1) outputDebugString("Still visible, do not proceed") end end
  24. Have you edited anything on race gamemode ever? Edited anything? If you haven't, then there is most likely something of your scripts that messed up the race gamemode
×
×
  • Create New...