Jump to content

thund3rbird23

Members
  • Posts

    129
  • Joined

  • Last visited

1 Follower

Recent Profile Visitors

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

thund3rbird23's Achievements

Poot-butt

Poot-butt (14/54)

10

Reputation

  1. What are the 12th and 13th indexes for? The getCameraMatrix function return only 8 number and you can't index them because they are just numbers. Do you mean the x,y coords given by the getCameraMatrix function? So, like this?: local cursorX, cursorY = getCursorPosition() local cameraX, cameraY = getCameraMatrix() local vehicleX, vehicleY = getElementPosition(vehicle) local stickerX = cursorX * 1024 - cameraX + vehicleX local stickerY = cursorY * 1024 - cameraY + vehicleY stickers[selectedStickerID][1] = stickerX stickers[selectedStickerID][2] = stickerY I tried that but got the same result, the sticker is moving perfectly forward and backward direction only if the camera is looking at the roof of the car (just like in the video) I think I need to play with the vehicle's center position too somehow, when I moving the cursor or something like that?! Because if you're looking at the top of the vehicle then the camera is looking exactly at the middle of the vehicle, isn't it?
  2. Any help or advice, please? I'm still struggling with it
  3. I want to move the sticker which is placed on the vehicle with mouse. At the moment I use the cursor's x,y position to set the sticker's x,y position inside the onClientRender event: local cursorX,cursorY = getCursorPosition() stickers[selectedStickerID][1] = cursorX * 1024 -- stickers is a table the first key is the sticker's x position (the 1024 is the UV-Map size which applied to the car) stickers[selectedStickerID][2] = cursorY * 1024 -- the second key is the sticker's y position but currently the moving is very strange... if the camera is looking on top of the car then the sticker moves as expected but for example if the camera is looking at the front of the car, if I move the mouse forwards the sticker moves backwards and so on as shown in the video below. so I think I need to calculate the x,y position from the cursor (getCursorPosition) the camera (getCameraMatrix) and maybe the vehicle position (getElementPosition) together (?) I tried to play a bit in that way too but that was even worse Here is a video to better understand what the problem is: https://streamable.com/dssr52
  4. Yeah, I know about these functions. But some server did it already they're just "highlighted" the engine for example when you are a mechanic and you are repair the engine then it's like the engine is "glowing", "highlighted" or I dont know which word can describe
  5. Thank you for your reply, but how can I get the vehicle engine's position and such things? I don't think so there is a function for that
  6. My goal is draw outline around the vehicle's engine when the hood is open but I don't know it's possible to do or not... of course there are modded vehicles not default ones. I know I need to open the vehicle's hood with SetVehicleDoorState but how can I draw the outline around the engine? is there any function to get the engine position for each vehicles or I need to calculate it manually? and then I can use the DxDrawLine function or which one? By outline I mean like this, but around the engine:
  7. I'm trying to do if I click on a "left" or "right" button then rotate the created ped, if I click on the left button then rotate the ped -10 if I click on the right button then rotate the ped +10 defPed = createPed(1, pedPosition[1], pedPosition[2], pedPosition[3], pedPosition[4]) function createPed(key, state) local rotX, rotY, rotZ = getElementRotation(defPed) if state then if key == "mouse1" then if isInSlot(sx*0.3 + 275/myX*sx, startY+250, 40/myX*sx, 40/myX*sx) then setElementRotation(defPed, rotX, rotY, rotZ - 10) end if isInSlot(sx*0.3 + 335/myX*sx, startY+250, 40/myX*sx, 40/myX*sx) then setElementRotation(defPed, rotX, rotY, rotZ + 10) end end end end The problem is that if I click on the "right" button, it turns to the right and then if I click on it once more, it turns back, same situation with the "left" button. Is it because I don't store rotX, rotY,rotZ after turning the ped to right/left? if so then where I need to store them?
  8. Yes, I realized it a few hours later after I posted it but thank you
  9. My problem is, when I click on the button 2 which is register then it's click twice on the button, but I only click once, why? function Panel:loginClick(button, state) if self.show and self.hovered == 'buttons' and self.selectedbutton == 1 then for key, value in pairs(self.loginGuis) do if value.text == '' then if clickTick + (5000) > getTickCount() then return end exports.ml_notification:addNotification('All fields are required!', 'warning') destroyAnimation() break else triggerServerEvent('loginaccount', localPlayer, localPlayer, self.loginGuis[1].text, self.loginGuis[2].text) destroyAnimation() end end elseif self.show and self.hovered == 'buttons' and self.selectedbutton == 2 then for key, value in ipairs(self.registerGuis) do if value.text == '' then if clickTick + (5000) > getTickCount() then return end exports.notification:addNotification('All fields are required!', 'warning') break else if self.registerGuis[2].text == self.registerGuis[3].text then if isValidMail(self.registerGuis[4].text) then outputChatBox(self.registerGuis[1].text) triggerServerEvent("registeraccount", localPlayer, localPlayer, self.registerGuis[1].text, self.registerGuis[2].text, self.registerGuis[4].text) break else exports.notification:addNotification('Wrong email!', 'warning') break end else exports.notification:addNotification('The passwords do not match!', 'warning') break end end end end end The registeraccount server side: function registerAcc(player, username, password, email) outputChatBox("register clicked") local password = base64Encode(password) local registerQuery = dbPoll(dbQuery(sql, "SELECT * FROM account"), -1) for _, row in ipairs(registerQuery) do if row["username"] == username then exports.notification:addNotification(player, 'This username is already taken!', 'warning') return end if row["serial"] == getPlayerSerial(player) then exports.notification:addNotification(player, 'You already have an account!', 'warning') return end end local registerInsert = dbQuery(sql, "INSERT INTO account SET username = ?, password = ?, email = ?, serial = ?", username, password, email, getPlayerSerial(player)) local result, num, insertID = dbPoll(registerInsert, -1) if insertID then exports.notification:addNotification(player, 'Register success!', 'info') end end addEvent("registeraccount", true) addEventHandler("registeraccount", root, registerAcc) The problem is because it's clicking on the button twice then always getting a warning notification when I register "You already have an account"
  10. The vehicle ID is the primary key in database. (id column)
  11. I'm getting the vehicle plate text from a client-side gui gridlist selection and want to check if the vehicle with the selected plate text is nearby then I can do whatever what I want with the vehicle. I had to modify the positions variable the positions debug is working well but I always getting "Vehicle is not nearby" doesn't matter if I'm close to the vehicle or not. And the vehicle position doesn't change while the player is in-game. That will change after the player is disconnected so I don't think so that's the good way of the vehicle's position?! function SetVehicleSellingDB(vehPlate) local query = dbQuery(con, "SELECT * FROM vehicle WHERE plate=?", vehPlate) local result = dbPoll(query, -1) if result then local vehicleplate = result[1]["plate"] local pos = fromJSON(result[1]["pos"]) local x = pos[1] local y = pos[2] local z = pos[3] iprint("x: "..x.. " y: "..y.." z: "..z) local nearby = 20 if getDistanceBetweenPoints3D(x, y, z, getElementPosition(source)) <= nearby then outputDebugString("Vehicle is nearby") else outputDebugString("Vehicle is not nearby") end end end
  12. I want to check if the selected vehicle is nearby by the vehicle's plate. I'm getting the vehicle's plate text from client-side gui (gridlist selection) then I query that plate from mysql in server-side and want to check if that is nearby or not. function SetVehicleSellingDB(vehPlate) local query = dbQuery(con, "SELECT * FROM vehicle WHERE plate=?", vehPlate) local result = dbPoll(query, -1) if result then local vehicleplate = result[1]["plate"] --- I getting the selected vehicle's plate from client-side gui succesfully local vehicle = getNearestVehicle( vehicleplate ) --- this doesn't work if vehicle then outputChatBox("Vehicle is nearby") end end end addEvent("SetVehSellingDB",true) addEventHandler("SetVehSellingDB",getRootElement(), SetVehicleSellingDB) It's works until I getting the vehicle's plate text but how can I insert the vehicleplate variable into the getNearestVehicle function? function getNearestVehicle( player ) local x, y, z = getElementPosition( player ) local prevDistance local nearestVehicle for i, v in ipairs( getElementsByType( "vehicle" ) ) do local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( v ) ) if distance <= ( prevDistance or distance + 1 ) then prevDistance = distance nearestVehicle = v end end return nearestVehicle or false end getNearestVehicle function source:
  13. Now the local Selected = DGS:dgsGridListGetSelectedItem(gridlist) iprint("Selected is correct:", Selected ~= -1, ">input>", Selected ) Selected returns false. But before that it worked without any problem
×
×
  • Create New...