Jump to content


Scripting Moderators
  • Posts

  • Joined

  • Days Won


Everything posted by srslyyyy

  1. You should fix it, before your server will die out of endless triggering. addEventHandler("onClientRender", root, function() triggerServerEvent("GetItem", root)--give an order to make this event "getItem" run in server per frame end) Trigger client/server even should be well maintained. Right now, you call this function every frame, what if more players will join?
  2. Using source variable isn't safe. function EventName() if client then outputChatBox("Hi player!", client) end end addEvent("EventName", true) addEventHandler("EventName", root, EventName) https://wiki.multitheftauto.com/wiki/Script_security
  3. Perhaps it's your issue: distance*0.033 It's a text scale.
  4. srslyyyy

    Clear table

    Just do: tabla = {} Before loop.
  5. srslyyyy

    Clear table

    Do you want clear table from memory, reset it or clear data for certain element?
  6. You should use locals whenever you can. local col1 = createColSphere(...) local col2 = createColSphere(...) local col3 = createColSphere(...) do col1 = "still local, but it's a string now" col2 = "still local, but it's a string now" col3 = "still local, but it's a string now" end Tip: Attaching resource start event to root will cause that function will be triggered when ANY resource starts, use resourceRoot instead. addEventHandler("onResourceStart", getRootElement(), createTreasure)
  7. Yes, but load IFP just once. This should work correct if player latejoined, now just do the same, with all players when you loaded IFP (so if you started or restarted resource it will affect all players)
  8. "This function only affects a specific player or ped, the internal animation is not replaced for everyone, for instance, different players and peds are able to have completely different crouching, walking, and fighting etc., animations running simultaneously at the same time. Also, it's not synchronized, you'll need to execute this function on every client in Lua to synchronize it.", after loading IFP loop all players, and replace animation for them, aswell you will need onClientPlayerJoin to replace animation for him (if he joined late).
  9. 41. It's same w/out stun animation.
  10. I don't think it's a mods issue, i remember that i had similiar case on tactics gamemode. Tested it without replaced models and seems like it's the same.
  11. Either there is no damage, body part is invalid (unknown) or hit counts but damage doesn't. Test code: local vHits = 0 local tMuzzle = {} local vParts = { [3] = "Torso", [4] = "Ass", [5] = "Left arm", [6] = "Right arm", [7] = "Left leg", [8] = "Right leg", [9] = "Head", } function onClientPlayerWeaponFire(pWeapon, pAmmo, pAmmoInClip, pHitX, pHitY, pHitZ, pHitElement, pStartX, pStartY, pStartZ) if not pHitElement then return end local vStartX, vStartY, vStartZ = getPedWeaponMuzzlePosition(source) local vCol = {processLineOfSight(pStartX, pStartY, pStartZ, pHitX, pHitY, pHitZ, true, true, true, true, false, true, true, false, nil, false, false)} local vHitPart = vParts[vCol[11]] or "UNKNOWN" tMuzzle = {pStartX, pStartY, pStartZ, pHitX, pHitY, pHitZ} vHits = vHits + 1 outputChatBox("[HIT #"..vHits.."]: X, Y, Z: "..pHitX..", "..pHitY..", "..pHitZ.." | Hit element: "..tostring(pHitElement).." | Hit bodypart: "..vHitPart) end addEventHandler("onClientPlayerWeaponFire", root, onClientPlayerWeaponFire) -- function onClientPlayerDamage() outputChatBox("Damage confirmed at hit: "..vHits) end addEventHandler("onClientPlayerDamage", root, onClientPlayerDamage) -- function onClientRender() if #tMuzzle == 6 then dxDrawLine3D(tMuzzle[1], tMuzzle[2], tMuzzle[3], tMuzzle[4], tMuzzle[5], tMuzzle[6], tocolor(200, 0, 0, 255), 3) end end addEventHandler("onClientRender", root, onClientRender) On screen below, there was no collision check. But hits #6, #7 confirmed that element got hit, but no damage was given. (don't mind bodypart, there was no collision check on it)
  12. Hi. I've just found out that it's a task. Is there any way to disable it? It cause some hits to not confirm.
  13. https://wiki.multitheftauto.com/wiki/SetVehicleDamageProof
  14. Still not possible to download.
  15. Script isn't accessible from link.
  16. Show your code and i might help you with optimisation. (if possible)
  17. What if user will delete cache? Or will manipulate it on other way? Do not be afraid to use SQLite/MySQL. If you have lot of data, you can store it in one column as a JSON string aswell.
  18. Tables aren't synced by default. If you create tables via shared script, they do not have same data (unless you will sync it). Take a look at this topic, might be helpful.
  19. Shared won't work. Example: -- Client local clientTable = {} -- function onClientDataSync(serverData) clientTable = serverData end addEvent("onClientDataSync", true) addEventHandler("onClientDataSync", resourceRoot, onClientDataSync) -- function onClientReceiveVehicleData(...) local receivedData = {...} local vehicleUserdata = receivedData[1] local vehicleData = receivedData[2] clientTable[vehicleUserdata] = vehicleData outputConsole(inspect(clientTable)) end addEvent("onClientReceiveVehicleData", true) addEventHandler("onClientReceiveVehicleData", resourceRoot, onClientReceiveVehicleData) -- Server local serverTable = {} local newVehicle = createVehicle(411, 0, 0, 3) -- serverTable[newVehicle] = "Some data you want to pass" About sync: --[[Sync for everyone]] triggerClientEvent(root, "onClientReceiveVehicleData", resourceRoot, newVehicle, serverTable[newVehicle]) --[[When player latejoined - pass data f.e when he logins]] triggerClientEvent(source, "onClientDataSync", resourceRoot, serverTable)
  20. You don't check if this gridlist exists. About this part of code, you are destroying your server network. for k,v in ipairs(getElementsByType("ped") do if getElementData(v, "created") then pedsToTrigger = {} table.insert(pedsToTrigger, v) triggerClientEvent(thePlayer, "someEvent", resourceRoot, pedsToTrigger) end end Trigger will be called 1 * count of peds, it's very bad. Because it could be done with just 1 trigger. -- Client local pedsGridlist = false -- function customEvent(serverTable) if not pedsGridlist then pedsGridlist = guiCreateGridList(200, 100, 50, 50, false) end -- Finish your code end addEvent("customEvent", true) addEventHandler("customEvent", resourceRoot, customEvent) local peds = { {11, 0, 0, 3, "NPC 1"}, {11, 0, 0, 4, "NPC 2"}, } -- function createPeds() local ped = false local pedData = false local dataToSend = {} for i = 1, #peds do pedData = peds[i] ped = createPed(pedData[1], pedData[2], pedData[3], pedData[4]) dataToSend[#dataToSend + 1] = {ped, pedData[5]} end setTimer(function() triggerClientEvent(root, "customEvent", resourceRoot, dataToSend) end, 1000, 1) end addEventHandler("onResourceStart", resourceRoot, createPeds)
  21. You didn't passed table. I prefer adding elements manually. local someTable = {} local somePed = createPed(11, 0, 0, 3) -- 1st way, ped will be accessible via number, mostly you will need to loop whole table if there's more elements someTable[#someTable + 1] = somePed print(tostring(someTable[1])) -- output: ped userdata -- 2nd way, ped will be accessible via reference someTable[somePed] = somePed print(tostring(someTable[somePed])) -- output: ped userdata
  22. Use vehicle variants maybe? https://wiki.multitheftauto.com/wiki/Vehicle_variants
  23. https://github.com/multitheftauto/mtasa-blue/issues/1415
  24. Other solution, you might try to use animation when they got hit by car. (onClientPedDamage)
  • Create New...