Jump to content

fairyoggy

Members
  • Posts

    269
  • Joined

  • Last visited

Everything posted by fairyoggy

  1. @CronossEverything works as it should, thanks a lot for your help
  2. @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
  3. --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?
  4. @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.
  5. 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?
  6. 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)
  7. 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?
  8. 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?
  9. 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?
  10. 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)
  11. Exactly what is needed. This will help me. Thank you so much
  12. 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
  13. 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.
  14. Perfect, you are a genius. Thank you so much
  15. @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?
  16. How can I use reading data from two tables at once in one function? There are two tables: 1) jobs_sys(x,y,z) 2) jobs(money) For the first table, I have everything ready but for second... How do I make a transfer "money" from second table to setElementData ? 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) -- need this line setElementData(jobsObject,"money",jobs.money) end end addEventHandler("onResourceStart", resourceRoot, function () dbQuery(loadAllJobs, dbJobsConnection, 'SELECT * FROM jobs_sys') end) 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) -- need this line setElementData(jobsObject,"money",jobs.money) end end function loadAllJobs2(dbJobsConnection) local results2 = dbPoll(dbJobsConnection,0) for index2, jobs in pairs(results2) do setElementData(jobsObject, "money", jobs.money) end end addEventHandler("onResourceStart", resourceRoot, function () dbQuery(loadAllJobs, dbJobsConnection, 'SELECT * FROM jobs_sys') dbQuery(loadAllJobs2, dbJobsConnection, 'SELECT * FROM jobs') end) but it doesn't work as planned. elementData "money" not assigned to all markers.
  17. function duty(thePlayer) local jobs = getElementsByType("marker") for index, jobs in pairs(jobs) do local checkjob = getElementByID("1") local checkjob2 = getElementByID("2") if isElementWithinMarker(thePlayer, jobs) then if jobs == checkjob then outputChatBox("1 job", thePlayer, 255, 0, 0) elseif jobs == checkjob2 then outputChatBox("2 job", thePlayer, 255, 0, 0) end else outputChatBox("not marker", thePlayer, 255, 0, 0) end end end addCommandHandler("duty", duty) Everything works as I want, but there is one nuance. If the player is outside the markers, then the message is duplicated. I guess this is because 2 markers were created, so 2 message. How to fix it? What would be one message Screen
  18. -- var 1 function paymoney(player,cmd, ...) for i, v in ipairs(getElementsByType("player")) do if #({...}) == 0 then outputChatBox ("Empty Message",v,255,255,255,false) else --if amount == nil then --outputChatBox ("Type Amount",v,255,255,255,false) --else -- --end end end end addCommandHandler("pay",paymoney) -- var 2 function paymoney(player,cmd, amount) for i, v in ipairs(getElementsByType("player")) do if amount == nil then outputChatBox ("Type Amount",v,255,255,255,false) else -- end end end addCommandHandler("pay",paymoney) In the first option, a check is made for an empty message, Example: player type in chat /pay and appears error message "empy message" but if player type /pay 1 it's fine In the second option, a check is made for an empty amount, example: /pay and appears error message "type amount" but if player type /pay 1 it's fine So... How to combine this into one function? I mean if the player type in chat /pay 1 1 it's ok but if player type /pay - error message "empy message" , if player type /pay 1 - error message "type amount" , if player type /pay 1 1 it's fine I am having difficulty with the string: function paymoney(player,cmd, ...) Need something like this: function paymoney(player,cmd, ... , amount) but i cant use code like this: Error: Loading script, ")" expected near ','
  19. fairyoggy

    check jump

    function playerPressedKey(button, press) if (button == "lshift" and press) then if getPedControlState(localPlayer,"jump") == true then outputChatBox("jump", 0, 255, 0) end end end addEventHandler("onClientKey", root, playerPressedKey) Jump bind to keys "lshift" and "rctrl" How do I make a jump check? For example, I pressed the button "lshift" and checks whether the player jumped or not. need an instant check. I pressed the button and writes that the player has jumped or not. Now it works like this. If you press "lshift" Nothing happens but if you hold down the button "rctrl" and after this press "lshift" then message appears. What am I doing wrong, how to fix it?
  20. That's right, thanks for the help
  21. Can I remove chat notification in chat like this " Oggy_Slaps is now known as hip" ? I want that when a player's nickname changes, this message does not appear in the chat.
  22. That's what I need, you have solved my problem. Thank you
  23. Can i remove the standart text "say: You are muted" when is the player muted?
  24. fairyoggy

    chat

    @Tekken Thank you for your responsiveness, but not working. Any other suggestions? function chatDetect(message,mstype, ...) if mstype == 1 then sendMessage(source,"me",message) cancelEvent() end end addEventHandler("onPlayerChat",root,chatDetect) function sendMessage(player,cmd,...) local distance local x,y,z = getElementPosition(player) local nick = getPlayerName(player) local message = table.concat( {...}, " ") if ... then --With this line, I solved the problem, but not for "me"; if cmd == "me" then outputChatBox("* "..nick.." "..message,player,247,97,224,false) elseif cmd == "do" then outputChatBox("* "..nick.." "..message,player,247,97,224,false) end else outputChatBox ( "not message", player, 255, 125, 125, true ) end end addCommandHandler("do",sendMessage) @Tekken I found a solution like this, but it doesn't work for the command "me" For the command "do" works but for "me" not working. As I understand it, this is due to the fact that the command "me" Already automatically created in the mta itself but "do" i create with addCommandHandler. How can I solve this problem?
  25. fairyoggy

    chat

    function chatDetect(message,mstype, ...) if mstype == 1 then sendMessage(source,"me",message) cancelEvent() -- if ... then outputChatBox ( "not message", v, 255, 125, 125, true ) end -- end end addEventHandler("onPlayerChat",root,chatDetect) function sendMessage ( player, cmd, ... ) local message = table.concat( {...}, " ") for i, v in ipairs ( getElementsByType( "player" ) ) do local x, y, z = getElementPosition ( player ) local xt, yt, zt = getElementPosition ( v ) if getDistanceBetweenPoints3D ( x, y, z, xt, yt, zt ) <= 10 then outputChatBox ( "** "..message.." ("..getPlayerName(player)..")", v, 255, 125, 125, true ) end end end how do I do when a command is entered without a message, it writes an error? like this: 1) /me 2) /me hello 1 - need output error (not message) 2 - it's ok
×
×
  • Create New...