Jump to content

srslyyyy

Scripting Moderators
  • Posts

    635
  • Joined

  • Days Won

    8

Everything posted by srslyyyy

  1. checkOnline is custom function, which doesn't exist normally in MTA. For console command - delete/comment check for player. function checkOnline(player, cmd) --if player then outputChatBox(#getElementsByType("player")) --end end addCommandHandler("players", checkOnline)
  2. Wrong. bool addCommandHandler ( string commandName, function handlerFunction [, bool restricted = false, bool caseSensitive = true ] ) root shouldn't be there, but anyways you don't need to add command to execute this function. You can simply add createCar() under your function, and it will be processed.
  3. function checkOnline(player, cmd) if player then outputChatBox(#getElementsByType("player")) end end addCommandHandler("players", checkOnline)
  4. What's your server/client version? This could be problem due of https://github.com/multitheftauto/mtasa-blue/commit/d2c53c73e327ade55862043af9bd53da64dd351a (r20391), but it should be fixed, there was 2 commits that should correct this - https://github.com/multitheftauto/mtasa-blue/commit/24a233f6e897771504a270940e05ccc4652bce53 (r20394), and https://github.com/multitheftauto/mtasa-blue/commit/a5508d8cead013a0b08e9c2cddb5914e46be1abd (r20398), so i suggest you to update your server/client to r20398 or even higher.
  5. Not finished comment i guess? -dxSetBlendMode("blend") Perhaps do you use /debugscript 3 because it doesn't seems to?
  6. If you want to do so, your event should be attached to root. resource_1 function onResourceStart() triggerEvent("eventHandler", root) end addEventHandler("onResourceStart", resourceRoot, onResourceStart) resource_2 function eventHandler() iprint("Serverside function was triggered at resource: "..getResourceName(getThisResource()).." from resource: "..getResourceName(sourceResource)) end addEvent("eventHandler", true) addEventHandler("eventHandler", root, eventHandler) Result:
  7. He can also use ipb resource which is available by default: start ipb ipb In console.
  8. I play on 4% for horizontal/vertical sensitivity. Try reduce it, even to 0%, i know players which play well and doesn't complain about it. (at 0%)
  9. What's your mouse sensitivity in MTA settings?
  10. Looks awesome, can you share shader code as .fx?
  11. It should be something like that: (if am i wrong i hope someone will correct me) local startTick = getTickCount() local players = getElementsByType("player") -- ipairs for i = 1, 10000 do for index, player in ipairs(players) do outputChatBox(getPlayerName(player)) end end outputDebugString("ipairs done in "..getTickCount() - startTick.." ms.") -- pairs startTick = getTickCount() for i = 1, 10000 do for index, player in pairs(players) do outputChatBox(getPlayerName(player)) end end outputDebugString("pairs done in "..getTickCount() - startTick.." ms.") -- int startTick = getTickCount() for i = 1, 10000 do for i = 1, #players do outputChatBox(getPlayerName(players[i])) end end outputDebugString("int done in "..getTickCount() - startTick.." ms.") By the way, if you gonna use some variables in loop, it is better (faster) to declare them out of scope, and reuse them. I suggest to test it singly, because sometimes it could give you different results, as you can see here - pairs should be faster than ipairs - as far i know Separately:
  12. Related, perhaps you doing it wrong. And yes for i = 1, #tablesize is faster, much people don't care much about performance. I can tell you that with integer loop, i achieved pretty nice performance boost on bone attach resource (and some other tricks.)
  13. So explain what doesn't work in here?
  14. By the way there's no need to attach sound by using bone attach. You can use attachElements instead - https://wiki.multitheftauto.com/wiki/AttachElements
  15. Should help a bit - https://springrts.com/wiki/Lua_Performance
  16. Randomize damage every time zombie is hitting you.
  17. Why not create your own gamemode, instead of basing on something that is badly written? From public: https://github.com/NullSystemWorks/mtadayz
  18. If uses data from table, then there's is your problem: gameplayVariables["zombiedamage"] = math.random(800,2000) It is only randomized once, on script initalization.
  19. In my honest opinion this would be worse, you are just complicating it, but before that. 1) Don't attach events to root, use resourceRoot instead - this is sufficient if event is handled by same resource, as wiki says events attached to root are very CPU intensive (client/server) 2. getLocalPlayer() it's a function call which returns local player, you should use existing predefined variable localPlayer instead. 3. Use client predefined variable on server-side, when using events - https://wiki.multitheftauto.com/wiki/Script_security 4. ipairs it's slowest loop you can use. You might use integer loop which is fastest loop: local players = getElementsByType("player") local player = nil for i = 1, #players do player = players[i] -- it's your player end I understand you, and your trial to improve an server/client performance, i'm one of those persons which care about that. To the point, the way you presented above could by replaced by simply server-side check for players around (i suggested possibility to add table as receiver instead of looping players, hope someone would do it) rather than sending informations to client and sending it back to server. Passing data between sides seems to be more expensive. If i am wrong, i'm pretty sure IIYAMA could correct me.
  20. Why? I'm using tables n triggers since past year, and everything works well :)
  21. You can pass tables in triggerClientEvent/triggerServerEvent as argument.
  22. Perhaps you use maybe wrapper for element data? if GetElementData(player,"AdminLvl", 5) then Should be: if getElementData(player,"AdminLvl", 5) then Lua is case sensitive.
  23. This will work faster and better: local players = getElementsByType("player") local playersList = {} local player = nil for i = 1, #players do player = players[i] if player ~= localPlayer then playersList[#playersList + 1] = player end end We use integer loop, which is fastest loop so far. We avoid using table.insert, manually adding is faster.
×
×
  • Create New...