كلنت
function busGui ()
bsWindow1 = guiCreateWindow(0.25,0.35,0.4,0.4, "plan jop ", true)
bsLabel1 = guiCreateLabel(0.09,0.09,0.8,0.5,[[Welcome to t plan jop]], true,bsWindow1)
guiCreateStaticImage(0.4,0.4,0.1,0.1,"blip.PNG",true, bsWindow1)
guiLabelSetHorizontalAlign(bsLabel1,"center",true)
btnAccept1 = guiCreateButton(0.115,0.7,0.25,0.2, "Accept",true, bsWindow1)
addEventHandler("onClientGUIClick",btnAccept1,bsAccept1)
btnReject1 = guiCreateButton(0.615,0.7,0.25,0.2, "Reject", true, bsWindow1)
addEventHandler("onClientGUIClick",btnReject1,bsReject1)
guiSetVisible(bsWindow1, false)
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
busGui ()
end
)
function markerhit1(thePlayer, matchingDimension)
if ( thePlayer == getLocalPlayer() ) then
guiSetVisible(bsWindow1, true)
showCursor(true)
end
end
addEvent("showbsGui2",true)
addEventHandler("showbsGui2", root, markerhit1)
function bsReject1 ()
guiSetVisible(bsWindow1, false)
showCursor(false)
end
function bsAccept1 (thePlayer)
triggerServerEvent("givebsJob2", getLocalPlayer(), getLocalPlayer() )
bsReject1()
end
سيرفر
local bsMarker = createMarker(1937.98682,-2301.14429,12.6000,"cylinder",2,252,0,255,50)
createBlipAttachedTo(bsMarker,56)
local bsLocations = {
{1443.55371, -2493.37646, 12.99999},
{1477.70557, 1304.07092, 12.99999},
{-1634.96631, -145.10735, 12.99999},
{1443.55371, -2493.37646, 12.99999},
{1477.70557, 1304.07092, 12.99999},
{-1634.96631, -145.10735, 12.99999},
{1443.55371, -2493.37646, 12.99999},
{1477.70557, 1304.07092, 12.99999},
{-1634.96631, -145.10735, 12.99999},
{1439.33911, -2596.01294, 12.99999}}
local bsNumber = {}
addEventHandler("onMarkerHit",bsMarker,
function(hitElement,_)
if (hitElement and getElementType(hitElement) == "player" and not isPedInVehicle(hitElement)) then
if not (getElementData(hitElement,"AGJob2") == "plan driver") then -- we use this to check if the player did not take the job before
triggerClientEvent("showbsGui2", hitElement, hitElement)
else
outputChatBox("Your job already started. Get back to your plan and continue to work!", hitElement,229,250,2)
end
end
end)
local bsVehicle = {}
local bsVehicleBlip = {}
local bsJobMarker = {}
local bsJobBlip = {}
function startbsJob(thePlayer)
setElementData(thePlayer,"AGJob2","plandriver")
bsVehicle[thePlayer] = createVehicle(593,1938.10779, -2320.12524, 13.54688)
bsVehicleBlip[thePlayer] = createBlipAttachedTo(bsVehicle[thePlayer],5)
setElementVisibleTo(bsVehicleBlip[thePlayer],getRootElement(),false)
setElementVisibleTo(bsVehicleBlip[thePlayer],thePlayer,true)
setElementData(bsVehicle[thePlayer],"JobOwner", getPlayerName(thePlayer))
setElementData(bsVehicle[thePlayer],"AGJob2","taxi")
warpPedIntoVehicle(thePlayer,bsVehicle[thePlayer])
showDaBusMarker(thePlayer)
end
addEvent("givebsJob2",true)
addEventHandler("givebsJob2", root,startbsJob)
function showDaBusMarker(thePlayer)
if bsNumber[thePlayer] then
--outputChatBox("bsnumber")
if bsNumber[thePlayer] == 1 then
bsNumber[thePlayer] = bsNumber[thePlayer] + 1
--outputChatBox("bsnumber == 1, so + 1")
elseif bsNumber[thePlayer] == 10 then
bsNumber[thePlayer] = bsNumber[thePlayer] - math.random(1,8)
--outputChatBox("bsnumber - ")
else
bsNumber[thePlayer] = bsNumber[thePlayer] + 1
--outputChatBox("bsnumber + 1")
end
bsJobMarker[thePlayer] = createMarker(bsLocations[bsNumber[thePlayer]][1],bsLocations[bsNumber[thePlayer]][2],bsLocations[bsNumber[thePlayer]][3],"cylinder",2,100,100,0,200)
bsJobBlip[thePlayer] = createBlipAttachedTo(bsJobMarker[thePlayer],19)
setElementData(bsJobMarker[thePlayer],"JobOwner",getPlayerName(thePlayer))
setElementVisibleTo(bsJobMarker[thePlayer],getRootElement(),false)
setElementVisibleTo(bsJobBlip[thePlayer],getRootElement(),false)
setElementVisibleTo(bsJobMarker[thePlayer],thePlayer,true)
setElementVisibleTo(bsJobBlip[thePlayer],thePlayer,true)
addEventHandler("onMarkerHit", bsJobMarker[thePlayer], givebsPay)
else
bsNumber[thePlayer] = math.random(1,10)
--outputChatBox("no bsnumber")
--outputChatBox(bsNumber[thePlayer])
bsJobMarker[thePlayer] = createMarker(bsLocations[bsNumber[thePlayer]][1],bsLocations[bsNumber[thePlayer]][2],bsLocations[bsNumber[thePlayer]][3],"cylinder",2,100,100,0,200)
setElementData(bsJobMarker[thePlayer],"JobOwner",getPlayerName(thePlayer))
bsJobBlip[thePlayer] = createBlipAttachedTo(bsJobMarker[thePlayer],19)
setElementVisibleTo(bsJobMarker[thePlayer],getRootElement(),false)
setElementVisibleTo(bsJobBlip[thePlayer],getRootElement(),false)
setElementVisibleTo(bsJobMarker[thePlayer],thePlayer,true)
setElementVisibleTo(bsJobBlip[thePlayer],thePlayer,true)
addEventHandler("onMarkerHit", bsJobMarker[thePlayer], givebsPay)
end
end
function givebsPay(hitElement,_)
if (getElementType(hitElement) == "player" and getElementData(hitElement,"AGJob2")== "busdriver" and isPedInVehicle(hitElement)) then
--outputChatBox("first step")
if (getElementData(source,"JobOwner") == getPlayerName(hitElement)) then
--outputChatBox("second step")
local vehicle = getPedOccupiedVehicle(hitElement)
if (getElementData(vehicle,"JobOwner") == getElementData(source,"JobOwner" )) then
setElementFrozen(vehicle,true)
setElementFrozen(hitElement,true)
outputChatBox("The passengers are getting down",hitElement,999,0,255)
destroyElement(bsJobMarker[hitElement])
destroyElement(bsJobBlip[hitElement])
setTimer(givebsPayNow,3000,1,hitElement)
else
outputChatBox("Get back to your job vehicle!!!!",hitElement,0,246,255)
end
end
end
end
function givebsPayNow(thePlayer)
setElementFrozen(thePlayer,false)
setElementFrozen(bsVehicle[thePlayer],false)
givePlayerMoney(thePlayer,1500)
showDaBusMarker(thePlayer)
end
function destroybs()
if getElementData(source,"AGJob2") == "busdriver" then
if isElement(bsVehicle[source]) then
destroyElement(bsVehicle[source])
end
if isElement(bsVehicleBlip[source]) then
destroyElement(bsVehicleBlip[source])
end
if isElement(bsJobMarker[source]) then
destroyElement(bsJobMarker[source])
end
if isElement(bsJobBlip[source]) then
destroyElement(bsJobBlip[source])
end
bsNumber[source] = nil
end
end
addEventHandler("onPlayerQuit",getRootElement(), destroybs)
addEventHandler("onVehicleExplode", getRootElement(),
function()
if getElementData(source,"AGJob2") == "busdriver" then
local player = getPlayerFromName(getElementData(source,"JobOwner"))
if isElement(bsVehicle[player]) then
destroyElement(bsVehicle[player])
end
if isElement(bsVehicleBlip[player]) then
destroyElement(bsVehicleBlip[player])
end
if isElement(bsJobMarker[player]) then
destroyElement(bsJobMarker[player])
end
if isElement(bsJobBlip[player]) then
destroyElement(bsJobBlip[player])
end
bsNumber[player] = nil
setElementData(player,"AGJob2",nil)
end
end)
addEventHandler("onVehicleStartEnter",getRootElement(),
function(player,seat,jacked,door)
if (getElementData(source,"AGJob2") and getElementData(source,"AGJob2")=="busdriver") then
if (getElementData(source,"JobOwner") ~= getPlayerName(player)) then
cancelEvent(true)
outputChatBox("This is not your vehicle!!",player,144,0,50)
end
end
end)
addEventHandler("onElementDataChange",getRootElement(),
function(dataName,oldValue)
if getElementType(source) == "player" then
if dataName == "AGJob2" then
if oldValue == "busdriver" then
if isElement(bsVehicle[source]) then
destroyElement(bsVehicle[source])
end
if isElement(bsVehicleBlip[source]) then
destroyElement(bsVehicleBlip[source])
end
if isElement(bsJobMarker[source]) then
destroyElement(bsJobMarker[source])
end
if isElement(bsJobBlip[source]) then
destroyElement(bsJobBlip[source])
end
bsNumber[source] = nil
end
end
end
end)
جربه