Jump to content

srslyyyy

Scripting Moderators
  • Posts

    635
  • Joined

  • Days Won

    8

Everything posted by srslyyyy

  1. No, i want to know if i need to destroy sound. Attached sound have normal behaviour like sound which isn't attached to player? (loop = false)
  2. Hey. I have question, if i attach sound to player i need destroy it? By using attachElements or attachElementToBone(aSound, source, 3, 0.19, -0.31, -0.1, 0, 270, -90) Thanks for help anyway.
  3. @DNL291 I tried to do it, but doesn't work, I am sure that i am doing it wrong. row1, column1 = guiGridListGetSelectedItem(gridlistItems["inventory"]) -- this is at beginning of function which refresh player inventory. local row = guiGridListAddRow(gridlistItems["inventory"]) -- this is in middle of function, there's some more loops with other categories. guiGridListSetItemText(gridlistItems["inventory"], row, gridlistItems["inventory_colum"], "Food and Drinks", true, false) for i, item in ipairs(inventoryItems["Food and Drinks"]) do if getElementData(getLocalPlayer(), item[1]) and getElementData(getLocalPlayer(), item[1]) >= 1 then local row = guiGridListAddRow(gridlistItems["inventory"]) guiGridListSetItemText(gridlistItems["inventory"], row, gridlistItems["inventory_colum"], item[1], false, false) guiGridListSetItemText(gridlistItems["inventory"], row, gridlistItems["inventory_colum_amount"], getElementData(getLocalPlayer(), item[1]), false, false) end end if row1 and column1 then -- and this is nearly at the end of function guiGridListSetSelectedItem(gridlistItems["inventory"], row1, column1) end Or i should do it after player drop a item. I don't have idea, can u help me a bit? This is clear, not edited function.
  4. srslyyyy

    Performance

    You can use 'ipb' resource in-game. Type start ipb, then type ipb in console. It shows usage of CPU, for client/server. In options you can type -d, by that you will know source (first line of function).
  5. I'll test it out soon, thanks for answer
  6. Tested it and doesn't work. I tried to change guiGridListSetSelectedItem(gridlistItems["inventory"], row1, column1) on guiGridListSetSelectedItem(gridlistItems["inventory"], row1 - 1, column1) It works, however it executes each time player drop a item. I will try to explain it better, here's a picture. Green arrow (from top to bottom): - Player drop a item, Pepsi. When there's no more Pepsi, script marks next item (Coca-Cola) - Player drop a item, Coca-Cola, When there's no more Coca-Cola, script marks next item (Mountain Dew) - Player drop a item, Mountain Dew, When there's no more Mountain Dew, script clear selection (which it's fine, because there's no more items in this category) Red arrow (from bottom to top): - Player drop a item, Mountain Dew, When there's no more Mountain Dew, script clear selection (and that's the problem, because it should mark the item which is above - Coca-Cola) By other words, if player drop item from bottom, script should mark next item, because of that player is forced to do it manually.
  7. Hey. I need a little help from you guys. row1, column1 = guiGridListGetSelectedItem(gridlistItems["inventory"]) if row1 and column1 then guiGridListSetSelectedItem(gridlistItems["inventory"], row1, column1) end This thing select next item in inventory, it works as it should, however if this is last item then item which it's above don't select, and i need to mark it manually.
  8. I need to get length of all values from table. If atleast one value text length it's >= 25 then i need to do something. Sorry i can't explain it better for now.
  9. What? Code is correct, but i need to make it on other way, this is no answer for my questions.
  10. Hey, today a problem appeared, i need to do something but i don't know how i can solve it. 1. How can i get text length of everything what's in the table. 2. If length atleast of one value from table will be >= 25 then do something for everything. Code: local textTable = { "abcdefghijklmnopqrstu", -- 21 "abcdefghijklmnopqrstu123", -- 24 "abcdefghijklmnopqrstu124", -- 25 } addEventHandler("onClientRender", getRootElement(), function() if getPedOccupiedVehicle(getLocalPlayer()) then return end for k, v in pairs(textTable) do dxDrawingColorTextMenuScroll(v, 6, 350 + k * boxSpace, 6, 350 + (k + 1) * boxSpace, tocolor(255, 255, 255, 255), 170, 1, "sans", "left", "center") if string.len(v) >= 25 then -- problem is here, this works only for the value which have text >= 25 -- do something for everything in table else -- otherwise end end end)
  11. Thanks. But about 1st question, what obfuscate option really does?
  12. Hey. Some questions about securing scripts. So as far i know there is no guarantee that my script will be 100 % safe. I can compile both, side or client side scripts. Someone also said that compiling scripts make that scripts works better, as MTA doesn't need to convert plaintext to lua bytecode. So here are my questions: 1. What does really obfuscate 1/2 option does, it's worth to use it when compiling? 2. Compiling scripts make them load faster or work more efficient? 3. After compiling script to luac, there's nothing wrong if i change extension of file to lua? Kind of funny question, but i want to know.
  13. Oh well, that's my bad, thank you for explaining everything.
  14. That's probably everything what i need to know. About second step if i wanna replace it for RPG i should use createExplosion within onPlayerWeaponFire?: endX, endY, endZ: float world coordinates representing an end point. Because as i see onClientPlayerWeaponFire: Note: This does not trigger for projectiles, melee weapons, or camera. I am right?
  15. Hello. I wanna do something as default GTA SA have. It's about explosion damage, which it's not same all the time, it depends on distance of where explosion was created and how close player was. Following code: function damage(attacker, weapon, bodypart, loss) cancelEvent() outputChatBox(weapon.." "..loss) end addEventHandler("onClientPlayerDamage", getLocalPlayer(), damage) Give me that results: 19 82.5 19 65.310546875 19 58.554851531982 First explosion was under me, and others were a little further from me. So i have a question, how i can create something similar to it, and i don't want to use the default GTA SA damage for my gamemode (for known reasons). I think i can use getDistanceBetweenPoints, but what next?
  16. By the way, there is other way than onClientRender to keep image stay visible, and refresh it frequently, so i can reduce usage of player CPU's?
  17. Well i should care about it, because onClientRender is the one and only event which use a lot of CPU. It's used to draw icons, vehicle menu, speedometer and other things. And i want that my code looks clearly, and works efficiently, as far it's possible. ipairs it's for iterating through numbers, and pairs iterates through all keys?
  18. Hi. I have a question about efficient. I have a function which creates, and update a image every frame (onClientRender), and i need to change color of those images. So i have two ways: 1. Using a lot of if's, and by that change a image color. 2. Or use a function which is using data from table, loop "for" which returns color value. local partsColor = { {maxv = 1000, minv = 1001, r = 92, g = 141, b = 71}, {maxv = 910, minv = 999, r = 92, g = 141, b = 71}, {maxv = 910, minv = 909, r = 90, g = 141, b = 71}, } function getColor(value) for i, color in ipairs(partsColor) do if value >= color.maxv and value <= color.minv then return color.r, color.g, color.b end end end I'm asking because i don't know if i should loop within onClientRender.
  19. I'm very grateful, thank you for help. I will test out it asap, and if something will be wrong i will inform you
  20. So if i don't want count sound to it i need just add a condition, like this? Because i think there is no other way. Or this will not work? I just wanna be sure. function onClientPlayerWeaponFire(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if source == getLocalPlayer() then -- don't count sound else -- count sound? end end addEventHandler("onClientPlayerWeaponFire", getRootElement(), onClientPlayerWeaponFire)
  21. I don't understand element tree for now, so as far i understand this, it will store sounds, after sound will end, it will disappear from this. This should avoid playing more than 5 sounds in one time, i am right? If not, sorry, i'm new to this. But what if want "give" an immunited for a sound that is created by me, so it will not count to it? Thanks anyway.
  22. -- outside the function local checkSound = getTickCount() -- inside the function local lastShot = getTickCount() if lastShot > checkSound then -- playsound checkSound = lastShot + 20 end Thank you for the answer , this is the similar function which i used, and it was causing huge lags. About tables. I used them already, in some ways. However i don't have idea how can i make a sound system like this. Inserting in table, iterate weapon sounds in table - through loop 'for' , check if it's more than x sounds? Can you guide me a bit more?
  23. Hi. I have some questions about sounds. Which are important in my server, because they are playing often. 1. Is the .ogg format better than .wav? I noticed that .ogg have better quality, and weight it's much less than .wav, f.e: - .wav weapon sound: 140 kb - .ogg weapon sound: 10 kb 2. I saw somewhere on forum, that sound created by playSound3D doesn't disappear, and it need to be destroyed manually, or i am wrong? 3. How can i reduce frequency of playing weapon sounds, if a lot of players shoot in one time, it decrease performance. I tried to reduce them with using and comparing: getTickCount() But server started to lagging on 30 + players. 4. How can i create some kind of a sound system which: - will check if there's for example 4-5 weapon sounds playing. - if yes, then not all of them will be hearable, but your own weapon sound will plays without any delays.
  24. Hello. I am using an setPedAnimation for reload system, but i have two problems which i can't solve. setPedAnimation(source, "rifle", "RIFLE_load", -1, false, true, false, false) 1. During animation you can't move. (looks like freeze but it isn't) 2. Your character stands up when you are crouching. (annoying) Some servers solved it but i don't know how can i fix it on my server, that's why i'm looking for workaround and asking you guys about help.
  25. Hi. I have some questions about things above. As far i understand: getRootElement() it's same as root and getResourceRootElement() it's same as resourceRoot But i don't really understand where i should use getRootElement() / getResourceRootElement(). Can someone explain me about this, would be nice with a 2 examples.
×
×
  • Create New...