Jump to content

spaghetti1337

Members
  • Posts

    17
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

spaghetti1337's Achievements

Square

Square (6/54)

2

Reputation

  1. I re-created the resource and now works fine but I still don't know what was the problem... but at least it works now, lol - but thanks your replies and time again
  2. 1, no errors 2, <script src="server.lua" type="server" cache="false"></script>
  3. I'm trying to trigger server event: ---server side --- function removePlayerVehicle(player, vehicle) local playerID if isElement(player) then playerID = getElementData(player, "acc:id") elseif tonumber(player) then playerID = tonumber(player) end local vehicleID if isElement(vehicle) then vehicleID = getElementData(vehicle, "veh:id") elseif tonumber(vehicle) then vehicleID = tonumber(vehicle) end if playerID >= 1 then if ownerCache[playerID] then local data = ownerCache[playerID] for k,v in pairs(data) do if v == vehicleID then table.remove(ownerCache[playerID], k) return true end end end end return false end addEvent("removePlayerVehicle", true) addEventHandler("removePlayerVehicle", root, removePlayerVehicle) --- client side --- triggerServerEvent("removePlayerVehicle", localPlayer, vehicle) Error: Client (player) triggered serverside event removePlayerVehicle, but event is not added serverside Also I tried to replace triggerServerEvent with exports: exports['vehicle']:removePlayerVehicle(localPlayer, vehicle) --- meta.xml --- <export function="removePlayerVehicle" type="shared"></export> Error: call: failed to call 'vehicle:removePlayerVehicle' [string "?"]
  4. No, I have a function which named dxDrawRectangleBox and draws a custom box. Well, I stored the positions with setElementData I know that is not the best way and I don't know it will cause some lags for the players or no because it's update the elementdata everytime when he is inside the distance and looking around, currently works fine and doesn't laggy
  5. Storing the variables to global is okay? Like this: vehscreenX = screenX - x/2 vehscreenY = screenY - y / 2 vehx = x vehy = y And then call these global variables inside the isMouseInPosition() ?
  6. I want to get the dxDrawRectangleBox's position from Panel function inside the onClick function, how can I do that? function Panel() local cameraX, cameraY, cameraZ = getCameraMatrix(); for element, value in pairs(renderCache) do local distance = value["distance"] if distance <= maxDistance then local boneX, boneY, boneZ = getElementPosition(element); local size = 1 - (distance / maxDistance); local screenX, screenY = getScreenFromWorldPosition(boneX, boneY, boneZ + (1.1)); if screenX and screenY then local alpha = interpolateBetween(0,0,0,255, 0, 0, size, "Linear") local text = "Text" local length = dxGetTextWidth(text, size, font) + 15 * size local x = length local y = 25 * size; dxDrawRectangleBox(screenX - x/2, screenY - y / 2, x, y, tocolor(20,20,20,alpha * 0.7)); --- I want to put these positions inside the isMouseInPosition function dxDrawText(text, screenX, screenY, screenX, screenY, tocolor(255,255,255,alpha), size, font, "center", "center"); end end end end function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function onClick(button, state) if (button == "left") and (state == "up") then if isMouseInPosition() then --- I want to put the position here which is in the "Panel" function outputChatBox ("click") end end end addEventHandler( "onClientClick", root, onClick )
  7. Fixed it by adding tostring(getElementData(value, "veh >> id")) weird thing that the debugscript didn't show that before, just after a lot of try...
  8. Why I can't add items from "myVehicles" table? If I do outputChatBox then works like a charm, but the gridlist shows nothing. myVehicles = {} for key, value in ipairs(getElementsByType("vehicle")) do if getElementData(value, "veh >> owner") == getElementData(localPlayer, "acc >> id") then table.insert(myVehicles, value) end end for key, value in ipairs(myVehicles) do outputChatBox(getElementData(value, "veh >> id")) --- I have 6 vehicles and displays all of them in the chat gridlist:AddItem(1, getElementData(value, "veh >> id")) --- shows nothing in the gridlist I also tried with tonumber(getElementData(value, "veh >> id")) end if I just change the gridlist:AddItem(1, getElementData(value, "veh >> id")) to gridlist:AddItem(1, "test") then displays 6 "test" in the gridlist so the table works fine but can't get the veh id inside the gridlist
  9. Okay, I chosen this one https://github.com/t3wz/dxGridlists , this is works. I can scroll inside the gridlist but doesn't have a scrollbar can you take a look inside that code and help me out please? and I want to display the items like every second item color is light gray and other ones is a bit darker you can see what I mean below:
  10. Okay I think this is hard for me with my current lua "skill" so I decided to use an external dxlib, I'll try DGS but then I can't combine the default gui with this dxlib? function showDashBoard () if showdashboard == true then dxDrawRectangle(screenW * 0.2130, screenH * 0.1676, screenW * 0.5745, screenH * 0.6648, tocolor(47, 45, 47, 255), false) loadstring(exports.dgs:dgsImportFunction())() local gridlist = dgsCreateGridList(screenW * 0.2443, screenH * 0.2241, screenW * 0.1313, screenH * 0.2148,false) dgsGridListAddColumn(gridlist,"test1",0.4) dgsGridListAddColumn(gridlist,"test2",0.4) for i=1,20 do local row = dgsGridListAddRow(gridlist) dgsGridListSetItemText(gridlist,row,1,i) dgsGridListSetItemText(gridlist,row,2,i-1) end end end addEventHandler ( "onClientRender", root, showDashBoard ) Because if I combine them in this way I can't scroll the gridlist and so laggy... (and the gridlist doesn't disappear when I close the dashboard)
  11. Hello, I did some research and if I'm get it right then I can "reproduce" the gridlist's scrollbar (I just needed the gridlist because of the scrollbar) So basically, if I draw a 200x200 rectangle for example with DxDrawRectangle and add text from a table for example with GuiSetText inside the rectangle and I determine the mouse x,y position when scroll_up, scroll_down then I can create my own "gridlist" with scrollbar? or it's a "bit" harder? I found NeXuS's code which is a dx scroll... but erm I want to add a table in the DxDrawRectangle which you can scroll down and up until the last "item" in the table. Also I know that I need the onClientKey function for the move up and down like this: addEventHandler( "onClientKey", root, function (button, press) if button == "mouse_wheel_up" then --- scroll up elseif button == "mouse_wheel_down" then --- scroll down end end )
  12. I want to delete the "pier3_sfe", "pier1_sfe" model which are located in SF (Esplanade East). You can see here addEventHandler ("onResourceStart",resourceRoot, function() removeWorldModel(9951, 10000, -1535.4219, 1168.6641, 18.20313) -- pier3_sfe model removeWorldModel(9965, 10000, -1535.4219, 1168.6641, 18.20313) -- pier3_sfe lod removeWorldModel(9949, 10000, -1535.4219, 1054.5234, 18.20313) -- pier1_sfe model removeWorldModel(9964, 10000, -1535.4219, 1054.5234, 18.20313) -- pier1_sfe lod end) This is delete both of them, but then if I go "behind" the two buildings everything will be invisible/bug which is in front of the removed buildings, you can see the picture below. How can I fix this?
  13. Oh, well it's difficult to understand at first reading but I'll try to get the best out of myself. Thanks
  14. I don't want to edit someone's resource, I want to do it for myself. So I must use some layout engine for this? I know how to make this gui with the simple gui which is in the MTA. I just have problem with the gridlist/scrollbar/dropdown. The other parts are fine
  15. I know there is so many topic with titles like "how to create custom gui" etc but never found how these guys are doing these good looking dashboard for example. So I know that I can create with built-in functions like guiCreateWindow etc. Or dxgui/thisdp's gui but then I can't make look like this (below the picture) I want to know more about how I can create gridlist, dropdown (not with the in-built functions) and if I hover to the button then change to other image (or just add a little more light)
×
×
  • Create New...