Hello! I am beginner for scripting... I want put in the script line, who give player drugs for one circle.
--[[
--[[
(c) Kikisons, 2014
Skripts izstrādāts RP.EXS.LV MTA serverim, Kreiss frakcijai.
]]--
mysql = exports.mysql -- Importējam mySQL, datubāzes savienojumam.
local startBlip = createBlip(-1549.9873046875, -2762.40625, 48, 51, 2, 0, 0, 0, 0, 0, 999999)
function trucking_init(thePlayer, commandname)
if getElementData(thePlayer, "faction") == 79 then
setElementData(thePlayer, "trucking", 0)
setElementData(thePlayer, "truckingprofit", 0)
setElementData(thePlayer, "truckingMarkerVisible", 0)
outputChatBox("Iekāp automašīnā, lai redzētu sākumpunktu.", thePlayer)
destroyElement(startMarker)
destroyElement(jobMarker)
destroyElement(jobBlip)
end
end
addCommandHandler("kreiss", trucking_init, false, false) --
function showStartMarker(thePlayer)
if (getElementData(thePlayer, "faction") == 79 and getElementData(thePlayer, "trucking") == 0 and getElementData(thePlayer, "truckingMarkerVisible") ~= 1) then
startMarker = createMarker (-1549.9873046875, -2762.40625, 48, "cylinder", 4.0, 255, 0, 0, 150, thePlayer)
addEventHandler("onMarkerHit", startMarker, startTrucking)
setElementData(thePlayer, "truckingMarkerVisible", 1)
end
end
addEventHandler("onVehicleEnter", getRootElement(), showStartMarker)
function startTrucking(thePlayer)
if (getElementData(thePlayer, "faction") == 79) then
theVehicle = getPedOccupiedVehicle (thePlayer)
vehicleID = getElementModel(theVehicle)
if vehicleID == 403 then
if getVehicleTowedByVehicle(theVehicle) then
outputChatBox("Sākam darbu...", thePlayer, 0, 255, 0)
setElementData(thePlayer, "trucking", 1)
truckJob(thePlayer)
else
outputChatBox("Piekabini treileri, lai sāktu darbu.", thePlayer, 255, 0, 0)
end
else
outputChatBox("Tev ir jāatrodas Linerunner markas automašīnā!", thePlayer, 255, 0, 0)
end
else
outputChatBox("Tikai \"Kreiss\" frakcijas biedriem ir iespēja izmantot šo darbu!", thePlayer, 255, 0, 0)
end
end
function truckJob(thePlayer)
theVehicle = getPedOccupiedVehicle (thePlayer)
if getElementData(thePlayer, "faction") == 79 then
if getVehicleTowedByVehicle(theVehicle) then
local progress = getElementData(thePlayer, "trucking")
if progress == 1 then
destroyElement(startMarker)
end
marker = markers[tonumber(progress)]
if marker then
x = marker[1]
y = marker[2]
z = marker[3]
end
if progress <= 11 and progress > 0 then
jobMarker = createMarker(x, y, z, "cylinder", 4.0, 255, 102, 51, 150, thePlayer)
jobBlip = createBlip(x, y, z, 0, 4, 255, 102, 51, 255, 0, 999999, thePlayer)
addEventHandler("onMarkerHit", jobMarker, timerIncreaseJob)
else
destroyElement(jobMarker)
destroyElement(jobBlip)
endJob(thePlayer)
return
end
else
outputChatBox("Tev nav piekabināts treileris!", thePlayer, 255, 0, 0)
end
else
outputChatBox("Nav pieejams!", thePlayer, 255, 0, 0)
end
end
function timerIncreaseJob(thePlayer)
theVehicle = getPedOccupiedVehicle (thePlayer)
if getElementData(thePlayer, "faction") == 79 then
if getVehicleTowedByVehicle(theVehicle) then
truck = getPedOccupiedVehicle(thePlayer)
trailer = getVehicleTowedByVehicle(theVehicle)
setElementFrozen(truck, true)
setElementFrozen(trailer, true)
outputChatBox("Uzgaidiet, kamēr jūsu fūre tiek izkrauta." , thePlayer, 255, 102, 51)
setTimer(increaseJob, 20000, 1, thePlayer)
else
outputChatBox("Tev nav piekabināts treileris!", thePlayer, 255, 0, 0)
end
else
outputChatBox("Nav pieejams!", thePlayer, 255, 0, 0)
end
end
function increaseJob(thePlayer)
theVehicle = getPedOccupiedVehicle (thePlayer)
if getElementData(thePlayer, "faction") == 79 then
if getVehicleTowedByVehicle(theVehicle) then
truck = getPedOccupiedVehicle(thePlayer)
setElementFrozen(truck, false)
setElementData(thePlayer, "truckingprofit", getElementData(thePlayer, "truckingprofit") + 80)
outputChatBox("Jūs veicāt savu "..getElementData(thePlayer, "trucking")..". piegādi šajā fūrē.", thePlayer, 255, 255, 255)
--outputChatBox("Jūs nopelnijāt $80. [Kopā: $"..getElementData(thePlayer, "truckingprofit").."]" , thePlayer, 255, 255, 255)
outputChatBox("Frakcija par to saņēma $1600." , thePlayer, 255, 255, 255)
mysql:query_free("UPDATE `factions` SET `bankbalance` = `bankbalance` + 1600 WHERE `id` = 79")
setElementData(thePlayer, "trucking", getElementData(thePlayer, "trucking") + 1)
destroyElement(jobMarker)
destroyElement(jobBlip)
truckJob(thePlayer)
else
outputChatBox("Tev nav piekabināts treileris!", thePlayer, 255, 0, 0)
end
else
outputChatBox("Nav pieejams!", thePlayer, 255, 0, 0)
end
end
function endJob(thePlayer)
theVehicle = getPedOccupiedVehicle (thePlayer)
if getElementData(thePlayer, "faction") == 79 then
if getVehicleTowedByVehicle(theVehicle) then
exports.global:giveMoney(thePlayer, 2000)
outputChatBox("Darbs pabeigts. Atgriezies bāzē. Frakcija saņēma: $"..getElementData(thePlayer, "trucking")*1600 ..".", thePlayer, 0, 255, 0)
outputChatBox("Lai strādātu atkal, raksti /kreiss", thePlayer)
outputChatBox("Tu saņem $2000 prēmiju par pabeigtu darbu!", thePlayer)
setElementData(thePlayer, "trucking", 0)
setElementData(thePlayer, "truckingprofit", 0)
else
outputChatBox("Tev nav piekabināts treileris!", thePlayer, 255, 0, 0)
end
else
outputChatBox("Nav pieejams!", thePlayer, 255, 0,0)
end
end