Jump to content

How to remove blip?


saluta

Recommended Posts

Salute dear programmers. How to remove the blip icon on the map? I indicated in the code the creation of an icon by coordinates and ID, but how can I do this deleting an icon by coordinates that I also indicated in the code? help, I beg you.

Spoiler

local blip = createBlip ( -715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000 )
	setTimer(function()
	addCommandHandler ( "blip", 
    function ( thePlayer ) 
        for index, element in ipairs ( getAttachedElements ( thePlayer ) ) do 
            if ( getElementType ( element ) == "blip" ) then 
                destroyElement ( element ) 
            end 
        end 
    end 
) 
	end, 5000, 0)
end

function finish()
how to do it here --> removeBlip ( -715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 0 )
end

 

 

Link to comment
local theBlip = createBlip(0, 0, 4, 2, 255, 255, 255, 255)

function removeBlip(posX, posY, posZ)
   for _,blip in ipairs(getElementsByType("blip")) do
      local x,y,z = getElementPosition(blip)
      if(posX == x and posY == y and posZ == z) then
         destroyElement(blip)
      end
   end
end

removeBlip(0, 0, 4)

 

  • Thanks 1
Link to comment
On 08/06/2021 at 15:59, Burak5312 said:

local theBlip = createBlip(0, 0, 4, 2, 255, 255, 255, 255)

function removeBlip(posX, posY, posZ)
   for _,blip in ipairs(getElementsByType("blip")) do
      local x,y,z = getElementPosition(blip)
      if(posX == x and posY == y and posZ == z) then
         destroyElement(blip)
      end
   end
end

removeBlip(0, 0, 4)

 

And how to do this in the work resource, here in the goo window I will click to start work how to make the mark disappear?

Link to comment
On 09/06/2021 at 17:29, saluta said:

And how to do this in the work resource, here in the goo window I will click to start work how to make the mark disappear?

I don't understand. Do you want to create a panel for this function?

Edited by Burak5312
Link to comment
2 hours ago, Burak5312 said:

Я не понимаю. Вы хотите создать панель для этой функции?

No, I have a quest system and a miner's work, in general, a quest appears there a mark appears that I have already done a person reaches the mark clicks start work and the mark must disappear exactly 41 id blip radar_waypoint icons. How to implement and do it.

Link to comment
function removeBlip(posX, posY, posZ)
   for _,blip in ipairs(getElementsByType("blip")) do
      local x,y,z = getElementPosition(blip)
      if(posX == x and posY == y and posZ == z) then
         destroyElement(blip)
      end
   end
end

local blip = createBlip (-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)

	setTimer(function()
	addCommandHandler ( "blip", 
    function ( thePlayer ) 
        for index, element in ipairs ( getAttachedElements ( thePlayer ) ) do 
            if ( getElementType ( element ) == "blip" ) then 
                destroyElement ( element ) 
            end 
        end 
    end 
) 
	end, 5000, 0)
end

function finish()
   removeBlip (-715.8314, 2328.1269, 44.1525)
end

maybe something like this?

Edited by Burak5312
Link to comment

The problem is that getElementPosition returns exact coordinates (in this case X coordinate is "-715.83142089844").
And you are comparing it with "-715.8314".

To make it work you will have to round the coordinates.
You can either use the useful function math.round or do it like this:

local theBlip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)

function removeBlip(posX, posY, posZ)
	for _,blip in ipairs(getElementsByType("blip")) do
		local x,y,z = getElementPosition(blip)
		if(math.ceil(posX) == math.ceil(x) and math.ceil(posY) == math.ceil(y) and math.ceil(posZ) == math.ceil(z)) then
			destroyElement(blip)
		end
	end
end

addCommandHandler("blip", function () -- the cmd way is for an example
	removeBlip(-715.8314, 2328.1269, 44.1525)
end)

*Changed @Burak5312's code a bit.
Note that this way it won't be very accurate but if you don't plan to have close blips it should not cause any problems.
Otherwise use the math.round function I mentioned above and specify how many digits to have after the decimal point.

