Torugo Posted October 28, 2019 Share Posted October 28, 2019 (edited) Preciso de ajuda estou mexendo em um mod de armas que transfere de um jogador para outro mas n consegui colocar preço pra vender alguém me ajuda ===Client=== -- Script Criado by Torugo -- -- www.Modsbr-MTA.blogspot.com.br -- -- Obrigado por Baixar ;D -- local KEY = "F6" -- Hot Key outputChatBox("#0ffff0 Sistema de Armas criado por Torugo",255,0,0,true) -- My Right's ( Don't Change it ) -- ## Important Functions function centerWindow(center_window) -- 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) -- 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,"Pessoas...",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,"Municao",0.3) info = guiCreateLabel(0.5012,0.6092,0.4707,0.0699,"Digite o valor da municao",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 Armas",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) else outputChatBox("Erro: Você não tem munição suficiente para esta arma",255,0,0) end else outputChatBox("Error: Escreva um número na Editar",255,0,0) end else outputChatBox("Erro: Não é possível enviar Arma Para Seu Auto",255,0,0) end else RefreshLists() outputChatBox("Error: Jogador não encontrado, Lists refrescado",255,0,0) end end end ) fileDelete("Client.Lua") ===Server=== -- Script Criado por Torugo -- -- www.Modsbr-MTA.blogspot.com.br -- -- Obrigado por Baixar ;D -- addEvent("SendWeapon",true) addEventHandler("SendWeapon",root, function (player,id,ammo) local id = tonumber(id) local ammo = tonumber(ammo) giveWeapon(player,id,ammo) takeWeapon(source,id,ammo) outputChatBox("#ffffff Enviou #ff0000" .. getWeaponNameFromID(id) .. "#ffffffPara #ff0000" .. getPlayerName(player),source,255,0,0,true) outputChatBox("# " .. getPlayerName(source) .. " #ffffffEnviou #ff0000" .. getWeaponNameFromID(id) .. " #ffffffPara você com #ff0000" .. ammo .. " #FFFFFFMunição",player,255,0,0,true) end ) ===Meta=== <meta> <info author="Torugo" name="Sistema de Transferir armas" version="1.0.0" type="script" /> <script src="Client.Lua" type="client" /> <script src="Server.Lua" type="server" /> </meta> se alguém puder me ajudar Edited October 28, 2019 by Lord Henry Corrigida formatação de texto para Lua, XML. Link to comment
Other Languages Moderators Lord Henry Posted October 28, 2019 Other Languages Moderators Share Posted October 28, 2019 Utilize o botão <> do fórum para postar scripts. 1 Link to comment
Torugo Posted October 28, 2019 Author Share Posted October 28, 2019 (edited) Desculpa como edito n aparece mais Edited October 28, 2019 by Torugo Link to comment
Other Languages Moderators Lord Henry Posted October 28, 2019 Other Languages Moderators Share Posted October 28, 2019 Corrigi para você. 1 Link to comment
Torugo Posted October 28, 2019 Author Share Posted October 28, 2019 Ok obrigado mas consegue me ajudar Tipo oque vou usar oq preciso Link to comment
DNL291 Posted October 29, 2019 Share Posted October 29, 2019 valor = 1000 if player and getPlayerMoney(player) >= valor then local id = tonumber(id) local ammo = tonumber(ammo) giveWeapon(player,id,ammo) takeWeapon(source,id,ammo) takePlayerMoney(player, valor) end ^ Exemplo 1 Link to comment
Other Languages Moderators Lord Henry Posted October 29, 2019 Other Languages Moderators Share Posted October 29, 2019 Não se esqueça do givePlayerMoney pro source. 1 Link to comment
Torugo Posted October 29, 2019 Author Share Posted October 29, 2019 Ok esse eu coloco no server ou no client Tipo eu vou precisar editar o painel recomenda usar dx ou cegui Link to comment
Other Languages Moderators Lord Henry Posted October 29, 2019 Other Languages Moderators Share Posted October 29, 2019 2 minutes ago, Torugo said: Ok esse eu coloco no server ou no client Está vendo as partes em laranja? O que está em laranja significa que é server-side e portanto não vai funcionar no client. O que está em azul significa que funciona em ambos. Ou seja, coloque no server-side. 3 minutes ago, Torugo said: recomenda usar dx ou cegui CEGUI por ser mais fácil e mais rápido de fazer. 1 Link to comment
Torugo Posted October 29, 2019 Author Share Posted October 29, 2019 Obrigado e desculpa pelas muitas perguntas sou iniciante Link to comment
Other Languages Moderators Lord Henry Posted October 29, 2019 Other Languages Moderators Share Posted October 29, 2019 (edited) Sem problemas, qualquer coisa pode voltar a perguntar. Estamos aqui para ajudar. Agradeça deixando um Thanks nas respostas que lhe ajudaram. Edited October 29, 2019 by Lord Henry 1 Link to comment
DNL291 Posted October 29, 2019 Share Posted October 29, 2019 Lembre-se de ver os tópicos fixados pelo fórum, vai responder suas perguntas futuras e te ajudar a ter um entendimento de como aqui e o MTA funciona. https://forum.multitheftauto.com/topic/116681-informações-úteis-scriptingconfiguraçõestutoriais-para-o-mta/ 1 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