Jump to content

Dúvidas sobre algumas coisas / Script de LimparFicha


Recommended Posts

Olá , eu estou criando de delegacia e limparficha porém algumas coisas não estão a funcionar e eu tenho a certeza que estão corretas,

queria também fazer algumas questões que eu não encontrei na internet.

delentrar = createMarker (1555.1665039063,-1675.5999755859,15.1953125 ,"cylinder",1,255,255,255,50)
delsair = createMarker (246.8049621582,62.963237762451,1002.640625 ,"cylinder",1,255,255,255,50)
setElementDimension(delsair,0)
setElementInterior(delsair,6)

function teleporte1 (source)
setElementPosition(source,246.44583129883,67.712219238281,1003.640625)
setElementDimension(source,0)
setElementInterior(source,6)
end
addEventHandler("onMarkerHit",delentrar,teleporte1)

function teleporte2 (source)
setElementPosition(source,1550.6947021484,-1675.6839599609,15.521661758423)
setElementDimension(source,0)
setElementInterior(source,0)
end
addEventHandler("onMarkerHit",delsair,teleporte2)

esse é a parte do script de entrar/sair da delegacia , porém quando eu passo em cima dos markers nada acontece.

CkISqfQ.jpg

Nesta foto aqui tenho uma dúvida que é a seguinte : como colocar a palavra "Limpar Ficha" por cima do marker (flutuando)

outra coisa é o meu código de limpar a ficha não está funcionando fiquei pesquisando e não encontrei nada. se alguém puder dizer os erros que cometi no código ficaria muito agradecido! 

este é o primeiro script tão complexo que crio.

estrelasL = createMarker(256.59426879883,66.13907623291,1002.640625, "cylinder" ,1,0,0,255,100)
setElementDimension(estrelasL,0)
setElementInterior( estrelasL,6)

function msg(player)
		outputChatBox("Use /limparficha para remover suas estrelas de procurado!", player, 255, 255, 255, true)
	end
addEventHandler("onMarkerHit",estrelasL,msg)


function limparE (player,commandName)
		if getPlayerMoney(source) > 1499 then
			setPlayerWantedLevel(source,0)
			takePlayerMoney(source , 1499)
			outputChatBox("[Delegacia] Você limpou a sua ficha!" , player ,255,255,255,true)
	    else
			outputChatBox("[Delegacia] Você não tem dinheiro suficiente!")
		end
	if isElementWithinMarker(player, estrelasL) then
	end
end
addEvent("limparE", true)
addEventHandler("limparficha" , getRootElement() , limparE)

vou explicar o código . dentro da delegacia existe um marker azul , quando a pessoa passa-se por cima do marker aparecia um painel dx mas desisti dessa ideia e decidi criar normalmente.

quando ele passa-se por cima do marker aparecer uma mensagem no chat para ele usar o /limparficha  para limpar as ficha e remover todas as estrelas , e caso ele não tivesse dinheiro aparecia a outra mensagem "Você não tem dinheiro" , se alguém poder me ajudar ficaria muito agradecido!

Link to comment
function limparE (player, commandName)
	if isElementWithinMarker (player, estrelasL) then
  		if getPlayerMoney (player) >= 1500 then
			setPlayerWantedLevel (player, 0)
			takePlayerMoney (player , 1500)
			outputChatBox("[Delegacia] Você limpou a sua ficha!" , player)
		else
			outputChatBox("[Delegacia] Você não tem dinheiro suficiente!", player)
		end
	end
end
addEvent("limparE", true)
addEventHandler("limparficha" , getRootElement() , limparE)

Tente assim o de limpar a ficha.

Edited by Jonas^
  • Thanks 1
Link to comment

Esta é a parte toda que tem a ver com o  Limpar Ficha 

estrelasL = createMarker(256.59426879883,66.13907623291,1002.640625, "cylinder" ,1,0,0,255,100)
setElementDimension(estrelasL,0)
setElementInterior( estrelasL,6)

function msg(player)
		outputChatBox("Use /limparficha para remover suas estrelas de procurado!", player, 255, 255, 255, true)
	end
addEventHandler("onMarkerHit",estrelasL,msg)


function limparE (player, commandName)
	if isElementWithinMarker(player, estrelasL) then
  		if getPlayerMoney(player) > 1499 then
			setPlayerWantedLevel(player,0)
			takePlayerMoney(player , 1499)
			outputChatBox("[Delegacia] Você limpou a sua ficha!" , player ,255,255,255,true)
		else
			outputChatBox("[Delegacia] Você não tem dinheiro suficiente!", player)
		end
	end
end
addEvent("limparE", true)
addEventHandler("limparficha" , getRootElement() , limparE)

 

 