Edited by SpecT
  • Thanks 1
Link to comment

 

16 minutes ago, SpecT said:

The problem is that getElementPosition returns exact coordinates (in this case X coordinate is "-715.83142089844").
And you are comparing it with "-715.8314".

To make it work you will have to round the coordinates.
You can either use the useful function math.round or do it like this:


local theBlip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)

function removeBlip(posX, posY, posZ)
	for _,blip in ipairs(getElementsByType("blip")) do
		local x,y,z = getElementPosition(blip)
		if(math.ceil(posX) == math.ceil(x) and math.ceil(posY) == math.ceil(y) and math.ceil(posZ) == math.ceil(z)) then
			destroyElement(blip)
		end
	end
end

addCommandHandler("blip", function () -- the cmd way is for an example
	removeBlip(-715.8314, 2328.1269, 44.1525)
end)

*Changed @Burak5312's code a bit.
Note that this way it won't be very accurate but if you don't plan to have close blips it should not make any problems.

it didn’t work as a miner, in general I figured out how to do it. you can create a marker and when you get up on the marker the blip disappears, how to do it?

Link to comment
local blip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)
local finishMarker = createMarker(-715.8314, 2328.1269, 125.6, "cylinder", 3.0, 255, 0, 0, 255)

addEventHandler("onMarkerHit", finishMarker,
   function(hitElement)
      if(getElementType(hitElement) == "player" and isElement(blip)) then
         destroyElement(blip)
      end
   end
)

 

Link to comment
On 12/06/2021 at 17:40, Burak5312 said:

local blip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)
local finishMarker = createMarker(-715.8314, 2328.1269, 125.6, "cylinder", 3.0, 255, 0, 0, 255)

addEventHandler("onMarkerHit", finishMarker,
   function(hitElement)
      if(getElementType(hitElement) == "player" and isElement(blip)) then
         destroyElement(blip)
      end
   end
)

 

It does not work, but how to make a marker appear in one quest system and come up to the NPC, this is a different system, the work of a miner and you click on the goo window so that the blip icon disappears, I don’t understand how to combine this and do the work synchronously. how to do it?

In general, I tried using callas to call a function with an argument in the resource resource, errors appear in the debug, please help, the problem is still relevant.??

Link to comment

Well you keep telling that everything we post here doesn't work (even tho I tested).
So please be more specific - doesn't work OR it's not what you need. Because there is a difference!

It would be best to show the code where you tried and tell us what's wrong with it and what you want to achieve.
Also you mentioned you got errors in debugscript so it would be good if you show them as well.

Link to comment
On 6/18/2021 at 6:37 PM, Burak5312 said:

Вы можете показать код и сказать нам, где и что вы хотите сделать?

 

On 6/18/2021 at 6:45 PM, SpecT said:

Что ж, вы продолжаете говорить, что все, что мы публикуем здесь, не работает (даже если я тестировал).
Так что будьте более конкретными - не работает ИЛИ это не то, что вам нужно. Потому что разница есть!

Было бы лучше показать код, в котором вы пробовали, и рассказать нам, что с ним не так и чего вы хотите достичь.
Также вы упомянули, что у вас есть ошибки в сценарии отладки, поэтому было бы хорошо, если бы вы также их показали.

Spoiler


localPlayer = getLocalPlayer ()

function start_Main_Q ()
	showQuestWindow ( "Unknown", "It's so good that I managed to save you from homeless people. Just a little more and you would be their dinner. Are you okay?", "I've been better", "norm_Main_Q()", "Where I am?", "where_Main_Q()", "Thanks for saving", "thanks_surv_Main_Q()", "Who are you?", "whohe_Main_Q()" )
end

function norm_Main_Q ()
	showQuestWindow ( "John ", "It's good. And my name is John. You are in neutral territory between other states. I found you near a Russian factory. Do you remember anything? ", "Nope, everything is in a fog", "tuman_Main_Q()", "0", "where_Main_Q()", "0", "thanks_surv_Main_Q()", "0", "whohe_Main_Q()" )
