Jump to content

koragg

Members
  • Posts

    730
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by koragg

  1. Default maps are in server-mods-deathmatch-gamemodes-race-maps if i remember correctly. You can't put the same map with the exact same name twice in your server. It just won't load neither of them. So i advise you to delete the default maps unless there are ones that you specifically like and to just put your maps in a [maps] folder under "resources".
  2. Nice, works like a charm. But is there a way to keep the focus of the camera behind the object when I'm not moving my mouse? I mean, when the object I'm spectating (a ghost car) makes a turn the camera stays at the same spot at which I left it via my mouse. I need it to go behind the object (ghost car) after a few seconds of not moving my mouse. Hope you can help!
  3. This did it, camera moves around while spectating ghost vehicle just as if I'm spectating a normal player: But is there a way to keep the focus always behind the vehicle (while not moving the mouse)? Right now if the ghost vehicle makes a turn the camera remains facing the spot I left it at with my mouse. It should go back to behind the ghost car automatically. Any help appreciated!
  4. Thanks a lot for sharing. I guess to disable it i put the same function again?
  5. And the distance is how far you see around the object, right?
  6. A similar effect is done on 6s server. I too would like to know how.
  7. @orel56000 AngX and AngZ are not defined anywhere and give error. Can you give example on how to use these functions to set the camera on an object and make it move freely to look around that object via mouse move (just like it is in normal spectating).
  8. Would this work btw? https://community.multitheftauto.com/index.php?p=resources&s=list&name=freecam&descr=&category=
  9. You can do like this: local state = getElementData(localPlayer, "player state") if state == "dead" or state == "waiting" then return end Here's how to sync it (lines 6-10): function nitroShow() if isPedInVehicle(localPlayer) then local target = getCameraTarget() local car = getPedOccupiedVehicle(localPlayer) local nitro = getVehicleNitroLevel(car) if target and getElementType(target) == "vehicle" then nitro = getVehicleNitroLevel(getVehicleOccupant(target)) elseif target and getElementType(target) == "player" then nitro = getVehicleNitroLevel(target) end if isPedDead(localPlayer) then return end if nitro ~= false and nitro ~= nil and nitro > 0 then dxDrawRectangle(x*1305, y*814, x*126, y*23, tocolor(44, 44, 44, 255), true) -- Nos Show dxDrawRectangle(x*1305, y*814, x*126/10*10*nitro, y*23, tocolor(0, 70, 149, 255), true) -- Nos Show dxDrawText((math.floor(nitro/1*100)).."% Nitro", x*1290, y*810, x*1454, y*842, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, true, false, false) -- Nos Show else dxDrawText("No Nitro", x*1290, y*810, x*1454, y*842, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, true, false, false) -- Nos Hide end end end addEventHandler("onClientRender", root, nitroShow)
  10. lol I needed the exact same thing just a few hours ago Have a look at my topic: The functions which did it for me were: GetCamera() setElementPosition() atachElements() The code example at the first function's wiki is what we're looking for.
  11. GetCamera (combined with the other functions in it's example) fixed a huge part of the problem Thanks @pa3ck, @CodyJ(L) would be nice, only thing left to do is to enable free camera movement while spectating the ghost vehicle.
  12. But i don't need to set the target to myself. It should be kept on the ghost car, only need to enable camera movement. I'll try with warpPedIntoVehicle () to put myself in the ghost car and then setCameraTarget () on me. If only setCameraTarget() worked on other objects except players...it would be so easy to achieve this.
  13. Sadly i have no idea why it won't work then. Check to see if the column name is indeed "player state" and not something else. Maybe my scoreboard is so modified that those things work only in it. Who knows
  14. Hey guys, I feel a bit awkward asking for a function name but...xd I'm pretty sure there was some function to force the player's camera movement on and off. What I mean is that after i set the camera with setCameraMatrix() I can't use the mouse to look around me. So I need to add that function which forces camera movement to be on after using setCameraMatrix(). Hope some of you remember it, I asked a few guys but none do PS: It's for my race ghost spectating resource.
  15. Weird, works for me. Maybe you're not using the dxScoreboard?
  16. I doubt that you'll find exactly what you're looking for. Better download one of the given resources and edit it with your preferences (on / off switch for everything, adding sirens etc).
  17. Here you go: https://www.mediafire.com/file/bk1ipa4vhq1swal/scoreboard.zip
  18. Here you go. By the way instead of removing it when you're spectating you can make it update the health and nitro level of the person you're spectating so it shows their values. Anyway, code to remove both if you're spectating below, let me know if you want to sync it instead and I'll be glad to help you out (it's ready for me, just copy-paste xd). local sx, sy = guiGetScreenSize() local px, py = 1600, 900 local x, y = (sx/px), (sy/py) function drawHealthAndNOS() local playerVehicle = getPedOccupiedVehicle(localPlayer) if playerVehicle then local vehicleHealth = getElementHealth(playerVehicle) local vehicleSpeed = getElementVelocity(playerVehicle) if isPedDead(localPlayer) then return end local state = getElementData(localPlayer, "player state") if state == "spectating" then return end dxDrawLine(x*1293, y*802, x*1590, y*802, tocolor(0, 0, 0, 255), 3, true) dxDrawLine(x*1293, y*886, x*1590, y*886, tocolor(0, 0, 0, 255), 3, true) dxDrawLine(x*1293, y*801, x*1293, y*887, tocolor(0, 0, 0, 255), 3, true) dxDrawLine(x*1590, y*800, x*1590, y*886, tocolor(0, 0, 0, 255), 3, true) dxDrawRectangle(x*1294, y*803, x*297, y*83, tocolor(0, 0, 0, 170), true) -- Rahmen dxDrawRectangle(x*1454, y*814, x*126, y*23, tocolor(44, 44, 44, 255), true) -- Health dxDrawRectangle(x*1454, y*814, x*126/1000*vehicleHealth, y*23, tocolor(59, 141, 0, 255), true) -- Health dxDrawText((math.floor(vehicleHealth/10)).."% Health", x*1440, y*810, x*1604, y*842, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, true, false, false) -- Health sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) -- Speed vehiclekmh = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) -- Speed dxDrawText(""..tostring(vehiclekmh).." kmh", x*1358, y*857, x*1522, y*877, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, true, false, false) -- Speed end end addEventHandler("onClientRender", root, drawHealthAndNOS) function nitroShow() if isPedInVehicle(localPlayer) then local car = getPedOccupiedVehicle(localPlayer) local nitro = getVehicleNitroLevel(car) if isPedDead(localPlayer) then return end local state = getElementData(localPlayer, "player state") if state == "spectating" then return end if nitro ~= false and nitro ~= nil and nitro > 0 then dxDrawRectangle(x*1305, y*814, x*126, y*23, tocolor(44, 44, 44, 255), true) -- Nos Show dxDrawRectangle(x*1305, y*814, x*126/10*10*nitro, y*23, tocolor(0, 70, 149, 255), true) -- Nos Show dxDrawText((math.floor(nitro/1*100)).."% Nitro", x*1290, y*810, x*1454, y*842, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, true, false, false) -- Nos Show else dxDrawText("No Nitro", x*1290, y*810, x*1454, y*842, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, true, false, false) -- Nos Hide end end end addEventHandler("onClientRender", root, nitroShow) And in the post window there are two opposite arrows in the control bar at the top. Something like '<>'. Click that and paste your code there so it looks like in Notepad++
  19. I'm from phone so can't give any code but i did notice one thing. You can't set the flag just by setting element data as you can other things. To put flags in the scoreboard you have to use dxDrawImage. I'll give you my scoreboard's flags lines tomorrow so you see how it's made. I can give you my modified scoreboard actually. It puts flags and full country names in column called "Country". Reply here if you want it. (It didn't work by using a 3rd party resource for me neither when i tried to use one from community.)
  20. I used the same resource in my server since the design is so simplistic yet awesome looking. Try this for your case (also fixed up code a bit since it wasn't positioned correctly): local sx, sy = guiGetScreenSize() local px, py = 1600, 900 local x, y = (sx/px), (sy/py) function drawHealthAndNOS() local playerVehicle = getPedOccupiedVehicle(localPlayer) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) local vehicleSpeed = getElementVelocity ( playerVehicle ) if isPedDead(localPlayer) then return end dxDrawLine(x*1293, y*802, x*1590, y*802, tocolor(0, 0, 0, 255), 3, true) dxDrawLine(x*1293, y*886, x*1590, y*886, tocolor(0, 0, 0, 255), 3, true) dxDrawLine(x*1293, y*801, x*1293, y*887, tocolor(0, 0, 0, 255), 3, true) dxDrawLine(x*1590, y*800, x*1590, y*886, tocolor(0, 0, 0, 255), 3, true) dxDrawRectangle(x*1294, y*803, x*297, y*83, tocolor(0, 0, 0, 170), true) -- Rahmen dxDrawRectangle(x*1454, y*814, x*126, y*23, tocolor(44, 44, 44, 255), true) -- Health dxDrawRectangle(x*1454, y*814, x*126/1000*vehicleHealth, y*23, tocolor(59, 141, 0, 255), true) -- Health dxDrawText((math.floor(vehicleHealth/10)).."% Health", x*1440, y*810, x*1604, y*842, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, true, false, false) -- Health sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) -- Speed vehiclekmh = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) -- Speed dxDrawText(""..tostring(vehiclekmh).." kmh", x*1358, y*857, x*1522, y*877, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, true, false, false) -- Speed end end addEventHandler("onClientRender", root, drawHealth) function nitroShow() if isPedInVehicle(localPlayer) then local car = getPedOccupiedVehicle(localPlayer) local nitro = getVehicleNitroLevel(car) if isPedDead(localPlayer) then return end if nitro ~= false and nitro ~= nil and nitro > 0 then dxDrawRectangle(x*1305, y*814, x*126, y*23, tocolor(44, 44, 44, 255), true) -- Nos Show dxDrawRectangle(x*1305, y*814, x*126/10*10*nitro, y*23, tocolor(0, 70, 149, 255), true) -- Nos Show dxDrawText((math.floor(nitro/1*100)).."% Nitro", x*1290, y*810, x*1454, y*842, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, true, false, false) -- Nos Show else dxDrawText("No Nitro", x*1290, y*810, x*1454, y*842, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, true, false, false) -- Nos Hide end end end addEventHandler("onClientRender", root, nitroShow)
  21. Edited a bit and tested with a real-life player (woah ). Everything works perfect, also optimized a bit as you suggested @IIYAMA.
  22. It just refused to work without a slight delay after the map has started OK, I'll try to fix it up a bit after dinner and report back soon. PS: i just saw there's no need to trigger client event on login logout and namechange will just put licence plate function in server side.
  23. Thanks for your input @IIYAMA but setTimer says: timesToExecute: The number of times you want the timer to execute, or 0 for infinite repetitions. And I set it to '1' so that it executes just once on every map start. Am I missing something? Shouldn't it be '0' to be an infinite timer?
  24. Here goes. So I wasted ~ 1 hour and did the following things: Cliend-side stuff: visual = { -- Standard Settings, 0 = off -- ["plate"] = string.sub(getPlayerName(localPlayer):gsub('#%x%x%x%x%x%x', ''), 1, 8), } ------------------------------------------------------------------------------------------------------------------------- function visual_ButtonHandler() if source == GUIEditor.button["plate"] then local nr = guiGetText(GUIEditor.edit["plate"]) if not nr then outputChatBox("Please insert a string to use as your licence plate before clicking ok.") return end if nr == nil or nr == "" or nr == " " or nr == " " or nr == " " or nr == " " or nr == " " or nr == " " or nr == " " or nr == " " then outputChatBox("Your licence plate cannot be empty. Changed to default one. ") nr = string.sub(getPlayerName(localPlayer):gsub('#%x%x%x%x%x%x', ''), 1, 8) end local veh = getPedOccupiedVehicle(localPlayer) if veh then if getElementData(localPlayer, "LoggedIn") ~= true then outputChatBox("You need to register and login in order to set a custom licence plate!", 255, 153, 0, true) return end setVehiclePlateText(veh, nr) setElementData(localPlayer, "savedPlate", nr) setElementData(localPlayer, "plate", nr) visual["plate"] = nr v_setSaveTimer() end end end end addEventHandler("onClientGUIClick", resourceRoot, visual_ButtonHandler) ------------------------------------------------------------------------------------------------------------------------- function visual_LoadSettings() for w, c in pairs(visual) do -- Move settings to visual table -- local theChild = xmlFindChild( v_loadXML, w, 0 ) if not theChild then local theChild = xmlCreateChild( v_loadXML, w ) xmlNodeSetValue( theChild, c ) end if w ~= "nitrocolor" and w ~= "plate" then -- nitrocolor is not a number value local val = xmlNodeGetValue( theChild ) visual[w] = tonumber(val) else local val = xmlNodeGetValue( theChild ) visual[w] = val end if w == "plate" then local veh = getPedOccupiedVehicle(localPlayer) setElementData(localPlayer, "savedPlate", c) setElementData(localPlayer, "plate", c) local pltTxt = c if getElementData(localPlayer, "LoggedIn") ~= true then pltTxt = string.sub(getPlayerName(localPlayer):gsub('#%x%x%x%x%x%x', ''), 1, 8) end if veh then setVehiclePlateText(veh, pltTxt) end end end setVisualGUI() end addEventHandler("onClientResourceStart", resourceRoot, visual_LoadSettings) ------------------------------------------------------------------------------------------------------------------------- addEvent("changePlateOnLogout", true) function changePlateOnLogout(veh, pltTxt) if veh and pltTxt then setVehiclePlateText(veh, pltTxt) end end addEventHandler("changePlateOnLogout", root, changePlateOnLogout) ------------------------------------------------------------------------------------------------------------------------- addEvent("changePlateOnLogin", true) function changePlateOnLogin(veh, pltTxt) if veh and pltTxt then setVehiclePlateText(veh, pltTxt) end end addEventHandler("changePlateOnLogin", root, changePlateOnLogin) ------------------------------------------------------------------------------------------------------------------------- addEvent("changePlateOnNickChange", true) function changePlateOnNickChange(veh, pltTxt) if veh and pltTxt then setVehiclePlateText(veh, pltTxt) end end addEventHandler("changePlateOnNickChange", root, changePlateOnNickChange) ------------------------------------------------------------------------------------------------------------------------- function setVisualGUI() for f, u in pairs(visual) do if f == "plate" then if u ~= nil or u ~= "" or u ~= " " or u ~= " " or u ~= " " or u ~= " " or u ~= " " or u ~= " " or u ~= " " or u ~= " " then guiSetText(GUIEditor.edit["plate"], u) local veh = getPedOccupiedVehicle(localPlayer) if veh then if getElementData(localPlayer, "LoggedIn") ~= true then outputChatBox("You need to register and login in order to set a custom licence plate!", 255, 153, 0, true) return end setVehiclePlateText(veh, u) setElementData(localPlayer, "savedPlate", u) setElementData(localPlayer, "plate", u) visual["plate"] = u end else local plate local veh = getPedOccupiedVehicle(localPlayer) if veh then plate = getVehiclePlateText(veh) end if plate then guiSetText(GUIEditor.edit["plate"], plate) end end end end end Server-side stuff: addEvent("onMapStarting", true) function setLicencePlate() setTimer(function() for k,v in ipairs(getElementsByType("player")) do local account = getPlayerAccount(v) if account and isGuestAccount(account) then return end local veh = getPedOccupiedVehicle(v) local plateText = getElementData(v, "plate") if veh and plateText and plateText ~= nil then setVehiclePlateText(veh, plateText) end end end, 50, 1) end addEventHandler("onMapStarting", root, setLicencePlate) addEventHandler("onPlayerSpawn", root, setLicencePlate) addEventHandler("onPlayerJoin", root, setLicencePlate) ------------------------------------------------------------------------------------------------------------------------- function onPlayerLogout() local vehicle = getPedOccupiedVehicle(source) local newPlate = string.sub(getPlayerName(source):gsub('#%x%x%x%x%x%x', ''), 1, 8) triggerClientEvent(root, "changePlateOnLogout", source, vehicle, newPlate) end addEventHandler("onPlayerLogout", root, onPlayerLogout) ------------------------------------------------------------------------------------------------------------------------- function onPlayerLogin() local newPlate local vehicle = getPedOccupiedVehicle(source) local savedPlate = getElementData(source, "savedPlate") if savedPlate then newPlate = string.sub(savedPlate:gsub('#%x%x%x%x%x%x', ''), 1, 8) else newPlate = string.sub(getPlayerName(source):gsub('#%x%x%x%x%x%x', ''), 1, 8) end triggerClientEvent(root, "changePlateOnLogin", source, vehicle, newPlate) end addEventHandler("onPlayerLogin", root, onPlayerLogin) ------------------------------------------------------------------------------------------------------------------------- function onPlayerChangeNick(oldNick, newNick) local account = getPlayerAccount(source) local savedPlate = getElementData(source, "savedPlate") if savedPlate and account and not isGuestAccount(account) then return end local vehicle = getPedOccupiedVehicle(source) local newPlate = string.sub(newNick:gsub('#%x%x%x%x%x%x', ''), 1, 8) triggerClientEvent(root, "changePlateOnNickChange", source, vehicle, newPlate) end addEventHandler("onPlayerChangeNick", root, onPlayerChangeNick) ------------------------------------------------------------------------------------------------------------------------- function onPlayerLogin() local playeraccount = getPlayerAccount(source) if playeraccount then if not isGuestAccount(playeraccount) then setElementData(source, "LoggedIn", true) else setElementData(source, "LoggedIn", false) end end end addEventHandler("onPlayerLogin", root, onPlayerLogin) Obviosly this is just the part for the plates (there is a :~load of code for other settings in the resource). For me - it works. No bugs, no problems. But would it be synced to all other players is my question? Like, when I change my licence plate to a custom one from the GUI, would a player next to me or spectating me see the updated custom plate? If anyone can take a look at the above lines and tell me, I'd appreciate it.
×
×
  • Create New...