Jump to content

uBiT

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by uBiT

  1. uBiT

    Text labels

    Nope, no errors/warnings at all. EDIT: Solved. Just needed to change in function destroy3DText this line: table.remove(TextLabels, i) to TextLabels = nil Because with table.remove it removes row in that table and other row's gets a new 'id' - thats why it couldn't destroy a label.
  2. uBiT

    Text labels

    Hello, i'm trying to create a function create3DText, to show in-game 3D text, which was created with dxDrawText. Although function works, but i have a strange problem and i don't know how to solve it. Here are my client-side script: local TextLabels = { } local i = 0 function create3DText(text, color, font, scale, x, y, z, dist, dimension, hex) if not dimension then dimension = 0 end i = i + 1 local elm = createElement('base') setElementPosition(elm, x, y, z) setElementDimension(elm, dimension) TextLabels[i] = elm local elmData = { } elmData['text'] = text elmData['color'] = color elmData['font'] = font elmData['scale'] = scale elmData['dist'] = dist elmData['hex'] = hex setElementData(elm, 'text.elm.Data', elmData) return i end function destroy3DText(labelID) if not labelID or not TextLabels[labelID] then return end table.remove(TextLabels, labelID) setElementData(TextLabels[labelID], 'text.elm.Data', false) if isElement(TextLabels[labelID]) then destroyElement(TextLabels[labelID]) end end function showLabels() for i, label in pairs(TextLabels) do if isElement(label) then local elmData = getElementData(label, 'text.elm.Data') if isElement(elmData['attach']) then local posX, posY, posZ = getElementPosition(elmData['attach']) setElementPosition(label, posX, posY, posZ) end create3DText_(label, elmData['text'], elmData['color'], elmData['font'], elmData['scale'], elmData['dist'], elmData['hex'], elmData['aX'], elmData['aY'], elmData['aZ']) else table.remove(TextLabels, i) end end end addEventHandler('onClientRender', getRootElement(), showLabels) function create3DText_(elm, text, color, font, scale, dist, hex, x, y, z) if not x then x = 0.0 end if not y then y = 0.0 end if not z then z = 0.0 end local mX, mY, mZ = getElementPosition(elm) local cX, cY, cZ = getCameraMatrix() if isLineOfSightClear(cX, cY, cZ, mX, mY, mZ, false, false, false, false, false, false, false, elm) then local distance = getDistanceBetweenPoints3D(cX, cY, cZ, mX, mY, mZ) if distance <= dist then local pX, pY = getScreenFromWorldPosition(mX + x, mY + y, mZ + z, 0.06) if pX then dxDrawText(text, pX, pY, pX, pY, color, scale, font, 'center', 'center', false, false, false, hex) end end end end function attach3DText(labelID, element, x, y, z) if not element or not labelID then return end for i, label in pairs(TextLabels) do if i == labelID then local elmData = getElementData(label, 'text.elm.Data') elmData['attach'] = element elmData['aX'] = x elmData['aY'] = y elmData['aZ'] = z setElementData(label, 'text.elm.Data', elmData) break end end end addCommandHandler('say1', function(cmd, ...) if isTimer(timer) then killTimer(timer) destroy3DText(getElementData(getLocalPlayer(), 'text.elm.attach')) setElementData(getLocalPlayer(), 'text.elm.attach', false) end local ontop = create3DText('* '..getPlayerName(getLocalPlayer())..' '..table.concat({...}, ' '), tocolor(194, 162, 218, 255), 'default-bold', 1.05, 1404.7156,238.8190,19.5547, 20.0, 0, false) attach3DText(ontop, getLocalPlayer(), 0.0, 0.0, 1.2) setElementData(getLocalPlayer(), 'text.elm.attach', ontop) timer = setTimer(function(label) destroy3DText(label) setElementData(getLocalPlayer(), 'text.elm.attach', false) end, 1000 * 10, 1, ontop) end) The problem is, with destroying 3D text's. For a test, i written /say1 command. Example: if i type '/say1 one' - it shows, everything is ok, and after 10 seconds timer destroys it, same as for '/say1 two', '/say1 three'... BUT Dunno why, but after third test, typing '/say1 four' it shows but timer won't destroy it... Also this part from command: if isTimer(timer) then killTimer(timer) destroy3DText(getElementData(getLocalPlayer(), 'text.elm.attach')) setElementData(getLocalPlayer(), 'text.elm.attach', false) end won't destroy it and i dunno why this could be happen. Any solution would be really appreciated.
  3. So, if mysql_query success, it returns result and if not - returns false. I known that. I need, to use mysql functions in other resources without connecting to mysql server in each resource. So, with my created function: executeQuery() it returns only string, but not result. EDIT: Nevermind, solved storing mysql results in table and return saved result id.
  4. Hello, how can i use mysql_query function in other resource? I created export function executeQuery(): function executeQuery(query) if query then allQueries = allQueries + 1 local result = mysql_query(dbHandler, query) if not result then sendSQLLog('>>> MySQL ERROR: ('..mysql_errno(dbHandler)..') '..mysql_error(dbHandler)) return false else return result end end end In local resource(where function is) it returns valid mysql result, but if i use in other resource ex.: local checkLogin = exports['mysql']:executeQuery('SELECT ID FROM accounts WHERE Username = \''..username..'\' AND Password = \''..password..'\' LIMIT 1') it returns only executed string, not mysql result.
  5. Yes i know, it has to be working, but it dont works. I can hear sound, but my friends cant.
  6. This works only for local player...
  7. Hello, is it possible to play sound using function playSound() for all players in the server? If yes, how?
  8. uBiT

    /me command

    I'm using latest mtasa, 1.2. Maybe it's an v1.2 issue? Maybe myonlake tried his code on 1.1 version, not 1.2.
  9. uBiT

    /me command

    Yeah, but i dont understand. For me, and my friend doesn't work. For myonlake his code works...
  10. uBiT

    /me command

    I need to show usage, if user types /me without any text...
  11. uBiT

    /me command

    Yes started, tried right now - same, no usage... As i said, if i add /ME command, it works... Shows usage. But in built-in /me command doesn't work. JR10, With this script, /me command doen't work.
  12. uBiT

    /me command

    myonlake, yes everything is ok, no errors. JR10, with your script, /me command doesn't work anymore. Whenever i type something: /me testing nothing happens, no debugscript errors.
  13. uBiT

    /me command

    Hmm, i dont understand. For me it doesn't work, tried windows and linux servers. For my friend either, in his local windows server. Strange... JR10, Tried your code, same. I'm saying again: /me command is working, but i need print this command usage. Example: if i type /me it prints something like: USAGE: /me [text]. I just need to show usage...
  14. uBiT

    /me command

    Same, i type /me nothing happens.
  15. uBiT

    /me command

    Hello, i want to make /me command. But how i can output /me command usage? Here's my code: addEventHandler('onPlayerChat', getRootElement(), function(message, messageType) if(messageType == 1) then cancelEvent() meCommand(source, 'me', message) end end) function meCommand(thePlayer, commandName, ...) if(...) then local posX, posY, posZ = getElementPosition(thePlayer) local chatSphere = createColSphere(posX, posY, posZ, 20) local nearbyPlayers = getElementsWithinColShape(chatSphere, 'player') destroyElement(chatSphere) for index, nearbyPlayer in ipairs(nearbyPlayers) do outputChatBox('* '..getPlayerName(thePlayer)..' '..table.concat({...}, ' '), nearbyPlayer, 194, 162, 218) end else outputChatBox(' NAUDOJIMAS: /me [tekstas]', thePlayer, 255, 255, 255) end end addCommandHandler('Me', meCommand) With /Me command everything works, shows usage. But /me doesn't. When i type /me nothing happens.
×
×
  • Create New...