- 
                Posts3,875
- 
                Joined
- 
                Days Won67
Everything posted by DNL291
- 
	Probably your code is set as client-side on the meta.xml. And on the client-side there is no 'player' parameter for addCommandHandler. You should learn the difference between client and server-side, I also recommend you study programming logic and Lua syntax in the MTA.
- 
	Se quiser postar em português use a seção Portuguesa, aqui: Portuguese / Português Server-side version: function showLocalHealth( thePlayer ) -- get the player's health and output it local playerHealth = getElementHealth ( thePlayer ) outputChatBox ( "Your health: " .. playerHealth ) -- get the player's vehicle: if he is in one, output its health as well local playerVehicle = getPedOccupiedVehicle ( thePlayer ) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) / 10 -- Divide this by 10, as default the denominator is 1000 outputChatBox ( "Your vehicle's health: " .. vehicleHealth, thePlayer ) end end addCommandHandler ( "showhealth", showLocalHealth )
- 
	Ok, atualizei o código, coloquei uma verificação no evento onPlayerMarkerLeave.
- 
	Tente o seguinte (não testado): function openPainel (marker, md) if getElementData (source, "DeltaSCR_HaveRG") ~= "Sim" then if md and marker == mkRG then triggerClientEvent ( source, "DeltaSCR_OCRG", source, true ) end else outputChatBox ("#ffff00Atenção: Você já possui seu RG", source, 255, 255, 255, true) end end addEventHandler ("onPlayerMarkerHit", getRootElement(), openPainel) function closePainel (marker, md) if md and marker == mkRG and getElementData (source, "DeltaSCR_HaveRG") ~= "Sim" then triggerClientEvent ( source, "DeltaSCR_OCRG", source ) end end addEventHandler ("onPlayerMarkerLeave", getRootElement(), closePainel) Client: function openCreateRG( open ) if open then -- abrir o painel showCursor (true) -- O resto é desnecessário postar else -- fechar showCursor (false) end end addEvent( "DeltaSCR_OCRG", true ) addEventHandler( "DeltaSCR_OCRG", root, openCreateRG )
- 
	It should work, I see no errors by looking at the code. Make sure to set it as client-side in meta.xml and type the command correctly.
- 
	I would do that using image.
- 
	Respondido aqui:
- 
	O salvamento em banco de dados no lugar do setAccountData acho que foi uma escolha dele, em banco de dados pode ser feito um sistema para mostrar os dados fora do server por exemplo. E o set/get dos diamantes no server está sendo feito com element-data fazendo com que o banco de dados seja utilizado quando é realmente necessário - pelo que eu vejo no código e que está correto em questão de otimização. Embora seja uma forma melhor armazenar temporariamente com tabelas, mas se tiver usando esses dados no lado cliente então não vejo problemas; se não tiver usando esses dados no lado cliente, de fato, o mínimo a se fazer é desativar a sinc no setElementData.
- 
	https://community.multitheftauto.com/index.php?p=gallery&s=show&pic=13813 https://community.multitheftauto.com/index.php?p=gallery&s=show&pic=13196
- 
	"onPlayerLogin" getAccountData -- verifica se o jogador já tem um time salvo triggerClientEvent -- se são tiver, chama um evento client para criar a janela setPlayerTeam -- se já tiver, apenas seta o time addEvent addEventHandler guiCreateWindow guiCreateButton guiCreateGridList guiGridListAddColumn guiGridListAddRow guiGridListSetItemText "onClientGUIClick" guiGridListGetSelectedItem guiSetVisible setPlayerTeam -- usa um trigger event; seta no lado server --salvar team "onPlayerQuit" getPlayerAccount isGuestAccount getPlayerTeam getTeamName setAccountData "onResourceStop" getElementsByType -- loop -- + algumas das funções acima para obter o time e salvar na conta
- 
	Esse erro foi por não ter passado o jogador na função targetF - linha 14. Linha 14 > targetF(source)
- 
	Entendi. Mas deveria funcionar com o source, pode ser que você tenha definido uma variável global com esse mesmo nome e esteja dando conflito. Sobre o LIMIT 1 ele vai fazer retornar apenas 1 resultado da consulta; e valor do banco de dados, é retornado numa tabela definida com chaves (o datas["Diamantes"] por exemplo).