end

function where_Main_Q ()
	showQuestWindow ( "John ", "And my name is John. You are in neutral territory between other states. I found you near a Russian factory. Do you remember anything? ", "Nope, everything is in a fog", "tuman_Main_Q()", "0", "where_Main_Q()", "0", "thanks_surv_Main_Q()", "0", "whohe_Main_Q()" )
end

function thanks_surv_Main_Q ()
	showQuestWindow ( "John ", "You're welcome. My name is John. You are in neutral territory between other states. I found you near a Russian factory. Do you remember anything? ", "Nope, everything is in a fog", "tuman_Main_Q()", "0", "where_Main_Q()", "0", "thanks_surv_Main_Q()", "0", "whohe_Main_Q()" )
end

function whohe_Main_Q ()
	showQuestWindow ( "John ", "I - John. You're welcome. You are in neutral territory between other states. I found you near a Russian factory. Do you remember anything? ", "Nope, everything is in a fog", "tuman_Main_Q()", "0", "where_Main_Q()", "0", "thanks_surv_Main_Q()", "0", "whohe_Main_Q()" )
end

function tuman_Main_Q()
	showQuestWindow ( "John ", "I get it. You know, I'll tell you this: it doesn't matter who you were before. Now you are a human being, because right now you will sit in a bike and go to your first job, then you will go to Russia to get a driver's license.", "Okay, I remember. Where to go?", "what_do_Main_Q()", "Ok, ok. Where to go?", "what_do_Main_Q()", "0", "thanks_surv_Main_Q()", "0", "whohe_Main_Q()" )
end

function removeBlip(posX, posY, posZ)
	for _,blip in ipairs(getElementsByType("blip")) do
		local x,y,z = getElementPosition(blip)
		if(math.ceil(posX) == math.ceil(x) and math.ceil(posY) == math.ceil(y) and math.ceil(posZ) == math.ceil(z)) then
			destroyElement(blip)
		end
	end
end

function what_do_Main_Q()
	showQuestWindow ( "John ", "I'm glad you understood everything. sit in the bike, drive through the left opening and then turn straight, it turns out in the back of neutral territory, we go and see a man he has a job for you.", "OK, thank you for the information!", "", "Thanks again for saving me!", "", "0", "thanks_surv_Main_Q()", "0", "whohe_Main_Q()" )
	exports.guimessages:Draw("John: Good luck, Удачи, Noroc")
	local blip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)
	setTimer(function()
	addCommandHandler ( "blip", 
    function ( thePlayer ) 
        for index, element in ipairs ( getAttachedElements ( thePlayer ) ) do 
            if ( getElementType ( element ) == "blip" ) then 
                destroyElement ( element ) 
            end 
        end 
    end 
) 
	end, 5000, 0)
	outputChatBox("Item Received: Pager-GPS")
--	setElementModel(localPlayer,285)
end

addEventHandler("onMarkerHit", finishMarker,
   function(hitElement)
      if(getElementType(hitElement) == "player" and isElement(blip)) then
         destroyElement(blip)
      end
   end
)

function finish()
finishMarker = createMarker(-715.8314, 2328.1269, 44.1525, "cylinder", 3.0, 255, 0, 0, 255)
removeBlip(-715.8314, 2328.1269, 44.1525)
exports.guimessages:Draw("The task is completed, work.")
end

Quest system

Spoiler


addEvent( "infoWindow" , true )
screenWidth, screenHeight = guiGetScreenSize()

jobed = false
animated = false
droped = false

jobSkin = 16

 
function startAnim()

	setTimer ( function()
	
		if (animated == true) then
			animated = not animated
			setPedAnimation ( getLocalPlayer(), false)
			outputChatBox("Отнесите руду на переработку", 255, 255, 0, true)
			
			setPedAnimation ( getLocalPlayer(), "CARRY", "crry_prtial", 1,true )
			yashik = createObject(1355, 1, 1, 1)
			attachElements ( yashik, getLocalPlayer(), 0, 0.5, 0.5)
			toggleControl("sprint", false)
			
		end
		
	end, 5000, 1 )
	
