Jump to content

I need a little help!


Recommended Posts

I want to put a blip in this script, where should I put the createBlip line?

client:

local storagePoint = {false, false};
local currentDelivery = {false, false};
local endJob = {false, false};

local deliveryPoints = {
	{2243.4775390625, -1395.4364013672, 24},
	{2051.61328125, -1117.5706787109, 25.003568649292},
	{1467.8787841797, -1048.9409179688, 23.828125},
	{327.58129882813, -1515.5727539063, 36.0390625},
	{1336.6231689453, -1063.1055908203, 27.638366699219},
	{1906.8187255859, -2043.4294433594, 13.539081573486},
	{1855.6429443359, -1991.7288818359, 13.546875},
	{2193.7561035156, -1465.6889648438, 25.5390625},
	{776.95318603516, -1038.4600830078, 24.264934539795},
	{1129.3745117188, -1034.0670166016, 31.900709152222},
	{1182.3781738281, -1253.4052734375, 15.1796875},
	{2006.8341064453, -1731.9776611328, 13.546875},
	{2408.9558105469, 11.318985939026, 26.484375},
	{2208.9074707031, -41.475128173828, 26.96821975708},
	{2234.5593261719, 161.04037475586, 27.208700180054},
	{1425.3210449219, 354.81228637695, 18.84375},
	{1298.7332763672, 141.98175048828, 20.420993804932},
	{782.72180175781, 355.49261474609, 19.574863433838},
	{260.8395690918, -270.61233520508, 1.5835752487183},
	{244.20251464844, -32.189167022705, 1.578125},
	{924.92437744141, -1823.4632568359, 12.592874526978},
	{975.53649902344, -759.5634765625, 112.203125},
	{2093.3505859375, -1064.6656494141, 27.788551330566},
	{632.46899414063, -1754.3098144531, 13.33126449585},
	{724.98651123047, -1438.1890869141, 13.531820297241},
	{615.04418945313, -1104.4587402344, 46.910369873047},
	{347.41256713867, -1195.2513427734, 76.515625},
	{571.57623291016, -1132.0529785156, 50.319370269775},
	{1025.8366699219, -981.75268554688, 42.685222625732},
	{1447.6071777344, -1319.2266845703, 13.5412},
	{951.17224121094, -912.78070068359, 45.765625},
	{1325.431640625, -1558.9908447266, 13.539655685425},
	{1415.72265625, -1700.3260498047, 13.539485931396},
	{883.36114501953, -1798.0211181641, 13.765440940857},
	{2502.5837402344, -1134.4586181641, 39.223068237305},
	{1724.6293945313, -1176.0129394531, 23.828125},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
	--{327.58129882813, -1515.5727539063, 36.0390625},
};

function newDelivery()
	storagePoint[1] = createMarker(2377.2541503906, -1909.2963867188, 13.3828125, "checkpoint", 6, 0, 0, 100, 175);
	storagePoint[2] = createBlip(2377.2541503906, -1909.2963867188, 13.3828125, 51, 1, 0, 0, 0, 255);

	outputChatBox("#FFFFFFBig Joe#FECE01[Munkaadó]:#AAAAAA Érkezett egy megrendelés. Vedd fel a kifőzdéből és szállítsd ki!", 0, 0, 0, true);
end

addEventHandler("onClientVehicleEnter", root,
	function(thePlayer, seat)
		if (source == getElementData(localPlayer, "jobVehicle")) then
			if (seat == 0) then
				if not (storagePoint[1]) then
					newDelivery();
				end
				
				if not (endJob[1]) then
					endJob[1] = createMarker(1016.8585205078, -1099.0649414063, 23.834857940674, "checkpoint", 4, 100, 0, 0, 175);
					endJob[2] = createBlip(1016.8585205078, -1099.0649414063, 23.834857940674, 55, 1, 0, 0, 0, 255);
				end
			end
		end
	end
);