- 
	Não entendi o propósito do loop aí, se for executar só pro source então mais fácil você tirar o resto que é desnecessário: addEventHandler("onPlayerLogin", root, function() loadDiamonds(source) end ) --quit addEventHandler("onPlayerQuit", root, function() if not (isGuestAccount(getPlayerAccount(source))) then saveDiamonds(source) end end )
- 
	local criar = createMarker(1604.15, -1612.056, 13.881, 'corona', 1.0, 0, 255, 255, 0 ) function vehicleSpawner(hitElement,matchingDimension) if getElementType(hitElement) == "player" then local vehicle = getPedOccupiedVehicle(hitElement) if vehicle == false then local veh = createVehicle(599, 1604.15, -1612.056, 13.881) warpPedIntoVehicle(hitElement,veh) elseif vehicle then destroyElement( vehicle ) end end end addEventHandler("onMarkerHit",criar,vehicleSpawner)
- 
	Eu tinha mandado o código com o [4], depois corrigi o erro kk. E aquele loop nos players no onPlayerLogin? o certo não seria chamar só pra quem logou? E o loop no evento onResourceStart.
- 
	@Ryan Pablo Da próxima vez poste na seção em Português: Portuguese / Português Sobre o seu problema, use tabela para organizar os locais de spawn, exemplo: local spawnTorcidas = { ["flamengo"] = { spawnX, spawnY, spawnZ, spawnRot }, ["corinthians"] = { spawnX, spawnY, spawnZ, spawnRot }, } addEventHandler( "onPlayerLogin", root, function() if getPlayerTeam(source) then local x,y,z,rot = 0,0,0,0 local team = getPlayerTeam(source) if spawnTorcidas[getTeamName(team)] then x,y,z,rot = unpack( spawnTorcidas[getTeamName(team)] ) end spawnPlayer( source, x, y, z, rot ) end end )
- 
	Ninguém responde porque ninguém vai te entender postando em Português na seção internacional. Poste aqui da próxima vez: Portuguese / Português