Edited by Renazz
editar comando
Link to comment

Aí não tem nenhum comando, logicamente não vai funcionar, desculpa a demora, caiu a energia aqui, oque você estava fazendo de errado:

R: Você declarou 'player'  como parâmetro e estava usando 'source' e esqueceu de fazer a verificação se o cara realmente esta procurado ou não, adicionei o marker no centro do mapa e adicionei um comando pra você ir até ele e testar, use: /ir.

Correção:

local estrelasL = createMarker (0, 0, 3, "cylinder", 1, 0, 0, 255, 100)
setElementDimension (estrelasL, 0)
-- setElementInterior (estrelasL, 6)

function msg (thePlayer)
	outputChatBox ("Use /limparficha para remover suas estrelas de procurado!", thePlayer, 0, 255, 0)
end
addEventHandler ("onMarkerHit", estrelasL, msg)

function clearFicha (thePlayer, cmd)
	if isElementWithinMarker (thePlayer, estrelasL) then -- Se o jogador estiver no marker, então:
		if getPlayerMoney (thePlayer) >= 1500 then -- Se o jogador tiver 1500 ou mais, então:
			if getPlayerWantedLevel (thePlayer) > 0 then -- Se o jogador tiver + de 1 estrela de procurado, então:
				setPlayerWantedLevel (thePlayer, 0) -- Seta a estrela do jogador em 0
				takePlayerMoney (thePlayer , 1500) -- Retira a quantia do jogador, 1500.
				outputChatBox ("[Delegacia] Você limpou a sua ficha e pagou $1500!" , thePlayer, 0, 255, 0)
			else
				outputChatBox ("[Delegacia] Você não esta procurado!", thePlayer, 255, 30, 30)
			end
		else	
			outputChatBox ("[Delegacia] Você não tem dinheiro suficiente!", thePlayer, 255, 30, 30)
		end
	else
		outputChatBox ("Você não esta na delegacia.", thePlayer, 255, 30, 30)
	end	
end
addCommandHandler ("limparficha", clearFicha)

addCommandHandler ("ir", function (thePlayer)
	setElementPosition (thePlayer, 0, 2, 3)
end)	

 

Edited by Jonas^
Correção.
  • Thanks 1
Link to comment

Enfim, aqui funcionou perfeitamente, você esta fazendo alguma coisa errada ai colega, o comando não tem nenhum erro de sintaxe.

/debugscript 3

Limpe seu arquivo server, coloque somente essa parte pra testar.

Edited by Jonas^
  • Thanks 1
Link to comment
  • vou reiniciar o servidor aqui é ver já dou meu feedback se funcionou ou não

beleza está funcionando , depois é só mudar as cordenadas do marker azul correto? 

 

no caso eu mudei as cordenadas do marker azul e apaguei aquele addCommandHandler do "ir" e ele está me dizendo que não estou na delegacia sendo que o marker está aqui -'

Link to comment
local delentrar = createMarker (1554, -1675, 15, "cylinder", 1.3, 255, 255, 255, 50)
local estrelasL = createMarker (256, 66, 1003, "cylinder", 1.3, 0, 0, 255, 100)
setElementDimension (estrelasL, 1)
setElementInterior (estrelasL, 6)
local delsair = createMarker (247, 63, 1003, "cylinder", 1.3, 255, 255, 255, 50)
setElementDimension (delsair, 1)
setElementInterior (delsair, 6)

function msg (thePlayer)
	outputChatBox ("Use /limparficha para remover suas estrelas de procurado!", thePlayer, 0, 255, 0)
end
addEventHandler ("onMarkerHit", estrelasL, msg)

function teleporte1 (thePlayer)
	setElementPosition (thePlayer, 246.44583129883, 67.712219238281, 1003.640625)
	setElementInterior (thePlayer, 6)
	setElementDimension (thePlayer, 1)
end
addEventHandler ("onMarkerHit", delentrar, teleporte1)

function teleporte2 (thePlayer)
	setElementPosition (thePlayer, 1543, -1675, 13)
	setElementInterior (thePlayer, 0)
	setElementDimension (thePlayer, 0)
end
addEventHandler ("onMarkerHit", delsair, teleporte2)