end

function checkAnim ()
	if (animated == true) then
		if (getPedAnimation(getLocalPlayer()) == "baseball") then
			
		else
			animated = not animated
			
			if (animated == false) then
				outputChatBox("Вы уронили уголь! За эту добычу вы получите 0$", 255, 0, 0, true)
				setPedAnimation ( getLocalPlayer(), false)
				droped = not droped --true
			end
			
		end
	end
end
addEventHandler ( "onClientRender", root, checkAnim )


function wind ()
	infowind = guiCreateWindow((screenWidth - 300) / 2, (screenHeight - 220) / 2, 300, 220, "Работа шахтёром", false)
	infotext = guiCreateMemo(0, 20, 300, 150, "Переоденьтесь в рабочую одежду и идите добывать руду. Потом отнесите её на склад для переплавки", false, infowind)
	guiMemoSetReadOnly(infotext, true)
	showCursor(true)
	guiSetVisible(infowind, true)
	guiWindowSetMovable (infowind, false )
	guiWindowSetSizable(infowind, false)
	Button_Close = guiCreateButton(10, 174, 140, 45, "Закрыть", false, infowind)
	Button_Start = guiCreateButton(150, 174, 140, 45, "Начать/Закончить", false, infowind)
end
addEventHandler("infoWindow", resourceRoot, wind)

function closewindow ()
	if (source == Button_Close) then
		guiSetVisible(infowind, false)
		showCursor(false)
	end
end
addEventHandler("onClientGUIClick", resourceRoot, closewindow)

function start ()

	----------Инициализация---------
	pname = getPlayerName(getLocalPlayer())

	if (source == Button_Start) then
		
	--	createBlip ( -801.7380, 1962.5622, 44.5, 60, 2, 255, 0, 0, 255, 0, 100 )
	
		if (jobed == false) then --Если игрок не работает
		
			guiSetVisible(infowind, false)
			showCursor(false)
			outputChatBox("Идите на место добычи руды, она отмечена желтым маркером", 255, 0, 0, true)
			
			currentSkin = getElementModel(getLocalPlayer())
			cash = 0
			
			--setElementModel(getLocalPlayer(), jobSkin)
			triggerServerEvent("setJobSkin", resourceRoot, getLocalPlayer()) --установка скина рабочего
	
			triggerServerEvent("markerCreate", resourceRoot, pname)
			
			guiSetVisible(infowind, false)
			showCursor(false)
			
			jobed = not jobed
			
		else
		
			outputChatBox("Вы заверишили рабочий день и получили "..cash.."$", 0, 255, 0, true)
			triggerServerEvent("destroyMarker", resourceRoot, getElementByID(pname.."Shahta"), pname, getLocalPlayer())
			triggerServerEvent("destroyMarkerTwo", resourceRoot, getElementByID(pname.."ShahtaTwo"), pname, getLocalPlayer())
			
			givePlayerMoney(cash)
			--setElementModel(getLocalPlayer(), currentSkin)
			triggerServerEvent("setDefaultSkin", resourceRoot, getLocalPlayer(), currentSkin) --установка своего скина
			
			if (cash >= 2000) then
				setPedAnimation ( getLocalPlayer(), "casino", "manwind", 2000, false, true, true, false)
			end
			
			guiSetVisible(infowind, false)
			showCursor(false)
			
			jobed = not jobed
			
		end
		
	end
end
addEventHandler("onClientGUIClick", resourceRoot, start)




function getElement(element, marker)
	markerFromS = marker
	elementToS = element
end
addEvent("getElement", true)
addEventHandler("getElement", resourceRoot, getElement)


function getElementTwo(element, marker)
	markerFromSTwo = marker
	elementToSTwo = element
end
addEvent("getElementTwo", true)
addEventHandler("getElementTwo", resourceRoot, getElementTwo)



