thund3rbird23
Members-
Posts
129 -
Joined
-
Last visited
Everything posted by thund3rbird23
-
dxDrawText get the value of the clicked text?
thund3rbird23 replied to thund3rbird23's topic in Scripting
Thank you. Everything works fine now but with the GUI elements... that's a little bit ugly. I just want to know how can I do this without the GUI gridlist? This was my main problem when I opened the thread local weapons = guiGridListGetItemText ( weapgridlist, guiGridListGetSelectedItem ( weapgridlist ), 1 ) -
dxDrawText get the value of the clicked text?
thund3rbird23 replied to thund3rbird23's topic in Scripting
I'm trying to make with guiCreateGridList but I have some problems. 1) I can't select the item on gridlist and can't click to the button 2) Only one item are shown instead of 5 items or more depends on how much weapons the player have 3) My FPS is dropping to 2 if the gridlist are shown I figured out the 1) problem... it just because I display the gridlist with onClientRender event , if I do the same with onResourceStart event then I can select the item, etc... but I want to display only if the openPanel is true function drawPanel() if openPanel == true then local items = getElementData(localPlayer, "weaponmodel") gridlist = guiCreateGridList(screenW - 177 - 10, (screenH - 177) / 2, 177, 177, false) guiGridListAddColumn(gridlist, "Weapons", 0.9) for k, v in ipairs(items) do guiGridListAddRow(gridlist) guiGridListSetItemText(gridlist, 0, 1, v[1], false, false) button = guiCreateButton(0.62, 0.82, 0.32, 0.12, "Sell", true, gridlist) end end end addEventHandler("onClientRender", root, drawPanel ) I'm trying to make with guiCreateGridList but I have some problems. 1) I can't select the item on gridlist and can't click to the button 2) Only one item are shown instead of 5 items or more depends on how much weapons the player have If I debug the items variable then I got table with the items like this: {{"123"},{"231"},{"321"},{"132"},{"213"}} but the gridlist only shows the last (213) item... 3) My FPS is dropping to 2 if the gridlist are shown I figured out the 1) problem... it just because I display the gridlist with onClientRender event , if I do the same with onResourceStart event then I can select the item, etc... but I want to display only if the openPanel is true function drawPanel() if openPanel == true then local items = getElementData(localPlayer, "weaponmodel") gridlist = guiCreateGridList(screenW - 177 - 10, (screenH - 177) / 2, 177, 177, false) guiGridListAddColumn(gridlist, "Weapons", 0.9) for k, v in ipairs(items) do guiGridListAddRow(gridlist) guiGridListSetItemText(gridlist, 0, 1, v[1], false, false) button = guiCreateButton(0.62, 0.82, 0.32, 0.12, "Sell", true, gridlist) end end end addEventHandler("onClientRender", root, drawPanel ) -
dxDrawText get the value of the clicked text?
thund3rbird23 replied to thund3rbird23's topic in Scripting
Oh, I understand but what about if I can't determine what will be the label's value? I want to do this for the previously asked topic which you solved for me. I getting the weaponmodels from mysql then save with setElementData and getting with GetElementData local items = getElementData(localPlayer, "weaponmodel") -- output -- {{123}, {321}, {231}, {312}, {132}} How can I refer to these random values if I click to the button next to any of them without knowing what they will be? -
dxDrawText get the value of the clicked text?
thund3rbird23 replied to thund3rbird23's topic in Scripting
Ummm I can do that if I click on the dxRectangle or on the dxDraw then output something. But I want to output the value from the items table. Assume that I do a button next to each items with dxRectangle (test, test1, test2) and if I click on that button then output the value from the items table. So if I click next to test2 button then output test2 from items table... and so on but I can't determine what will be in the items table because that's will be random numbers, these just examples for more clear understanding... Take a look at this I want to do almost the same but without GuiCreateGridList and guiGridListGetSelectedItem: -
dxDrawText get the value of the clicked text?
thund3rbird23 replied to thund3rbird23's topic in Scripting
@IIYAMA Can you help please if you understand what I want to do? -
Can I get the value of the clicked text somehow with dxDrawText? I mean I have a table with values: "Test 1", "Test 2", "Test 3" and if I click to the "Give" text for ex.: next to "Test 2" text then output "Test 2" in the chatbox and so on... Or I must use GuiGridListGetSelectedItem? I draw the panel, this will add 3 row with the items table and add "Give" buttons next to them. function drawPanel() local items = {{"Test"},{"Test1"},{"Test2"},} for i = currentCell + 1, maxRows + currentCell do local value = items[i] local key = i - currentCell - 1 if value ~= nil then dxDrawRectangle(screenW * 0.7499, screenH * 0.3269+((key)*27), screenW * 0.2380, screenH * 0.0250, tocolor(1, 2, 3, 90), false) dxDrawText(value[1], screenW * 0.759, screenH * 0.3269+(key*54), screenW * 0.2380, screenH * 0.3519, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, false, false, false) dxDrawText("Give", screenW * 0.920, screenH * 0.3269+(key*54), screenW * 0.2380, screenH * 0.3519, tocolor(255, 255, 255 ,255), 1.00, "default-bold", "left", "center", false, false, false, false, false) end end end addEventHandler("onClientRender", root, drawPanel ) This is handle the click on the Give button: addEventHandler("onClientClick", root, function(button, state) if isCursorOnElement(screenW * 0.920, screenH * 0.3269, screenW * 0.2380, screenH * 0.3519) then if button == "left" and state == "down" then outputChatBox("Clicked") end end end) This is working but I want to output which value I clicked on.
-
How to send these server side values to a client side list?
thund3rbird23 replied to thund3rbird23's topic in Scripting
Well , my bad then. Thanks for your help! -
How to send these server side values to a client side list?
thund3rbird23 replied to thund3rbird23's topic in Scripting
local query = dbQuery(con,"SELECT * FROM weapons WHERE owner = ?", owner) local weapons = dbPoll(query,-1) if weapons then for k,v in ipairs(weapons) do newTable[#newTable + 1] = v["model"] setElementData(resourceRoot, "weaponmodel", newTable) end end Output doesn't seems like a table: {{ 123, 321, 231, 312, 132 }} That's what it should look like: {{123}, {321}, {231}, {312}, {132}} -
How to send these server side values to a client side list?
thund3rbird23 replied to thund3rbird23's topic in Scripting
Okay now it's displays more information... but how can I display only the "model" row? I know that I need to change the mysql query to: local query = dbQuery(con,"SELECT model FROM weapons WHERE owner = ?", owner) local weapons = dbPoll(query,-1) if weapons then setElementData(resourceRoot, "weaponmodel", weapons) end But in this way I got a table with model string on the screen: {{ model = 123 }, { model = 231 }, { model = 312 }, { model = 132 }, { model = 321 }} I want to display only the numbers. This is showing only the numbers but only one model not the 5 models what I have. local query = dbQuery(con,"SELECT * FROM weapons WHERE owner = ?", owner) local weapons = dbPoll(query,-1) if weapons then for k,v in ipairs(weapons) do weapmodel = v["model"] setElementData(resourceRoot, "weaponmodel", weapmodel) end end -
How to send these server side values to a client side list?
thund3rbird23 replied to thund3rbird23's topic in Scripting
Thanks, I replaced both to resourceRoot, now I get false in debug. --- set the elementdata in server-side --- setElementData(resourceRoot, "weaponmodel", weapmodel) --- get the elementdata in client-side & debug --- local model = getElementData ( resourceRoot, "weaponmodel" ) outputDebugString(model) EDIT: if I set the element to player in server-side and localPlayer in client-side then I still got only one weaponmodel (in client-side) instead of the 5 weaponmodel which I have in the database. -
How to send these server side values to a client side list?
thund3rbird23 replied to thund3rbird23's topic in Scripting
I did it with setElementData and working but this is showing only the last data from mysql... I want to display every data... for ex.: if you have 5 weapons then show 5 weapons not only the latest one. How can I do that? If I print the "weapmodel" to the chatbox like "outputChatBox(weapmodel)" after the mysql query string in server-side then showing all of my weapons... --- server side --- addEvent("weaponmodels",true) addEventHandler("weaponmodels",getRootElement(),function(player) for _, player in ipairs(getElementsByType("player")) do if getElementData(player, "loggedin") then local owner = getElementData(player, "acc:id") local query = dbQuery(con,"SELECT * FROM weapons WHERE owner = ?", owner) local weapons = dbPoll(query,-1) if weapons then for k,v in ipairs(weapons) do weapmodel = v["model"] setElementData(source, weapmodel, true) end end end end end) --- client side --- local weapon = getElementData(root, "weapmodel") local items = { {weapon}, } function draw() for i = currentCell + 1, maxRows + currentCell do local value = items[i] local key = i - currentCell - 1 if value ~= nil then dxDrawText(value[1], screenW * 0.759, screenH * 0.3269+(key*54), screenW * 0.2380, screenH * 0.3519, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, false, false, false) end end end addEventHandler("onClientRender", root, draw) -
How can I send these values from server-side to a client-sided list? function weaponmodels() for _, player in ipairs(getElementsByType("player")) do if getElementData(player, "loggedin") then local owner = getElementData(player, "acc:id") local query = dbQuery(con,"SELECT * FROM weapons WHERE owner = ?", owner) local weapons = dbPoll(query,-1) if weapons then for k,v in ipairs(weapons) do weapid = v["id"] weapmodel = v["model"] end end end end end I want to send the weapid and weapmodel to a client-sided list of course this is not working : local items = { {weapid,weapmodel, 1}, }
-
I want to make the dxDrawTextOnElement clickable for ex. here is a text "Buy" I want to make if I click on the Buy text then output "Clicked" in the chat. Is it possible to implement? And how can I put another text next to each others? I want to add "Sell" text too next to the "Buy" text This is draws the Buy text above every vehicles. function Draw() local vehs = getElementsByType("vehicle") for k,v in ipairs(vehs) do if getPedOccupiedVehicle( localPlayer ) ~= v then dxDrawTextOnElement (v, "Buy", 0.75, _, _, _, _, _, 2, _, tocolor(102,204,0,255)) end end end addEventHandler ("onClientRender", getRootElement(), Draw)
-
I want to use THIS resource because it's place shaders to all vehicle (non-UV vehicles too) it's working but how can I position the stickers? like I want to place on doors or roof or hood? And how can I place multiple stickers at the same time ex: roof & doors
-
[QUESTION] Where can I find a vertical dropdown menu?
thund3rbird23 replied to thund3rbird23's topic in Scripting
That's a gui not dx and just a dropdown can't use arrows (up,down,right,left) and doesn't have submenu -
[QUESTION] Where can I find a vertical dropdown menu?
thund3rbird23 replied to thund3rbird23's topic in Scripting
Can someone recommend something? -
I understand now. Thank you so much for the help and for the explanation!
-
Yes, this is way more cleaner, thanks. But I don't understand clearly, sorry. So what I need to do with the table? For example I want to set the deagle stat 999 how will the table look? id 1, stat 71 owner 1 and where do I put the skill value (999) ? or I dont interpret well?
-
Where can I find a simple vertical dropdown menu? Or just a tutorial how to do it? I really did research before opened the topic but almost find nothing about dx menus.. all of them are guis not dx or just the find mouse cursor position thing. Or what's the easiest way for a beginner to create a simple back colored (50% opacity) dx menu but I want to use arrows instead of mouse click... I mean up,down,right,left arrows for moving up, down, expand, close the menus and if I click to the for ex.: menu1 then expand the menu1 submenu and if I click to the submenu in the menu1 then output submenu1 in the chatbox (just for testing) I hope you guys understand what I want to do. But HERE is an example
-
Thanks, now works. But I got another problem. I want to seperate each skills so I did rows for all skills ak47,m4,pistol etc.... and I want to set all stat when the character is loaded but it's only set the ak stat. Now the code look this: local owner = charID dbQuery(function(qh) local poll = dbPoll(qh,0) for _,v in ipairs(poll) do local ak47 = v["ak47"] local m4 = v["m4"] local pistol = v["pistol"] local silencedpistol = v["silencedpistol"] local deagle = v["deagle"] local shotgun = v["shotgun"] local sawnoff = v["sawnoff"] local spas = v["spas"] local mp5 = v["mp5"] local sniper = v["sniper"] setPedStat(player, 77, ak47) setPedStat(player, 78, m4) setPedStat(player, 69, pistol) setPedStat(player, 70, silencedpistol) setPedStat(player, 71, deagle) setPedStat(player, 72, shotgun) setPedStat(player, 73, sawnoff) setPedStat(player, 74, spas) setPedStat(player, 76, mp5) setPedStat(player, 79, sniper) end end, {},connection,"SELECT * FROM weaponstats WHERE owner=?",owner)
-
EDIT: ak47 row sorry.
-
https://wiki.multitheftauto.com/wiki/SetPedStat bool setPedStat ( ped thePed, int stat, float value ) value: the new value of the stat. It must be between 0 and 1000. So set the value to 77... I want to get the value from mysql database. It's have a weaponstats table which contains id,owner,ak47 column. And the ak47 table value is 999 and I do query the ak47 row value "local ak47 = v["ak47"]" that's why I did put the ak47 instead of 999.
-
dbQuery(function(qh) local poll = dbPoll(qh,0) for _,v in ipairs(poll) do local ak47 = v["ak47"] end owner = 1 end,{},connection,"SELECT * FROM weaponstats WHERE owner=?",owner) setPedStat(player, 77, ak47) Bad argument @ 'setPedStat' [Expected number at argument 3, got nil]
-
Nothing changed with that extra line I think. But thanks @IIYAMA
-
I will try, thanks! What do you mean? The rotation thing?
