Jump to content

bradio10

Members
  • Posts

    118
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

bradio10's Achievements

Sucka

Sucka (13/54)

0

Reputation

  1. Nice job, looks cool! I also really like your speedometer too
  2. You would trigger an event using triggerClientEvent() And in the client event, show the GUI, you would use guiSetVisible() And when looking at triggerClientEvent, check out some of the other functions at the bottom of the page to see how to add events and stuff if you're not sure how to do that. If you're still confused, let us know
  3. bradio10

    Vehicles

    Have you tried doing: local upgrades = fromJSON(result[1].upgrades) or local upgrades = fromJSON(result.upgrades) instead of what you currently have which is local upgrades = fromJSON(result[1]["upgrades"]) Not sure if it will make any difference/fix the issue, but I've never seen the way you do it before.
  4. Hi, I have made a system so I can have multi language support and I currently have all the logic for translations in Lua tables, but I was wanting to know if it would be better to have all the tables in XML? Would XML be more faster and more efficient than having them in Lua tables or would it not really matter? Thanks.
  5. Have you tried passing the data to the clientside after you've done the loop on the server? Something like: I don't think I've used client for the triggerClientEvent properly, but do you get what I mean? EDIT: I just tested it and this works -- [[ SERVER SIDE ]] -- c_database = dbConnect("mysql", "dbname=DATABASE;host=localhost;port=3306", "USERNAME", "PASSWORD" ) local tbl = dbExec(c_database, "CREATE TABLE IF NOT EXISTS player_stats (account TEXT, health INT, hunger INT, thirst INT)") -- Using the queried data from queryDataFromDB, we assign each value to a variable (health, hunger & thirst) function insertDataFromTable(plr) passed_data = dbPoll(data_table,0) for i,thedata in ipairs(passed_data) do health = thedata.health hunger = thedata.hunger thirst = thedata.thirst end triggerClientEvent(plr, "sendToClient", plr, health, hunger, thirst) end -- We query for health, hunger & thirst for the player who called the event, who happens to the local player function queryDataFromDB() account = getAccountName(getPlayerAccount(client)) data_table = dbQuery(c_database,"SELECT health,hunger,thirst FROM player_stats WHERE account=?",account) setTimer(insertDataFromTable,1000,1, client) end addEvent("onQueryDataFromDB",true) addEventHandler("onQueryDataFromDB",root,queryDataFromDB) Clientside: addCommandHandler("getdata", function() triggerServerEvent("onQueryDataFromDB", localPlayer) outputChatBox("Asked for data", 255, 255, 0) end ) addEvent("sendToClient", true) addEventHandler("sendToClient", root, function(health, hunger, thirst) if (health and hunger and thirst) then outputChatBox("Health: " .. tostring(health) .. ", Hunger: " .. tostring(hunger) .. ", Thirst: " .. tostring(thirst), 255, 255, 0) else outputChatBox("Not there", 255, 255, 0) end end ) Once I did the command, I received the output.
  6. Oh thanks for that. Solves one issue Any ideas about the other stuff though?
  7. Just to bump their current post, They have added more locations! New locations: - Perth, Australia - Melbourne, Australia - Montreal, Canada - Miami, USA Not all are listed on the product page, but I'm sure you can contact them and ask if they can set one up in the location you want! Links: https://www.streamline-servers.com/gameservers/mta.html I personally have one in Melbourne, Australia and its very smooth and fast for me! Very satisfied with the service and customer support has been awesome! And before you ask, no I wasn't paid or given anything to post this, I simply think they offer awesome service at an awesome price and I'm just doing them a favor.
  8. Hi, I'm currently using a method to detect when I click on a DX element by checking if the cursor is within the DX elements coordinates. I'm wanting to know if there is a better way of doing this? I thought about just putting gui buttons over something that would be clicked on and using GUI functions, but there should be either an easier or better way of doing that right? And also, I saw a post that someone said that onClientClick executes twice which is annoying because I'm using that to detect the click on a DX button and when I want it to output something, it outputs it twice. Which is another reason why I'm wanting to know if there is another way. And another reason is for DX gridlists. Since the DX elements would change position when you move a slider up and down, it wouldn't work with mu current method. Here is an example of what I am currently doing: function inside(x1, y1, x2, y2, w2, h2) return not (x1 < x2 or x2+w2 < x1 or y1 < y2 or y2+h2 < y1) end addEventHandler("onClientClick", root, function(_, _, x, y) --Check if the cursor is within the Close button if (inside(x, y, screenW * 0.5182, screenH * 0.8620, screenW * 0.0781, screenH * 0.0491)) then outputChatBox("Closed", 255, 255, 0) end end )
  9. Well, you could do it like that, but I was referfering to just using the relative ratios, like: 0 = 0% of screen 0.5 = 50% of screen 1 = 100% of screen So, something like this: guiCreateWindow ( 0.3, 0.3, 0.6, 0.6, "Relative Window", true ) I see. Thats how I normally create my GUIs atm. I have also noticed that if I create a relative GUI's in a resolution like 1920x1080 and then someone views it with a smaller resolution, the scale of the elements is really weird and they look funny. But when people use absolute values and calculate them, it doesnt seem to do that.
  10. Thanks for the answers. Really has helped! One question though about your answer to my second question, by ratio numbers, you mean like what you did with the dxDrawRectangle on every element right? I have seen some people do it on GUIs and only do it for the window. I understand you have to do it for all DX elements, but do you have to do it also for all GUI elements?
  11. Hi, I have a couple of questions that I still have been confused about for a while. 1) When creating GUI's and DX stuff, whats the correct way to have it aligned and "all good" for all resolutions? I have seen people do it multiple ways and it just makes me confused. So if anyone has a fully working solution, please let me know 2) When creating GUI's, if I create it using absolute values, do I have to calculate all the GUI elements with the screenHeight, screenWidth solution? Or do I just have to do it for the window? 3) Is it best to just create GUIs with relative values or is doing it with absolute and calculating it better? Or is it just preference? 4) Whats the best way to store lots of data? I am wanting to create an inventory system and I'm wanting to know how to store data in the most effiecient way. Would SQLite or MySQL be the best option? And is there a way to put all the players items into one 'value' or 'table' and store it as a one line in the SQL database? Or is that not the best way to do it and just have each item from each player as a row in the database? Anything at all that is better is appreciated. Thats all I really have to ask, thanks for reading!
  12. Hi, So I've been mucking around with moveObject and trying to rotate doors and the police barrier. Now, I have noticed something strange and I can't seem to get my head around it. When I create the barrier, I set it to create with a rotation of 90, 0, 90. When I enter the marker, it moves to point the sky (like I want it to), but when I output what the rotation of it is when its pointing to the sky, it still says 90, 0, 90. When I exit the marker, it moves back to the rotation it was created with, but it says its 0, 0, 90. So I tried to create the object starting at 0, 0, 90 (cus it says that its 0, 0, 90 when it comes back down), but it then creates itself pointing to the sky. I'm pretty sure its something that I am not understanding when it says: the rotation along the X axis relative to its current rotation, which is its starting angle. (from the wiki on moveObject), but I dont understand what this actually means. The reason why I am wanting to know all this is because I noticed that when to you go into the marker, if you exit quick enough while its around half way up, it then comes back down but it goes to the wrong angle. So I am trying to make it so I can check to see if the angle if the wrong angle, it'll fix itself and go back to normal. If there is an easier way to do this, then please let me know. Here is the code: x1, y1, z1 = -721.30396, 945.42999, 12.13281 rotx, roty, rotz = 0, 0, 90 x, y, z = -720.60193, 967.94867, 11.13281 rotx1, roty1, rotz1 = -90, 0, 0 marker1 = createMarker(x1 + 3, y1, z1 - 1, "cylinder", 5, 255, 255, 0, 100) marker2 = createMarker(x, y, z, "cylinder", 5, 255, 255, 0, 100) object1 = createObject(2920, x1, y1, z1, 90, 0, 90) object2 = createObject(2948, x, y, z, 0, 0, 0) addEventHandler("onMarkerHit", marker2, function() --setTimer( function() moveObject(object2, 1000, x, y, z, rotx, roty, rotz) --end --, 200, 1) end ) addEventHandler("onMarkerLeave", marker2, function() --setTimer( function() moveObject(object2, 1000, x, y, z, 0, 0, -90) --end --, 1100, 1) end ) addEventHandler("onMarkerHit", marker1, function() --setTimer( function() --setElementData(object1, "opening", false) --cRotX, cRotY, cRotZ = getElementRotation(object1) --if () if (getElementData(object1, "opening") == false and getElementData(object1, "closing") == false) then setElementData(object1, "opening", true) outputChatBox(tostring(getElementData(object1, "opening")), root) moveObject(object1, 500, x1, y1, z1, rotx1, roty1, rotz1) setTimer( function() setElementData(object1, "opening", false) outputChatBox(tostring(getElementData(object1, "opening")), root) end, 500, 1) end --setElementData(object1, "opening", false) --end --, 200, 1) end ) addEventHandler("onMarkerLeave", marker1, function() --setTimer( function() if (getElementData(object1, "closing") == false and getElementData(object1, "opening") == false) then setElementData(object1, "closing", true) outputChatBox(tostring(getElementData(object1, "closing")), root) moveObject(object1, 500, x1, y1, z1, 90, 0, 0) setTimer( function() setElementData(object1, "closing", false) outputChatBox(tostring(getElementData(object1, "closing")), root) end, 500, 1) end --end --, 1100, 1) end ) addCommandHandler("getdata", function() local cRotX1, cRotY1, cRotZ1 = getElementRotation(object1) local cRotX2, cRotY2, cRotZ2 = getElementRotation(object2) outputChatBox("Closing: " .. tostring(getElementData(object1, "closing")), root) outputChatBox("Opening: " .. tostring(getElementData(object1, "opening")), root) outputChatBox("Object1 rot = x: " .. tostring(cRotX1) .. ", y: " .. tostring(cRotY1) .. ", z: " .. tostring(cRotZ1), root) outputChatBox("Object2 rot = x: " .. tostring(cRotX2) .. ", y: " .. tostring(cRotY2) .. ", z: " .. tostring(cRotZ2), root) end ) It's abit messy and I understand if my description that I wrote above doesnt make sense to some, so if thats the case, I am happy to make a video and post it on youtube to better describe my problem. (The element data stuff was my way of trying to get it so if you exit quick enough, it wont glitch the angle, but after awhile, it still does it) PS: I also tried it with the door which is object2 and it has the same thing happen to it. Thanks!
  13. Thanks for your help, timer works great!
  14. One problem that I have noticed when driving into the colshape is that when I leave, it still detects a vehicle in the colshape, even though I have driven out and no other vehicle is within the colshape.
×
×
  • Create New...