Jump to content

I have a problem with 2 jobs


AlexWo

Recommended Posts

Ok hey guys

I found a pilot job and I downloaded it.

Then I started making my own job( I just chaged some data in the "pilotjob-script".

Well now my Job is working but if im running both jobs at the same time on my server and I take one of this jobs , both jobs start I don't know exactly why but for example If I take my job then its starts my job and the plane job to my player.

Here is the original "Pilot job script"

Server:

----------------------------------------------------------------------------------------------------------------------------- 
--CREATE Plane STUFF 
----------------------------------------------------------------------------------------------------------------------------- 
function planeCreatePlaneStuff() 
    plane_marker_request = createMarker(-1146.98,-240.68,13.14,"arrow",2, 225, 225, 0, 150 ) 
    blip2 = createBlip (-1146.98,-240.68,13.14,5) 
end 
addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),planeCreatePlaneStuff) 
----------------------------------------------------------------------------------------------------------------------------- 
--CREATE Plane 
----------------------------------------------------------------------------------------------------------------------------- 
function planeCreatePlane () 
    thePlane = createVehicle (553,-1163.93,-269.41,17.15) 
    outputChatBox ("*The Plane is behind you.",source,10,235,250) 
end 
addEvent ("planeCreatePlane",true) 
addEventHandler ("planeCreatePlane",getRootElement(),planeCreatePlane) 
---------------------------------------------------------------------------------------------------------------------------------- 
--GIVE MONEY 
---------------------------------------------------------------------------------------------------------------------------------- 
addEvent ("jobsTrainDriverGiveMoney",true) 
addEventHandler ("jobsTrainDriverGiveMoney",getRootElement(), 
function (theMoney) 
    givePlayerMoney(source,theMoney) 
end) 
---------------------------------------------------------------------------------------------------------------------------------- 
--CREATE Plane GUI 
---------------------------------------------------------------------------------------------------------------------------------- 
function planeCreatePlaneGUI(hitElement) 
    if source == plane_marker_request then 
        triggerClientEvent (hitElement,"planeCreatePlaneGUI",getRootElement()) 
    end 
end 
addEventHandler ("onMarkerHit",getRootElement(),planeCreatePlaneGUI) 
  

Client:

---------------------------------------------------------------------------------------------------------------------------------- 
--Plane TABLE 
---------------------------------------------------------------------------------------------------------------------------------- 
local planeTable = { 
[1]={1324.92,1581.27,9.82}, 
[2]={350.09,2537.41,15.73}, 
[3]={-1349.78,-233.62,13.14}, 
[4]={1650.08,-2441.07,12.55}--<----- LA ULTIMA LINEA DE TABLA NO LLEVA COMA 
} 
---------------------------------------------------------------------------------------------------------------------------------- 
--GET PLANE LOCATION 
---------------------------------------------------------------------------------------------------------------------------------- 
function getPlaneLocation(ID) 
if isElement (marker) then 
    destroyElement(marker) 
end 
if isElement (blip) then 
    destroyElement(blip) 
end 
local x, y, z = planeTable[iD][1], planeTable[iD][2], planeTable[iD][3] 
local marker = createMarker(x,y,z,"checkpoint",10,10,235,250,150) 
local blip = createBlipAttachedTo(marker,19,2,10,235,250,225) 
     
    function rewardPlayer (hitPlayer) 
        if hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then 
            if getElementVelocity(getPedOccupiedVehicle(hitPlayer)) <= 2 then 
                outputChatBox ("You arrived succesfully!",hitPlayer,10,235,250) 
                if getElementModel(getPedOccupiedVehicle(hitPlayer)) == 553 then 
                    playSoundFrontEnd (11) 
                    triggerServerEvent("jobsTrainDriverGiveMoney",getLocalPlayer(),math.random(700,800)) 
                    if #planeTable == tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver")) then 
                        setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",1) 
                    else 
                        setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))+1) 
                    end 
                    blipsAttached = getAttachedElements (source) 
                    for i,blips in ipairs (blipsAttached) do 
                        if getElementType (blips) == "blip" then 
                            destroyElement(blips) 
                        end 
                    end 
                    if isElement (source) then 
                        destroyElement(source) 
                    end  
                    getPlaneLocation(tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))) 
                end 
               else 
                    outputChatBox ("*You're going very fast!",hitPlayer,10,235,250) 
             end 
        end 
    end 
    addEventHandler("onClientMarkerHit",marker,rewardPlayer,hitPlayer) 
  
    addEventHandler("onClientVehicleExit",getRootElement(), 
    function (leaveElement) 
        if leaveElement == getLocalPlayer() then 
            if isElement (marker) then 
                destroyElement(marker) 
            end 
            if isElement (blip) then 
                destroyElement(blip) 
            end 
        end 
    end) 