- 
	Tenta isto: function loadDiamonds(player, acc) local accName = getAccountName(getPlayerAccount(player)) local datas = db:query("SELECT * FROM Diamonds WHERE Usuario=? LIMIT 1", accName) if (datas and type(datas) == "table" and #datas > 0) then datas = datas[1] db:query("UPDATE Diamonds SET Nick=?, Usuario=?, Serial=?, Diamantes=?", getPlayerName(player):gsub("#%x%x%x%x%x%x", ""), accName, getPlayerSerial(player), datas["Diamantes"]) setElementData(player, "CRP:Diamonds", tonumber(datas["Diamantes"])) else setElementData(player, "CRP:Diamonds", 10) db:exec("INSERT INTO Diamonds VALUES (?, ?, ?, ?)", getPlayerName(player):gsub("#%x%x%x%x%x%x", ""), accName, getPlayerSerial(player), getElementData(player, "CRP:Diamonds") or 10) end end Edit: correção.
- 
	Use onClientResourceStart to trigger the event "playerLoadItemsToServer" or trigger another server event to mark that the client is ready to communicate with the server side. Also, you'll need to remove any call for the function 'loadPlayerItems' in events that should be causing that error (it may be the event "onResourceStart" for example).
- 
	Não quero ser chato mas é questão de respeitar as regras, evite usar o tópico como chat ou com mensagens fora do assunto, você pode mandar mensagem em privado nesse caso.
- 
	Sem problemas. Quando for assim, use o comando debugscript 3 e mostre aqui a mensagem de erro, poderia também ter mostrado o código que você testou.
- 
	Esses 2 eventos é dentro da função pegartrab4 como eu já disse, não precisa nem de conhecimento em programação para fazer, acho que você nem tentou ao menos colar na função e testar, dá próxima vez faça a sua parte, aqui o código: local trab4 = createMarker ( 1222.684, -1789.943, 15.7, "cylinder", 1.5, 255, 140, 0, 255) local marcacao = createMarker ( 2482.79126, -2090.34351, 18.54296, "arrow", 1.5, 255,140,0, 255) setElementVisibleTo ( marcacao, root, false ) local entregartrab4 = createMarker ( -2336.06299, -1660.78528, 483.70313 , "corona", 3, 0, 255, 209, 255) setElementVisibleTo ( entregartrab4, root, false ) local blipfim4 = createBlipAttachedTo(entregartrab4, 41, 3, 255, 0, 0, 255, 0, 65535, source) setElementVisibleTo ( blipfim4, root, false ) function msg (source) outputChatBox ('#ffffffPara pegar o trabalho digite #ff0000/caminhoneiro', source, 255, 255, 255, true) end addEventHandler( "onMarkerHit", trab4, msg ) local carga = {} local veh = {} function pegartrab4 ( source ) if isElementWithinMarker (source, trab4 ) then if veh[source] and isElement( veh[source] ) then destroyElement(veh[source] ) veh[source] = nil end local x,y,z = getElementPosition(source) veh[source] = createVehicle(403 ,2479.15234, -2091.43652, 14.56156) carga[source] = createVehicle(450 ,2487.23511, -2090.43604, 13.54688 + 1) setElementVisibleTo ( marcacao, root, true ) setElementRotation ( veh[source], 0, 0, 90) setElementRotation ( carga[source], 0, 0, 90) warpPedIntoVehicle (source,veh[source]) setElementVisibleTo ( blipfim4, source, true ) setElementVisibleTo ( entregartrab4, source, true ) outputChatBox ('#ffffffAgora pegue a carga e leve-a até o Blip no #FF0000Mount Chilliad.', source, 255, 255, 255, true) setTimer ( function() setElementVisibleTo ( marcacao, root, false ) end, 13000, 1 ) addEventHandler( "onVehicleStartEnter", veh[source], function ( player ) if not (veh[player]) or veh[player] ~= source then cancelEvent() end end ) local player = source addEventHandler( "onVehicleExplode", veh[source], function() destroyPlayerVehicles( player ) end ) addEventHandler( "onVehicleExplode", carga[source], function() destroyPlayerVehicles( player ) end ) else outputChatBox ('#ffffffVocê tem que ficar no lugar certo para pegar o Trabalho de Caminhoneiro.', source, 255, 255, 255, true) end end addCommandHandler ( "caminhoneiro", pegartrab4 ) function finalizartrab4 (source) if veh[source] and isElement(veh[source]) then if (carga[source]) and isElement(carga[source]) then setElementVisibleTo ( entregartrab4, source, false ) setElementVisibleTo ( blipfim4, source, false ) givePlayerMoney (source, 8000) destroyElement (veh[source]) destroyElement (carga[source]) outputChatBox ('#ffffffTrabalho finalizado, você recebeu #0F9C08$8.000 #FFFFFFpelo serviço.', source, 255, 255, 255, true) else end end end addEventHandler( "onMarkerHit", entregartrab4, finalizartrab4 ) addEventHandler( "onPlayerQuit", function() if veh[source] then destroyPlayerVehicles( source ) end end ) function sair4 (vehicle) if eventName == "onPlayerVehicleExit" and veh[source] and vehicle == veh[source] then destroyPlayerVehicles( source ) end if (veh[source]) and isElement(veh[source]) then destroyPlayerVehicles( source ) setElementVisibleTo ( blipfim4, source, false ) setElementVisibleTo ( entregartrab4, source, false ) outputChatBox ('#ffffffVocê saiu do veículo e perdeu o trabalho.', source, 255, 255, 255, true) end end addEventHandler ("onPlayerVehicleExit", root, sair4) addEventHandler ("onPlayerWasted", root, sair4) function destroyPlayerVehicles( p ) if p then if (veh[p]) and isElement(veh[p]) then destroyElement (veh[p]) veh[p] = nil end if (carga[p]) and isElement(carga[p]) then destroyElement (carga[p]) carga[p] = nil end end end
- 
	Valeu, funcionou graças a você que se esforçou pra fazer uma parte difícil pra quem tá iniciando que é tabelas. Continue assim e você irá aprender rapidamente, programação não é para preguiçosos.
- 
	Você não passou o jogador pra função depois de 1 no fim da função. Você pode fazer assim que será mais fácil: setTimer( fadeCamera, 5000, 1, source, true, 1.0 )

 
         
                 
					
						