Jump to content

Addlibs

Members
  • Posts

    1,060
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by Addlibs

  1. -- (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.
  2. 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..".")?
  3. 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.
  4. 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 )
  5. 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?
  6. Addlibs

    String

    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.
  7. 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?
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. 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?
  15. Addlibs

    [Help-me]

    You haven't asked a question, and you've just pased your code without code tags. It's barely readable.
  16. 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
  17. 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.
  18. 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.
  19. 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.
  20. 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.
  21. Addlibs

    help

    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.
  22. I'd avoid using files, they're more of a hassle to work with, you have to save manually, etc. They're useful for configurations and whatnot. Databases are better, and you can index, sort and filter the logs much easier with SQL. dbQuery, and db* functions in general, don't cause server lag, only dbPoll if you use -1 for timeout as it awaits results of the query, but for adding entries into the logs you don't need to poll at all; poll is only needed to retrieve the logs, and async callback can let you know when the result is ready without freezing the server.
  23. If you're looking for someone to script it for you, you'd be better off trying here ☞ https://forum.multitheftauto.com/forum/149-looking-for-staff/ If you want to attempt it yourself: addEventHandler onMarkerHit takeAllWeapons
  24. If every pickup does a different message, it would be best to do something like messages = { [pickupSource1] = "message for hitting pickupSource1", [pickupSource2] = "message for hitting pickupSource2", ... } addEventHandler("onPickupHit", resourceRoot, function(player) if messages[source] then -- if a message is defined for this pickup element outputChatBox(messages[source], player) -- output that message to the player that hit it cancelEvent() end end )
  25. If you want the bus to not interfere with other players at all and not be seen by them, your best bet is to just spawn the bus client-side, and a ped-clone of the player. Have this ped play the animation of entering the bus, preferably have the ped attached to the bus at the right offset to ensure that the animation will play in the right place all the time. Then, at the right time, have the ped warpPedIntoVehicle, or just destroy/place them away from the screen. The client-side bus can have another ped to be it's driver, and you can use setPedControlState to have the bus accelerate as the camera fades out. When it comes to the bus approaching, having the bus stop at the correct place can be more difficult, so you may need to utilise some interpolations between keyframes -- onClientRender, interpolateBetween, setElementPosition and setElementRotation.
×
×
  • Create New...