end 
---------------------------------------------------------------------------------------------------------------------------------- 
--ON CLIENT VEHICLE ENTER 
---------------------------------------------------------------------------------------------------------------------------------- 
addEventHandler("onClientVehicleEnter",getRootElement(), 
function (thePlayer) 
    if getElementModel(source) == 553 and getElementModel(thePlayer) == 61 and thePlayer == getLocalPlayer() then  
           outputChatBox ("Now You Can Go To Diferents Airports For Delivery",10,235,250) 
        getPlaneLocation(1) 
        setElementData(thePlayer,"SAMR.jobs_civilian_train_driver",1) 
    end 
end) 
----------------------------------------------------------------------------------------------------------------------------- 
--CREATE Plane GUI 
----------------------------------------------------------------------------------------------------------------------------- 
function planeCreatePlaneGUI() 
plane_window_main = guiCreateWindow (0.3,0.2,0.4,0.5,"Plane Missions",true) 
memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Hello im Robbie, please take the plane and go to the next airport",true,plane_window_main) 
    plane_window_main_button_accept = guiCreateButton(0.52,0.85,0.45,0.1,"Acept",true,plane_window_main) 
    plane_window_main_button_decline = guiCreateButton(0,0.85,0.45,0.1,"Decline",true,plane_window_main) 
    showCursor (true) 
end 
addEvent ("planeCreatePlaneGUI",true) 
addEventHandler ("planeCreatePlaneGUI",getResourceRootElement(getThisResource()),planeCreatePlaneGUI) 
----------------------------------------------------------------------------------------------------------------------------- 
--DESTROY Plane GUI 
----------------------------------------------------------------------------------------------------------------------------- 
function planeDestroyPlaneGUI() 
    destroyElement(plane_window_main) plane_window_main = false 
    showCursor (false) 
end 
----------------------------------------------------------------------------------------------------------------------------- 
--ON plane WINDOW CLICK 
----------------------------------------------------------------------------------------------------------------------------- 
function planeOnPlaneWindowClick() 
   if source == plane_window_main_button_accept then 
        triggerServerEvent ("planeCreatePlane",getLocalPlayer()) 
        planeDestroyPlaneGUI () 
   elseif source == plane_window_main_button_decline then 
        planeDestroyPlaneGUI () 
    end 
end 
addEventHandler("onClientGUIClick",getRootElement(),planeOnPlaneWindowClick) 
  

Now my Changed Job:

Server:

----------------------------------------------------------------------------------------------------------------------------- 
--CREATE Plane STUFF 
----------------------------------------------------------------------------------------------------------------------------- 
function planeCreatePlaneStuff() 
    plane_marker_request = createMarker(816,856,13,"arrow",2, 225, 225, 0, 150 ) 
    blip2 = createBlip (816,856,12.7,56) 
end 
addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),planeCreatePlaneStuff) 
----------------------------------------------------------------------------------------------------------------------------- 
--CREATE Plane 
----------------------------------------------------------------------------------------------------------------------------- 
function planeCreatePlane () 
    thePlane = createVehicle (406,832,832,13) 
    setElementModel(source, 260) 
    outputChatBox ("*The Dumper is behind you.",source,10,235,250) 
end 
addEvent ("planeCreatePlane",true) 
addEventHandler ("planeCreatePlane",getRootElement(),planeCreatePlane) 
---------------------------------------------------------------------------------------------------------------------------------- 
--GIVE MONEY 
---------------------------------------------------------------------------------------------------------------------------------- 
addEvent ("jobsTrainDriverGiveMoney",true) 
addEventHandler ("jobsTrainDriverGiveMoney",getRootElement(), 
function (theMoney) 
    givePlayerMoney(source,theMoney) 
end) 
---------------------------------------------------------------------------------------------------------------------------------- 
--CREATE Plane GUI 
---------------------------------------------------------------------------------------------------------------------------------- 
function planeCreatePlaneGUI(hitElement) 
    if source == plane_marker_request then 
        triggerClientEvent (hitElement,"planeCreatePlaneGUI",getRootElement()) 
    end 
end 
addEventHandler ("onMarkerHit",getRootElement(),planeCreatePlaneGUI) 
  

Client:

---------------------------------------------------------------------------------------------------------------------------------- 
--Plane TABLE 
---------------------------------------------------------------------------------------------------------------------------------- 
local planeTable = { 
[1]={683,977,-12.7}, 
[2]={633,950,-34}, 
[3]={600,820,-43}, 
[4]={500,926,-29}, 
[5]={813,844,11}, 
[6]={835,1116,32}, 
[7]={350,900,22}, 
[8]={835,1116,32}--<----- LA ULTIMA LINEA DE TABLA NO LLEVA COMA 
} 
---------------------------------------------------------------------------------------------------------------------------------- 
--GET PLANE LOCATION 
---------------------------------------------------------------------------------------------------------------------------------- 
function getPlaneLocation(ID) 
if isElement (marker) then 
    destroyElement(marker) 
