-
Posts
269 -
Joined
-
Last visited
fairyoggy's Achievements
Peon (20/54)
11
Reputation
-
@CronossEverything works as it should, thanks a lot for your help
-
@CronossI showed the code with which I call these functions in the first post I mean how to do it. I press the button and using the function "j1client0" which removes the window and calls the server function "j1server" , here in the code I just called another server function("j1server2"), with the line: j1server2() and here the function should transfer the coordinates to the client side "j1client" and the sound also works, using the line: playSoundFrontEnd(1) Maybe I didn’t use the logic correctly somewhere, but everything seems to work as it should, except for a nuance, the sound is heard by all players, and I want to do it only for the player who presses the button
-
--client function w1() w1 = guiCreateWindow((sW - 419) / 2, (sH - 165) / 2, 280, 310, "W1", false) w1btn1 = guiCreateButton ( 5, 25, 120, 25, "btn1", false, w1) addEventHandler("onClientGUIClick",w1btn1,j1client0,false) end function j1client0() triggerServerEvent("j1server",localPlayer) destroyElement(w1) showCursor(false) end function j1client() playSoundFrontEnd(1) end addEvent("j1client", true) addEventHandler("j1client", root, j1client) --server function j1server() local car1 = createVehicle (408, 0, 0, 0, 0, 0, 0, "car1", 0, 0, 0) j1server2() end addEvent("j1server",true) addEventHandler("j1server",root,j1server) function j1server2() local x,y,z = 0, 0, 0 triggerClientEvent("j1client",source, x,y,z) end addEvent("j1server2",true) addEventHandler("j1server2",root,j1server2) Everything works as intended, with the exception of 1 nuance. The sound happens for everyone on the server, but need only for the player who presses the button. How to fix it?
-
@Addlibs finding a car is not a problem, I just don’t understand how can I find the coordinates of the back of the car - the trunk? update: I found the solution with the help of the tips above, thanks.
-
how to attach coordinates to the back of the car? I mean to make the marker appear on the side of the trunk? function findcar(player, cmd) local carx, cary, carz = getElementPosition(getElementByID("car1")) local marker = createMarker(carx,cary,carz, "cylinder", 1.5, 255, 0, 0, 255) end addCommandHandler("ff", findcar) The car can be located in different places, but I need the marker to always be at the trunk, how can I do this?
-
you didn’t understand, the button action works, but I need the button to enabled off when pressed, but if I use my code, i have error: "[Expected gui-element at argument 1, got nil] " in line: guiSetEnabled (button1,false)
-
How can I define a button for a function? function test1() window1test1 = guiCreateWindow((sW - 419) / 2, (sH - 165) / 2, 280, 310, "test1", false) local button1 = guiCreateButton ( 5, 25, 120, 25, "btn1", false, window1test1) addEventHandler("onClientGUIClick",button1,test2,false) end addEvent("test1", true) addEventHandler("test1", root, test1) addCommandHandler("test1",test1) function test2() guiSetEnabled (button1,false) end [Expected gui-element at argument 1, got nil] At the moment, I'm getting an error because it can't find the button, how fix?
-
How can I shorten this code so as not to write many lines? local ex1 = math.random(1,10) local ex2 = math.random(1,10) local ex3 = math.random(1,10) local ex4 = math.random(1,10) local ex5 = math.random(1,10) local ex6 = math.random(1,10) local ex7 = math.random(1,10) local ex8 = math.random(1,10) local ex9 = math.random(1,10) local ex10 = math.random(1,10) I want to shorten the code so as not to write a lot of lines, but at the same time so that each variable has a different random number. I'm sure it's easy, but I still don't understand how?
-
Hello, how can I use a function from one script in another? For example, In one script, this function is written: function changeWalkSettings (arg) toggleControl(source, "sprint", arg) toggleControl(source, "jump", arg) toggleControl(source, "aim_weapon", arg) toggleControl(source, "next_weapon", arg) toggleControl(source, "previous_weapon", arg) toggleControl(source, "fire", arg) toggleControl(source, "enter_exit", arg) end In another script, I want to call this command with a command like: changeWalkSettings(true) or changeWalkSettings(false) How can I do it right?
-
fairyoggy changed their profile photo
-
I have a question What are the normal values for cpu usage for client? For example, for something like this(text above npc head): Screen Now 2.03% is used there but how good is that? Maybe I can reduce the load in some way or are these normal numbers? function testcpu() local x, y, z = getCameraMatrix() local dimension = getElementDimension(localPlayer) local px, py, pz = getElementPosition(getElementByID("ped1")) local distance = getDistanceBetweenPoints3D(px, py, pz, x, y, z) if distance <= 7 then local sx, sy = getScreenFromWorldPosition(px, py, pz + 1.2) if sx and sy then dxDrawText("Unknown", sx, sy, sx, sy, tocolor(3, 169, 252, 255), 2.02, "default-bold", "center", "center", false, false, false, false, false) end end end addEventHandler("onClientRender", getRootElement(), testcpu)
-
Exactly what is needed. This will help me. Thank you so much
-
or let's do it differently function duty(thePlayer) local marker = getElementsByType("marker") for i, marx in pairs(marker) do local id = getElementID(marx) outputChatBox(id, thePlayer, 255, 0, 0) end end addCommandHandler("duty", duty) Let's say we have 2 markers with ElementID How can I correctly implement a check for an element id ? use this: isElementWithinMarker -- or isElementWithinColShape There should be something similar to the code above, but without using(if there are more objects): local checkjob = getElementByID("1") local checkjob2 = getElementByID("2") local checkjob3 = getElementByID("3") local checkjob4 = getElementByID("4") local checkjob5 = getElementByID("5") local checkjob6 = getElementByID("6") local checkjob7 = getElementByID("7") local checkjob8 = getElementByID("8") local checkjob9 = getElementByID("9") The idea is that when a player steps on a marker and writes a command, a message appears with a element ID
-
Okay, but how to convert this code if adding "setElementID" without code I mean, no code editing like this: local checkjob = getElementByID("1") local checkjob2 = getElementByID("2") local checkjob3 = getElementByID("3") local checkjob4 = getElementByID("4") local checkjob5 = getElementByID("5") local checkjob6 = getElementByID("6") local checkjob7 = getElementByID("7") local checkjob8 = getElementByID("8") local checkjob9 = getElementByID("9") I made the creation of these objects through the game, but how can I make the correct check for this.
-
Perfect, you are a genius. Thank you so much
-
@IIYAMA How to use it correctly? i tried like this: function loadAllJobs(dbJobsConnection) local results = dbPoll(dbJobsConnection,0) for index, jobs_sys in pairs(results) do jobsObject = createMarker(jobs_sys.x,jobs_sys.y,jobs_sys.z,"cylinder",1,255,0,0,255) setElementData(jobsObject, "uid", jobs_sys.uid) setElementID(jobsObject,jobs_sys.uid) setElementData(jobsObject,"money",jobs_sys.money) end end addEventHandler("onResourceStart", resourceRoot, function () dbQuery(loadAllJobs, dbJobsConnection, 'SELECT * FROM jobs_sys LEFT JOIN jobs') end) But something is wrong. Looking at my old code(This code in the first post): function loadAllJobs(dbJobsConnection) local results = dbPoll(dbJobsConnection,0) for index, jobs_sys in pairs(results) do jobsObject = createMarker(jobs_sys.x,jobs_sys.y,jobs_sys.z,"cylinder",1,255,0,0,255) setElementData(jobsObject, "uid", jobs_sys.uid) setElementID(jobsObject,jobs_sys.uid) end end addEventHandler("onResourceStart", resourceRoot, function () dbQuery(loadAllJobs, dbJobsConnection, 'SELECT * FROM jobs_sys') end) If use my old code and add the line smth like this: outputChatBox(jobs_sys.uid, thePlayer, 255, 0, 0) We will receive a list of numbers of two markers in the chat Screen1 but if we use the new code and draw the output of these numbers, we get duplication of these numbers Screen2 P.S: Both tables use the string "uid" Maybe this is related to this, but what to do about it? Table1 Table2 What is it all about ... With the help of you, I was able to withdraw the line money from table 2, to check I used the method above outputChatBox(jobs_sys.money, thePlayer, 255, 0, 0) and got the same duplication Screen Plus, this line stopped working for markers other than the first: setElementID(jobsObject,jobs_sys.uid) What have I done wrong?