Gaimo Posted July 6, 2020 Share Posted July 6, 2020 (edited) Não estou conseguindo exibir um GUI, quero que quando um jogador envie uma proposta de venda para outro, exiba um GUI na tela com as informações da venda. Exemplo: O jogador (nome-do-jogador), está oferecendo uma (nome-da-arma) por R$ (valor). [ACEITAR] - [RECUSAR] Não está sendo exibido o GUI quando é feito a proposta de venda. GUI Spoiler addEvent( "buy", true ) addEventHandler( "buy", localPlayer, function(seller, weaponID, ammo, price) local seller = getPlayerName(seller) outputChatBox("O Jogador "..seller.." esta te oferecendo uma "..getWeaponNameFromID(weaponID).. "por R$ "..price..".") local sW, sH = guiGetScreenSize() mainWindow = guiCreateWindow((sW-300)/2, (sH-60)/2, 600, 120, "UM NOME LEGAL", false) guiWindowSetMovable(mainWindow, false) guiWindowSetSizable(mainWindow, false) bt_accept = guiCreateButton(10, 80, 80, 30, "ACEITAR", false, mainWindow) guiSetProperty(bt_accept, "NormalTextColour", "FF14EA37") text = guiCreateLabel(53, 27, 494, 28, "O Jogador "..seller.." esta te oferecendo uma "..getWeaponNameFromID(weaponID).. "por R$ "..price..".", false, mainWindow) bt_cancel = guiCreateButton(510, 80, 80, 30, "RECUSAR", false, mainWindow) guiSetProperty(bt_cancel, "NormalTextColour", "FFFD0000") end) Esse é o evento que está no servidor: Spoiler addEvent("sellWeapon",true) addEventHandler("sellWeapon",root, function(buyer, weaponID, ammo, price) -- seller = source triggerClientEvent(buyer, "comprar", source, weaponID, ammo, price) end ) e é assim que estou chamando o evento: triggerServerEvent("sellWeapon",localPlayer,player,WeaponID,Ammo,900) -- 900 é o price. Código todo do client: Spoiler -- Script Criado by +CH4P4D0 -- -- www.Modsbr-MTA.blogspot.com.br -- -- Obrigado por Baixar ;D -- local KEY = "F10" -- Hot Key -- ## Important Functions function centerWindow(center_window) -- https://modsbr-mta.blogspot.com.br/wiki/CenterWindow local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end function getPedWeapons(ped) -- https://modsbr-mta.blogspot.com.br/wiki/GetPedWeapons local playerWeapons = {} if ped and isElement(ped) and getElementType(ped) == "ped" or getElementType(ped) == "player" then for i=2,9 do local wep = getPedWeapon(ped,i) if wep and wep ~= 0 then table.insert(playerWeapons,wep) end end else return false end return playerWeapons end -- ## Main Window ## wnd = guiCreateWindow(202,74,427,458,"Sistema de Transferir Armas",false) players_grid = guiCreateGridList(0.0211,0.0546,0.4707,0.9258,true,wnd) guiGridListSetSelectionMode(players_grid,1) guiGridListAddColumn(players_grid,"Jogadores...",0.9) weapons_grid = guiCreateGridList(0.5035,0.0546,0.4707,0.5415,true,wnd) guiGridListSetSelectionMode(weapons_grid,1) guiGridListAddColumn(weapons_grid,"Armas",0.6) guiGridListAddColumn(weapons_grid,"Munições",0.3) info = guiCreateLabel(0.5012,0.6092,0.4707,0.0699,"Digite o valor da munição",true,wnd) guiLabelSetColor(info,0,255,0) guiLabelSetVerticalAlign(info,"center") guiLabelSetHorizontalAlign(info,"center",false) guiSetFont(info,"default-bold-small") ammo = guiCreateEdit(0.5035,0.679,0.4731,0.0852,"",true,wnd) send = guiCreateButton(0.5035,0.7838,0.4731,0.0895,"Enviar Arma",true,wnd) guiSetFont(send,"default-bold-small") close = guiCreateButton(0.5035,0.8843,0.4731,0.0895,"Fechar",true,wnd) guiSetFont(close,"default-bold-small") guiSetVisible(wnd,false) centerWindow(wnd) bindKey(KEY,"down", function () if guiGetVisible(wnd) then guiSetVisible(wnd,false) showCursor(false) guiSetInputEnabled(false) else guiSetVisible(wnd,true) showCursor(true) guiSetInputEnabled(true) putPlayers() putWeapons() end end ) function putPlayers() guiGridListClear(players_grid) for _,player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(players_grid) guiGridListSetItemText(players_grid,row,1,getPlayerName(player),false,false) end end function putWeapons() guiGridListClear(weapons_grid) for _,weapon in ipairs(getPedWeapons(localPlayer)) do if getPedTotalAmmo(localPlayer,getSlotFromWeapon(weapon)) > 0 then local row = guiGridListAddRow(weapons_grid) guiGridListSetItemText(weapons_grid,row,1,getWeaponNameFromID(weapon),false,false) guiGridListSetItemText(weapons_grid,row,2,getPedTotalAmmo(localPlayer,getSlotFromWeapon(weapon)),false,false) end end end function RefreshLists() putPlayers() putWeapons() end addEventHandler("onClientGUIClick",close, function () guiSetVisible(wnd,false) showCursor(false) guiSetInputEnabled(false) end ,false) addEventHandler("onClientGUIClick",send, function () local sel_1 = guiGridListGetSelectedItem(players_grid) local sel_2 = guiGridListGetSelectedItem(weapons_grid) if sel_1 ~= -1 and sel_2 ~= -1 then local PlayerName = guiGridListGetItemText(players_grid,sel_1,1) local player = getPlayerFromName(PlayerName) if isElement(player) then if player ~= localPlayer then local WeaponName = guiGridListGetItemText(weapons_grid,sel_2,1) local WeaponAmmo = guiGridListGetItemText(weapons_grid,sel_2,2) local WeaponID = getWeaponIDFromName(WeaponName) local Ammo = guiGetText(ammo) if tonumber(Ammo) and tonumber(Ammo) >= 10 then if tonumber(WeaponAmmo) >= tonumber(Ammo) then setTimer(RefreshLists,500,1) --triggerServerEvent("SendWeapon",localPlayer,player,WeaponID,Ammo) triggerServerEvent("sellWeapon",localPlayer,player,WeaponID,Ammo,900) else outputChatBox("Erro: Voce não tem munição suficiente para esta arma",255,0,0) end else outputChatBox("Error: Digite a quantidade de munição",255,0,0) end else outputChatBox("Erro: Você não pode enviar arma para você mesmo.",255,0,0) end else RefreshLists() outputChatBox("Error: Jogador não encontrado, atualizando lista...",255,0,0) end end end ) addEvent( "buy", true ) addEventHandler( "buy", localPlayer, function(seller, weaponID, ammo, price) local seller = getPlayerName(seller) outputChatBox("O Jogador "..seller.." esta te oferecendo uma "..getWeaponNameFromID(weaponID).. "por R$ "..price..".") local sW, sH = guiGetScreenSize() mainWindow = guiCreateWindow((sW-300)/2, (sH-60)/2, 600, 120, "UM NOME LEGAL", false) guiWindowSetMovable(mainWindow, false) guiWindowSetSizable(mainWindow, false) bt_accept = guiCreateButton(10, 80, 80, 30, "ACEITAR", false, mainWindow) guiSetProperty(bt_accept, "NormalTextColour", "FF14EA37") text = guiCreateLabel(53, 27, 494, 28, "O Jogador "..seller.." esta te oferecendo uma "..getWeaponNameFromID(weaponID).. "por R$ "..price..".", false, mainWindow) bt_cancel = guiCreateButton(510, 80, 80, 30, "RECUSAR", false, mainWindow) guiSetProperty(bt_cancel, "NormalTextColour", "FFFD0000") end) Estou adaptando um script da net. Edited July 6, 2020 by Gaimo 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