Jump to content

ShayF2

Members
  • Posts

    230
  • Joined

  • Last visited

  • Days Won

    1

ShayF2 last won the day on January 11 2018

ShayF2 had the most liked content!

3 Followers

Details

  • Gang
    Grove
  • Location
    Grove St
  • Occupation
    Drifting
  • Interests
    Scripting

Recent Profile Visitors

3,369 profile views

ShayF2's Achievements

Trick

Trick (18/54)

53

Reputation

  1. ShayF2

    MTA Offline Wiki

    should i continue on this?
  2. You have to use relative positioning on everything you draw.
  3. Use absolute positioning (your resolution whole numbers) then calculate the relative position with this local devx, devy = 1366, 768 -- your resolution local clientx, clienty = guiGetScreenSize() -- everyone's resolution function absoluteToRelativeDX(x, y, w, h) return x/devx*clientx, y/devy*clienty, w/devx*clientx, h/devy*clienty end Hopefully this helps you.
  4. ShayF2

    Who am I?

    @IIYAMA you got it boss.
  5. ShayF2

    Who am I?

    Who am I? Anyone can respond. Be honest, I wont argue.
  6. I think you first need to learn what table index's and table keys are, @MissionComp. Table index's are the positions inside the table, and using such index can allow you to grab things from a specific spot in the table. Index's go up from 0, and they go to like an infinite amount. Say you have a table: local t = {} Now lets put something in the table: table.insert(t, 'Hello World') Okay so we've put a string that says Hello World into the table. Now the table looks like this, without you having to recreate it again: t = {'Hello World'} So now that we have a value in there I can explain how index's work. Since the tables index starts at 0, as soon as you put an item in it, the index count goes up. So now, 'Hello World' has an index of 1 in the table. To call this you do: t[1] Here is an example of using this: outputChatBox(t[1]) t = {position1, position2, position3, etc} t = {index1, index2, index3, etc} I wont cover keys because I don't really need to but I will cover loops. When you use the function getElementsByType, it returns a table, that table contains elements. You can look up a list of elements on MTA's Wiki, I'll post a link below. You use this function to get a table of all the elements of the specified type. Say we get the players in the server for example: local t = getElementsByType('player') Each player is put into a table, and the index simply is the position inside the table where a specific player is. So say you only wanted the 4th player in the server: local t = getElementsByType('player') killPed(t[4]) and then we would kill that player. #table just returns the amount of items in a table So say we wanted to get the amount of players in the server: local t = getElementsByType('player') print(#t) So now onto loops. There are two types of loops, a pairs loop and an integer loop. The difference between a pairs loop and an integer loop is simple. An integer loop simply goes from one number to another, basically counting up, or down if you will. A pairs loop actually runs through a table and returns its data in defined variables. Example of an integer loop: for i=1, 5 do this will go from 1 to 5, in like a count-up. i is your defined variable that you use to get what number it is on. for i=1, 5 do print(i) end so this would print: 1 2 3 4 5 An example of using this would be local t = {'hello', 'world'} for i=1, #t do print(t[i]) end this would print: hello world Example of a pairs loop: for i, v in pairs(getElementsByType('player')) do Inside of the pairs function would go your table, i becomes your index and v becomes your value/item, this returns both and they will always match each-other, so here's an example of using that: local t = {'hello', 'world'} -- and you can use either the index method shown above or use v for i, v in pairs(t) do print(v); print(t[i]); end I wasn't going to go through and fix the code I give you because I honestly expected it to work. So I figured I'd teach you and other people something, in hopes that you can solve the issue yourself. I hope that this response helps you and I wish you a good day. Page to MTA SA Element List: Element
  7. -- this is for individual objects if u want to count only the ones u create local objects = {} local _obj = createObject Object = createObject function createObject(...) local obj = _obj(...) objects[#objects+1] = obj return obj end -- then you would use index's on objects table like before if objects[1] then print(getElementPosition(objects[1])) end -- this is for if you want to grab all objects local objects = getElementsByType('object') -- then use index's like I said before if objects[1] then print(getElementPosition(objects[1])) end
  8. line 93 is just killTimer, replace this with if isTimer(timerVehicle) then killTimer(timerVehicle) end
  9. Bad TXD ? Vertex's may not be lined up correctly, textures could be missing, textures could be overlapping, idk. I'm not so big into modeling lol.
  10. If you're running this clientside then oyuncu doesn't exist. Try running it serverside.
  11. function TST(player, command, accountName) assert(type(accountName) == 'string', 'Expected string @ TST:accountName, got "'..type(accountName)..'"') local account = getAccount(accountName) assert(account, 'Unable to get account @ TST:account, got "'..type(account)..'"') local player = getAccountPlayer(account) assert(player, 'Unable to get player from account @ TST:account, got "'..type(player)..'"') if player then Try this for debugging
  12. local players = getElementsByType('player') local vehicles = getElementsByType('vehicle') -- then just use index's, like this if player[1] then -- 1, 2, 3, 4, 5 etc inside of [], this number will be your index or your 'id' outputChatBox(getPlayerName(player[1])) end
  13. ShayF2

    pairs vs ipairs

    When you run a loop in pairs, it grabs not only indexed items but also objects. Objects have keys and values. for k, v in pairs(table) do in this case k would be your key, and v would be its value. Keys are always strings. Say it's not an object, instead its an indexed item, k would become the index, and v would be the value for that index. ipairs however, loops through ONLY indexed items and it does them in order. So ipairs will not grab objects. pairs is faster than ipairs since it does not have to sort through the table first. for i=1, #table do this is called an Int loop, where it simply goes from 1 number to another, i=start, end i represents index mostly because people use this loop to grab table index's. it is by far the fastest loop, as it doesn't have to sort through the table, or return an extra argumented variable. #table just returns the amount of items in a table
  14. Sending data between server and client is called Syncing. You can sync easily, however you only want the traffic to go from server to client and not the other way around. If you were to go the other way around then players would be able to exploit certain parts of your data transfer. You can sync using element data (which is faster, I tested myself) or the safer and more reliable way with events. Either one should work just fine. Az adatok küldése a kiszolgáló és az ügyfél között szinkronizálás. Könnyedén szinkronizálható, de csak azt szeretné, ha a forgalom kiszolgálóról ügyfélre megy, és nem fordítva. Ha a másik irányba megy, akkor a játékosok képesek lesznek kihasználni az adatátvitel bizonyos részeit. Szinkronizálhatja az elemadatokat (ami gyorsabb, teszteltem magam) vagy a biztonságosabb és megbízhatóbb módokat az eseményekkel. Bármelyiknek jól kell működnie.
×
×
  • Create New...