Jump to content

Pedro Colto

Members
  • Posts

    133
  • Joined

  • Last visited

Posts posted by Pedro Colto

  1. 2 hours ago, DNL291 said:

    Você podia ter explicado melhor sobre o que você quer fazer e qual valor vai ser salvo no element-data.

    Seria mais ou menos isto?

    
    function createDeathPickup ( totalammo, killer, killerweapon, bodypart )
    	local x, y, z = getElementPosition ( source ) 
    	local aPickup = createPickup ( x, y, z, 3, 1279 )
    	setElementData( aPickup, "pickup-playerValue", (getElementData(source,"valorData") or "0"), false )
    end
    addEventHandler ( "onPlayerWasted", getRootElement(), createDeathPickup )
    
    addEventHandler( "onPickupUse", resourceRoot,
    	function ( player )
    		if getElementData( source, "pickup-playerValue" ) then
    			setElementData( player, "valorData", getElementData( source, "pickup-playerValue" ), false )
    		end
    	end
    )
    

     

    O código não funcionou.

    Vou tentar explicar direito, criei um elementdata que vai representa uma "moeda vip" e player que não são vip podem consegur essas moedas vip após matarem alguém que tenha essas "moedas vip", no caso conseguiria pegar passando nesse pickup mais eles ao invés de pegar uma quantia aleatória eles pegariam a quantia total dessa "moeda vip" que o jogador que morreu tinha e o jogador que morreu perderia essas "moedas vip".

     

    nome do elementdata é "valorData"

  2. function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) 
        x, y, z = getElementPosition ( source ) 
        local valorArg = getElementData(source,"valorData")
        local aPickup = createPickup ( x, y, z, 3, 1279, valorArg)
    	addEventHandler ( "onPickupHit", aPickup, picked)
    end
    addEventHandler ( "onPlayerWasted", getRootElement(), createDeathPickup )
    
    function picked ( player )
    	if getPickupType(source) == 3 then 
    		local amount = getPickupAmount(source) 
    		setElementData(player,"valorData",getElementData(player,"valorData") + tonumber(getPickupAmount(source)) )
    		outputChatBox ( amount, player )
    	end
    end

    Eu queria setar no pickup um valor que ja existia no jogador e após a morte passa para o pickups e quem pegar esse pickups conseguiria obter o valor que o antigo jogador (o jogador que morreu) tinha.

     

    oque estou fazendo de errado?

  3. On 2017-5-29 at 10:01, Lord Henry said:

    Se você estiver se referindo a você mesmo, não é possível desativar o seu blip no mapa (aquele ponteiro branco). A não ser que você desative o mapa inteiro e crie outro sem a função do GPS.

    não amigo, estou me referindo a todos os jogadores aparecerem no map e no gps, segue a print:

     

  4. estou utilizando a gamemode 'play' que vem ja com o mta, gostaria de saber como desativar os blips dos jogadores.

    Tipo eu aperto f11 e aparece o blip do jogador no caso a localzação dele a mesma coisa no gps/radar

    Como desativo isso?

  5. function start (thePlayer,commandName, cmd)
    if commandName == "start" then
    	cmd = "test"
    	 if cmd then
    		triggerClientEvent ( thePlayer, "onClientStart", thePlayer )
    		else
    		outputChatBox("Erro")
    		end	
    	end	
    end
    addCommandHandler("start",start)

    é um comando com espaço, "/start test", mas não esta funcionando, alguém pode me ajudar?

  6. Bem estou tentando fazer um script de cofre, para não pedir muita ajuda quero que me acompanhem para que consiga criar o script..

    Bem como funcionara, o player digita "/cCofre" e cria um objeto e abre um gui pedindo para ele criar uma senha, após ele criar a senha o correto sera ele chegar perto do cofre e aparecer outro gui para que ele digite a senha escolhida e assim após ele colocar a senha correta não precise acontecer nada somente uma mensagem no chat para que depois eu coloque o que deve acontecer...

     

    Codigos:

    Client

    Spoiler
    
    		GUIEditor = {button = {},window = {},edit = {},label = {}}
    		local screenW, screenH = guiGetScreenSize()
    
            GUIEditor.window[1] = guiCreateWindow((screenW - 262) / 2, (screenH - 127) / 2, 262, 127, "", false)
            guiWindowSetSizable(GUIEditor.window[1], false)
    		guiSetVisible(GUIEditor.window[1],false)
    		
            GUIEditor.label[1] = guiCreateLabel(0.00, 0.16, 1.00, 0.18, "Crie sua senha", true, GUIEditor.window[1])
            guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false)
            guiLabelSetVerticalAlign(GUIEditor.label[1], "center")
            GUIEditor.edit[1] = guiCreateEdit((262 - 210) / 2, (127 - 27) / 2, 210, 27, "", false, GUIEditor.window[1])
            GUIEditor.button[1] = guiCreateButton(0.34, 0.66, 0.33, 0.22, "ok", true, GUIEditor.window[1])    
    
            GUIEditor.window[2] = guiCreateWindow((screenW - 262) / 2, (screenH - 127) / 2, 262, 127, "", false)
            guiWindowSetSizable(GUIEditor.window[2], false)
    		guiSetVisible(GUIEditor.window[2],false)
    		
            GUIEditor.label[2] = guiCreateLabel(0.00, 0.15, 1.00, 0.22, "Digite a senha correta", true, GUIEditor.window[2])
            guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false)
            guiLabelSetVerticalAlign(GUIEditor.label[2], "center")
            GUIEditor.edit[2] = guiCreateEdit(38, 47, 192, 33, "", false, GUIEditor.window[2])
            GUIEditor.button[2] = guiCreateButton(101, 90, 67, 27, "ok", false, GUIEditor.window[2])    
    
    		addEvent("cGuiPassWord",true)
    		function cGuiPassWord ()
    			guiSetVisible(GUIEditor.window[1],true)
    			showCursor(true)
    		end
    		addEventHandler("cGuiPassWord",root,cGuiPassWord)		
    		
    		addEvent("cGuiPassWord",true)
    		function cGuiPassWord ()
    			guiSetVisible(GUIEditor.window[1],true)
    			guiSetVisible(GUIEditor.window[2],false)
    			showCursor(false)
    		end
    		addEventHandler("cGuiPassWord",root,cGuiPassWord)
    		
    		addEvent("sGuiPassWord",true)
    		function sGuiPassWord ()
    			guiSetVisible(GUIEditor.window[2],true)
    			guiSetVisible(GUIEditor.window[1],false)
    			showCursor(false)
    		end
    		addEventHandler("sGuiPassWord",root,sGuiPassWord)
    		
    		
    	

     

     Server

    Spoiler
    
    function cCofre(thePlayer)
    local x,y,z = getElementPosition( thePlayer )
    local obj = createObject ( 1829, x+3,y,z, 0, 0, 0 )
    local col = createColSphere(x+3,y,z,2)
    outputChatBox("cCofre")
    triggerClientEvent ( thePlayer, "cGuiPassWord", thePlayer)
    end
    addCommandHandler("cCofre",cCofre)
    
    
    
    function colEnter ( thePlayer, matchingDimension )
    	if getElementType ( thePlayer ) == "player" then
    		--local nameOfThePlayer = getPlayerName ( thePlayer )
    		outputChatBox ( "colEnter", getRootElement(), 255, 255, 109 )
    		triggerClientEvent ( thePlayer, "sGuiPassWord", thePlayer)
    	end
    end
    addEventHandler ( "onColShapeHit", root, colEnter )

     

     

  7. function consoleCreateMarker ( playerSource, commandName )
    	if ( playerSource ) then
    		x, y, z = getElementPosition ( playerSource )
    		createMarker ( x, y, z, 0, "checkpoint", 255, 0, 0, 255 )
    		outputChatBox ( "You got a red marker", playerSource )
    	end
    end
    addCommandHandler ( "createmarker", consoleCreateMarker )
    
    
    addEventHandler("onPlayerLogin", root,
      function(playerSource)
        executeCommandHandler ( "createmarker", playerSource )
      end
    )

    Já coloquei o recurso no grupo admin e console, mesmo assim da warning avisando que o script não esta permitido para dar "ExecuteCommandHandler"

    terá alguma grupo ou areá para permitir, não esta dando certo, já coloque corretamente nos grupos da acl e nada, ja tentei colocando o seguinte;

    <object name="resource.*"></object>
    
    <!-- E também com o proprio nome do recurso -->
    
    <object name="resource.test"></object>

     

  8. 19 hours ago, Pedro861 said:

    Como assim meu xará setTimer dentro de onClientRender?

     

    o correto seria crie um setTimer dentro da função onde esta ligado o evento someRoda1

    após isso criar um outro evento dando kill no timer, tipo esse:

    
    addEvent("eventName",true)
    addEventHandler("eventName",root,
    function()
    	timers = getTimers ( 5000 ) -- obtém os milissegundo (ms) existentes 
    	for timerKey, timerValue in ipairs(timers) do
            killTimer ( timerValue )
            outputChatBox("tempo cancelado!")
    	end
    end)
    

    e ai sim chamar quando você quiser cancelar o tempo.

    Obrigado, consegui dar killtimer pelo server, não esta exatamente desses jeito que vc quis dizer mas pelo menos me ajudou a refazer a parte server e funcionou. Muito obrigado mesmo @Pedro861 e @DNL291.

    • Like 1
  9. function pedro(frontLeft, rearLeft, frontRight, rearRight)
    	if localPlayer == getLocalPlayer() then
    		local theVehicle = getPedOccupiedVehicle ( localPlayer )
    		for i, vehiclea in ipairs(getElementsByType("vehicle")) do 
    			local speedX, speedY, speedZ = getElementVelocity ( vehiclea  )
    			local actualSpeed = (speedX^2 + speedY^2 + speedZ^2)^(0.5) 
    			local KMH = math.floor(actualSpeed*180)	
    			local frontLeft, rearLeft, frontRight, rearRight = getVehicleWheelStates ( theVehicle ) 
    			if frontLeft == 1 and theVehicle and KMH > 29 then
    				outputChatBox(""..frontLeft)
    				timer_Varible = setTimer(function()triggerServerEvent ( "someRoda1", root)end,5000,1)
    				outputChatBox(KMH)
    			else
    				if frontLeft == 1 and theVehicle and KMH < 29 then
    					if isTimer(timer_Varible) then
    						killTimer(timer_Varible)
    						timer_Varible=nil
    						outputChatBox("AFF")
    					end	
    				end	
    			end	
    		end	
    	end	
    end
    ..

    O evento é "onClientRender".

    não esta dando kill no timer, me ajuda pfvr.

  10. Olha desta forma que eu tentei fazer, mas também sem sucesso..

     

    function closeDoor(player,colshape)
    	local data = DoorsTable[colshape]
    	if data == nil then return end
    	if getElementData(data["door"],"object.moved") == "moved"  and getElementData(player,"gang") == data["camp"] or data.camp == "false" or not data["camp"] then
    			moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,-90)
    			setElementRotation(data["door"],data.rot.x,data.rot.y,data.rot.z - -90)
    			--setElementData(data["door"],"object.moved","notmoved")
    			setElementData(data["door"],"object.moved","notmoved") 
    			outputChatBox(getElementData(data["door"],"object.moved"))
    			end
    end
    ahuh=false
    
    function openDoor(player, key, keyState, colshape)
    	local data = DoorsTable[colshape]
    	if data == nil then return end
    	local rx,ry,rz=getElementRotation(data["door"])
    	if ahuh and getElementData(data["door"], "object.moved") == "notmoved" and getElementData(player,"gang") == data["camp"] or data.camp == "false" or not data["camp"] then
    		ahuh=true
    		moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,90)
    		setElementData(data["door"],"object.moved","moved") 
    		outputChatBox(getElementData(data["door"],"object.moved"))
    				
    		--setTimer(closeDoor,5000,1,colshape)
    	end
    		if getElementData(data["door"],"object.moved") == "moved" then
    		closeDoor()
    		outputChatBox("check")
    		ahuh=false
    end
    end
    
    function bind(hitPlayer, matchingDimension) 
    	if getElementType(hitPlayer) == "player" then
    		if isKeyBound( hitPlayer, ",", "down", openDoor ) ~= true then
    			bindKey(hitPlayer, ",", "down", openDoor, source)
    			outputChatBox("onColShapeHit add bind")
    		end
    	end
    end 
    addEventHandler("onColShapeHit", resourceRoot, bind) 

     

  11. 8 hours ago, DNL291 said:

    Tente:

    
    function openDoor(player, key, keyState, colshape)
    	local data = DoorsTable[colshape]
    	if data == nil then return end
    	local rx,ry,rz=getElementRotation(data["door"])
    	if getElementData(player,"gang") == data["camp"] or data.camp == "false" or not data["camp"] then
    		moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,90)
    		setTimer(closeDoor,5000,1,colshape)
    	end
    end
    
    function bind(hitPlayer, matchingDimension) 
    	if getElementType(hitPlayer) == "player" then
    		if isKeyBound( hitPlayer, ",", "down", openDoor ) ~= true then
    			bindKey(hitPlayer, ",", "down", openDoor, source)
    			outputChatBox("onColShapeHit add bind")
    		end
    	end
    end 
    addEventHandler("onColShapeHit", resourceRoot, bind) 
    

     

    Certo entendi, pode me explicar como consigo fazer para a mesma bind fechar a porta apos ela esta na rotação de "open"/"aberta"??

    eu devo dar uma data para objeto ligado a rotação, isso que to meio confuso -'

  12. ..
    function openDoor(hitElement)
    	local data = DoorsTable[source]
    	if data == nil then return end
    	local rx,ry,rz=getElementRotation(data["door"])
    	if getElementData(hitElement,"gang") == data["camp"] or data.camp == "false" or not data["camp"] then
    		moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,90)
    		setTimer(closeDoor,5000,1,source)
    	end
    end
    addEventHandler("onColShapeHit",resourceRoot,openDoor)
    ..

     

  13. ..
    function openDoor()
    local data = DoorsTable[source]
    	if data == nil then return end
    	local rx,ry,rz=getElementRotation(data["door"])
    	if getElementData(source,"Group") == data["camp"] or data.camp == "false" or not data["camp"] then
    		moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,90)
    		--setTimer(closeDoor,5000,1,source)
    	end
    end
    --addEventHandler("onColShapeHit",resourceRoot,openDoor)
    
    function bind(hitPlayer, matchingDimension) 
    	if getElementType(hitPlayer) == "player" then 
    		bindKey(hitPlayer, ",", "down", openDoor) 
    		outputChatBox("onColShapeHit add bind")
    	end 
    end 
    addEventHandler("onColShapeHit", resourceRoot, bind) 
    
    ..

    Este é meu código.

    Oque ele deveria fazer? Quando o player chegar nesse Col Shape (dar hit) o objeto se mover apenas quando o player aperta a bind "," porém não é isso que acontecesse, sinceramente nada acontece, não da warning nem erro e o objeto continua sem se mover... 

    Se eu coloco o evento "onColShapeHit" ligado a função openDoor() funciona normal, no caso a porta abre só quando o player der hit no col shape..

    Oque estou fazendo de errado?

  14. 19 hours ago, DNL291 said:

    Esse erro era porque você criou outra função, lá no setTimer, aí source retornava nulo. Nesse caso, você precisa passar o jogador no parâmetro, desta forma:

    
    function onPlayerLogin (_, playeraccount )
    	if ( playeraccount ) then
    		local playerfood = getAccountData ( playeraccount, "hud.food" )
    		if ( playerfood ) then
    			setTimer( function( p )
    				setElementData(p,"food", playerfood) 
    				outputDebugString (  playerfood )
    			end, 500, 1, source )
    		end
    	end
    end
    

     

    Muito obrigado por tentar ajudar, mas ja resolvi, até postei ai nos comentários ja que não consegui editar o topic

  15. [RESOLVIDO]

    Aqui esta o código para quem tiver a mesma duvida de save em SetElementData

    Créditos (Meus) Pedro861

     

    function onPlayerQuit ( )
          local playeraccount = getPlayerAccount ( source )
          if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
                local playerfood = getElementData(source, "food")
                setAccountData ( playeraccount, "hud.food", playerfood )
    			outputDebugString (  getPlayerName(source).. " - [SALVO FOOD: "..playerfood.."]" )
          end
    end
     
    function onPlayerLogin (_, playeraccount,thePlayer )
     local thePlayer = getAccountPlayer ( playeraccount )
        if ( getElementType ( thePlayer ) == "player" ) then 
    		  if ( playeraccount ) then
    				local playerfood = getAccountData ( playeraccount, "hud.food" )
    				if ( playerfood ) then
    					  setTimer(function()
    					  setAccountData( playeraccount,"hud.food",tonumber( getAccountData(playeraccount,"hud.food") or 0 ) )  -- Não ha necessidade de ter essa linha, coloquei só por prevenção.
    					  setElementData( thePlayer, "food",tonumber( getAccountData(playeraccount,"hud.food") or 0 ) ) 
    					  outputDebugString (  playerfood )
    					end,500,1)
    				end
                end
          end
    end
     
    addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
    addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin )

     

    OBS: É um sistema save não há porque escode-lo de quem precisa!

  16. function onPlayerQuit ( )
          local playeraccount = getPlayerAccount ( source )
          if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
                local playerfood = getElementData(source, "food")
                setAccountData ( playeraccount, "hud.food", playerfood )
    			outputDebugString (  getPlayerName(source).. " - [SALVO FOOD: "..playerfood.."]" )
          end
    end
     
    function onPlayerLogin (_, playeraccount )
          if ( playeraccount ) then
                local playerfood = getAccountData ( playeraccount, "hud.food" )
                if ( playerfood ) then
    				  setTimer(function()
    				  setElementData(source,"food", playerfood) 
    				  outputDebugString (  playerfood )
    				end,500,1)
                end
          end
    end
     
    addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
    addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin )

    NÃO ESTOU CONSEGUINDO ENTENDER ESSE WARNING MDS!

    QUEM PODER ME AJUDAR...

    WARNING que aparece:

    xCHzQgD.png

  17. Pra quê serve este script? Serve só pra criar essa cadeira e anexá-la ao carro?

    Pelo que eu vi nas imagens o objeto foi criado e não há erros no código.

    Se o problema for offSet, edita os últimos 3 argumentos do código.

    Pra deixar o objeto acima do carro, por exemplo, só editar o último argumento, isto é, a posição Z do alinhamento.

    seria um sistema de uma arma especial, vou dar um exemplo: esta arma seria criar objetos no carro mais apenas admin poderia fazer isso sacou, seria um personalização de carro com arma hushsuhs, mais eu só preciso dessa parte ai que eu pedi ajuda na parte de selecionar acl e o resto ja esta feito.... é mesmo uma personalização que cria luzes etc onde o admin atira no carro...

    resumo: a arma criara um objeto fixado no carro aonde a bala acertar ..... não em uma posição setada no script, mais sim uma posição onde a bala acertar no carro.

×
×
  • Create New...