function MarkerHit ( hitPlayer, matchingDimension ) 
	if (source == markerFromS) and (pname == getPlayerName(hitPlayer)) and ( not isPedInVehicle(getLocalPlayer()) )  then
		triggerServerEvent("destroyMarker", resourceRoot, elementToS, pname, hitPlayer)
		--outputChatBox("Отнесите руду на переработку", 255, 255, 0, true)
		
		setPedAnimation ( getLocalPlayer(), "baseball", "bat_4", 5000, true, false, false, true)
		animated = not animated --true
		startAnim()
		
		triggerServerEvent("markerCreateTwo", resourceRoot, pname)
		
		
		
	elseif (source == markerFromSTwo) and (pname == getPlayerName(hitPlayer)) and ( not isPedInVehicle(getLocalPlayer()) ) then
		if (droped == true) then
			droped = not droped
			
			outputChatBox("На вашем счету ".. cash.."$", 0, 255, 0, true)
		
			triggerServerEvent("destroyMarkerTwo", resourceRoot, elementToSTwo, pname, hitPlayer)
		
			triggerServerEvent("markerCreate", resourceRoot, pname)
		
			outputChatBox("Добудьте руды, не облажайтесь", 255, 255, 0, true)
			
			setPedAnimation ( getLocalPlayer(), "casino", "cards_lose", 2000, false, true, true, false)
			
		else
			cash = cash + math.random(50,150)
			outputChatBox("На вашем счету "..cash.."$", 0, 255, 0, true)
		
			triggerServerEvent("destroyMarkerTwo", resourceRoot, elementToSTwo, pname, hitPlayer)
		
			triggerServerEvent("markerCreate", resourceRoot, pname)
		
			outputChatBox("Добудьте еще руды", 255, 255, 0, true)
			
			setPedAnimation ( getLocalPlayer(), "carry", "putdwn", 2000, false, true, true, false)
			
		end
	end
end
addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit )



function endDayS(oldNick)
	
	if (droped == true) then
		droped = not droped
	end
	
	if (jobed == true) then
		jobed = not jobed
		
		outputChatBox("Вы сменили ник или умерли, поэтому рабочий день завершён, заработано "..cash.."$", 0, 255, 0, true)
			
		triggerServerEvent("destroyMarker", resourceRoot, getElementByID(pname.."Shahta"), pname, getLocalPlayer(), oldNick)
		triggerServerEvent("destroyMarkerTwo", resourceRoot, getElementByID(pname.."ShahtaTwo"), pname, getLocalPlayer(), oldNick)
			
		givePlayerMoney(cash)
		triggerServerEvent("setDefaultSkin", resourceRoot, getLocalPlayer(), currentSkin) --установка своего скина
	end
end
addEvent("endDayS", true)
addEventHandler("endDayS", resourceRoot, endDayS)

work system

I just wanted the mark to appear on the map during the quest, by the way, I did it from scratch, but here's how to make the mark disappear from the radar and the map when you press start work in another work resource, tried it differently through calla and export too.

Edited by saluta
Change text
Link to comment
On 18.06.2021 at 18:45, SpecT said:

Что ж, вы продолжаете говорить, что все, что мы публикуем здесь, не работает (даже если я тестировал).
Так что будьте более конкретными - не работает ИЛИ это не то, что вам нужно. Потому что разница есть!

Было бы лучше показать код, в котором вы пробовали, и рассказать нам, что с ним не так и чего вы хотите достичь.
Также вы упомянули, что у вас есть ошибки в сценарии отладки, поэтому было бы хорошо, если бы вы также их показали.

Okay, you don’t want to help, but if I pay you 20 rubles for your work?

Link to comment
4 hours ago, saluta said:

Okay, you don’t want to help, but if I pay you 20 rubles for your work?

It's not that we don't want to help but we can't help you since you don't show the full code.
The examples we gave you should be enough to get the idea how to do it.

You mentioned it's about 2 resources communicating - 1st resouce calls 2nd resource to remove the blip ? At least this is what I understood.
Well if you show the code of both resources where this "communication" happens we could be able to help you.

Link to comment
22 часа назад SpecT сказал:

Это не значит, что мы не хотим помогать, но мы не можем помочь вам, поскольку вы не показываете полный код.
Приведенных нами примеров должно быть достаточно, чтобы понять, как это сделать.

Вы использовали, что речь идет о взаимодействии двух ресурсов - 1-й ресурс вызывает 2-й ресурс для удаления сообщения? По крайней мере, я так понял.
Что ж, если вы покажете код обоих ресурсов, где происходит «общение», мы сможем вам помочь.

Spoiler

addEvent( "infoWindow" , true )
screenWidth, screenHeight = guiGetScreenSize()

jobed = false
animated = false
droped = false

jobSkin = 16

 
function startAnim()

	setTimer ( function()
	
		if (animated == true) then
			animated = not animated
			setPedAnimation ( getLocalPlayer(), false)
			outputChatBox("Отнесите руду на переработку", 255, 255, 0, true)
			
			setPedAnimation ( getLocalPlayer(), "CARRY", "crry_prtial", 1,true )
			yashik = createObject(1355, 1, 1, 1)
			attachElements ( yashik, getLocalPlayer(), 0, 0.5, 0.5)
			toggleControl("sprint", false)
			
		end
		
	end, 5000, 1 )
	
end

function checkAnim ()
	if (animated == true) then
		if (getPedAnimation(getLocalPlayer()) == "baseball") then
			
		else
			animated = not animated
			
			if (animated == false) then
				outputChatBox("Вы уронили уголь! За эту добычу вы получите 0$", 255, 0, 0, true)
				setPedAnimation ( getLocalPlayer(), false)
				droped = not droped --true
			end
			
		end
	end
end
addEventHandler ( "onClientRender", root, checkAnim )


function wind ()
	infowind = guiCreateWindow((screenWidth - 300) / 2, (screenHeight - 220) / 2, 300, 220, "Работа шахтёром", false)
	infotext = guiCreateMemo(0, 20, 300, 150, "Переоденьтесь в рабочую одежду и идите добывать руду. Потом отнесите её на склад для переплавки", false, infowind)
	guiMemoSetReadOnly(infotext, true)
	showCursor(true)
	guiSetVisible(infowind, true)
	guiWindowSetMovable (infowind, false )
	guiWindowSetSizable(infowind, false)
	Button_Close = guiCreateButton(10, 174, 140, 45, "Закрыть", false, infowind)
	Button_Start = guiCreateButton(150, 174, 140, 45, "Начать/Закончить", false, infowind)
end
addEventHandler("infoWindow", resourceRoot, wind)

function closewindow ()
	if (source == Button_Close) then
		guiSetVisible(infowind, false)
		showCursor(false)
	end
end
addEventHandler("onClientGUIClick", resourceRoot, closewindow)

function start ()

	----------Инициализация---------
	pname = getPlayerName(getLocalPlayer())

	if (source == Button_Start) then
	
		if (jobed == false) then --Если игрок не работает
			createBlip ( -715.8314, 2328.1269, 44.1525, 60, 2, 255, 0, 0, 255, 0, 0 )
			guiSetVisible(infowind, false)
			showCursor(false)
			outputChatBox("Идите на место добычи руды, она отмечена желтым маркером", 255, 0, 0, true)
			
			currentSkin = getElementModel(getLocalPlayer())
			cash = 0
			
			--setElementModel(getLocalPlayer(), jobSkin)
			triggerServerEvent("setJobSkin", resourceRoot, getLocalPlayer()) --установка скина рабочего
	
			triggerServerEvent("markerCreate", resourceRoot, pname)
			
			guiSetVisible(infowind, false)
			showCursor(false)
			
			jobed = not jobed
			
		else
		
			outputChatBox("Вы заверишили рабочий день и получили "..cash.."$", 0, 255, 0, true)
			triggerServerEvent("destroyMarker", resourceRoot, getElementByID(pname.."Shahta"), pname, getLocalPlayer())
			triggerServerEvent("destroyMarkerTwo", resourceRoot, getElementByID(pname.."ShahtaTwo"), pname, getLocalPlayer())
			
			givePlayerMoney(cash)
			--setElementModel(getLocalPlayer(), currentSkin)
			triggerServerEvent("setDefaultSkin", resourceRoot, getLocalPlayer(), currentSkin) --установка своего скина
			
			if (cash >= 2000) then
				setPedAnimation ( getLocalPlayer(), "casino", "manwind", 2000, false, true, true, false)
			end
			
			guiSetVisible(infowind, false)
			showCursor(false)
			
			jobed = not jobed
			
		end
		
	end
