Bilal135 Posted April 20, 2015 Share Posted April 20, 2015 My script ain't working at all, the GUI opens but the dx doesn't appear, and nothing happens when I write amount of money into the editbox and press the desired button. Please fix my code, can't figure out how to fix it. client: GUIEditor = { button = {}, window = {}, edit = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(315, 125, 763, 472, "Stock Market", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(10, 28, 202, 32, "LCN Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(11, 66, 134, 21, "Company Names", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.label[3] = guiCreateLabel(155, 66, 109, 17, "Information", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[3], "default-bold-small") GUIEditor.label[4] = guiCreateLabel(11, 87, 57, 20, "Binco", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(157, 88, 543, 21, "Sells various clothes to the people of San Andreas. Progress Rate: 10.11, Loss Rate: 5.43", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(9, 400, 93, 40, "Invest For Binco", false, GUIEditor.window[1]) GUIEditor.edit[1] = guiCreateEdit(19, 444, 73, 18, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(10, 109, 94, 19, "AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.label[7] = guiCreateLabel(156, 109, 544, 19, "Life Insurance company. Progress Rate 60.2, Loss Rate: 40.7", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(112, 400, 106, 40, "Invest For AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(126, 444, 82, 18, "", false, GUIEditor.window[1]) GUIEditor.label[8] = guiCreateLabel(10, 130, 96, 15, "AirEmu", false, GUIEditor.window[1]) GUIEditor.label[9] = guiCreateLabel(155, 130, 545, 18, "Makes cargo and passenger planes. Progress Rate: 11.7, Loss Rate: 5.64", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(228, 400, 110, 40, "Invest For AirEmu", false, GUIEditor.window[1]) GUIEditor.edit[3] = guiCreateEdit(244, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[10] = guiCreateLabel(11, 153, 93, 15, "FlyUS", false, GUIEditor.window[1]) GUIEditor.label[11] = guiCreateLabel(154, 153, 546, 15, "Makes cargo and passenger planes. Progress Rate: 17.2, Loss Rate: 10.29", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(348, 400, 104, 40, "Invest For FlyUS", false, GUIEditor.window[1]) GUIEditor.edit[4] = guiCreateEdit(358, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[12] = guiCreateLabel(10, 175, 112, 15, "Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.label[13] = guiCreateLabel(154, 175, 547, 18, "Tuning shops all over Los Santos. Progress Rate: 2.76, Loss Rate: 8.90", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(461, 402, 103, 38, "Invest For Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.edit[5] = guiCreateEdit(471, 444, 83, 19, "", false, GUIEditor.window[1]) GUIEditor.label[14] = guiCreateLabel(573, 406, 176, 28, "Liberty City National", false, GUIEditor.window[1]) local font0_ChineseText = guiCreateFont(":guieditor/fonts/ChineseText.ttf", 16) guiSetFont(GUIEditor.label[14], font0_ChineseText) guiLabelSetColor(GUIEditor.label[14], 0, 159, 3) GUIEditor.label[15] = guiCreateLabel(621, 430, 79, 29, "Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[15], font0_ChineseText) guiLabelSetColor(GUIEditor.label[15], 0, 159, 3) GUIEditor.button[6] = guiCreateButton(710, 26,38, 28, "X", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) end ) function closeGui() if (source == GUIEditor.button[6]) then guiSetVisible(GUIEditor.window[1], false) end if (source == GUIEditor.button[1]) then local a = guiGetText(GUIEditor.edit[1]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, tonumber(a)) else return outputChatBox("You must invest more than $100 or you don't have enough money!", 255, 0, 0) end end if (source == GUIEditor.button[2]) then local b = guiGetText(GUIEditor.edit[2]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, b) end end if (source == GUIEditor.button[3]) then local c = guiGetText(GUIEditor.edit[3]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, c) end end if (source == GUIEditor.button[4]) then local d = guiGetText(GUIEditor.edit[4]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, d) end end if (source == GUIEditor.button[5]) then local e = guiGetText(GUIEditor.edit[5]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, e) end end end addEventHandler("onClientGUIClick", getRootElement(), closeGui) addCommandHandler("stockexchange", function() dxDrawRectangle(323, 186, 746, 333, tocolor(0, 0, 0, 255), false) dxDrawLine(467, 188, 467, 517, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 208, 1067, 208, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(323, 230, 1068, 231, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 252, 1066, 252, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 274, 1067, 274, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 296, 1066, 297, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 317, 1064, 317, tocolor(255, 255, 255, 255), 1, false) guiSetVisible(GUIEditor.window[1], true) showCursor(true) end ) Link to comment
Dimos7 Posted April 20, 2015 Share Posted April 20, 2015 GUIEditor = { button = {}, window = {}, edit = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(315, 125, 763, 472, "Stock Market", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(10, 28, 202, 32, "LCN Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(11, 66, 134, 21, "Company Names", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.label[3] = guiCreateLabel(155, 66, 109, 17, "Information", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[3], "default-bold-small") GUIEditor.label[4] = guiCreateLabel(11, 87, 57, 20, "Binco", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(157, 88, 543, 21, "Sells various clothes to the people of San Andreas. Progress Rate: 10.11, Loss Rate: 5.43", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(9, 400, 93, 40, "Invest For Binco", false, GUIEditor.window[1]) GUIEditor.edit[1] = guiCreateEdit(19, 444, 73, 18, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(10, 109, 94, 19, "AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.label[7] = guiCreateLabel(156, 109, 544, 19, "Life Insurance company. Progress Rate 60.2, Loss Rate: 40.7", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(112, 400, 106, 40, "Invest For AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(126, 444, 82, 18, "", false, GUIEditor.window[1]) GUIEditor.label[8] = guiCreateLabel(10, 130, 96, 15, "AirEmu", false, GUIEditor.window[1]) GUIEditor.label[9] = guiCreateLabel(155, 130, 545, 18, "Makes cargo and passenger planes. Progress Rate: 11.7, Loss Rate: 5.64", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(228, 400, 110, 40, "Invest For AirEmu", false, GUIEditor.window[1]) GUIEditor.edit[3] = guiCreateEdit(244, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[10] = guiCreateLabel(11, 153, 93, 15, "FlyUS", false, GUIEditor.window[1]) GUIEditor.label[11] = guiCreateLabel(154, 153, 546, 15, "Makes cargo and passenger planes. Progress Rate: 17.2, Loss Rate: 10.29", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(348, 400, 104, 40, "Invest For FlyUS", false, GUIEditor.window[1]) GUIEditor.edit[4] = guiCreateEdit(358, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[12] = guiCreateLabel(10, 175, 112, 15, "Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.label[13] = guiCreateLabel(154, 175, 547, 18, "Tuning shops all over Los Santos. Progress Rate: 2.76, Loss Rate: 8.90", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(461, 402, 103, 38, "Invest For Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.edit[5] = guiCreateEdit(471, 444, 83, 19, "", false, GUIEditor.window[1]) GUIEditor.label[14] = guiCreateLabel(573, 406, 176, 28, "Liberty City National", false, GUIEditor.window[1]) local font0_ChineseText = guiCreateFont(":guieditor/fonts/ChineseText.ttf", 16) guiSetFont(GUIEditor.label[14], font0_ChineseText) guiLabelSetColor(GUIEditor.label[14], 0, 159, 3) GUIEditor.label[15] = guiCreateLabel(621, 430, 79, 29, "Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[15], font0_ChineseText) guiLabelSetColor(GUIEditor.label[15], 0, 159, 3) GUIEditor.button[6] = guiCreateButton(710, 26,38, 28, "X", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) end ) function closeGui() if (source == GUIEditor.button[6]) then guiSetVisible(GUIEditor.window[1], false) end if (source == GUIEditor.button[1]) then local a = guiGetText(GUIEditor.edit[1]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, tonumber(a)) else return outputChatBox("You must invest more than $100 or you don't have enough money!", 255, 0, 0) end end if (source == GUIEditor.button[2]) then local b = guiGetText(GUIEditor.edit[2]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, b) end end if (source == GUIEditor.button[3]) then local c = guiGetText(GUIEditor.edit[3]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, c) end end if (source == GUIEditor.button[4]) then local d = guiGetText(GUIEditor.edit[4]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, d) end end if (source == GUIEditor.button[5]) then local e = guiGetText(GUIEditor.edit[5]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, e) end end end addEventHandler("onClientGUIClick", getRootElement(), closeGui) function Draw() dxDrawRectangle(323, 186, 746, 333, tocolor(0, 0, 0, 255), false) dxDrawLine(467, 188, 467, 517, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 208, 1067, 208, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(323, 230, 1068, 231, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 252, 1066, 252, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 274, 1067, 274, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 296, 1066, 297, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 317, 1064, 317, tocolor(255, 255, 255, 255), 1, false) guiSetVisible(GUIEditor.window[1], true) showCursor(true) end addCommandHandler("stockexchange", Draw) addEventHandler("onClientRender", root, Draw) Link to comment
Bilal135 Posted April 20, 2015 Author Share Posted April 20, 2015 GUIEditor = { button = {}, window = {}, edit = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(315, 125, 763, 472, "Stock Market", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(10, 28, 202, 32, "LCN Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(11, 66, 134, 21, "Company Names", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.label[3] = guiCreateLabel(155, 66, 109, 17, "Information", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[3], "default-bold-small") GUIEditor.label[4] = guiCreateLabel(11, 87, 57, 20, "Binco", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(157, 88, 543, 21, "Sells various clothes to the people of San Andreas. Progress Rate: 10.11, Loss Rate: 5.43", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(9, 400, 93, 40, "Invest For Binco", false, GUIEditor.window[1]) GUIEditor.edit[1] = guiCreateEdit(19, 444, 73, 18, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(10, 109, 94, 19, "AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.label[7] = guiCreateLabel(156, 109, 544, 19, "Life Insurance company. Progress Rate 60.2, Loss Rate: 40.7", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(112, 400, 106, 40, "Invest For AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(126, 444, 82, 18, "", false, GUIEditor.window[1]) GUIEditor.label[8] = guiCreateLabel(10, 130, 96, 15, "AirEmu", false, GUIEditor.window[1]) GUIEditor.label[9] = guiCreateLabel(155, 130, 545, 18, "Makes cargo and passenger planes. Progress Rate: 11.7, Loss Rate: 5.64", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(228, 400, 110, 40, "Invest For AirEmu", false, GUIEditor.window[1]) GUIEditor.edit[3] = guiCreateEdit(244, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[10] = guiCreateLabel(11, 153, 93, 15, "FlyUS", false, GUIEditor.window[1]) GUIEditor.label[11] = guiCreateLabel(154, 153, 546, 15, "Makes cargo and passenger planes. Progress Rate: 17.2, Loss Rate: 10.29", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(348, 400, 104, 40, "Invest For FlyUS", false, GUIEditor.window[1]) GUIEditor.edit[4] = guiCreateEdit(358, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[12] = guiCreateLabel(10, 175, 112, 15, "Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.label[13] = guiCreateLabel(154, 175, 547, 18, "Tuning shops all over Los Santos. Progress Rate: 2.76, Loss Rate: 8.90", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(461, 402, 103, 38, "Invest For Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.edit[5] = guiCreateEdit(471, 444, 83, 19, "", false, GUIEditor.window[1]) GUIEditor.label[14] = guiCreateLabel(573, 406, 176, 28, "Liberty City National", false, GUIEditor.window[1]) local font0_ChineseText = guiCreateFont(":guieditor/fonts/ChineseText.ttf", 16) guiSetFont(GUIEditor.label[14], font0_ChineseText) guiLabelSetColor(GUIEditor.label[14], 0, 159, 3) GUIEditor.label[15] = guiCreateLabel(621, 430, 79, 29, "Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[15], font0_ChineseText) guiLabelSetColor(GUIEditor.label[15], 0, 159, 3) GUIEditor.button[6] = guiCreateButton(710, 26,38, 28, "X", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) end ) function closeGui() if (source == GUIEditor.button[6]) then guiSetVisible(GUIEditor.window[1], false) end if (source == GUIEditor.button[1]) then local a = guiGetText(GUIEditor.edit[1]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, tonumber(a)) else return outputChatBox("You must invest more than $100 or you don't have enough money!", 255, 0, 0) end end if (source == GUIEditor.button[2]) then local b = guiGetText(GUIEditor.edit[2]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, b) end end if (source == GUIEditor.button[3]) then local c = guiGetText(GUIEditor.edit[3]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, c) end end if (source == GUIEditor.button[4]) then local d = guiGetText(GUIEditor.edit[4]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, d) end end if (source == GUIEditor.button[5]) then local e = guiGetText(GUIEditor.edit[5]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(localPlayer, e) end end end addEventHandler("onClientGUIClick", getRootElement(), closeGui) function Draw() dxDrawRectangle(323, 186, 746, 333, tocolor(0, 0, 0, 255), false) dxDrawLine(467, 188, 467, 517, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 208, 1067, 208, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(323, 230, 1068, 231, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 252, 1066, 252, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 274, 1067, 274, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 296, 1066, 297, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 317, 1064, 317, tocolor(255, 255, 255, 255), 1, false) guiSetVisible(GUIEditor.window[1], true) showCursor(true) end addCommandHandler("stockexchange", Draw) addEventHandler("onClientRender", root, Draw) GUI opens on resource start, and still it doesn't work even if I have the money, it doesn't show the message then and doesn't take the money. Link to comment
HunT Posted April 20, 2015 Share Posted April 20, 2015 Some problems inside. 1) What about the position window? you have not use the guiGetScreenSize() 2) https://wiki.multitheftauto.com/wiki/TakePlayerMoney Note: Using this function client side (not recommended) will not change a players money server side. 3) About Dx u need : https://wiki.multitheftauto.com/wiki/OnClientRender https://wiki.multitheftauto.com/wiki/RemoveEventHandler Link to comment
Bilal135 Posted April 20, 2015 Author Share Posted April 20, 2015 Some problems inside.1) What about the position window? you have not use the guiGetScreenSize() 2) https://wiki.multitheftauto.com/wiki/TakePlayerMoney Note: Using this function client side (not recommended) will not change a players money server side. 3) About Dx u need : https://wiki.multitheftauto.com/wiki/OnClientRender https://wiki.multitheftauto.com/wiki/RemoveEventHandler Can you do it for me, I wanna see how it has to be done. Link to comment
Dimos7 Posted April 20, 2015 Share Posted April 20, 2015 (edited) GUIEditor = { button = {}, window = {}, edit = {}, label = {} } function openGUI() GUIEditor.window[1] = guiCreateWindow(315, 125, 763, 472, "Stock Market", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(10, 28, 202, 32, "LCN Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(11, 66, 134, 21, "Company Names", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.label[3] = guiCreateLabel(155, 66, 109, 17, "Information", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[3], "default-bold-small") GUIEditor.label[4] = guiCreateLabel(11, 87, 57, 20, "Binco", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(157, 88, 543, 21, "Sells various clothes to the people of San Andreas. Progress Rate: 10.11, Loss Rate: 5.43", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(9, 400, 93, 40, "Invest For Binco", false, GUIEditor.window[1]) GUIEditor.edit[1] = guiCreateEdit(19, 444, 73, 18, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(10, 109, 94, 19, "AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.label[7] = guiCreateLabel(156, 109, 544, 19, "Life Insurance company. Progress Rate 60.2, Loss Rate: 40.7", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(112, 400, 106, 40, "Invest For AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(126, 444, 82, 18, "", false, GUIEditor.window[1]) GUIEditor.label[8] = guiCreateLabel(10, 130, 96, 15, "AirEmu", false, GUIEditor.window[1]) GUIEditor.label[9] = guiCreateLabel(155, 130, 545, 18, "Makes cargo and passenger planes. Progress Rate: 11.7, Loss Rate: 5.64", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(228, 400, 110, 40, "Invest For AirEmu", false, GUIEditor.window[1]) GUIEditor.edit[3] = guiCreateEdit(244, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[10] = guiCreateLabel(11, 153, 93, 15, "FlyUS", false, GUIEditor.window[1]) GUIEditor.label[11] = guiCreateLabel(154, 153, 546, 15, "Makes cargo and passenger planes. Progress Rate: 17.2, Loss Rate: 10.29", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(348, 400, 104, 40, "Invest For FlyUS", false, GUIEditor.window[1]) GUIEditor.edit[4] = guiCreateEdit(358, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[12] = guiCreateLabel(10, 175, 112, 15, "Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.label[13] = guiCreateLabel(154, 175, 547, 18, "Tuning shops all over Los Santos. Progress Rate: 2.76, Loss Rate: 8.90", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(461, 402, 103, 38, "Invest For Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.edit[5] = guiCreateEdit(471, 444, 83, 19, "", false, GUIEditor.window[1]) GUIEditor.label[14] = guiCreateLabel(573, 406, 176, 28, "Liberty City National", false, GUIEditor.window[1]) local font0_ChineseText = guiCreateFont(":guieditor/fonts/ChineseText.ttf", 16) guiSetFont(GUIEditor.label[14], font0_ChineseText) guiLabelSetColor(GUIEditor.label[14], 0, 159, 3) GUIEditor.label[15] = guiCreateLabel(621, 430, 79, 29, "Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[15], font0_ChineseText) guiLabelSetColor(GUIEditor.label[15], 0, 159, 3) GUIEditor.button[6] = guiCreateButton(710, 26,38, 28, "X", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) end function closeGui() if (source == GUIEditor.button[6]) then guiSetVisible(GUIEditor.window[1], false) showCursor(false) end if (source == GUIEditor.button[1]) then local a = guiGetText(GUIEditor.edit[1]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(a) else return outputChatBox("You must invest more than $100 or you don't have enough money!", 255, 0, 0) end end if (source == GUIEditor.button[2]) then local b = guiGetText(GUIEditor.edit[2]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(b) end end if (source == GUIEditor.button[3]) then local c = guiGetText(GUIEditor.edit[3]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(c) end end if (source == GUIEditor.button[4]) then local d = guiGetText(GUIEditor.edit[4]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(d) end end if (source == GUIEditor.button[5]) then local e = guiGetText(GUIEditor.edit[5]) local money = getPlayerMoney(localPlayer) if (money > 99) then takePlayerMoney(e) end end end addEventHandler("onClientGUIClick", getRootElement(), closeGui) function Draw() openGUI() dxDrawRectangle(323, 186, 746, 333, tocolor(0, 0, 0, 255), false) dxDrawLine(467, 188, 467, 517, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 208, 1067, 208, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(323, 230, 1068, 231, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 252, 1066, 252, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 274, 1067, 274, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 296, 1066, 297, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 317, 1064, 317, tocolor(255, 255, 255, 255), 1, false) guiSetVisible(GUIEditor.window[1], true) showCursor(true) end addCommandHandler("stockexchange", Draw) addEventHandler("onClientRender", root, Draw) Edited April 20, 2015 by Guest Link to comment
HunT Posted April 20, 2015 Share Posted April 20, 2015 Dimos7 please can you stop reply in scripting section if u can't help the members? ------------------------------------------------------------------------------------------------ Client : GUIEditor = { button = {}, window = {}, edit = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(315, 125, 763, 472, "Stock Market", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(10, 28, 202, 32, "LCN Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(11, 66, 134, 21, "Company Names", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.label[3] = guiCreateLabel(155, 66, 109, 17, "Information", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[3], "default-bold-small") GUIEditor.label[4] = guiCreateLabel(11, 87, 57, 20, "Binco", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(157, 88, 543, 21, "Sells various clothes to the people of San Andreas. Progress Rate: 10.11, Loss Rate: 5.43", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(9, 400, 93, 40, "Invest For Binco", false, GUIEditor.window[1]) GUIEditor.edit[1] = guiCreateEdit(19, 444, 73, 18, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(10, 109, 94, 19, "AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.label[7] = guiCreateLabel(156, 109, 544, 19, "Life Insurance company. Progress Rate 60.2, Loss Rate: 40.7", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(112, 400, 106, 40, "Invest For AuguryInsurance", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(126, 444, 82, 18, "", false, GUIEditor.window[1]) GUIEditor.label[8] = guiCreateLabel(10, 130, 96, 15, "AirEmu", false, GUIEditor.window[1]) GUIEditor.label[9] = guiCreateLabel(155, 130, 545, 18, "Makes cargo and passenger planes. Progress Rate: 11.7, Loss Rate: 5.64", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(228, 400, 110, 40, "Invest For AirEmu", false, GUIEditor.window[1]) GUIEditor.edit[3] = guiCreateEdit(244, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[10] = guiCreateLabel(11, 153, 93, 15, "FlyUS", false, GUIEditor.window[1]) GUIEditor.label[11] = guiCreateLabel(154, 153, 546, 15, "Makes cargo and passenger planes. Progress Rate: 17.2, Loss Rate: 10.29", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(348, 400, 104, 40, "Invest For FlyUS", false, GUIEditor.window[1]) GUIEditor.edit[4] = guiCreateEdit(358, 444, 84, 19, "", false, GUIEditor.window[1]) GUIEditor.label[12] = guiCreateLabel(10, 175, 112, 15, "Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.label[13] = guiCreateLabel(154, 175, 547, 18, "Tuning shops all over Los Santos. Progress Rate: 2.76, Loss Rate: 8.90", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(461, 402, 103, 38, "Invest For Los Santos Customs", false, GUIEditor.window[1]) GUIEditor.edit[5] = guiCreateEdit(471, 444, 83, 19, "", false, GUIEditor.window[1]) GUIEditor.label[14] = guiCreateLabel(573, 406, 176, 28, "Liberty City National", false, GUIEditor.window[1]) local font0_ChineseText = guiCreateFont(":guieditor/fonts/ChineseText.ttf", 16) guiSetFont(GUIEditor.label[14], font0_ChineseText) guiLabelSetColor(GUIEditor.label[14], 0, 159, 3) GUIEditor.label[15] = guiCreateLabel(621, 430, 79, 29, "Exchange", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[15], font0_ChineseText) guiLabelSetColor(GUIEditor.label[15], 0, 159, 3) GUIEditor.button[6] = guiCreateButton(710, 26,38, 28, "X", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) end ) function closeGui() if (source == GUIEditor.button[6]) then guiSetVisible(GUIEditor.window[1], false) removeEventHandler( "onClientRender", root, dxRectangle ) -- Hide dx elements end if (source == GUIEditor.button[1]) then local ammount = guiGetText(GUIEditor.edit[1]) local money = getPlayerMoney(localPlayer) if (money > 99) then triggerServerEvent ( "takeMoneyPlayer", getLocalPlayer(),ammount) else return outputChatBox("You must invest more than $100 or you don't have enough money!", 255, 0, 0) end end if (source == GUIEditor.button[2]) then local ammount = guiGetText(GUIEditor.edit[2]) local money = getPlayerMoney(localPlayer) if (money > 99) then triggerServerEvent ( "takeMoneyPlayer", getLocalPlayer(),ammount) end end if (source == GUIEditor.button[3]) then local cammount = guiGetText(GUIEditor.edit[3]) local money = getPlayerMoney(localPlayer) if (money > 99) then triggerServerEvent ( "takeMoneyPlayer", getLocalPlayer(),ammount) end end if (source == GUIEditor.button[4]) then local ammount = guiGetText(GUIEditor.edit[4]) local money = getPlayerMoney(localPlayer) if (money > 99) then triggerServerEvent ( "takeMoneyPlayer", getLocalPlayer(),ammount) end end if (source == GUIEditor.button[5]) then local ammount = guiGetText(GUIEditor.edit[5]) local money = getPlayerMoney(localPlayer) if (money > 99) then triggerServerEvent ( "takeMoneyPlayer", getLocalPlayer(),ammount) end end end addEventHandler("onClientGUIClick", getRootElement(), closeGui) function dxRectangle() dxDrawRectangle(323, 186, 746, 333, tocolor(0, 0, 0, 255), false) dxDrawLine(467, 188, 467, 517, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 208, 1067, 208, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(323, 230, 1068, 231, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 252, 1066, 252, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 274, 1067, 274, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 296, 1066, 297, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(321, 317, 1064, 317, tocolor(255, 255, 255, 255), 1, false) end addCommandHandler("stockexchange", function () if ( guiGetVisible ( GUIEditor.window[1]) == false )then addEventHandler("onClientRender", root, dxRectangle) -- Show dx elements guiSetVisible(GUIEditor.window[1], true) showCursor(true) end end ) Server : addEvent("takeMoneyPlayer",true) function takeMoneyPlayer (ammount) if not (tonumber(ammount) <= 0) then player = source takePlayerMoney(player, ammount) end end addEventHandler("takeMoneyPlayer", getRootElement(), takeMoneyPlayer) Link to comment
Bilal135 Posted April 21, 2015 Author Share Posted April 21, 2015 I got one more problem. I added this line to client: local investedmoney = guiGetText(GUIEditor.edit[1]) triggerServerEvent ("result", getLocalPlayer(), investedmoney) and this to the server: addEvent("result", true) function investedMoney(investedmoney) if (tonumber(investedmoney) <= 9999) then player = source local profit = givePlayerMoney(player, math.random(1000, 15000)) local loss = takePlayerMoney(player, math.random(1000, 15000)) end if profit then outputChatBox("------", player, 0, 255, 0) outputChatBox("You invested "..investedmoney.." in a company in Libery City Exchange (LCN). The results are below.", player, 0, 255, 0) outputChatBox("Result: Profit ("..profit..")", player, 0, 255, 0) end if loss then outputChatBox("------", player, 255, 0, 0) outputChatBox("You invested "..investedmoney.." in a company in Libery City Exchange (LCN). The results are below.", player, 255, 0, 0) outputChatBox("Result: Profit ("..loss..")", player, 255, 0, 0) end end addEventHandler("result", getRootElement(), investedMoney) Still console gives errors and it doesn't work. server.lua:3: Attempt to compare nil with number. server.lua:12: Attempt to compare number with nil. Also, how can I make that profit and loss happen randomly every five minutes? I know the setTimer but other things. Thanks. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now