Jump to content

Маркер виден всем!!


Recommended Posts

Всем привет, такая проблема, в кодинге не сильно шарю, написал простенький скрипт на работу шахтёра, был очень рад, что у меня всё получается, но решил я затестить скрипт, зашёл со второго компа и увидел, что во время действия функций, временные маркеры видны всем игрокам, т.е. я начинаю работу одним игроком, но к маркеру может подойти и активировать функцию другой игрок, весь инет перешарил, скачивал скрипты для проверки, но как оказалось половина скриптов так работают коряво, есть и нормальные скрипты, но с ними я так и не разобрался Прикрепляю код

--local markerJobStart = createMarker ( -1819, -1615, 22.1, 'cylinder', 1, 255, 0, 0, 255)
local startJob = createPickup(-1819, -1615, 23.1, 3, 1275, 0)
local blipJobStart = createBlip ( -1819, -1615, 23, 53, 1, 255, 0, 0, 255, 0, 1000)

local skin = 0
local skinJob = 27
local jobActive = false
local money = 0
local sum = 0
local score = 0

function jobTake(thePlayer)
	if (thePlayer) then
		setPedAnimation(thePlayer, 'sword', 'sword_4', -1, true)
		outputChatBox('копаете...', thePlayer, 255, 255, 255, false)
		setTimer ( function()
			setPedAnimation(thePlayer, false)
			outputChatBox('Вы скололи руду, отнесите её в ангар', thePlayer, 255, 255, 0, false)
			destroyElement(markerJobTake)
			destroyElement(blipJobTake)
			createMarkerDrop() 
			score = math.random(56, 100)
			end, 5000, 1)
	end
end

function jobDrop(thePlayer)
	if (thePlayer) then
		outputChatBox('бросаете...', thePlayer, 255, 255, 255, false)
		setPedAnimation(thePlayer, 'sword', 'sword_4', -1, true)
		setTimer( function()
			sum = sum + score
			setPedAnimation(thePlayer, false)
			outputChatBox('Идите за рудой', thePlayer, 255, 255, 0, false)
			outputChatBox('Ты принёс '..score..'кг. Всего: '..sum..'кг.', thePlayer, 255, 255, 0, false)
			destroyElement(markerJobDrop)
			destroyElement(blipJobDrop)
			createMarkerTake()
			end, 1000, 1)
	end	
end


function createMarkerDrop(thePlayer)
	markerJobDrop = createMarker ( -1865.732, -1622.147, 20.9, 'cylinder', 2, 255, 0, 0, 255)
	blipJobDrop = createBlip ( -1865.732, -1622.147, 21.904, 0, 2, 255, 0, 0, 255, 0, 1000)
	addEventHandler('onMarkerHit', markerJobDrop, jobDrop)
end

function createMarkerTake(thePlayer)
	markerJobTake = createMarker ( -1806.709, -1649.031, 22.8, 'cylinder', 2, 255, 0, 0, 255)
	blipJobTake = createBlip ( -1806.709, -1649.031, 24.018, 0, 2, 255, 0, 0, 255, 0, 1000)
	addEvent ("jobTake", true)
	addEventHandler('onMarkerHit', markerJobTake, jobTake)
end


function createMarkerStartJob(thePlayer)
	if (thePlayer) then
		--local skin = 0
		if(jobActive == false ) then
			outputChatBox('Вы устроились шахтёром', thePlayer, 255, 255, 0, false)
			createMarkerTake()
			skin = getElementModel(thePlayer)
			outputChatBox(''..skin..'', thePlayer, 255, 255, 0, false)
			setPlayerSkin(thePlayer, 27)
			jobActive = true
		
	    elseif (jobActive == true) then
	    	money = sum*5
	    	outputChatBox('Вы уволились с работы шахтёра и заработали: '..money..'$.', thePlayer, 255, 0, 100, false)
	    	destroyElement(markerJobDrop)
	    	destroyElement(markerJobTake)
	    	destroyElement(blipJobDrop)
	    	destroyElement(blipJobTake)
	    	givePlayerMoney(thePlayer, money)
	    	setPlayerSkin(thePlayer, skin)
	    	sum=0
	    	score=0
	    	jobActive = false
	    	skin=0

	    end	
	end
end



--bindKey('n', 'down', createMarkerTake)
--addCommandHandler ( "start", jobTake )
--addEventHandler('onMarkerHit', markerJobStart, createMarkerStartJob)
addEventHandler('onPickupHit', startJob, createMarkerStartJob)

 

