Jump to content

Help needed.(Tables)


Prat

Recommended Posts

Hello

after wasting a lot of my time , i made a script but itsn't working.

so basically the script is about Pilot job , when you do /startshift , a blip and marker displays on ur map , so its working perfectly so far , but the problem is , when i add markerhit event in other function it doesn't work , so i need ur help here.

the script should work in these ways :-

only "Pilot" team can do /startshift

you will only get money when you hit the marker by the vehicle "Dodo".

local deliverP = { 
    --Los Santos 
    {1787.7626953125, -2555.7822265625, 13}, 
    {-1662.8570556641, -291.42846679688, 14}, 
    {1448.5712890625, 1508.5714111328, 10}, 
} 
thisRes = getResourceRootElement(getThisResource())  
  
local PilotPlane = createVehicle (593, 1890.3594970703, -2493.8330078125, 13.53911781311) 
function PilotDeliver() 
        random = math.random(#deliverP) 
        x, y, z = deliverP[random][1], deliverP[random][2], deliverP[random][3] 
        delBlip = createBlip ( x,y,z, 51) 
        delmarker = createMarker ( x,y,z, "cylinder", 5, 255, 160, 0, 100) 
        outputChatBox ( "You have a new flight , go to location bliped on your map!", root, 255, 100, 0, true ) 
end 
addCommandHandler ("startshift", PilotDeliver) 
  
function DelPayment(hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
    randomPay = math.random ( 2000, 5000 ) 
    givePlayerMoney (randomPay) 
    outputChatBox ( "You Arrived to your distenation , This is your payment"..tostring(randomPay).."$", root, 255, 100, 0, true ) 
    end 
end 
addEventHandler ("onMarkerHit", delmarker, DelPayment) 
  

thanks for reading.

cheers

Link to comment

try no tested

local deliverP = { 
    --Los Santos 
    {1787.7626953125, -2555.7822265625, 13}, 
    {-1662.8570556641, -291.42846679688, 14}, 
    {1448.5712890625, 1508.5714111328, 10} 
} 
thisRes = getResourceRootElement(getThisResource()) 
  
local PilotPlane = createVehicle (593, 1890.3594970703, -2493.8330078125, 13.53911781311) 
function PilotDeliver() 
       local random1 = math.random(#deliverP) 
        x, y, z = deliverP[random1][1], deliverP[random1][2], deliverP[random1][3] 
        delBlip = createBlip ( x,y,z, 51) 
        delmarker = createMarker ( x,y,z, "cylinder", 5, 255, 160, 0, 100) 
        outputChatBox ( "You have a new flight , go to location bliped on your map!", root, 255, 100, 0, true ) 
end 
addCommandHandler ("startshift", PilotDeliver) 
  
function DelPayment(hitElement) 
    if getElementType(hitElement) == "player" and getElementModel(getVehicleController(hitElement)) == 593 then 
    randomPay = math.random ( 2000, 5000 ) 
    givePlayerMoney (randomPay) 
    outputChatBox ( "You Arrived to your distenation , This is your payment"..tostring(randomPay).."$", root, 255, 100, 0, true ) 
    end 
end 
addEventHandler ("onMarkerHit", delmarker, DelPayment) 

Link to comment
local deliverP = { 
    --Los Santos 
    {1787.7626953125, -2555.7822265625, 13}, 
    {-1662.8570556641, -291.42846679688, 14}, 
    {1448.5712890625, 1508.5714111328, 10}, 
} 
  
local PilotPlane = createVehicle ( 593, 1890.3594970703, -2493.8330078125, 13.53911781311 ) 
local data = { } 
  
function PilotDeliver ( thePlayer ) 
    local team = getPlayerTeam ( thePlayer ) 
    if ( team and getTeamName ( team ) == "Pilot" ) then 
        local x, y, z = unpack ( deliverP [ math.random ( #deliverP ) ] ) 
        data [ thePlayer ] = 
            { 
                delBlip = createBlip ( x, y, z, 51 ), 
                delmarker = createMarker ( x, y, z, "cylinder", 5, 255, 160, 0, 100 ) 
            } 
        addEventHandler ( "onMarkerHit", data [ thePlayer ].delmarker, DelPayment ) 
        outputChatBox ( "You have a new flight , go to location bliped on your map!", thePlayer, 255, 100, 0, true ) 
    end 
end 
addCommandHandler ( "startshift", PilotDeliver ) 
  
function DelPayment ( hitElement ) 
    if ( getElementType ( hitElement ) == "player" ) then 
        local vehicle = getPedOccupiedVehicle ( hitElement ) 
        if ( vehicle and getElementModel ( vehicle ) == 593 ) then 
            local randomPay = math.random ( 2000, 5000 ) 
            givePlayerMoney ( randomPay ) 
            outputChatBox ( "You Arrived to your distenation , This is your payment".. tostring ( randomPay ) .."$", hitElement, 255, 100, 0, true ) 
            if ( data [ hitElement ] ) then 
                if isElement ( data [ hitElement ].delBlip ) then 
                    destroyElement ( data [ hitElement ].delBlip ) 
                end 
                if isElement ( data [ hitElement ].delmarker ) then 
                    destroyElement ( data [ hitElement ].delmarker ) 
                end 
            end 
        end 
    end 
end 

Link to comment
local deliverP = { 
    --Los Santos 
    {1787.7626953125, -2555.7822265625, 13}, 
    {-1662.8570556641, -291.42846679688, 14}, 
    {1448.5712890625, 1508.5714111328, 10}, 
} 
  
local PilotPlane = createVehicle ( 593, 1890.3594970703, -2493.8330078125, 13.53911781311 ) 
local data = { } 
  
function PilotDeliver ( thePlayer ) 
    local team = getPlayerTeam ( thePlayer ) 
    if ( team and getTeamName ( team ) == "Pilot" ) then 
        if ( data [ thePlayer ] and isElement ( data [ thePlayer ].delBlip ) and isElement ( data [ thePlayer ].delmarker ) ) then 
            return outputChatBox ( "You already got a destination.", thePlayer, 255, 0, 0 ) 
        end 
  
        local x, y, z = unpack ( deliverP [ math.random ( #deliverP ) ] ) 
        data [ thePlayer ] = 
            { 
                delBlip = createBlip ( x, y, z, 51 ), 
                delmarker = createMarker ( x, y, z, "cylinder", 5, 255, 160, 0, 100 ) 
            } 
        addEventHandler ( "onMarkerHit", data [ thePlayer ].delmarker, DelPayment ) 
        outputChatBox ( "You have a new flight , go to location bliped on your map!", thePlayer, 255, 100, 0, true ) 
    end 
end 
addCommandHandler ( "startshift", PilotDeliver ) 
  
function DelPayment ( hitElement ) 
    if ( getElementType ( hitElement ) == "player" ) then 
        local vehicle = getPedOccupiedVehicle ( hitElement ) 
        if ( vehicle and getElementModel ( vehicle ) == 593 ) then 
            local randomPay = math.random ( 2000, 5000 ) 
            givePlayerMoney ( randomPay ) 
            outputChatBox ( "You Arrived to your distenation , This is your payment".. tostring ( randomPay ) .."$", hitElement, 255, 100, 0, true ) 
            if ( data [ hitElement ] ) then 
                if isElement ( data [ hitElement ].delBlip ) then 
                    destroyElement ( data [ hitElement ].delBlip ) 
                end 
                if isElement ( data [ hitElement ].delmarker ) then 
                    destroyElement ( data [ hitElement ].delmarker ) 
                end 
            end 
        end 
    end 
end 

Link to comment
local deliverP = { 
    --Los Santos 
    {1787.7626953125, -2555.7822265625, 13}, 
    {-1662.8570556641, -291.42846679688, 14}, 
    {1448.5712890625, 1508.5714111328, 10}, 
} 
  
local PilotPlane = createVehicle ( 593, 1890.3594970703, -2493.8330078125, 13.53911781311 ) 
local data = { } 
  
function PilotDeliver ( thePlayer ) 
    local team = getPlayerTeam ( thePlayer ) 
    if ( team and getTeamName ( team ) == "Pilot" ) then 
        if ( data [ thePlayer ] and isElement ( data [ thePlayer ].delBlip ) and isElement ( data [ thePlayer ].delmarker ) ) then 
            return outputChatBox ( "You already got a destination.", thePlayer, 255, 0, 0 ) 
        end 
  
        giveDestination ( thePlayer ) 
    end 
end 
addCommandHandler ( "startshift", PilotDeliver ) 
  
function DelPayment ( hitElement ) 
    if ( getElementType ( hitElement ) == "player" ) then 
        local vehicle = getPedOccupiedVehicle ( hitElement ) 
        if ( vehicle and getElementModel ( vehicle ) == 593 ) then 
            local randomPay = math.random ( 2000, 5000 ) 
            givePlayerMoney ( randomPay ) 
            outputChatBox ( "You Arrived to your distenation , This is your payment".. tostring ( randomPay ) .."$", hitElement, 255, 100, 0, true ) 
            if ( data [ hitElement ] ) then 
                if isElement ( data [ hitElement ].delBlip ) then 
                    destroyElement ( data [ hitElement ].delBlip ) 
                end 
                if isElement ( data [ hitElement ].delmarker ) then 
                    destroyElement ( data [ hitElement ].delmarker ) 
                end 
            end 
            setTimer ( giveDestination, 5000, 1, hitElement ) 
        end 
    end 
end 
  
function giveDestination ( thePlayer ) 
    if ( not isElement ( thePlayer ) ) then 
        return 
    end 
  
    local x, y, z = unpack ( deliverP [ math.random ( #deliverP ) ] ) 
    data [ thePlayer ] = 
        { 
            delBlip = createBlip ( x, y, z, 51 ), 
            delmarker = createMarker ( x, y, z, "cylinder", 5, 255, 160, 0, 100 ) 
        } 
    addEventHandler ( "onMarkerHit", data [ thePlayer ].delmarker, DelPayment ) 
    outputChatBox ( "You have a new flight , go to location bliped on your map!", thePlayer, 255, 100, 0, true ) 
end 

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