addEventHandler("onClientMarkerHit", resourceRoot,
	function(hitPlayer, mDim)
		if (mDim) then
			if (source == storagePoint[1]) then
				if (hitPlayer == localPlayer) then
					local vehicle = getPedOccupiedVehicle(hitPlayer);
					if (vehicle) then
						if (vehicle == getElementData(localPlayer, "jobVehicle")) then
							setElementFrozen(localPlayer, true);
							setElementFrozen(vehicle, true);
							
							setTimer(function()
								setElementFrozen(localPlayer, false);
								setElementFrozen(vehicle, false);
								
								destroyElement(storagePoint[1]);
								destroyElement(storagePoint[2]);
								
								local index = math.random(1, #deliveryPoints);
								
								currentDelivery[1] = createMarker(deliveryPoints[index][1], deliveryPoints[index][2], deliveryPoints[index][3], "checkpoint", 4, 0, 0, 100, 175);
								currentDelivery[2] = createBlip(deliveryPoints[index][1], deliveryPoints[index][2], deliveryPoints[index][3], 51, 1, 0, 0, 0, 255);
								
								outputChatBox("#FFFFFF[Kifőzdés]:#AAAAAA Felpakoltuk az árut. Jó utat!", 0, 0, 0, true);
							end, math.random(3000, 5000), 1);
						end
					end
				end
			end
			
			if (source == currentDelivery[1]) then
				if (hitPlayer == localPlayer) then
					local vehicle = getPedOccupiedVehicle(hitPlayer);
					if (vehicle) then
						if (vehicle == getElementData(localPlayer, "jobVehicle")) then
							setElementFrozen(localPlayer, true);
							setElementFrozen(vehicle, true);
							
							setTimer(function()
								setElementFrozen(localPlayer, false);
								setElementFrozen(vehicle, false);
								
								destroyElement(currentDelivery[1]);
								destroyElement(currentDelivery[2]);
								
								newDelivery();
								
								triggerServerEvent("successfulDelivery", resourceRoot, localPlayer);
							end, math.random(3000, 5000), 1);
						end
					end
				end
			end
			
			if ( (source == endJob[1]) and (hitPlayer == localPlayer) ) then
				if (storagePoint[1]) then
					destroyElement(storagePoint[1]);
					destroyElement(storagePoint[2]);
				end
				
				if (currentDelivery[1]) then
					destroyElement(currentDelivery[1]);
					destroyElement(currentDelivery[2]);
				end
				
				triggerServerEvent("endJob", resourceRoot, localPlayer);
				
				destroyElement(endJob[1]);
				destroyElement(endJob[2]);
				
				storagePoint = {false, false};
				currentDelivery = {false, false};
				endJob = {false, false};
				
			end
		end
	end
);

server

 

for i, player in ipairs(getElementsByType("player")) do
	setElementData(player, "jobVehicle", false);
end

local vehicleSpots = {
	[1] = {1031.9377441406, -1103.7866210938, 23.828125, createColCuboid(1016.8585205078, -1099.0649414063, 23.834857940674, 12.7, 6.6, 7, 5)},
	[2] = {1043.2022705078, -1104.6474609375, 23.828125, createColCuboid(1016.8585205078, -1099.0649414063, 23.834857940674, 12.7, 8.5, 7, 5)},
};

local jobMarker = createMarker(1003.3190917969, -1104.7777099609, 23.828125, "cylinder", 2, 0, 0, 100, 175);

local deliveryVehicles = {565, 565};

addEventHandler("onMarkerHit", resourceRoot,
	function(hitElement, mDim)
		if (mDim) then
			if (source == jobMarker) then
				if (getElementType(hitElement) == "player") then
					if not ( getElementData(hitElement, "jobVehicle") ) then
						local isVehicle = false;
						for i, spot in pairs(vehicleSpots) do
							local vehicleInSpot = getElementsWithinColShape(spot[4], "vehicle");
							if not (#vehicleInSpot > 0) then
								local jobVehicle = createVehicle(deliveryVehicles[math.random(1,2)], spot[1], spot[2], spot[3]);
								setElementData(hitElement, "jobVehicle", jobVehicle);
								outputChatBox("#FFFFFF[Étel szállító]:#00FF00 A járműved készen áll!", hitElement, 0, 0, 0, true);
								isVehicle = true;
								break;
							end
						end
						
						if not (isVehicle) then
							outputChatBox("#FFFFFF[Étel szállító]:#FF0000 Nincs szabad hely.#AAAAAA Várj egy keveset!", hitElement, 0, 0, 0, true);
						end
					else
						outputChatBox("#FFFFFF[Étel szállító]:#FF0000 Már van járműved!#AAAAAA Keresd meg és menj azzal!", hitElement, 0, 0, 0, true);
					end
				end
			end
		end
	end
);

addEvent("successfulDelivery", true);
addEventHandler("successfulDelivery", resourceRoot,
	function(player)
		if (player == client) then
			local pMoney = getPlayerMoney(client);
			local moneyPlus = math.random(300, 800);
			setPlayerMoney(client, pMoney+moneyPlus);
			outputChatBox("#FFFFFF[Vevő]:#AAAAAA Lepakoltunk. Köszönjük! (A megrendelő "..moneyPlus.."-t fizetett.)", client, 0, 0, 0, true);
		end
	end
);

addEvent("endJob", true);
addEventHandler("endJob", resourceRoot,
	function(player)
		if (player == client) then
			local vehicle = getPedOccupiedVehicle(client);
			if (vehicle) then
				if (vehicle == getElementData(client, "jobVehicle")) then
					local vHealth = getElementHealth(vehicle);
					if (vHealth < 1000) then
						local pMoney = getPlayerMoney(client);
						setPlayerMoney(client, pMoney-(1000-vHealth));
						outputChatBox("#FFFFFF[Étel szállító]:#FF0000 A jármű sérült!#AAAAAA Levonunk tőled "..(1000-vHealth).."$-t a javításokra!", client, 0, 0, 0, true);
					end
					destroyElement(vehicle);
					setElementData(client, "jobVehicle", false);
				end
			end
		end
	end
);

 

Link to comment
  • Moderators
Posted (edited)

There are several createBlips already. Please be more specific.
Also I want to remind you, this is a scripting related topic, where you can ask for help about your OWN code. I'm sure this is not your code. 

Edited by Patrick
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...