end
addEventHandler("onClientGUIClick", resourceRoot, start)




function getElement(element, marker)
	markerFromS = marker
	elementToS = element
end
addEvent("getElement", true)
addEventHandler("getElement", resourceRoot, getElement)


function getElementTwo(element, marker)
	markerFromSTwo = marker
	elementToSTwo = element
end
addEvent("getElementTwo", true)
addEventHandler("getElementTwo", resourceRoot, getElementTwo)



function MarkerHit ( hitPlayer, matchingDimension ) 
	if (source == markerFromS) and (pname == getPlayerName(hitPlayer)) and ( not isPedInVehicle(getLocalPlayer()) )  then
		triggerServerEvent("destroyMarker", resourceRoot, elementToS, pname, hitPlayer)
		--outputChatBox("Отнесите руду на переработку", 255, 255, 0, true)
		
		setPedAnimation ( getLocalPlayer(), "baseball", "bat_4", 5000, true, false, false, true)
		animated = not animated --true
		startAnim()
		
		triggerServerEvent("markerCreateTwo", resourceRoot, pname)
		
		
		
	elseif (source == markerFromSTwo) and (pname == getPlayerName(hitPlayer)) and ( not isPedInVehicle(getLocalPlayer()) ) then
		if (droped == true) then
			droped = not droped
			
			outputChatBox("На вашем счету ".. cash.."$", 0, 255, 0, true)
		
			triggerServerEvent("destroyMarkerTwo", resourceRoot, elementToSTwo, pname, hitPlayer)
		
			triggerServerEvent("markerCreate", resourceRoot, pname)
		
			outputChatBox("Добудьте руды, не облажайтесь", 255, 255, 0, true)
			
			setPedAnimation ( getLocalPlayer(), "casino", "cards_lose", 2000, false, true, true, false)
			
		else
			cash = cash + math.random(50,150)
			outputChatBox("На вашем счету "..cash.."$", 0, 255, 0, true)
		
			triggerServerEvent("destroyMarkerTwo", resourceRoot, elementToSTwo, pname, hitPlayer)
		
			triggerServerEvent("markerCreate", resourceRoot, pname)
		
			outputChatBox("Добудьте еще руды", 255, 255, 0, true)
			
			setPedAnimation ( getLocalPlayer(), "carry", "putdwn", 2000, false, true, true, false)
			
		end
	end
end
addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit )



function endDayS(oldNick)
	
	if (droped == true) then
		droped = not droped
	end
	
	if (jobed == true) then
		jobed = not jobed
		
		outputChatBox("Вы сменили ник или умерли, поэтому рабочий день завершён, заработано "..cash.."$", 0, 255, 0, true)
			
		triggerServerEvent("destroyMarker", resourceRoot, getElementByID(pname.."Shahta"), pname, getLocalPlayer(), oldNick)
		triggerServerEvent("destroyMarkerTwo", resourceRoot, getElementByID(pname.."ShahtaTwo"), pname, getLocalPlayer(), oldNick)
			
		givePlayerMoney(cash)
		triggerServerEvent("setDefaultSkin", resourceRoot, getLocalPlayer(), currentSkin) --установка своего скина
	end
end
addEvent("endDayS", true)
addEventHandler("endDayS", resourceRoot, endDayS)

client

I already completely threw off the quest system for you, a few posts above ...
And now I will completely throw off the system of work

Spoiler