function clearFicha (thePlayer, cmd)
	if isElementWithinMarker (thePlayer, estrelasL) then -- Se o jogador estiver no marker, então:
		if getPlayerMoney (thePlayer) >= 1500 then -- Se o jogador tiver 1500 ou mais, então:
			if getPlayerWantedLevel (thePlayer) > 0 then -- Se o jogador tiver + de 1 estrela de procurado, então:
				setPlayerWantedLevel (thePlayer, 0) -- Seta a estrela do jogador em 0
				takePlayerMoney (thePlayer , 1500) -- Retira a quantia do jogador, 1500.
				outputChatBox ("[Delegacia] Você limpou a sua ficha e pagou $1500!" , thePlayer, 0, 255, 0)
			else
				outputChatBox ("[Delegacia] Você não esta procurado!", thePlayer, 255, 30, 30)
			end
		else	
			outputChatBox ("[Delegacia] Você não tem dinheiro suficiente!", thePlayer, 255, 30, 30)
		end
	else
		outputChatBox ("Você não esta na delegacia.", thePlayer, 255, 30, 30)
	end	
end
addCommandHandler ("limparficha", clearFicha)

addCommandHandler ("ir", function (thePlayer)
	setElementPosition (thePlayer, 1543, -1675, 13)
end)

Digite /ir para ir até a delegacia, todos markeres estão nas posições normais novamente.

  • Thanks 1
Link to comment

Ainda falta colocar o comando anexado no marker, pra colocar coisas anexada ao marker é pelo client, então vamos ter que usar os 2 lados, server e client, é um pouco mais complicado, mas vou fazer pra você entender, faça assim:

client-side

local estrelasL = createMarker (256, 66, 1003, "cylinder", 1.3, 0, 0, 255, 100)
setElementDimension (estrelasL, 1)
setElementInterior (estrelasL, 6)

addEventHandler ("onClientMarkerHit", estrelasL, function (hitPlayer, matchingDimension)
	outputChatBox ("Para limpar a ficha use /limparficha", 0, 255, 0)
end)

addEventHandler ("onClientRender", getRootElement(), function ()
	dxDrawTextOnElement (estrelasL, "Limpe sua ficha aqui: /limparficha", 1, 20, 0, 255, 0, 255, 2, "default-bold")
end)

function dxDrawTextOnElement (TheElement, text, height, distance, R, G, B, alpha, size, font, ...)
	local x, y, z = getElementPosition (TheElement)
	local x2, y2, z2 = getCameraMatrix ()
	local distance = distance or 20
	local height = height or 1
	if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then
		local sx, sy = getScreenFromWorldPosition (x, y, z+height)
		if(sx) and (sy) then
			local distanceBetweenPoints = getDistanceBetweenPoints3D (x, y, z, x2, y2, z2)
			if (distanceBetweenPoints < distance) then
				dxDrawText (text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center")
			end
		end
	end
end

addCommandHandler ("limparficha", function ()
	if isElementWithinMarker (localPlayer, estrelasL) then -- Se o jogador estiver no marker, então:
		triggerServerEvent ("onRequestLimparFicha", localPlayer)
	else
		outputChatBox ("Você não esta na delegacia", 255, 30, 30)
	end	
end)	
	

server-side

local delentrar = createMarker (1554, -1675, 15, "cylinder", 1.3, 255, 255, 255, 50)
local delsair = createMarker (247, 63, 1003, "cylinder", 1.3, 255, 255, 255, 50)
setElementDimension (delsair, 1)
setElementInterior (delsair, 6)

function teleporte1 (thePlayer)
	setElementPosition (thePlayer, 246.44583129883, 67.712219238281, 1003.640625)
	setElementInterior (thePlayer, 6)
	setElementDimension (thePlayer, 1)
end
addEventHandler ("onMarkerHit", delentrar, teleporte1)

function teleporte2 (thePlayer)
	setElementPosition (thePlayer, 1543, -1675, 13)
	setElementInterior (thePlayer, 0)
	setElementDimension (thePlayer, 0)
end
addEventHandler ("onMarkerHit", delsair, teleporte2)

function clearFicha ()
	if getPlayerMoney (client) >= 1500 then -- Se o jogador tiver 1500 ou mais, então:
		if getPlayerWantedLevel (client) > 0 then -- Se o jogador tiver + de 1 estrela de procurado, então:
			setPlayerWantedLevel (client, 0) -- Seta a estrela do jogador em 0
			takePlayerMoney (client , 1500) -- Retira a quantia do jogador, 1500.
			outputChatBox ("[Delegacia] Você limpou a sua ficha e pagou $1500!" , client, 0, 255, 0)
		else
			outputChatBox ("[Delegacia] Você não esta procurado!", client, 255, 30, 30)
		end
	else	
		outputChatBox ("[Delegacia] Você não tem dinheiro suficiente!", client, 255, 30, 30)
	end
end
addEvent ("onRequestLimparFicha", true) 
addEventHandler ("onRequestLimparFicha", getRootElement(), clearFicha)

 

Meta:

<meta>
	<script src="server.lua" type="server"/>
	<script src="client.lua" type="client" cache="false"/>
</meta>

 

Edited by Jonas^
Adicionando meta.xml
  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...