Jump to content

Jonas^

Members
  • Posts

    1,016
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by Jonas^

  1. Se procurasse um pouquinho mais veria que tem 2 exemplos de como fazer isso. SetPedAnimation AddCommandHandler
  2. client-side addCommandHandler ("discord", function (thePlayer, cmd) local discord = "discord.gg/link_de_convite" setClipboard (discord) outputChatBox ("Link do discord copiado automaticamente use ctrl + v para colar", 0, 255, 0) end)
  3. addCommandHandler ("chat", function (thePlayer, cmd) if (hasObjectPermissionTo (thePlayer, "command.mute", true)) then -- Se o jogador possuir permissão de mute, então: (Todos grupos padrões tem permissão de mute, então todos poderam usar o comando.) clearChatBox () -- Limpa o chat do servidor outputChatBox ("ᴏ ᴄʜᴀᴛ ғᴏɪ ʟɪᴍᴘᴏ ᴘᴏʀ #FFFF00"..getPlayerName(thePlayer).." #FF0000!!!", root, 0, 255, 0, true) else outputChatBox ("Voce nao e da staff!!!", thePlayer, 0, 255, 0) end end)
  4. No caso teria que ser OnPlayerLogin no lugar de OnPlayerJoin pois apenas quando é efetuado o login que esses dados são carregados. Eu faria desta forma: addEventHandler ("onPlayerLogin", root, function (prevAcc, currAcc) if (getAccountData (currAcc, "fistSpawn")) then -- Se a data já existir na conta do jogador, então: outputChatBox ("@antigo jogador", source) setElementPosition (source, 0, 0, 3) -- Seta o jogador na coordenada especifica (vamos chamar de y) else -- Se a data não existir, então: outputChatBox ("@novo jogador", source) setElementPosition (source, 30, 30, 3) -- Seta o jogador na coordenada especifica (vamos chamar de x) setAccountData (currAcc, "fistSpawn", true) -- Seta a data na conta do jogador fazendo que no próximo login ele de spawn em y. end end)
  5. E assim esta longe de funcionar, faça assim: client-side local sX, sY = guiGetScreenSize () addEventHandler ("onClientResourceStart", resourceRoot, function () mainWindow = guiCreateWindow (sX/2 - 140, sY/2 - 135, 280, 270, "Loja de Armas", false) guiWindowSetSizable (mainWindow, false) guiSetProperty (mainWindow, "CaptionColour", "FF00FF00") btnM4 = guiCreateButton (59, 46, 163, 37, "M4 = 12000R$", false, mainWindow) guiSetProperty (btnM4, "HoverTextColour", "FF00FF00") btnDeagle = guiCreateButton (59, 93, 163, 37, "Deagle = 7000R$", false, mainWindow) guiSetProperty (btnDeagle, "HoverTextColour", "FF00FF00") btnAk = guiCreateButton (59, 140, 163, 37, "Ak-47 = 15000R$", false, mainWindow) guiSetProperty (btnAk, "HoverTextColour", "FF00FF00") btnMP5 = guiCreateButton (59, 187, 163, 37, "MP5 = 30000$", false, mainWindow) guiSetProperty (btnMP5, "HoverTextColour", "FF00FF00") btnClose = guiCreateButton (244, 240, 26, 20, "x", false, mainWindow) guiSetProperty (btnClose, "HoverTextColour", "FFFF0000") end) addEventHandler ("onClientGUIClick", root, function (btn) if btn ~= "left" then return end -- Se o botão clicado do mouse não for o esquerdo, nada acontece. if (source == btnM4) then -- Se o botão clicado for o botão de comprar a m4, então: triggerServerEvent ("onBuyWeapon", localPlayer, "m4") elseif (source == btnDeagle) then -- Se o botão clicado for o botão de comprar a deagle, então: triggerServerEvent ("onBuyWeapon", localPlayer, "deagle") elseif (source == btnAk) then -- Se o botão clicado for o botão de comprar a ak, então: triggerServerEvent ("onBuyWeapon", localPlayer, "ak") elseif (source == btnMP5) then -- Se o botão clicado for o botão de comprar a mp5, então: triggerServerEvent ("onBuyWeapon", localPlayer, "mp5") elseif (source == btnClose) then -- Se o botão clicado for o botão de fechar o painel, então: guiSetVisible (mainWindow, false) -- Seta a janela principal como false (desativada). showCursor (false) -- Seta o cursor como false (desativado). end end) function showPanel () if guiGetVisible (mainWindow) then -- Se o painel estiver aberto, então: guiSetVisible (mainWindow, false) -- Seta a janela principal como false (desativada). showCursor (false) -- Seta o cursor como false (desativado). else -- Se ela não estiver aberta ainda, entao: guiSetVisible (mainWindow, true) -- Seta a janela principal como true (ativada). showCursor (true) -- Seta o cursor como true (ativado). end end addEvent ("openShopWindow", true) addEventHandler ("openShopWindow", getRootElement(), showPanel) server-side local markerShop = createMarker (-714, 960, 11, "cylinder", 2, 0, 255, 0) local comandoComprar = "comprar" -- Comando que ira abrir o painel function weaponGive (string, weapon, ammo) if (string == "m4") then -- Se for a string 'm4' enviada pelo client, então: if getPlayerMoney(client) >= 12000 then -- Se o jogador tiver 12000 ou mais, então: takePlayerMoney (client, 12000) -- Retira a quantia de 12000 do saldo do jogador. giveWeapon (client, 31, 300) -- Da ao jogador uma m4 com 300 munições. outputChatBox ("Você comprou uma M4 com 300 munições.", client, 0, 255, 0) -- Feedback informando a compra com sucesso da arma. else outputChatBox ("Você não tem dinheiro suficiente!", client, 255, 0, 0) end elseif (string == "deagle") then if getPlayerMoney(client) >= 7000 then -- Se o jogador tiver 7000 ou mais, então: takePlayerMoney (client, 7000) -- Retira a quantia de 7000 do saldo do jogador. giveWeapon (client, 24, 300) -- Da ao jogador uma deagle com 300 munições. outputChatBox ("Você comprou uma Deagle com 300 munições.", client, 0, 255, 0) -- Feedback informando a compra com sucesso da arma. else outputChatBox ("Você não tem dinheiro suficiente!", client, 255, 0, 0) end elseif (string == "ak") then if getPlayerMoney(client) >= 15000 then -- Se o jogador tiver 15000 ou mais, então: takePlayerMoney (client, 15000) -- Retira a quantia de 15000 do saldo do jogador. giveWeapon (client, 30, 300) -- Da ao jogador uma ak com 300 munições. outputChatBox ("Você comprou uma AK com 300 munições.", client, 0, 255, 0) -- Feedback informando a compra com sucesso da arma. else outputChatBox ("Você não tem dinheiro suficiente!", client, 255, 0, 0) end elseif (string == "mp5") then if getPlayerMoney(client) >= 30000 then -- Se o jogador tiver 30000 ou mais, então: takePlayerMoney (client, 30000) -- Retira a quantia de 30000 do saldo do jogador. giveWeapon (client, 29, 300) -- Da ao jogador uma MP5 com 300 munições. outputChatBox ("Você comprou uma MP5 com 300 munições.", client, 0, 255, 0) -- Feedback informando a compra com sucesso da arma. else outputChatBox ("Você não tem dinheiro suficiente!", client, 255, 0, 0) end end end addEvent ("onBuyWeapon", true) addEventHandler ("onBuyWeapon", getRootElement(), weaponGive) addCommandHandler (comandoComprar, function (thePlayer, cmd) if isElementWithinMarker (thePlayer, markerShop) then -- Se o jogador estiver no marker "MarkerShop", então: triggerClientEvent (thePlayer, "openShopWindow", thePlayer) -- Inicia conexão com o client pra exibir o painel. else outputChatBox ("Você não esta no shop de armas!", thePlayer, 255, 0, 0) end end) @IShiftey Você pode mudar o comando pra exibir o painel e as coordenadas do marker no começo do código, pra exibir o painel precisa estar encima do marker como você queria, quando chegar encima do marker use o botão /comprar por padrão definido por mim!
  6. @MesaDowNComo você acha que esse código ira funcionar usando funções server-side em client-side?
  7. Ok, faça desta forma então: function cuff (thePlayer, cmd, nick) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("BOPE")) or isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("PMRJ"))) then local nickJogador = getPlayerFromPartialName (nick) if (nickJogador) then local x, y, z = getElementPosition (thePlayer) local x1, y1, z1 = getElementPosition (nickJogador) if (getDistanceBetweenPoints3D (x1, y1, z1, x, y, z) <= 20) then if not (getElementData (nickJogador, 'cuff')) then setCuffPlayer (nickJogador) setElementData (nickJogador, 'cuff', true) toggleControl (nickJogador, "fire", false) toggleControl (nickJogador, "jump", false) toggleControl (nickJogador, "left", false) toggleControl (nickJogador, "right", false) toggleControl (nickJogador, "forwards", false) toggleControl (nickJogador, "backwards", false) toggleControl (nickJogador, "sprint", false) toggleControl (nickJogador, "crouch", false) toggleControl (nickJogador, "walk", false) toggleControl (nickJogador, "aim_weapon", false) outputChatBox (getPlayerName(thePlayer)..'#ff0000 Algemou você agora você não pode se mover', nickJogador, 255, 255, 255, true) else removeElementData (nickJogador, 'cuff') destroyElement (getElementData (nickJogador, 'cuffOb')) removeElementData (nickJogador, 'cuff') toggleControl (nickJogador, "fire", true) toggleControl (nickJogador, "jump", true) toggleControl (nickJogador, "left", true) toggleControl (nickJogador, "right", true) toggleControl (nickJogador, "forwards", true) toggleControl (nickJogador, "backwards", true) toggleControl (nickJogador, "sprint", true) toggleControl (nickJogador, "crouch", true) toggleControl (nickJogador, "walk", true) toggleControl (nickJogador, "aim_weapon", true) setPedAnimation (nickJogador, 'ped', 'pass_Smoke_in_car', 0, false, false, false, false) outputChatBox (getPlayerName(thePlayer)..'#008800 Soltou suas algemas e agora você esta livre', nickJogador, 255, 255, 255, true) end else outputChatBox ("O jogador estã longe demais se aproxime!", thePlayer, 255, 0, 0) end else outputChatBox ("Nenhum jogador com esse nick foi encontrado!", thePlayer, 255, 0, 0) end else outputChatBox ("Você não tem acesso a esse comando!", thePlayer, 255, 0, 0) end end addCommandHandler ('a', cuff)
  8. Não explique seu problema no titulo do tópico, aprenda a usar nosso fórum de forma correta e evite futuras punições, informações úteis: Clique Aqui
  9. Estranho, não vejo problemas, agora não posso testar, mas tenho 99% de certeza que esta funcionando, acredito que você esta colocando no lado client-side ao invés de server-side, leia o tópico que lhe mandei ali encima você ira aprender bastante coisa
  10. Não é client, é server. Faça desta forma o meta: <meta> <script src="server.Lua" type="server"/> </meta> E no lugar do nome do arquivo onde você colocou client.Lua coloque server.Lua
  11. Em qualquer arquivo server-side amigo, parece que você é novo aqui no fórum e parece que esta começando agora com programação no MTA, então, irei te dar uma ajudinha recomendando dois tópicos excelentes. Algumas coisas sobre nosso fórum: Clique Aqui Informações úteis sobre configurações no geral e entre outras informações legais: Clique Aqui Espero ter ajudado, tenha uma boa noite e seja muito bem vindo a nossa comunidade
  12. Pra fazer isso, você pode guardar a skin que ele estava em uma tabela, e após o respawn percorrer um loop obtendo essa skin e setando no jogador novamente. Há também outra possibilidade de usar element-datas, que foi oque eu fiz neste exemplo: addEventHandler ("onPlayerWasted", root, function (ammo, attacker, weapon, bodypart) local saveSkin = getElementModel (source) setElementData (source, "skinID", saveSkin) outputChatBox (saveSkin, source, 255, 0, 0) end) addEventHandler ("onPlayerSpawn", root, function () local getSkin = getElementData (source, "skinID") or 0 setElementModel (source, getSkin) outputChatBox (getSkin, source, 0, 255, 0) end) @Sumexr
  13. Mano........................ presta só um pouco de atenção, não precisa nem ser muito, eu copiei só o comando, troque o comando apenas que esta la por esse.......
  14. function cuff (thePlayer, cmd, nick) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("BOPE")) or isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("PMRJ"))) then local nickJogador = getPlayerFromPartialName (nick) if (nickJogador) then local x, y, z = getElementPosition (thePlayer) local x1, y1, z1 = getElementPosition (nickJogador) if (getDistanceBetweenPoints3D (x1, y1, z1, x, y, z) <= 20) then if not (getElementData (nickJogador, 'cuff')) then -- if isPedInVehicle (nickJogador) then -- setControlState (nickJogador, 'enter_exit', true) -- setTimer (setCuffPlayer, 2800, 1, nickJogador) -- setElementData (nickJogador, 'cuff', true) -- else setCuffPlayer (nickJogador) setElementData (nickJogador, 'cuff', true) -- toggleAllControls (nickJogador, false) setElementFrozen (nickJogador, true) outputChatBox (getPlayerName(thePlayer)..'#ff0000 Algemou você agora você não pode se mover', nickJogador, 255, 255, 255, true) -- end else removeElementData (nickJogador, 'cuff') destroyElement (getElementData (nickJogador, 'cuffOb')) removeElementData (nickJogador, 'cuff') -- toggleAllControls (nickJogador, true) setElementFrozen (nickJogador, false) setPedAnimation (nickJogador, 'ped', 'pass_Smoke_in_car', 0, false, false, false, false) outputChatBox (getPlayerName(thePlayer)..'#008800 Soltou suas algemas e agora você esta livre', nickJogador, 255, 255, 255, true) end else outputChatBox ("O jogador estã longe demais se aproxime!", thePlayer, 255, 0, 0) end else outputChatBox ("Nenhum jogador com esse nick foi encontrado!", thePlayer, 255, 0, 0) end else outputChatBox ("Você não tem acesso a esse comando!", thePlayer, 255, 0, 0) end end addCommandHandler ('a', cuff)
  15. addCommandHandler ("fix", function (thePlayer, cmd) if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("vip")) then local theVehicle = getPedOccupiedVehicle (thePlayer) if (theVehicle and getVehicleController (theVehicle) == thePlayer) then fixVehicle (theVehicle) outputChatBox ("|VIP| Você reparou seu veículo com sucesso!", thePlayer, 0, 255, 0) end end end)
  16. Jonas^#0001 A e só uma coisinha que acabei esquecendo fiz na pressa, esqueci de um argumento no outPut na linha 15, como não foi informado por se tratar de server-side ele ira mandar aquela mensagem pra todos e não apenas para o jogador que digitou o comando, troque ela por essa: outputChatBox ("Nenhum jogador encontrado com esse nick!", player, 255, 0, 0)
  17. Código melhorado e devidamente indentado..... addCommandHandler ("versujo", function (player, cmd, target) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Policial"))) then local targetplayer = getPlayerFromName (target) if (targetplayer) then local pX, pY, pZ = getElementPosition (player) -- posição do policial local bX, bY, bZ = getElementPosition (targetplayer) -- posição do abordado local dist = getDistanceBetweenPoints3D (pX, pY, pZ, bX, bY, bZ) -- calcula a distancia da duas posições if dist < 3 then -- se a distancia for menor que 3 então: local Dinheiro_Sujo = getElementData (targetplayer, "moneysujo") outputChatBox ("✘#ffffffINFO#0037FF✘➺ #ffffffO Jogador Tem: #FF0000R$"..Dinheiro_Sujo.."#ffffff Na Carteira !", player, 0, 22, 100, true) else --se não for então: outputChatBox ("✘#ffffffINFO#0037FF✘➺ #ffffffVocê esta muito longe!", player, 0, 22, 100, true) end else outputChatBox ("Nenhum jogador encontrado com esse nick!", player, 255, 0, 0) end else outputChatBox ("Você não tem acesso a esse comando!", player, 255, 0, 0) end end)
  18. Sim. (Não ira trazer bug's desde que faça da forma correta, ainda mais usando uma database separada, coisa que acho desnecessário)
  19. Da f5 na pagina e copie o codigo novamente e teste.
  20. Player não esta declarado em lugar algum na sua função. Sobre o debug basta usar o comando /debugscript 3 e /debugscript 0 pra desativar. Correção: function setPedAnimationSpeed (player, anim, speed) triggerClientEvent (player, "animSped", player, player, anim, speed) end function setCuffPlayer (player) setPedAnimation (player, nil) setPedAnimation (player, 'ped', 'pass_Smoke_in_car', 0, true, true, true) setTimer (setPedAnimationSpeed, 60, 1, player, 'pass_Smoke_in_car', 0) local x, y, z = getElementPosition (player) local box = createObject(364, x, y, z) exports.bone_attach:attachElementToBone (box, player, 12, 0,0,0, 0,40,-10) setElementCollisionsEnabled (box, false) setElementData (player,'cuffOb', box) toggleControl (player, 'jump', false) setTimer(function (player) if (getElementData (player, 'cuff') and getElementData (player, 'cuff') == true) then toggleControl (player, 'fire', false) end end, 60, 0, player) toggleControl (player, 'crouch', false) end function cuff (thePlayer, cmd, nick) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("BOPE")) or isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("PMRJ"))) then local nickJogador = getPlayerFromPartialName (nick) if (nickJogador) then local x, y, z = getElementPosition (thePlayer) local x1, y1, z1 = getElementPosition (nickJogador) if (getDistanceBetweenPoints3D (x1, y1, z1, x, y, z) <= 20) then if not (getElementData (nickJogador, 'cuff')) then -- if isPedInVehicle (nickJogador) then -- setControlState (nickJogador, 'enter_exit', true) -- setTimer (setCuffPlayer, 2800, 1, nickJogador) -- setElementData (nickJogador, 'cuff', true) -- else setCuffPlayer (nickJogador) setElementData (nickJogador, 'cuff', true) toggleAllControls (nickJogador, false) outputChatBox (getPlayerName(thePlayer)..'#ff0000 Algemou você', nickJogador, 255, 255, 255, true) -- end else removeElementData (nickJogador, 'cuff') destroyElement (getElementData (nickJogador, 'cuffOb')) removeElementData (nickJogador, 'cuff') toggleAllControls (nickJogador, true) setPedAnimation (nickJogador, 'ped', 'pass_Smoke_in_car', 0, false, false, false, false) outputChatBox (getPlayerName(thePlayer)..'#008800 Soltou suas algemas', nickJogador, 255, 255, 255, true) end else outputChatBox ("Você está longe demais!", thePlayer, 255, 0, 0) end else outputChatBox ("Nenhum jogador com esse nick foi encontrado!", thePlayer, 255, 0, 0) end else outputChatBox ("Você não tem acesso a esse comando!", thePlayer, 255, 0, 0) end end addCommandHandler ('prender', cuff) addEventHandler ('onPlayerQuit', root, function () if (getElementData (source, 'cuff') == true) then destroyElement(getElementData(source, 'cuffOb')) removeElementData (source, 'cuff') end end) addEventHandler ('onPlayerWasted', root, function () if (getElementData (source, 'cuff') == true) then destroyElement(getElementData(source, 'cuffOb')) removeElementData (source, 'cuff') end end) addEventHandler ('onVehicleStartEnter', getRootElement(), function (player, seat) if (getElementData (player, 'cuff') == true) then if (seat ~= 0) then destroyElement(getElementData(player, 'cuffOb')) else cancelEvent () outputChatBox ('Você não pode dirigir você tem algemas!', player, 255, 0, 0) end end end) setTimer(function () for _, player in ipairs(getElementsByType("player")) do if (getElementData (player, 'cuff') == true) then if isElementInWater(player) then setTimer(function(player) if isElementInWater(player) then killPed (player) end end, 5000, 1, player) end end end end, 1000, 0) addEventHandler ('onVehicleExit', getRootElement(), function (player, seat) if (getElementData (player, 'cuff') == true) then setCuffPlayer (player) end end) function getPlayerFromPartialName (name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end OBS: Não fiz nenhum teste, faça você mesmo e me diga o resultado.
  21. Aqui também acontece isso @Tommy., já tentei resolver mexendo em todas configurações mas nada resolveu, mas só com vscode, dai pra indentar uso o notepad++
×
×
  • Create New...