Jump to content

oggygod

Members
  • Posts

    260
  • Joined

  • Last visited

Recent Profile Visitors

803 profile views

oggygod's Achievements

Peon

Peon (20/54)

10

Reputation

  1. 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)
  2. Exactly what is needed. This will help me. Thank you so much
  3. 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
  4. 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.
  5. Perfect, you are a genius. Thank you so much
  6. @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?
  7. 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.
  8. 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
  9. -- 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 ','
  10. oggygod

    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?
  11. That's right, thanks for the help
  12. 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.
  13. That's what I need, you have solved my problem. Thank you
  14. Can i remove the standart text "say: You are muted" when is the player muted?
  15. oggygod

    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?
×
×
  • Create New...