Link to comment

попробуй вот так

local startJob = createPickup(-1819, -1615, 23.1, 3, 1275, 0)
local blipJobStart = createBlip ( -1819, -1615, 23, 53, 1, 255, 0, 0, 255, 0, 1000)

local skin = 0
local skinJob = 27
local jobActive = false
local money = 0
local sum = 0
local score = 0

local markers = {}
local blips = {}

function jobTake(thePlayer)
	if (thePlayer) then
		setPedAnimation(thePlayer, 'sword', 'sword_4', -1, true)
		outputChatBox('копаете...', thePlayer, 255, 255, 255, false)
		setTimer ( function()
			setPedAnimation(thePlayer, false)
			outputChatBox('Вы скололи руду, отнесите её в ангар', thePlayer, 255, 255, 0, false)
			destroyElement(markers[thePlayer])
			destroyElement(blips[thePlayer])
			createMarkerDrop() 
			score = math.random(56, 100)
			end, 5000, 1)
	end
end
addEventHandler('onMarkerHit', resourceRoot, jobTake)

function jobDrop(thePlayer)
	if (thePlayer) then
		outputChatBox('бросаете...', thePlayer, 255, 255, 255, false)
		setPedAnimation(thePlayer, 'sword', 'sword_4', -1, true)
		setTimer( function()
			sum = sum + score
			setPedAnimation(thePlayer, false)
			outputChatBox('Идите за рудой', thePlayer, 255, 255, 0, false)
			outputChatBox('Ты принёс '..score..'кг. Всего: '..sum..'кг.', thePlayer, 255, 255, 0, false)
			destroyElement(markers[thePlayer])
			destroyElement(blips[thePlayer])
			createMarkerTake()
			end, 1000, 1)
	end	
end
addEventHandler('onMarkerHit', resourceRoot, jobDrop)


function createMarkerDrop(thePlayer)
	markers[thePlayer] = createMarker ( -1865.732, -1622.147, 20.9, 'cylinder', 2, 255, 0, 0, 255, resourceRoot)
	blips[thePlayer] = createBlip ( -1865.732, -1622.147, 21.904, 0, 2, 255, 0, 0, 255, 0, 1000, resourceRoot)
	
	setElementVisibleTo(markers[thePlayer], thePlayer, true)
	setElementVisibleTo(blips[thePlayer], thePlayer, true)
end

function createMarkerTake(thePlayer)
	markers[thePlayer] = createMarker ( -1806.709, -1649.031, 22.8, 'cylinder', 2, 255, 0, 0, 255, resourceRoot)
	blips[thePlayer] = createBlip ( -1806.709, -1649.031, 24.018, 0, 2, 255, 0, 0, 255, 0, 1000, resourceRoot)
	
	setElementVisibleTo(markers[thePlayer], thePlayer, true)
	setElementVisibleTo(blips[thePlayer], thePlayer, true)
	
	addEvent ("jobTake", true)
end


function createMarkerStartJob(thePlayer)
	if (thePlayer) then
		--local skin = 0
		if(jobActive == false ) then
			outputChatBox('Вы устроились шахтёром', thePlayer, 255, 255, 0, false)
			createMarkerTake()
			skin = getElementModel(thePlayer)
			outputChatBox(''..skin..'', thePlayer, 255, 255, 0, false)
			setPlayerSkin(thePlayer, 27)
			jobActive = true
		
	    elseif (jobActive == true) then
	    	money = sum*5
	    	outputChatBox('Вы уволились с работы шахтёра и заработали: '..money..'$.', thePlayer, 255, 0, 100, false)
	    	destroyElement(markers[thePlayer])
	    	destroyElement(blips[thePlayer])
	    	-- destroyElement(blipJobDrop)
	    	-- destroyElement(blipJobTake)
	    	givePlayerMoney(thePlayer, money)
	    	setPlayerSkin(thePlayer, skin)
	    	sum=0
	    	score=0
	    	jobActive = false
	    	skin=0

	    end	
	end
end



--bindKey('n', 'down', createMarkerTake)
--addCommandHandler ( "start", jobTake )
--addEventHandler('onMarkerHit', markerJobStart, createMarkerStartJob)
addEventHandler('onPickupHit', startJob, createMarkerStartJob)

 

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