Jump to content

Drakath

Members
  • Posts

    768
  • Joined

  • Last visited

Everything posted by Drakath

  1. There is no newer crash log.
  2. Ah, I had it again today. Any idea who could cause this?
  3. Drakath

    Parachute

    It's just a default resource, I didn't edit it. local function onResourceStart ( resource ) local players = getElementsByType ( "player" ) for k, v in pairs ( players ) do setElementData ( v, "parachuting", false ) end end addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) function requestAddParachute () local plrs = getElementsByType("player") for key,player in ipairs(plrs) do if player == client then table.remove(plrs, key) break end end triggerClientEvent(plrs, "doAddParachuteToPlayer", client) end addEvent ( "requestAddParachute", true ) addEventHandler ( "requestAddParachute", resourceRoot, requestAddParachute ) function requestRemoveParachute () takeWeapon ( client, 46 ) local plrs = getElementsByType("player") for key,player in ipairs(plrs) do if player == client then table.remove(plrs, key) break end end triggerClientEvent(plrs, "doRemoveParachuteFromPlayer", client) end addEvent ( "requestRemoveParachute", true ) addEventHandler ( "requestRemoveParachute", resourceRoot, requestRemoveParachute ) If this is a bug, I think developers should take a look at it.
  4. Drakath

    Parachute

    WARNING: [gameplay]/parachute/parachute.lua:18: Bad usage @ 'triggerClientEvent' [ section in the meta.xml is incorrect or missing (expected at least server 1.3.0-9.04570 because a send list is being used)] WARNING: [gameplay]/parachute/parachute.lua:32: Bad usage @ 'triggerClientEvent' [ section in the meta.xml is incorrect or missing (expected at least server 1.3.0-9.04570 because a send list is being used)] Meta: <meta> <info author="Jax + Talidan" description="Parachutes script" version="1.0.1" /> <min_mta_version client="1.3.0-9.04570" /> <script src="utility.lua" type="client" /> <script src="parachute.lua" /> <script src="parachute_cl.lua" type="client" /> <script src="skydiving_cl.lua" type="client" /> <script src="openChute.lua" type="client" /> <script src="client_anim.lua" type="client" /> <file src="parachuteopen.mp3" /> <export function="removeParachute" type="client" /> <export function="stopSkyDiving" type="client" /> <export function="isPlayerSkyDiving" type="client" /> <export function="isPlayerParachuting" type="client" /> </meta>
  5. Drakath

    Tables

    I'm trying to index some stuff but I can't get it to work. I have a text which is assigned to a player. I want to check if this text is assigned. (I do not want to use account data) There can be many different texts. Here's what I tried: if pText[player] then table.insert(pText[player], {[text] = "someValue"}) else pText[player] = {[text] = "someValue") } end --I check if it is assigned like this: if pText[player][text] then doStuff() end The first text works but when it tries to assign the second text and uses table.insert, my script doesn't detect it anymore. Can anyone help me fix this?
  6. Ah, that's a lot of work. It worked before MTA 1.4 When MTA 1.4 was released I kept getting errors: WARNING: bone_attach\bone_attach_c.lua:79: Bad argument @ 'setElementPosition' [Expected number, got NaN] WARNING: bone_attach\bone_attach_c.lua:80: Bad argument @ 'setElementRotation' [Expected number, got NaN] So I added: if (not tonumber(tostring(objx)) or not tonumber(tostring(objy)) or not tonumber(tostring(objz))) then return end if (not tonumber(tostring(offrx)) or not tonumber(tostring(offry)) or not tonumber(tostring(offrz))) then return end This fixed the warnings but this problem appeared.
  7. I don't think I could. There can be up to 200 of those objects and in MTA wiki it says that you shouldn't disable streaming on too many elements. Maybe I should create those objects client-side?
  8. This doesn't work since MTA 1.0.5
  9. I already destroy them when a Player leaves. The problem happens not when a player leaves, it's completely random. Sam1er, are you saying that I should add setElementParent to attachElementToBone function? Because a function with the code you posted already exists: function attachElementToBone(element,ped,bone,x,y,z,rx,ry,rz) if not (isElement(element) and isElement(ped)) then return false end if getElementType(ped) ~= "ped" and getElementType(ped) ~= "player" then return false end bone = tonumber(bone) if not bone or bone < 1 or bone > 20 then return false end x,y,z,rx,ry,rz = tonumber(x) or 0,tonumber(y) or 0,tonumber(z) or 0,tonumber(rx) or 0,tonumber(ry) or 0,tonumber(rz) or 0 attached_ped[element] = ped attached_bone[element] = bone attached_x[element] = x attached_y[element] = y attached_z[element] = z attached_rx[element] = rx attached_ry[element] = ry attached_rz[element] = rz if setElementCollisionsEnabled then setElementCollisionsEnabled(element,false) end if script_serverside then triggerClientEvent("boneAttach_attach",root,element,ped,bone,x,y,z,rx,ry,rz) end return true end
  10. I'm not using pairs() or ipairs()...
  11. Alright, thanks everyone. So as I understood, local players = getElementsByType("player") for i=1, #players do outputChatBox("Hello", players[i]) end is the most efficient way possible.
  12. I know what each does but what I asked was: when should I use ipairs and when pairs? And what about the code's efficiency?
  13. So when should I use pairs and when ipairs? Or should I always use pairs instead? Is it more efficient to use Necktrox's code or: for _,v in pairs(getElementsByType("player")) do outputChatBox("Hello",v) end ?
  14. What is more efficient? This: for _,v in ipairs(getElementsByType("player")) do outputChatBox("Hello",v) end or this: outputChatBox("Hello",root)
  15. There is a crash dump: http://www67.zippyshare.com/v/87594783/file.html
  16. Sometimes (about once a month) my server randomly shutdowns by itself and the Screen is gone. I have to attach my server to Screen again to make it work. I thought it was a host problem but when I contacted the support, they said everything is fine on their side and something is wrong with the software I use, which is a MTA server. Can someone help me to find what causes this problem? I run Debian 7.0 64 bit. Logs look fine.
  17. I have a script that attaches weapons to players using bone_attach but sometimes the weapons hang in the air: Here's my bone_attach onClientPreRender part: function putAttachedElementsOnBones() for element,ped in pairs(attached_ped) do if not isElement(element) then clearAttachmentData(element) elseif isElementStreamedIn(ped) then local bone = attached_bone[element] local x,y,z = getPedBonePosition(ped,bone_0[bone]) local xx,xy,xz,yx,yy,yz,zx,zy,zz = getBoneMatrix(ped,bone) local offx,offy,offz = attached_x[element],attached_y[element],attached_z[element] local offrx,offry,offrz = attached_rx[element],attached_ry[element],attached_rz[element] local objx = x+offx*xx+offy*yx+offz*zx local objy = y+offx*xy+offy*yy+offz*zy local objz = z+offx*xz+offy*yz+offz*zz local rxx,rxy,rxz,ryx,ryy,ryz,rzx,rzy,rzz = getMatrixFromEulerAngles(offrx,offry,offrz) local txx = rxx*xx+rxy*yx+rxz*zx local txy = rxx*xy+rxy*yy+rxz*zy local txz = rxx*xz+rxy*yz+rxz*zz local tyx = ryx*xx+ryy*yx+ryz*zx local tyy = ryx*xy+ryy*yy+ryz*zy local tyz = ryx*xz+ryy*yz+ryz*zz local tzx = rzx*xx+rzy*yx+rzz*zx local tzy = rzx*xy+rzy*yy+rzz*zy local tzz = rzx*xz+rzy*yz+rzz*zz offrx,offry,offrz = getEulerAnglesFromMatrix(txx,txy,txz,tyx,tyy,tyz,tzx,tzy,tzz) if (not tonumber(tostring(objx)) or not tonumber(tostring(objy)) or not tonumber(tostring(objz))) then return end if (not tonumber(tostring(offrx)) or not tonumber(tostring(offry)) or not tonumber(tostring(offrz))) then return end setElementPosition(element,objx,objy,objz) setElementRotation(element,offrx,offry,offrz,"ZXY") else setElementPosition(element,getElementPosition(ped)) end end end addEventHandler("onClientPreRender",root,putAttachedElementsOnBones) Can someone help me fix it? There are no errors or warnings in the debugscript 3.
  18. Anyway, I got it working with getTickCount(). The tables worked perfectly. Thank you everyone.
  19. Thanks, the tables work fine now. There is one more problem, when my table starts from an index higher than 1, it stops working. I use JSON. For example, when myTable is [ { "2": 175614 } ], JmyTable = fromJSON(myTable) JmyTable[2] is nil.
  20. What if the range of things that I need to store can differ from 1 to 8? I also need to keep that index. This is the script that I had: function q(data1, data2) if data2 == 1 then timers[client][1] = data1 timers[client][2] = getTickCount() end if data2 == 2 then timers[client][3] = data1 timers[client][4] = getTickCount() end if data2 == 3 then timers[client][5] = data1 timers[client][6] = getTickCount() end if data2 == 4 then timers[client][7] = data1 timers[client][8] = getTickCount() end end This can be 1 and 2 or 3 and 4 or 5 and 6 or 7 and 8. How can I store them while keeping the right index?
  21. But I need to store 2 things with timers[client]. Do I need to create another table for that?
×
×
  • Create New...