pickup = createPickup(-715.8314, 2328.1269, 44.1525, 3, 1275, 0)
createPed ( 291, -714, 2328.1269, 44.1525, 90 )
function pickupUse ( thePlayer )
	if (source == pickup) then
		triggerClientEvent ( thePlayer, "infoWindow", getRootElement() )
	end
end
addEventHandler ( "onPickupUse", getRootElement(), pickupUse )



function markerCreate(playername)

	pName = playername
	
	pID = getPlayerFromName(playername)
	
	makerUp = createMarker ( -1807.32202, -1651.76880, 24.10105 - 1.1, "cylinder", 1.5, 228, 228, 0)
	
	setElementVisibleTo ( makerUp, root, false )
	setElementVisibleTo ( makerUp, pID, true )
	
	setElementID(makerUp, playername.."Shahta")
	
	
	triggerClientEvent ( pID, "getElement", resourceRoot, getElementByID(playername.."Shahta"), makerUp  )
	
end
addEvent("markerCreate", true)
addEventHandler( "markerCreate", getRootElement(), markerCreate )

function destroyMarker(element, name, hit, oldNick)
	if (getElementByID(name.."Shahta")) and (name == getPlayerName(hit)) then
		destroyElement(element)
	elseif (getElementByID(name.."Shahta")) and (name == oldNick) then
		destroyElement(element)
	end
end
addEvent("destroyMarker", true)
addEventHandler("destroyMarker", getRootElement(), destroyMarker)


function markerCreateTwo(playername)

	pNameTwo = playername
	
	pIDTwo = getPlayerFromName(playername)
	
	makerUpTwo = createMarker ( -1863.62292, -1605.91895, 21.75781 - 1.1, "cylinder", 1.5, 228, 228, 0)
	
	setElementVisibleTo ( makerUpTwo, root, false )
	setElementVisibleTo ( makerUpTwo, pIDTwo, true )
	
	setElementID(makerUpTwo, playername.."ShahtaTwo")
	
	
	triggerClientEvent ( pIDTwo, "getElementTwo", resourceRoot, getElementByID(playername.."ShahtaTwo"), makerUpTwo  )
	
end
addEvent("markerCreateTwo", true)
addEventHandler( "markerCreateTwo", getRootElement(), markerCreateTwo )


function destroyMarkerTwo(element, name, hit, oldNick)
	if (getElementByID(name.."ShahtaTwo")) and (name == getPlayerName(hit)) then
		destroyElement(element)
	elseif (getElementByID(name.."ShahtaTwo")) and (name == oldNick) then
		destroyElement(element)
	end
end
addEvent("destroyMarkerTwo", true)
addEventHandler("destroyMarkerTwo", getRootElement(), destroyMarkerTwo)

function setJobSkin(player)
	setElementModel(player, 16)
end
addEvent("setJobSkin", true)
addEventHandler("setJobSkin", getRootElement(), setJobSkin)

function setDefaultSkin(player, skin)
	setElementModel(player, skin)
end
addEvent("setDefaultSkin", true)
addEventHandler("setDefaultSkin", getRootElement(), setDefaultSkin)


---------------Удаление маркеров при смене ника--------------------
function wasNickChangedByUser(oldNick, newNick, changedByUser)
	if (getElementByID(oldNick.."Shahta")) then
		triggerClientEvent ( source, "endDayS", resourceRoot, oldNick )
	end
end
addEventHandler("onPlayerChangeNick", getRootElement(), wasNickChangedByUser)


function wasNickChangedByUser(oldNick, newNick, changedByUser)
	if (getElementByID(oldNick.."ShahtaTwo")) then
		triggerClientEvent ( source, "endDayS", resourceRoot, oldNick )
	end
end
addEventHandler("onPlayerChangeNick", getRootElement(), wasNickChangedByUser)
--------------------------------------------------------------------


---------------Удаление маркеров при смерти--------------------
function deadPlayer(ammo, attacker, weapon, bodypart)
	triggerClientEvent ( source, "endDayS", resourceRoot, getPlayerName(source) )
end
addEventHandler( "onPlayerWasted", getRootElement( ), deadPlayer)
--------------------------------------------------------------

server

 

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...