LopSided

User Guide Contributor
  • Content Count

    303
  • Joined

  • Last visited

  • Days Won

    2

LopSided last won the day on June 9

LopSided had the most liked content!

Community Reputation

78 Popular

3 Followers

About LopSided

  • Rank
    User Guide Contributor

Details

  • Gang
    EPG
  • Location
    UK

Recent Profile Visitors

2,458 profile views
  1. Try this addEvent("onSettingChange", true) addEventHandler("onSettingChange", localPlayer, function(variable, value) if variable == "draw_distance" then local state = not (value == "Off") draw.setVisible(state, true) end end) function draw.setVisible(visible, notifyDisplay) draw.visible = visible and true or false draw.changeDistance(draw.visible) if notifyDisplay then triggerEvent("notification:create", localPlayer, "Draw distance", "is now "..(draw.visible and "ON" or "OFF")) end end function draw.changeDistance(max) for i,object in pairs(getElementsByType("object")) do if isElement(object) then local elementID = getElementModel(object) engineSetModelLODDistance(elementID, max and 325 or 100) end end end function initialize() draw.setVisible(true, false) end addEventHandler("onClientResourceStart", resourceRoot, initialize) Your code had all sorts of logic errors, especially with the onClientResourceStart, which was only being added when you ran draw.setVisible, but also being attached for all resources, instead of just the current one. It would never run for the current resource that way.
  2. Just so you know, the actual max value for engineSetModelLODDistance is 325
  3. Can you explain in more detail what you mean by object vs array? Are you referring to JSON data format? If you're referring to element (object) data storage, versus standard storage in Lua tables, then Lua tables are always going to perform better. However, some more understanding of what you mean / what you're trying to do would help explain it
  4. @salh You are storing the password in plain text. This is NOT recommended in any circumstances! (you are breaking European law) I would advise you to remove this code from your server immediately and replace it with a secure login system. Please see the tutorial topic that I sent above.
  5. No, copying that code would not work because you have 2 undefined functions. Furthermore, as stated, this is a bad way to create a remember me functionality because you appear to be storing the password in plaintext (which is illegal if you're accepting European traffic by the way - and just bad practice in general). Instead, you should be using a token system as explained in the linked tutorial
  6. @salh This code doesn't do anything. You haven't defined the `getUserAndPass` function. Furthermore, you wouldn't be saving the actual password, you'd be using a token based system. @Master_11 Please see this tutorial which includes a "remember me" functionality
  7. The "getPedTargetStart" function will retrieve the starting point of the target range. This target range is probably linked to the camera position (I'm not entirely sure though), which would explain why your camera is "always moving forward" Let's say the target start range is always 1 unit in front of the camera. Your camera position is set to 0. Then you set the camera position to the start range (1), and the start range then subsequently changes to 2. This will happen forever whilst you are zoomed in. You should store the initial target start position, instead of getting it on each frame. This can be done quite easily. local targetStartPos = false function aim_test () if getControlState("aim_weapon") == true and getPedWeapon(localPlayer) == 34 then if not targetStartPos then local startX, startY, startZ = getPedTargetStart(localPlayer) targetStartPos = {x = startX, y = startY, z = startZ} end local x, y, z = targetStartPos.x, targetStartPos.y, targetStartPos.z local x2,y2,z2 = getPedTargetEnd(localPlayer) if not x2 then return false end local x3,y3,z3 = getPedTargetCollision(localPlayer) if x3 then setCameraMatrix(x,y,z,x3,y3,z3) else setCameraMatrix(x,y,z,x2,y2,z2) end else if not getCameraTarget(localPlayer) then targetStartPos = false setCameraTarget(localPlayer) end end end addEventHandler("onClientPreRender",root,aim_test) Haven't tested, but I'm fairly certain that should fix your issue.
  8. You want to listen to YouTube audio? You'll need to install these on your server https://github.com/ytdl-org/youtube-dl https://www.ffmpeg.org youtube-dl comes with a tutorial. You need to make a PHP script which is triggered by callRemote to initiate the download
  9. Alternatively, you can create your own file / download manager using PHP. Currently this is the only way.
  10. LopSided

    xml vs json

    Currently, JSON is better for something like that. You can store that information in a database (which is way more efficient than reading/writing XML files) I would give an example, but there really isn't much to show.
  11. Yeah, your arguments are all messed up. unix_socket should be part of the second argument, the string is also formatted incorrectly. dbConnect("mysql", "dbname="..databaseName..";host="..databaseHost..";unix_socket=/var/run/mysqld/mysqld.sock", databaseUsername, databasePassword, "autoreconnect=1")
  12. Your event handling is all wrong. Do not pass the local player as an argument to the event like this: triggerServerEvent("onLoginWith",localPlayer,user,pass) Things wrong here: - you're making the source element the local player, that will not work - you're trying to pass the local player as an argument You should use the predefined variable `client` on the serverside. `client` contains the player that called the event. This is for security purposes. You should also set the source argument to resourceRoot, instead of localPlayer So you'd have: triggerServerEvent("onLoginWith", resourceRoot, pass) addEventHandler("onLoginWith", root, function(pass) local user = client ... end) Now in the rest of your code where you've tried to use 'source' to get the player, replace it with client.
  13. This can be done with some basic math. Let's say we're positioning the notifications from 0,0 on the client's screen (top left) --Notification values local notificationBaseX, notificationBaseY = 0, 0 local notificationWidth, notificationHeight = 200, 60 local notificationMargin = 7 local notifications = {} --Our table where the notifications are stored. function createNotification(text) --Example function to create a notification table.insert(notifications, text) end function renderNotifications() --Draw the notifications for i, notificationText in ipairs(notifications) do local notificationX, notificationY = notificationBaseX + notificationMargin, notificationBaseY + (notificationHeight + notificationMargin) * (i - 1) --Add the notification height & margin, then multiply that by the current notification index. We'll start indexing at 0 by removing 1 from the current index. dxDrawRectangle(notificationX, notificationY, notificationWidth, notificationHeight, tocolor(255, 0, 0)) dxDrawText(notificationText, notificationX, notificationY, notificationX + notificationWidth, notificationY + notificationHeight, tocolor(255,255,255), 1, "default-bold", "center", "center") end end addEventHandler("onClientRender", root, renderNotifications) --Create the notifications createNotification("Notification 1") createNotification("Notification 2") createNotification("Notification 3") I hope that's enough to get you started. Any questions just ask
  14. LopSided

    Ped Atack

    Tons of things wrong with this. For a starter you're calling the onPedRender function every frame without any kind of checks to see if "thePed" exists, or if he already has the weapon which you're trying to give him - that's extremely bad practice. Also, where is this "findRotation" function? You haven't included in the code. In future please provide the full error, I highly doubt it was just "a nil value". That helps no one.
  15. Well it looks like you didn't enable OOP in the meta.xml, using <oop>true</oop>