Jump to content

novo

Members
  • Posts

    325
  • Joined

  • Last visited

Everything posted by novo

  1. novo

    Help [Mysql]

    That's because "result" contains the table's values as arrays with respective index to each column name. for i, row in ipairs(result) do outputChatBox(row.serial) outputChatBox(row.name) end Either way, I recommend you to use dbQuery as follows: (Note: It is usually good practice to surround table and column names with backticks (`) in case they contain spaces or SQL keywords (and therefore cause syntax errors). This is especially true when using variables for table and column names, as potential problems may not be apparent when the script is first written. @dbQuery) dbQuery(Database, "SELECT * FROM ? WHERE serial = ?", md5(map), serial)
  2. As specified here: onClientRender, the 'source' element specified should be the client's root element.
  3. Since you're actually able to write on any directory using PHP, you could simply place the uploaded images into a resource's folder. And as I guess you would like to retrieve a list of uploaded images without 'linking' them to the resource itself nor its meta file, I recommend you to use FileSystem in order to list all the files within the folder itself and then you can simply operate with their content or whatever. An example: local system = createFilesystemInterface() local folder = system.createTranslator("/") local files = folder.scanDir("/", "*", false) for i,v in ipairs(files) do print(v) end
  4. He means using the BBCODE. @ http://i.gyazo.com/bf13a341e59a1518a495f7e09255089c.png [xml][/xml]
  5. novo

    MetaTables

    Refer to this website for a deep explanation: http://nova-fusion.com/2011/06/30/lua-m ... -tutorial/ Anything you need to know about metatables is explained there, though in case you do not comprise something make sure to question about it.
  6. data[source].kills = kills -- You're only changing the value of the key "kills". data[source] = {kills= kills} -- You're actually replacing the entire table here. -- An example local table = {["value1"] = 0, value2 = 0} table.value1 = 0 table["value2"] = 0
  7. Thanks for pointing my mistake out, it could've been a further issue for others and even for myself. However, I guess I should've taken a slightly deeper look on the reference pages that I stated above before posting a piece of code.
  8. Only one player is shown because you're clearing the combo box (guiComboBoxClear) every time wypisywanieGraczy is triggered. You could store the players' name on an array instead, then send it to the client and finally iterate over the same in order to add its values (names) into the combo box. -- clientside local okno = guiCreateWindow(0.4, 0.3, 0.2, 0.3, "Panel Policji", true) guiWindowSetSizable(okno, false) local wybor = guiCreateComboBox(0.1, 0.2, 0.8, 0.6, "-wybierz-", true, okno) showCursor(true) function wypisywanieGraczy (players) local x, y = guiGetSize(wybor, false) guiSetSize(wybor, x, y+25, false) guiComboBoxClear(wybor) for i,v in ipairs(players) do guiComboBoxAddItem(wybor, v) end end addEvent("wypisywanieGraczy", true) addEventHandler("wypisywanieGraczy", getRootElement(), wypisywanieGraczy) --serverside: function pobieranieGraczy(plr) local x, y, z = getElementPosition(plr) local strefa = createColCircle(x, y, 50) local gracze = getElementsWithinColShape(strefa, "player") local players = {} for i,v in pairs(gracze) do local nicki = getPlayerName(v) outputChatBox(nicki, plr) table.insert(players, nicki) --triggerClientEvent(plr, "wypisywanieGraczy", plr, tostring(nicki)) end triggerClientEvent(plr, "wypisywanieGraczy", plr, players) destroyElement(strefa) end addCommandHandler("x", pobieranieGraczy) -- Fixed few mistakes, as referenced down below
  9. Why are you guys having such pointless discussion over here? The languages you know nor your knowledge within these has nothing to do with one's intelligence. Either way, using C++ actually gives you access to a larger library of functions, and also if I'm not wrong the execution time of those is slightly smaller. MTA's quite limited in this sense.
  10. Simply calculate the distance between the mouse pointer and the center of your circle and then decide whether it's inside: function circularHover (x, y, radius) local screenX, screenY = guiGetScreenSize() -- local mx, my = getCursorPosition() local mx, my = (mx or 0) * screenX, (my or 0) * screenY return math.sqrt((mx-x)^2 + (my-y)^2) <= radius^2 end You may check these websites out for a deeper and explicit explanation: http://stackoverflow.com/questions/1679 ... e-a-circle http://stackoverflow.com/questions/2212 ... or-polygon
  11. function isEventHandlerAdded (name, element, func) if type(name) ~= "string" or not isElement(element) or type(func) ~= "function" then return end for i, v in ipairs(getEventHandlers(name, element)) do if v == func then return true end end end -- addCommandHandler("turnOffMapInfo", function() local name = "onClientRender" local element = root local func = MapInfo return ((isEventHandlerAdded(name, element, func) and removeEventHandler(name, element, func)) or addEventHandler(name, element, func)) end ) bindKey("F3", "down", "turnOffMapInfo") Either way, you shouldn't have used "event ~= true" that way since addEventHandler returns true if the event handler was attached successfully or returns false if the specified event could not be found or any parameters were invalid.
  12. I'd use setPlayerMuted and isPlayerMuted instead, either way I don't see why wasEventCancelled would return false since the event itself is being cancelled. Although, "cancelEvent does not have an effect on all events, see the individual event's pages for information on what happens when the event is canceled. cancelEvent does not stop further event handlers from being called, as the order of event handlers being called is undefined in many cases. Instead, you can see if the currently active event has been cancelled using wasEventCancelled.". So basically, you could do it way easier by using the functions I stated above and therefore avoid having further issues.
  13. Open the file using Notepad ++ and open the Encoding menu and choose UTF-8 without BOM. (http://i.gyazo.com/86c8cf1ef46c84b50c4f3a8469a853b3.png)
  14. function createLogs(thePlayer, command, text) local time = getRealTime() local dia = time.hour local mes = time.month local anio = time.year local dir = "txt/plogs.txt" local fileHandle = ((fileExists(dir) and fileOpen(dir)) or fileCreate(dir)) if fileHandle then local content = (fileRead(fileHandle, (fileGetSize(fileHandle) or 0)) or "") fileWrite(fileHandle, content, "* ["..dia.."/"..mes.."/"..anio.."] nickname = '"..getPlayerName(thePlayer).."' text = '"..text.."' \n") fileClose(fileHandle) end end addCommandHandler("addtext", createLogs)
  15. You're welcome, either way make sure to be aware of 'sources' you're using from now on.
  16. Actually yes, it's exactly what Ciber told you above, though he's done few mistakes on the code he's given you. Anyway, it's as simple as: function createLogs(thePlayer, command, text) local time = getRealTime() local dia = time.hour local mes = time.month local anio = time.year local dir = "txt/plogs.txt" local fileHandle = fileOpen(dir) or fileCreate(dir) if fileHandle then local content = fileRead(fileHandle, fileGetSize(fileHandle)) or "" fileWrite(fileHandle, content, "* ["..dia.."/"..mes.."/"..anio.."] nickname = '"..getPlayerName(thePlayer).."' text = '"..text.."' \n") fileClose(fileHandle) end end addCommandHandler("addtext", createLogs)
  17. Well, as I told you above, you should do the following: setElementData(localPlayer, 30) -- wPanel = guiCreateWindow(14, 203, 176, 130, "ZA 1.0 - Panel", false) guiWindowSetSizable(wPanel, false) btnChar = guiCreateButton(14, 35, 150, 25, "Characters", false, wPanel) btnVeh = guiCreateButton(14, 86, 150, 25, "Vehicles", false, wPanel) wChar = guiCreateWindow(234, 178, 386, 170, "ZA 1.0 - Characters", false) btnClose = guiCreateButton(306, 134, 70, 26, "Close", false, wChar) guiWindowSetSizable(wChar, false) cGrid = guiCreateGridList(9, 23, 369, 104, false, wChar) guiGridListAddColumn(cGrid, "Characters", 0.9) for i = 1, 4 do guiGridListAddRow(cGrid) end guiGridListSetItemText(cGrid, 0, 1, "Army Skin 1", false, false) guiGridListSetItemText(cGrid, 1, 1, "Army Skin 2", false, false) guiGridListSetItemText(cGrid, 2, 1, "Army Skin 3", false, false) guiGridListSetItemText(cGrid, 3, 1, "Army Skin 5", false, false) guiSetVisible( wChar, false) guiSetVisible(wPanel, false) showCursor(false) bindKey('f1','down', function() guiSetVisible(wPanel, not guiGetVisible(wPanel)) showCursor(not isCursorShowing()) end ) function btnChars() if source == btnChar then guiSetVisible( wChar, true ) else if source == btnClose then guiSetVisible( wChar, false) end end end addEventHandler("onClientGUIClick", getRootElement(), btnChars) function setSkin() local row, col = guiGridListGetSelectedItem(cGrid) if ( row == 0 ) and ( col == 1) then setElementModel(localPlayer, 30) end end addEventHandler("onClientGUIClick", getRootElement(), setSkin)
  18. novo

    Custom HUD

    -- These functions will be called once the client-sided code is loaded itself, there's no specific need to run these within a function linked to 'onClientResourceStart' setPlayerHudComponentVisible("all", false) setPlayerHudComponentVisible("crosshair", true) setPlayerHudComponentVisible("radar", true) ---- addEventHandler("onClientRender", root, function() local shown = isPedDead(localPlayer) -- Check whether the player is dead or not -- In case of the 'Play/Freeroam' game mode, the player won't be alive until he's automatically 'spawned', so the HUD won't be shown until then if not shown then -- in case the player is NOT dead -- dxDrawings... end end )
  19. Since we're here to help you with any doubt or current problem you're having and not to 'fix' a piece of code directly, it would be cool if you specify what's exactly wrong or not properly working on the code you've introduced above; and only then we'll be able to possibly assist you.
  20. onClientGUIClick - The source of this event is the GUI element that was clicked. You should've used "localPlayer" instead of 'source' there.
  21. A simple example with time values: local tick = getTickCount() local duration = 6000 -- 6 seconds (ms) addEventHandler("onClientRender", root, function() local progress = ((getTickCount() - tick)/duration) local cX, cY = interpolateBetween(0, 0, 0, 0, 10, 0, progress, "Linear") dxDrawRectangle(cX, cY, 100, 100) end )
  22. You should specify an account with access to the "general.http" right (https://wiki.multitheftauto.com/wiki/Access_Control_List#HTTP_Interface), though I'm not sure you'll be able to call any function without giving any other rights to this account. And yes, it's necessary because you're actually going through the server's HTTP service with the API.
  23. novo

    Unbind Problem

    We would be able to help you deeply if you post the code you're trying to execute. Either way, I've only noticed issues whilst trying to remove keys bound with built-in commands, such as 'chatbox'.
  24. Since onResourceStart is a server-side event, it will be triggered once the resource's server-sided code is fully loaded. Same happens with client-side.
  25. local maps = {} local resources = getResources() --https://wiki.multitheftauto.com/wiki/GetResources for i,v in ipairs(resources) do local name = getResourceInfo(v, "name") local type = getResourceInfo(v, "type") --https://wiki.multitheftauto.com/wiki/GetResourceInfo if type == "map" then -- Check whether it's a map or not table.insert(maps, name) end end And in case you want to retrieve the total number of maps: local total = #maps -- You're able to use # here to retrieve the table's total size (this option only works for numerical indexed tables) local total = table.maxn(maps) -- Same as the above but returning the largest positive numerical index
×
×
  • Create New...