-
Posts
1,134 -
Joined
-
Last visited
-
Days Won
37
Everything posted by NeXuS™
-
Dude, you should really post this in your own language section, because I don't understand a word you are trying to say with the translator.
-
Streaming in happens when an object gets loaded in, because you get close to it, streaming out happens when an object gets loaded out, because you went to far away from it.
-
Gimme a minute, testing it atm. Szóval, tuti hogy lenne könnyebb megoldása ennek de ez egy működőképes dolog. addCommandHandler("changetire", function(thePlayer, cmdName, newValue) if isPedInVehicle(thePlayer) then local pVeh = getPedOccupiedVehicle(thePlayer) local defHandling = string.format("%x", getVehicleHandling(pVeh)["handlingFlags"]) local newHandling = "0x" .. string.sub(defHandling, 0, 2) .. newValue .. string.sub(defHandling, 5) outputChatBox("Default handling: " .. "0x" .. defHandling) outputChatBox("New handling: " .. newHandling) setVehicleHandling(pVeh, "handlingFlags", tonumber(newHandling)) end end)
-
Do you know what "stream" means in this case?
-
Try to debug if the dxDrawMaterialLine3D is an element, or not.
-
These 2 events happen when an element is streamed in/out on the client. (Like the visible distance)
-
If you wanna enable the 50 (skinID) to the player whose account ID is 2, then you just do local skinTable = { --[SKINID] = EXCEPTION [301] = 1, [50] = 2 }
-
Does it output the message? Adding a timer made the whole thing work. local skinTable = { --[SKINID] = EXCEPTION [301] = 1 } addEventHandler("onElementModelChange", getRootElement(), function(oldModel) local newModel = getElementModel(source) if skinTable[newModel] then if getElementData(source, "acc.accID") ~= skinTable[newModel] then outputChatBox("That model is prohibited to all users except one.", source) setTimer(setElementModel, 50, 1, source, oldModel) end end end)
-
You don't need to add that useless code, if you don't want to handle some really secure thing on client-side. It works on client-side aswell, it MAY return a value which is not the real value, depending if it's a faked serial on client-side or not.
-
Ahh, ye, right. I forgot that it's a table, and you wrote that indexing without me realizing it. local sX, sY = guiGetScreenSize() local contentList = { {"Skin #1", 1}, {"Skin #2", 2}, {"Skin #3", 3}, {"Skin #4", 4}, {"Skin #5", 5} } local boxW, boxH = 200, 30 local boxX, boxY = (sX-boxW)/2, (sY-boxH*#contentList)/2 local selectedItem = -1 local listOpened = false _getCursorPosition = getCursorPosition function getCursorPosition() local cX, cY = _getCursorPosition() if cX and cY then return cX*sX, cY*sY end return -1, -1 end function inBox(x, y, w, h) local cX, cY = getCursorPosition() return (cX > x and cX < x + w and cY > y and cY < y + h) end addEventHandler("onClientRender", getRootElement(), function() dxDrawRectangle(boxX, boxY, boxW, boxH, tocolor(0, 0, 0, 170)) dxDrawText(selectedItem > 0 and contentList[selectedItem][1] or "Select a skin", boxX+20, boxY, boxX+20, boxY+boxH, tocolor(255, 255, 255, 255), 1, "default-bold", "left", "center") if listOpened then for i, k in ipairs(contentList) do dxDrawRectangle(boxX, boxY+i*boxH, boxW, boxH, inBox(boxX, boxY+i*boxH, boxW, boxH) and tocolor(255, 0, 0, 170) or tocolor(0, 0, 0, 170)) dxDrawText(k[1], boxX+20, boxY+i*boxH, boxX+20, boxY+(i+1)*boxH, tocolor(255, 255, 255, 255), 1, "default-bold", "left", "center") end end end) addEventHandler("onClientClick", getRootElement(), function(cButton, cState) if cButton == "left" and cState == "down" then if inBox(boxX, boxY, boxW, boxH) then -- The main one listOpened = not listOpened return elseif listOpened then for i, k in ipairs(contentList) do if inBox(boxX, boxY+i*boxH, boxW, boxH) then selectedItem = i listOpened = false return end end end end end) showCursor(true) Final code, tested and working.
-
Right, I :Oed up. addEventHandler("onClientClick", getRootElement(), function(cButton, cState) if cButton == "left" and cState == "down" then if inBox(boxX, boxY, boxW, boxH) then -- The main one listOpened = not listOpened return elseif listOpened then for i, k in ipairs(contentList) do if inBox(boxX, boxY+i*boxH, boxW, boxH) then selectedItem = i listOpened = false return end end end end end)
-
Yes, it does ASSUME, you can still use it on client-side as far as I know.
-
I mean, it's kinda bad coding. Using variables will save you a lot of time. local sX, sY = guiGetScreenSize() local contentList = { {"Skin #1", 1}, {"Skin #2", 2}, {"Skin #3", 3}, {"Skin #4", 4}, {"Skin #5", 5} } local boxW, boxH = 200, 30 local boxX, boxY = (sX-boxW)/2, (sY-boxH*#contentList)/2 local selectedItem = -1 local listOpened = false _getCursorPosition = getCursorPosition function getCursorPosition() local cX, cY = _getCursorPosition() if cX and cY then return cX*sX, cY*sY end return -1, -1 end function inBox(x, y, w, h) local cX, cY = getCursorPosition() return (cX > x and cX < x + w and cY > y and cY < y + h) end addEventHandler("onClientRender", getRootElement(), function() dxDrawRectangle(boxX, boxY, boxW, boxH) dxDrawText(selectedItem > 0 and contentList[selectedItem] or "Select a skin", boxX+20, boxY, boxX+20, boxY+boxH, tocolor(255, 255, 255, 255), 1, "default-bold", "left", "center") if listOpened then for i, k in ipairs(contentList) do dxDrawRectangle(boxX, boxY+i*boxH, boxW, boxH, inBox(boxX, boxY+i*boxH, boxW, boxH) and tocolor(255, 0, 0, 170) or tocolor(0, 0, 0, 170) dxDrawText(k, boxX+20, boxY+i*boxH, boxX+20, boxY+(i+1)*boxH, tocolor(255, 255, 255, 255), 1, "default-bold", "left", "center") end end end) addEventHandler("onClientClick", getRootElement(), function() if inBox(boxX, boxY, boxW, boxH) then -- The main one listOpened = not listOpened return elseif listOpened then for i, k in ipairs(contentList) do if inBox(boxX, boxY+i*boxH, boxW, boxH) then selectedItem = i listOpened = false return end end end end) showCursor(true) Try this, it's not tested tho.
-
function msg() local x = getPlayerSerial(getLocalPlayer()) if x == "633DB08BE0185007B57225507C51C3A2" then print("works") print(x) else print("don't works") end end addEventHandler("onClientResourceStart", root, msg) You should read tutorials about programming before trying it out. The getPlayerSerial function returns a string, so you have to compare it with a string. Print is a function, calling functions are done by using parenthesis.
-
Using tables, dxDrawRectangle, dxDrawText and some math.
-
local sX, sY = guiGetScreenSize() local mapW, mapH = 500, 500 local mapX, mapY = (sX-mapW)/2, (sY-mapH)/2 local pixelW = mapW/6000 local pixelH = mapH/6000 local testX, testY = 0, 0 function calculateScreen(inX, inY) return (inX+3000)*pixelW, math.abs((inY-3000))*pixelH end wX, wY = calculateScreen(testX, testY) outputChatBox(wX .. " " .. wY) Try this.
-
Ahh, lol. I misunderstood the post. For more understanding I'd create a new variable which would indicate how many pixels one unit in GTA is. And then just use that to calculate everything.
-
Try to understand my other post.
-
So you have onResourceStart events. Use resourceRoot instead of root.
-
"root" and getRootElement are the same. It's a predefined variable in MTA. What do you mean it starts this one too?
-
I mean, I dont think you want to return anything. function detectClicks() for i, pos in pairs(t) do if isMouseInPosition(pos[2], pos[3], pos[4], pos[5]) then outputChatBox(pos[1]) return end end end addEventHandler("onClientClick", root, detectClicks) But yours should work too.
-
Use return after the outputChatBox, the reason why, is because if you think about it. You found the one text you clicked on, and there won't be anymore, so if you stop the cycle there, you'll save some performance and a micro amount of time.
-
I suppose you have different y position for each text. Try to imagine what your script does. If you don't understand this, just reply.