-
Posts
251 -
Joined
-
Last visited
-
Days Won
7
Posts posted by Angelo Pereira
-
-
On 05/12/2020 at 12:31, Ducks said:
No problem with the language
O que o moderador quis dizer é, você postou seu tópico em sessão errada, e então ele moveu para sessão correta.
On 05/12/2020 at 05:36, Ducks said:Olá, eu queria saber qual a base pra criar um celular no mta, procurei tutorial em tudo não Achei. Vlw
Sobre isto, basta você ter uma PNG de um celular, e então ou desenvolver por meio de DX ou CEGUI.
O tutorial que eu sugiro seria começar lendo pelo : Multi Theft Auto: Wiki
- 1
-
Espero que você consiga interpretar a minha correção em base no que você fez.
local screenW, screenH = guiGetScreenSize() local x, y = (screenW/1366), (screenH/768) local showdx = false local randomColors = 0 local color = { } --/> Basta uma table. function dxbutton ( ) if showdx == true then if isCursorOnElement ( x*35, y*410, x*105, y*85 ) then color[1] = tocolor(0, 255, 0, 255) else color[1] = tocolor(255, 255, 255, 255) end dxDrawRectangle(x*35, y*410, x*105, y*85, color[1], false) end end function opendx ( ) if showdx == true then removeEventHandler("onClientRender", root, dxbutton) showCursor(false) showdx = false else addEventHandler("onClientRender", root, dxbutton) showCursor(true) showdx = true end end bindKey("z", "down", opendx) ---------------------------------------------------------------------------------------------------------- function isCursorOnElement ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end
-
Tire as aspas (" ") do primeiro argumento da função.
-
Deixar o evento como root neste caso, qualquer marker que o usuário colidir no servidor, abrirá o portão.
Então, faça :
local gate = createObject (16775, 2532, -1514.5999755859, 27.10000038147, 0, 0, 0) local marker = createMarker (2532, -1514.5999755859, 27.10000038147, "cylinder", 8, 0, 0, 0, 0) function moveGate ( hitElement ) if isElement(hitElement) and getElementType(hitElement) == "player" then local accName = getAccountName ( getPlayerAccount ( hitElement ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "CV" ) ) then moveObject(gate, 1900, 2532, -1.514,5999755859, 18,89999961853) end end end addEventHandler ( "onMarkerHit", marker, moveGate ) function move_back_gate ( hitElement ) if isElement(hitElement) then moveObject (gate, 1900, 2532, -1514.5999755859, 27.10000038147, 0, 0, 0) end end addEventHandler ("onMarkerLeave", marker, move_back_gate)
-
Não é possível você alterar a origem do evento.
Eu fazeria desta forma, sempre trazendo a string.
function savePlayerData ( player ) local account = getPlayerAccount(player) local skin = getElementModel(player) local x,y,z = getElementPosition(player) local position = toJSON({x,y,z,getElementRotation(player)}) local interior = getElementInterior(player) local dimension = getElementDimension(player) setAccountData(account, "skin", skin) setAccountData(account, "position", position) setAccountData(account, "interior", interiror) setAccountData(account, "dimension", dimension) end addEventHandler("onPlayerQuit", root, function ( ) savePlayerData ( source ) end) addEventHandler("onResourceStop", resourceRoot, function ( ) for i, players in ipairs ( getElementsByType ("player") ) do savePlayerData ( players ) end end)
-
# Faça :
local carro = createMarker(2146.883, -2289.945, 14.761 -1,"cylinder", 2.0, 255,0,0,80) local desespawncm = createMarker(2151.133, -2290.037, 13.368 -1 , "cylinder",2.0,255,255,255,80) local veh = { } function spawnviaturaone(thePlayer) local job = getElementData(thePlayer,"Emprego") or false --/> ADD if job ~= "Entregador de Jornal" then --/> ADD return outputChatBox("Você Precisa Esta no Emprego Para Pegar Este Veiculo", thePlayer, 255, 255, 255, true) --/> ADD end --/> ADD local vehicle = getPedOccupiedVehicle(thePlayer) if isElementWithinMarker(thePlayer, carro) then if veh[thePlayer] and isElement(veh[thePlayer]) then destroyElement(veh[thePlayer]) veh[thePlayer] = nil else veh[thePlayer] = createVehicle(530, 2153.617, -2287.28, 13.524) warpPedIntoVehicle(thePlayer, veh[thePlayer]) end end end addEventHandler("onMarkerHit", carro, spawnviaturaone ) function desespawncmm( thePlayer ) if veh[thePlayer] and isElement(veh[thePlayer]) then --/> ADD destroyElement(veh[thePlayer]) end --/> ADD end addEventHandler("onMarkerHit", desespawncm, desespawncmm)
-
O fórum é um local para lhe ajudar em seus códigos, e não um ambiente de pedir scripts prontos.
Então anexe, o seu script utilizando <>, e formate em .lua.
# Sobre sua dúvida, utilize :
Eventos : onPlayerJoin / onPlayerLogin / onPlayerWasted ou onPlayerSpawn
Função : setElementModel
# Exemplo :
function setar_skin ( ) setElementModel ( source, 7 ) outputChatBox ("Você Recebeu a Skin Nº7", source, 255, 255, 255, true ) end addEventHandler("onPlayerJoin", root, setar_skin) addEventHandler("onPlayerLogin", root, setar_skin) addEventHandler("onPlayerSpawn", root, setar_skin)
-
# Sobre o fórum :
1. Não utilize um título do tópico muito longo, e seja objetivo/específico.
[ Exemplo ] Titulo : Proteção por ACL Somente Para STAFF.
2. Então, abaixo disto, você coloque sua dúvida, esclareça o que você quer realmente fazer.
[ Exemplo ] Texto : Alguém me ajuda na minha dúvida, como faço para apenas quem tiver numa determinada ACL, pode utilizar o comando.
3. Caso você tenha o script, clique no ícone < > , e cole o seu código lá, e formate em .Lua.
# Sobre a sua dúvida :
addCommandHandler ( "protecao", function ( thePlayer ) local conta = getAccountName ( getPlayerAccount ( thePlayer ) ) --/> Pegar Usuário do Jogador. if isObjectInACLGroup ("user."..conta, aclGetGroup ( "Admin" ) ) then --/> Verificar Se Este Usuário Esta na ACL "Admin". outputChatBox("#00ff00Você Tem Permissão!", thePlayer, 255, 255, 255, true) else --/> Se não Tiver, Então fazer : outputChatBox("#ff0000Você Não Tem Permissão a Este Comando!", thePlayer, 255, 255, 255, true) end end) --[[ # MTA WIKI / UTILIZADOS : https://wiki.multitheftauto.com/wiki/AddCommandHandler https://wiki.multitheftauto.com/wiki/isObjectInACLGroup https://wiki.multitheftauto.com/wiki/OutputChatBox --]]
- 1
-
Arrumado, basta testa :
function ComecarAAssaltar ( source ) if getElementData(source, "TS:Assaltando") then return end local arma = getPedWeapon ( source ) if arma == 0 or arma == 1 or arma == 2 or arma == 3 or arma == 4 or arma == 5 or arma == 6 or arma == 7 or arma == 8 or arma == 9 or arma == 16 or arma == 17 or arma == 18 or arma == 39 or arma == 41 or arma == 42 or arma == 43 or arma == 10 or arma == 11 or arma == 12 or arma == 14 or arma == 15 or arma == 44 or arma == 45 or arma == 46 or arma == 40 then return end if isObjectInACLGroup ( "user." ..getAccountName (getPlayerAccount(source)), aclGetGroup ( "Assalto" ) ) then for i, Policial in ipairs ( getElementsByType ( "player" ) ) do if isObjectInACLGroup ( "user." ..getAccountName ( getPlayerAccount( Policial ) ), aclGetGroup ( "ComandosPolicia" ) ) then triggerClientEvent(Policial, "TS:MensagemPolicial2", Policial) outputChatBox("EX: "..getPlayerName(source).." Está Assaltando a LOJA.", Policial, 255, 255, 255, true ) end end -- Encerra o LOOP. setElementData(source, "TS:Assaltando", true) setPedAnimation(source, "SHOP", "ROB_Loop", -1, false) setPedAnimation(PedLoja, "SHOP", "SHP_Rob_GiveCash", -1, false) setElementFrozen(source, true) toggleAllControls(source, false) setElementPosition(source, 397.9880065918, -1522.498046875, 32.2734375) setElementRotation(source, -0, 0, 100.156) setElementData(PedLoja, "TS:Assaltando", true) setPedAnimation(source, "SHOP", "ROB_Loop", -1, false) setPedAnimation(source, "SHOP", "ROB_Loop", -1, false) setPedAnimation(source, "SHOP", "ROB_Loop", -1, false) setPedAnimation(source, "SHOP", "ROB_Loop", -1, false) setPedAnimation(source, "SHOP", "ROB_Loop", -1, false) LojaAssaltada(source) setTimer( function ( ) setPedAnimation(source, nil) setPedAnimation(PedLoja, nil) setElementFrozen(source, false) toggleAllControls(source, true) givePlayerMoney(source, DinheiroAdicionado ) --/> Adicionado --local Dinheiro = getPlayerMoney ( source ) --setPlayerMoney (source, Dinheiro + DinheiroAdicionado ) setElementData(source, "TS:Assaltando", false) end, 1*60000, 1) else -- Você Não tem Permissão para ASSALTAR ! end end addEvent("TS:IniciarAssalto2", true) addEventHandler("TS:IniciarAssalto2", root, ComecarAAssaltar)
-
Você pode utilizar o evento onPlayerChangeNick.
Ex:
addEventHandler("onPlayerChangeNick", root, function ( oldNick, newNick ) outputChatBox( ""..oldNick.." Mudou o Nome Para "..newNick.."",root, 255, 255, 255, true ) end)
-
Você vai precisar do lado server-side, utilizar o evento "onPlayerLogin", e enviar um trigger event para o client-side.
Ex :
-- server-side addEventHandler("onPlayerLogin", root, function ( ) triggerClientEvent ( source, "PainelLogin:RemoverAnimacao", resourceRoot ) end) -- client-side addEvent("PainelLogin:RemoverAnimacao", true) addEventHandler("PainelLogin:RemoverAnimacao", resourceRoot, function ( ) removeEventHandler ( ) end)
-
Bom, refiz algumas coisas, onde você poder tiras suas dúvidas baseadas no que eu refiz.
local mrk = createMarker(-2405.083, -598.298, 131.648, "cylinder", 3.0, 255, 0, 0, 50) -- local do marker local bikes = { } --/> ADD. function msg ( thePlayer, dimension ) if isElement(thePlayer) and getElementType( thePlayer ) == "player" and dimension then --/> ADD. outputChatBox ("#0000FF|ALUGUEL DE BIKES CLASSE ALTA RP|", thePlayer, 255,255,255, true) outputChatBox ("----------------------------------------", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 1 -|BMX| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 2 -|MOUNTAIN| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 3 -|CLASSIC| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("----------------------------------------", thePlayer, 255,255,255, true) outputChatBox ("#0000FF3Digite '/alugar' e o numero da Bike que deseja.", thePlayer, 255,255,255, true) end end addEventHandler ("onMarkerHit", mrk, msg) function alugar_bike ( thePlayer, cmd, id) if not isElementWithinMarker (thePlayer, mrk) then return outputChatBox ("Comando Apenas Funciona no Marker de Aluguel de Bikes.", thePlayer, 255, 255, 255, true) elseif not id then return outputChatBox ("Utilize o Comando : </alugar id>,", thePlayer, 255, 255, 255, true) elseif not tonumber(id) or ( tonumber(id) <= 0 ) or ( tonumber(id) >= 4 ) then return outputChatBox ("Apenas Permitido Numeros de 1 a 3.", thePlayer, 255, 255, 255, true) elseif getPlayerMoney (thePlayer) < 150 then return outputChatBox ("#FF0000Você não tem dinheiro suficiente para alugar uma bicicleta.", thePlayer, 255, 255, 255, true) end if isElement(bikes[thePlayer]) then destroyElement ( bikes[thePlayer] ) bikes[thePlayer] = nil end if tonumber(id) == 1 then outputChatBox ("#FF0000Você Alugou uma BMX.", thePlayer, 255, 255, 255, true) takePlayerMoney ( thePlayer, 150 ) bikes[thePlayer] = createVehicle(481, -2422.081, -609.549, 132.563) elseif tonumber(id) == 2 then outputChatBox ("#FF0000Você Alugou uma MOUNTAIN.", thePlayer, 255, 255, 255, true) takePlayerMoney ( thePlayer, 150 ) bikes[thePlayer] = createVehicle(510, -2422.081, -609.549, 132.563) elseif tonumber(id) == 3 then outputChatBox ("#FF0000Você Alugou uma CLASSIC.", thePlayer, 255, 255, 255, true) takePlayerMoney ( thePlayer, 150 ) bikes[thePlayer] = createVehicle(509, -2422.081, -609.549, 132.563) end end addCommandHandler ("alugar", alugar_bike )
- 1
-
local Spawndt = createMarker(1166.3742675781,-1263.1636962891,15.250455856323 -1,"cylinder", 1.9, 255, 140, 0, 99) local Destroydt = createMarker(1166.2664794922,-1257.7770996094,15.268055915833 -2,"cylinder", 5.0, 128, 0, 0, 99) 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 local veh = { } function Spawnvtrdt ( thePlayer ) if isElement( veh[thePlayer] ) then destroyElement ( veh[thePlayer] ) veh[thePlayer] = nil end local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "SAMU") ) then veh[thePlayer] = createVehicle(416, 1189.8168945313,-1254.3963623047,15.52241897583, 0,0,180) warpPedIntoVehicle ( thePlayer, veh[thePlayer] ) exports.Scripts_Dxmessages:outputDx(thePlayer, "VEICULO CRIADO COM SUCESSO!", "success") else exports.Scripts_Dxmessages:outputDx(thePlayer, "VOCE NAO É DO SAMU PARA PEGAR ESTE VEICULO!", "error") end end addEventHandler("onMarkerHit", Spawndt, Spawnvtrdt) function Destroydtvtrdt ( thePlayer ) if isElement(thePlayer) and getElementType(thePlayer) == "player" and isElement(veh[thePlayer]) then destroyElement (veh[thePlayer]) veh[thePlayer] = nil exports.Scripts_Dxmessages:outputDx(thePlayer, "VEICULO DESTRUIDO COM SUCESSO!", "success") end end addEventHandler("onMarkerHit", Destroydt, Destroydtvtrdt) function Destroydt ( ) if isElement(veh[source]) then destroyElement (veh[source]) veh[source] = nil end end addEventHandler ("onPlayerQuit", getRootElement(), Destroydt)
Teste lá
- 1
-
addCommandHandler("policia", function ( thePlayer ) --/> comando policia. local contador = 0 --/> cria uma variavel para iniciar uma contagem. for i, players in ipairs ( getElementsByType ( "player" ) ) do --/> fazer um loop em todos jogadores no servidor. if getElementData(players, "TrabalhoPolicial") then --/> então, irá verificar cada player, se o elemento é true, então : contador = contador + 1 --/> adicionar +1 na contagem. end end --/> fim do loop. outputChatBox("Existe "..contador.." PM em Serviço.", thePlayer, 255, 255, 255, true) end)
- 1
-
apesar de haver erros no script, eu ainda não compreendi o que você esta tentando fazer.
Dessa forma que foi feito, setará sempre a col "BaseSVSF1" em todos.
o que eu faria (no meu entender do resource), salvar o nome da col, junto ao xml junto com as outras info, e logo depois apenas puxar esse informação.
addEventHandler("onPlayerLogin", getRootElement( ), function( thePreviousAccount,theCurrentAccount ) local xml = xmlLoadFile("Bases.xml") for i, groupp in pairs ( xmlNodeGetChildren(xml) ) do for i, member in ipairs ( xmlNodeGetChildren(xmlFindChild(groupp,"AllowedPlayers",0)) ) do if xmlNodeGetAttribute(member,"Account") == getAccountName(getPlayerAccount(source)) then local col = tostring(xmlNodeGetAttribute(groupp,"col")) --/> exemplo. / AGREGAR ao seu XML. local base = tostring(xmlNodeGetAttribute(groupp,"NomeBase")) local acc = tostring(xmlNodeGetAttribute(member,"Account")) local rank = tostring(xmlNodeGetAttribute(member,"Rank")) local joined = tostring(xmlNodeGetAttribute(member,"Joined")) setElementData( source, "config:"..col.."", { base, acc, rank, joined } ) local elementos = getElementData(source, "config_base:"..col.."") or {nil,nil,nil,nil) outputChatBox("BASE: "..elementos[1].." ==> "..base.." ", source, 255, 255, 255, true) end end end xmlUnloadFile(xml) end)
- 1
-
--# Você pode usa esta base : setElementData(source, "Aleatorio", { "A","B","C","D" } ) local valores = getElementData(source, "Aleatorio") or {nil,nil,nil,nil} print(valores[1]) ==> A print(valores[2]) ==> B print(valores[3]) ==> C print(valores[4]) ==> D
-
3 minutes ago, WeeD1 said:
Ah sim, entendi. Mas é possível eu fazer algo que após o player digitar o comando ele entre como passageiro de um veiculo? No mesmo modelo desse que você fez
talvez exista alguma maneira, porem, eu desconheço, desculpe
- 1
-
enter_passenger é um comando nativo do MTA, não funcionará.
-
--# server-side : https://wiki.multitheftauto.com/wiki/SetControlState addCommandHandler("teste1", function ( player ) if getPedOccupiedVehicle ( player ) then setControlState( player, "enter_exit", true ) end end) --/ou --# client-side : https://wiki.multitheftauto.com/wiki/SetPedControlState addCommandHandler("teste2", function ( ) if getPedOccupiedVehicle ( localPlayer ) then setPedControlState ( localPlayer, "enter_exit", true ) end end)
- 1
-
file: admin/client/gui/admin_main.lua --# altere na linha 1057 : 1057. guiSetText ( aTab1.IP, "IP: Desabilitado")
- 1
-
On 20/09/2020 at 21:40, Rakashy said:
Quando ele morre, da respawn no hospital com todas as armas, alguém pode me ajudar a resolver este problema ?
Ao morrer o jogador perde todas armas automaticamente, você deve ter um sistema, fazendo o respawn de armas ao spawnar novamente após a morte.
On 20/09/2020 at 21:40, Rakashy said:no caso de eu estar utilizando 1 inventário, eu teria de criar 1 script pra ler e retirar os itens de determinado jogador de dentro do inventário ?
Bom, sendo um sistema de inventário, deve ser em MY/SQL, você vai precisa fazer no resource, ao morrer, remover as informações de armas salvas no db.
On 20/09/2020 at 21:40, Rakashy said:Pode me dar uma ajuda ? como poderia introduzir este sistema ?
Você deu apenas 4 linhas do resource citado, é impossível ajuda-lo desta maneira.
Agora, se você queira uma "luz" de como você possa fazer seu sistema de drop arma, deixarei algo útil para você, basta fazer as alterações de como você deseja.
--[[ ==> Em si, ao morrer, criará um marker, e salvara estas informações numa tabela. ==> Então, ao atingir o marker, pegará as informações estroduzidas na tabela do marker. --]] local table_itens = { } addEventHandler("onPlayerWasted", root, function ( ) local armas = { } for i=1,12 do if getPedWeapon (source, i) > 0 then local w = getWeaponNameFromID (getPedWeapon ( source, i ) ) local m = getPedTotalAmmo ( source, i ) table.insert ( armas, toJSON( {w, m} ) ) end end if table.concat(armas) ~= "" then local x,y,z = getElementPosition(source) local marker = createMarker( x, y, z -1, "cylinder", 3, 255, 0, 0, 100 ) table_itens[marker] = armas end end) addEventHandler("onPlayerMarkerHit", root, function ( hit, d ) if table_itens[hit] then for i, v in pairs(table_itens[hit]) do local itens = fromJSON ( v ) giveWeapon( source, itens[1], itens[2] ) outputChatBox("Você pegou "..itens[1].." com "..itens[2].." Munições", source, 255, 255, 255, true) end table.remove(table_itens[hit]) destroyElement(hit) end end)
espero ter ajudado, e sanado suas dúvidas.
-
já existe no script esta função, porem com um erro de nome de função.
function AbrirAgenciaEmpregos ( ) local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local px, py, pz = getCameraMatrix() local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, worldx, worldy, worldz ) local tx, ty, tz = getElementPosition(localPlayer) local rx, ry, rz = getElementPosition(thePed) local screenWidth,screenHeight = guiGetScreenSize() MunitorC, MunitorL = guiGetScreenSize() abx, aby = (MunitorC/1366), (MunitorL/768) local distancia = getDistanceBetweenPoints3D(tx, ty, tz, rx, ry, rz) if not isEventHandlerAdded("onClientRender", root, AbrirAgenciaEmpregos) then if (distancia < 1.5) then if hit then if elementHit == thePed then addEventHandler("onClientRender", root, AbrirAgenciaEmpregos) showCursor(true) showChat(true) AgenciaEmpregosNew = true end end end end end addEventHandler ("onClientClick", root, AbrirAgenciaEmpregos)
-
Faça uma verificação, se o player esta em trabalho ou não, tanto com tabela ou elemento.
Exemplo :
-- table. local trabalhando = { } -- iniciar trabalho. trabalhando[source] = true -- pegar veiculo. if trabalhando[source] then print("Você pegou o veiculo do trabalho.") else print("Você não trabalha aqui para pegar veiculo.") end -- saiu do trabalho. trabalhando[source] = nil
- 1
-
Para isto, você vai precisar, que sua bindKey, ative um comando.
Exemplo :
-- # Client-Side. addCommandHandler ("painel aleatorio", function ( ) outputChatBox ( "Testar.", 255, 255, 255, true ) end) bindKey("F2", "down", "painel aleatorio")
Então, aparecerá no Esc/Opções/Teclas para ser editada.
- 1
Temporizador para comando, me ajuda :)
in Programação em Lua
Posted
Linha 4, e 5 te ajudará a entender.
Retirando o return, o script apenas irá informar, e continua lendo o código, utilizando o return, ele vai praticamente pausar onde você o utilizou.