end 
if isElement (blip) then 
    destroyElement(blip) 
end 
local x, y, z = planeTable[iD][1], planeTable[iD][2], planeTable[iD][3] 
local marker = createMarker(x,y,z,"checkpoint",10,10,235,250,150) 
local blip = createBlipAttachedTo(marker,19,2,10,235,250,225) 
     
    function rewardPlayer (hitPlayer) 
        if hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then 
            if getElementVelocity(getPedOccupiedVehicle(hitPlayer)) <= 2 then 
                outputChatBox ("You arrived succesfully!",hitPlayer,10,235,250) 
                if getElementModel(getPedOccupiedVehicle(hitPlayer)) == 406 then 
                    playSoundFrontEnd (11) 
                    triggerServerEvent("jobsTrainDriverGiveMoney",getLocalPlayer(),math.random(80,100)) 
                    if #planeTable == tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver")) then 
                        setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",1) 
                    else 
                        setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))+1) 
                    end 
                    blipsAttached = getAttachedElements (source) 
                    for i,blips in ipairs (blipsAttached) do 
                        if getElementType (blips) == "blip" then 
                            destroyElement(blips) 
                        end 
                    end 
                    if isElement (source) then 
                        destroyElement(source) 
                    end  
                    getPlaneLocation(tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))) 
                end 
               else 
                    outputChatBox ("*You're going very fast!",hitPlayer,10,235,250) 
             end 
        end 
    end 
    addEventHandler("onClientMarkerHit",marker,rewardPlayer,hitPlayer) 
  
    addEventHandler("onClientVehicleExit",getRootElement(), 
    function (leaveElement) 
        if leaveElement == getLocalPlayer() then 
            if isElement (marker) then 
                destroyElement(marker) 
            end 
            if isElement (blip) then 
                destroyElement(blip) 
            end 
        end 
    end) 
end 
---------------------------------------------------------------------------------------------------------------------------------- 
--ON CLIENT VEHICLE ENTER 
---------------------------------------------------------------------------------------------------------------------------------- 
addEventHandler("onClientVehicleEnter",getRootElement(), 
function (thePlayer) 
    if getElementModel(source) == 406 and getElementModel(thePlayer) == 260 and thePlayer == getLocalPlayer() then  
           outputChatBox ("Now You Can Go To Diferents Airports For Delivery",10,235,250) 
        getPlaneLocation(1) 
        setElementData(thePlayer,"SAMR.jobs_civilian_train_driver",1) 
    end 
end) 
----------------------------------------------------------------------------------------------------------------------------- 
--CREATE Plane GUI 
----------------------------------------------------------------------------------------------------------------------------- 
function planeCreatePlaneGUI() 
plane_window_main = guiCreateWindow (0.3,0.2,0.4,0.5,"Plane Missions",true) 
memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Hello im Robbie, please take the plane and go to the next airport",true,plane_window_main) 
    plane_window_main_button_accept = guiCreateButton(0.52,0.85,0.45,0.1,"Acept",true,plane_window_main) 
    plane_window_main_button_decline = guiCreateButton(0,0.85,0.45,0.1,"Decline",true,plane_window_main) 
    showCursor (true) 
end 
addEvent ("planeCreatePlaneGUI",true) 
addEventHandler ("planeCreatePlaneGUI",getResourceRootElement(getThisResource()),planeCreatePlaneGUI) 
----------------------------------------------------------------------------------------------------------------------------- 
--DESTROY Plane GUI 
----------------------------------------------------------------------------------------------------------------------------- 
function planeDestroyPlaneGUI() 
    destroyElement(plane_window_main) plane_window_main = false 
    showCursor (false) 
end 
----------------------------------------------------------------------------------------------------------------------------- 
--ON plane WINDOW CLICK 
----------------------------------------------------------------------------------------------------------------------------- 
function planeOnPlaneWindowClick() 
   if source == plane_window_main_button_accept then 
        triggerServerEvent ("planeCreatePlane",getLocalPlayer()) 
        planeDestroyPlaneGUI () 
   elseif source == plane_window_main_button_decline then 
        planeDestroyPlaneGUI () 
    end 
end 
addEventHandler("onClientGUIClick",getRootElement(),planeOnPlaneWindowClick) 
  

Hope you can help me :)

PS: My changed job is working fine

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