user123 Posted November 30, 2015 Share Posted November 30, 2015 Buenas a todos. Quiero Hacer un panel, donde estén todos los nombres de los players On, y que al seleccionar a un player, me aparezca una ventana para darle money al player. Que funciones debo utilizar para hacer eso. Link to comment
Castillo Posted November 30, 2015 Share Posted November 30, 2015 guiCreateWindow guiCreateGridList guiGridListAddColumn guiGridListAddRow guiGridListSetItemText guiCreateButton guiCreateEdit guiGetText guiGridListGetSelectedItem guiGridListGetItemText getElementsByType getPlayerName getPlayerFromName isElement triggerServerEvent givePlayerMoney Link to comment
user123 Posted December 1, 2015 Author Share Posted December 1, 2015 Ok, Intentare hacerlo. Link to comment
user123 Posted December 1, 2015 Author Share Posted December 1, 2015 Ahora tengo esto y ya no se que hacer, algunas partes lo saque de la wiki, me podrían orientar v: Client: addCommandHandler ( "abrir", function () showCursor ( true ) -- Shows cursor GUIEditor = { window = {} } guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.window[1] = guiCreateWindow(199, 98, 499, 349, "Give Money", false) editbox = guiCreateEdit(176, 94, 274, 45, "", false, GUIEditor.window[1]) Boton = guiCreateButton(176, 178, 182, 68, "Give", false, GUIEditor.window[1]) guiSetProperty(Boton, "NormalTextColour", "FF37FB02") function createPlayerList () -- Crear la gridlist con todos los jugadores playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( playerList, "Player", 0.85 ) if ( column ) then for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end addEventHandler ( "onClientGUIClick", playerList, click ) end end addEventHandler ( "onClientResourceStart", getRootElement(), createPlayerList ) function click () local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) --aqui ya no se que hacer v: triggerEvent ( "onSpecialEvent", getRootElement(), "test" ) end Server: addEvent ( "onSpecialEvent", true ) function givemoney ( thePlayer, amount) givePlayerMoney ( thePlayer, amount ) end addEventHandler ( "onSpecialEvent", getRootElement(), specialEventHandler ) Link to comment
alex17 Posted December 1, 2015 Share Posted December 1, 2015 function click () local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) local player = getPlayerFromName(playerName) local dinero = tonumber(guiGetText(editbox)) triggerEvent ( "onSpecialEvent", getRootElement(), player, dinero ) end --- server --- addEvent ( "onSpecialEvent", true ) function givemoney ( thePlayer, amount) givePlayerMoney ( thePlayer, amount ) takePlayerMoney(client, ammount) end addEventHandler ( "onSpecialEvent", getRootElement(), givemoney ) Link to comment
Tomas Posted December 1, 2015 Share Posted December 1, 2015 (edited) Cliente: GUI = { ventana = {}, edit = {}, gridlist = {}, boton = {}, } local status function crearPanel () if ( not status ) then status = true GUI.ventana[1] = guiCreateWindow(199, 98, 499, 349, "Give Money", false) guiWindowSetMovable(GUI.ventana[1], false) guiWindowSetSizable(GUI.ventana[1], false) GUI.edit[1] = guiCreateEdit(176, 94, 274, 45, "", false, GUI.ventana[1]) GUI.boton[1] = guiCreateButton(176, 178, 182, 68, "Give", false, GUI.ventana[1]) guiSetProperty(GUI.boton[1], "NormalTextColour", "FF37FB02") GUI.gridlist[1] = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true, GUI.ventana[1]) -- Agregar los jugadores for _, player in ipairs ( getElementsByType("player") ) do guiGridListSetItemText( GUI.gridlist[1], guiGridListAddRow(GUI.gridlist[1]), guiGridListAddColumn(GUI.gridlist[1], "Player", 0.85), getPlayerName(player), false, false) end addEventHandler("onClientGUIClick", GUI.boton[1], function () local row, column = guiGridListGetSelectedItem(GUI.gridlist[1]) if ( row ~= -1 and column ~= -1 ) then local player = getPlayerFromName( guiGridListGetItemText( GUI.gridlist[1], row, column ) local amount = guiGetText( GUI.edit[1] ) if ( tonumber(amount) and isElement(player) ) then triggerServerEvent("enviarDinero", player, amount) end end end, false) else status = false for keys in pairs ( GUI ) do for data in ipairs (keys) do destroyElement(data) end end end end addCommandHandler("dinero", crearPanel) Servidor: addEvent("enviarDinero", true) addEventHandler("enviarDinero", root, function ( amount ) givePlayerMoney(source, amount) end ) Edited December 1, 2015 by Guest Link to comment
starksZ Posted December 1, 2015 Share Posted December 1, 2015 Realmente te han hecho todo, Checa aca este video que encontre. Link to comment
user123 Posted December 2, 2015 Author Share Posted December 2, 2015 Cliente: GUI = { ventana = {}, edit = {}, gridlist = {}, boton = {}, } local status function crearPanel () if ( not status ) then status = true GUI.ventana[1] = guiCreateWindow(199, 98, 499, 349, "Give Money", false) guiWindowSetMovable(GUI.ventana[1], false) guiWindowSetSizable(GUI.ventana[1], false) GUI.edit[1] = guiCreateEdit(176, 94, 274, 45, "", false, GUI.ventana[1]) GUI.boton[1] = guiCreateButton(176, 178, 182, 68, "Give", false, GUI.ventana[1]) guiSetProperty(GUI.boton[1], "NormalTextColour", "FF37FB02") GUI.gridlist[1] = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true, GUI.ventana[1]) -- Agregar los jugadores for _, player in ipairs ( getElementsByType("player") ) do guiGridListSetItemText( GUI.gridlist[1], guiGridListAddRow(GUI.gridlist[1]), guiGridListAddColumn(GUI.gridlist[1], "Player", 0.85), getPlayerName(player), false, false) end addEventHandler("onClientGUIClick", GUI.boton[1], function () local row, column = guiGridListGetSelectedItem(GUI.gridlist[1]) if ( row ~= -1 and column ~= -1 ) then local player = getPlayerFromName( guiGridListGetItemText( GUI.gridlist[1], row, column ) local amount = guiGetText( GUI.edit[1] ) if ( tonumber(amount) and isElement(player) ) then triggerServerEvent("enviarDinero", player, amount) end end end, false) else status = false for keys in pairs ( GUI ) do for data in ipairs (keys) do destroyElement(data) end end end end addCommandHandler("dinero", crearPanel) Servidor: addEvent("enviarDinero", true) addEventHandler("enviarDinero", root, function ( amount ) givePlayerMoney(source, amount) end ) No funciona, al escribir el comando no pasa nada. Link to comment
Recommended Posts