Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Addlibs

  1. The error you're getting means Lua is expecting a function name on line 2, between function and (getPlayerName). But that's only the currently detected syntax error. There's a lot of other syntax and semantic errors in your code besides that one. addCommandHandler (which you misspelled as addComamandHandler) takes two arguments, the command name and a function that will handle it. You want to remove the ending bracket on line 1 and replace it with a comma, so that the function on the lower lines is an argument of addCommandHandler. Secondly, you take as parameter a value that you store in a variable called getPlayerName, thereby overriding the MTA function called getPlayerName with whatever value is sent to this function -- which, as it is a command handler, the parameters are source player and the command on the server side, just the command on the client side, plus extra arguments passed through the command by the player. Thirdly, on line 3, you attempt to get two returns out of the function getPlayerName which only returns one string. Fourthly, you never end the function and instead had two end brackets one on the first line and the other on the last line. Lastly, within the if-block, you create a string containing the text "Ez .. getPlayerName .. járműve!" literally when you likely wanted to concatenate getPlayerName variable between the strings "Ez" and "járműve!" addCommandHandler ( "playerInTheCar", -- no bracket at the end here function (player) -- anonymous function with corrected parameter name local playerName = getPlayerName ( player ) -- corrected return variables if playerInTheCar then -- this variable is not set and I am unsure what it was meant to be outputChatBox ("Ez ".. playerName .. " járműve!") end end -- end the anonymous function ) -- end of addCommandHandler arguments
  2. It acts differently depending on whether you're using a MySQL or sqlite connection; specifically, this is the escaping function for MySQL and this is the one for sqlite.
  3. Well, you have a couple options 1) A single timer using setTimer, generally the duration is not modifiable after it's been created but you can get current remaining time and set a new one with a different time if necessary. The callback is triggered when the timer runs out. 2) A timer set using setTimer that triggers every second (1000ms period) and increments or decrements a variable of how many seconds passed or are remaining, respectively; this way you get to change time remaining without having to deal with new timers (but this may be a bit more resource-hungry than the option above). Use the timer's callback and compare it against the remaining time to determine if the timer elapsed. 3) Use the missontimer resource packed with default MTA resources, as used by gamemodes like the default deathmatch. Using that you can abstract most of the internal timers and how to change durations using them, instead get exported functions that deal with it; and it takes care of rendering for you. onMissionTimerElapsed is triggered when the time runs out. When it comes to options 1 and 2, you need to render the remaining time yourself. Ideally, the server should have an authoritative timer while clients get a very close approximation through data sending using triggerClientEvent and triggerServerEvent. Clients should only have math that controls the display of the timer, not the actual timer.
  4. Either that or Installing and Configuring Nginx as an External Web Server should be helpful. The built-in HTTP server in MTA that takes care of downloading is a very simple server, and can't do things like transmission compression. Nginx or Squid (maybe? I haven't ever used it so I'm not entirely sure) should be able to compress the transmission and thus make it faster and use less bandwidth.
  5. -- (server side) function onPlayerCommandHandler(cmd) local playername = getPlayerName(source) outputChatBox(playername .. " entered command " .. cmd, root, 255, 0, 0) end addEventHandler("onPlayerCommand", root, onPlayerCommandHandler) source is the element of the player that entered the command, you can get the name using getPlayerName; the first parameter passed to the handler function is the command string that was entered.
  6. First of all, this is wrong syntax: addEventHandler("onPlayerQuit",getRootElement(),"Kicked",function() but more importantly, why not just dbExec(sql,"DELETE FROM characters WHERE id=?",accid) within ckPlayer(player, cmd, ...) right after kickPlayer(player, "CK: " ..info..".")?
  7. This is not a requests section. We can help you script it yourself but you must put in the effort. You should also tell us what exactly do you need help with, not just name something.
  8. You should do the element data check on the server's code, as onClientElementStreamIn is triggered for all clients. This means that if we have a player A who is on call (i.e. has the "call" element data set to true), and player B nearby but out of streaming range, and he gets nearer into the streaming range, the event is called on both player A and player B's clients, and normally both would contact the server to update their broadcast list. Player A's event handler was cut short by the if on call return end line, however, player B does not have this cancelling effect and thus updates their broadcast to be able to talk to player A. The entire broadcast update code ought to be improved, but for now the following serverside handler could work: addEvent("proximity-voice::broadcastUpdate", true) addEventHandler("proximity-voice::broadcastUpdate", root, function (broadcastList) -- client has streamed in or out another player and the broadcast list has changed if client and source == client then else return end -- Loop the requested broadcast list and remove players who are on call to someone else than the source element local validList = {} for k, v in ipairs(broadcastList) do if not getElementData(v, "call") or getElementData(v, "call") == source then table.insert(validList, v) end end setPlayerVoiceIgnoreFrom(source, nil) setPlayerVoiceBroadcastTo(source, validList) end ) The above code needs the call command to be edited slightly, namely, to make "cell" element data to reference the player someone is on call with: addCommandHandler("call", function(plr, cmd, target) local target = getPlayerFromPartialName(target) -- return a player setElementData(plr, "call", target) setElementData(target, "call", plr) setPlayerVoiceBroadcastTo(plr, target) setPlayerVoiceBroadcastTo(target, plr) end )
  9. Pretty sure the error message you gave is preceded by a dxCreateRenderTarget error. How is Map.new() called? Perhaps invalid W and H values are passed?
  10. Addlibs


    What do you mean by absence of it? What is kind of information stored in such string? Is it a number? If so, you can theNumber = tonumber(theString) to turn it from a string to a number If it's a boolean, you can do a sort-of tertiary operation theBool = theString == "true" which treats a string that equals to "true" as a true value and all other strings as a false value. If it's a JSON string object, you can fromJSON to turn in into a Lua table.
  11. Without telling us which script you're using we're unlikely to be of any help. Could you link the community resource link or wherever you got it from?
  12. aim_weapon and jump held together with fists or a melee weapon equipped determine whether a player/ped is blocking. The player/ped also needs to be on ground and not gliding or falling. You could disable the jump control while aim_weapon is pressed to prevent players from blocking.
  13. For that structure you need to slightly modify your table - first, to loop through each group, and secondly, to prevent duplicate entries (I believe the freeroam skins XML can have the same skin under different groups) local tabla = {} function XmlToTable() local added = {} -- table to keep track of which skins were added to prevent duplicates local xml = xmlLoadFile("skins.xml") -- load the xml local groups = xmlNodeGetChildren(xml) -- the the xml root's children nodes if groups then for i, group in ipairs(groups) do -- loop the xml root's children nodes local skins = xmlNodeGetChildren(group) -- the the group's children nodes if skins then for j, skin in ipairs(skins) do -- loop the group's children nodes local id = tonumber(xmlNodeGetAttribute(skin, "id")) -- ensure you convert the string to a number, if impossible, a nil is returned - this is caught by the next if statement if id and not added[id] then -- if tonumber didn't fail and the id wasn't yet added table.insert(tabla, id) -- add it added[id] = true -- and prevent it from being added again end end end end end xmlUnloadFile(xml) -- unload now that we're done with this end addEventHandler("onClientResourceStart", resourceRoot, XmlToTable) -- if this script is clientside addEventHandler("onResourceStart", resourceRoot, XmlToTable) -- if this script is serverside function teszt() for k, v in ipairs(tabla) do outputChatBox(v) end end addCommandHandler("asd",teszt) I've also noticed that "expected string at argument 1, got table" error is caused by storing tables within tabla instead of skin IDs - this originates from a typo in your code where you've written xmlNodeGetAttributes instead of xmlNodeGetAttribute.
  14. Nothing seems immediately wrong about this code (except the unnecessary use of xmlFindChild before xmlNodeGetChildren on the same xml node element). However, if this is client-side code, it's possible that the skins.xml file either isn't downloaded at all, or isn't ready to be read at the time the script begins execution (i.e. still downloading). To fix this, you should move the code that reads the XML into a function that's triggered upon the event onClientResourceStart. That is, if this is client-side code. Additionally, make sure that <file src="skins.xml" /> is in meta.xml otherwise the client never downloads the file. You could additionally show us a well-formed sample/snippet of the skins.xml file, how it's structured, etc.
  15. rt = dxCreateRenderTarget(200, 400, true) --draw dxSetRenderTarget(renderImage,true) Did you mean rt instead of renderImage in dxSetRenderTarget? Edit: Nevermind, I see dxSetRenderTarget(rt,true) in a different place.
  16. Are these port forwarding rules enabled or just listed? Some routers allow you to add rules without having them enabled, so you can toggle them without having to delete and (re)create them every time.
  17. What do you mean by "line chart compatible to [with] mysql"? Charts have nothing in common with database servers (except perhaps ERDs). I'm going to assume you mean you have a database with a records of historical prices and you want to display them in a line chart, right? If so, what you want to do is query that database, retrieve the historical data -- it's date (X axis value) and the price (Y axis value) and plot these into a chart, then connect those plot points with dxDrawLine.
  18. Does this happen to all clients or just you? If just you, have you tried rebooting your device? "CRC could not open file: No such file or directory" suggests to me your OS is having trouble locating and/or opening the file. Perhaps it's a non-persistent issue that can be fixed with a reboot. Try rebooting the device the server's running on too if possible. Have you tired to see if the file downloads correctly into your client's downloads folder? (.../resources/factions/myriadproregular.ttf). Is it corrupted? Is it fine on the server too?
  19. Addlibs


    You haven't asked a question, and you've just pased your code without code tags. It's barely readable.
  20. If you search for the error string and go backwards, you'll find it's triggering condition is id being false, and id is defined as the return of SmallestElevatorID(). This means that function failed to return a correct value. So let's look at the function function SmallestElevatorID( ) -- finds the smallest ID in the SQL instead of auto increment local result = mysql:query_fetch_assoc("SELECT MIN(e1.id+1) AS nextID FROM elevators AS e1 LEFT JOIN elevators AS e2 ON e1.id +1 = e2.id WHERE e2.id IS NULL") if result then return tonumber(result["nextID"]) end return false end My bet is you either don't have the mysql resource, or it's not running, or it's misconfigured or not connected to a db server, or you don't have the elevators table in your database, or its structure is wrong. Did you check /debugscript 3
  21. https://wiki.multitheftauto.com/wiki/AddPedClothes -> "Note: This function only works with peds using CJ skin (ID 0). " You can't use addPedClothes on non-CJ skins.
  22. bot isn't defined in attack or stopattack contexts. You need to declare the variable bot globally with bot = nil or declare it a local variable for the file by writing local bot at the top.
  23. Have you tried rudimentaly debugging steps? Have you checked /debugscript 3? Have you checked whether hoursplayed has a value and if it's numeric? You can check that with runcode (that is, make sure the runcode resource is running when attempting the following command) using /crun getElementData(localPlayer, "hoursplayed") If you're not getting debug errors in debugscript, I'd bet that hoursplayed element data is nil, and gets coalesced to 0 on this line elseif (getElementData(localPlayer, "hoursplayed") or 0) < 50 then and compared against 50, 0 is less than 50, so entire condition evaluates as false and the conditional code does not get executed.
  24. The reason is that your script only has storage for one flames element, while there can be multiple people. What you need to do is use tables, with the vehicle element as the key, and its flames element as the value. That way, you index the table to get the element, check if it exists, delete it if so, create new one if necessary, etc. Here, I've fixed one of the functions for you as an example, and you should be able to -- beginning of serverside code firethrusters = { --structure: [vehicle] = {[1] = firethrustl, [2] = firethrustr} } -- ... the rest of the code here ... function ThrustersOff(veh, x, y, z) -- you forgot to collect the parameters the event was sending over --if thePlayer ~= localPlayer then return end -- no idea what this line does. localPlayer isn't defined on the server, neither is thePlayer in this function if not firethrusters[veh] then return end -- if there is no firethruster for this vehicle, abort here destroyElement(firethrusters[veh][1]) destroyElement(firethrusters[veh][2]) firethrusters[veh] = nil -- presence of this data determines whether an attempt will be made to delete, remove this data to prevent potential 'nil passed instead of element to destroyElement' error end addEvent("thrustersoff", true) addEventHandler("thrustersoff", getRootElement(), ThrustersOff) You'll need to do the same for the light. You'll also want to handle the event onElementDestroy to catch the vehicle disappearing for whatever reason, and make sure these thruster elements and stuff are also deleted, otherwise they'll remain in the place where the vehicle last was, forever.
  25. Addlibs


    for i,v in pairs(WhellTable) do WhellTable is not defined and hence a 'nil' value where a table was expected. It appears it's structure should be something like WhellTable = { ["key"] = {"text1", "text2"}, [1] = {"sampletext1", "sampletext2"}, } yielding a gridlist rows "(key) text1 | text2" where | denotes a new column for the first item, and "(1) sampletext1 | sampletext2" for the second item.
  • Create New...