Jump to content

Vehicle not Recognized


InVision

Recommended Posts

addEvent("pizzaReachDestination",true) 
addEventHandler("pizzaReachDestination",getRootElement(), 
function (thePlayer) 
    if not isPedInVehicle(thePlayer) then return end 
    theVehicle = getPedOccupiedVehicle(thePlayer) 
    if not getElementModel(theVehicle) == "448" then return end 
    outputChatBox("You have delivered the pizza, and received $25", thePlayer, 0, 255, 0) 
    exports.global:giveMoney(thePlayer, 25) 
    if getElementData(thePlayer,"pizzaStop") == #pizzaRoute[getElementData(thePlayer,"pizzaRoute")] then 
        setElementData(thePlayer,"pizzaStop",1) 
    else 
        setElementData(thePlayer,"pizzaStop",tonumber(getElementData(thePlayer,"pizzaStop"))+1) 
    end 
    GGgetNewDDestination(thePlayer, getElementData(thePlayer,"pizzaStop")) 
end 
) 

The script is not recognizing the Pizza Boy as vehicle? maybe there's something I did wrong?

Link to comment
  • Moderators
addEvent("pizzaReachDestination",true) 
addEventHandler("pizzaReachDestination",getRootElement(), 
function (thePlayer) 
    local theVehicle = getPedOccupiedVehicle(thePlayer) 
     
     
    if not theVehicle or getElementModel(theVehicle) ~= 448 then return end  
    -- must be a number, not a string "448" > 448 -- 
     
     
    outputChatBox("You have delivered the pizza, and received $25", thePlayer, 0, 255, 0) 
    exports.global:giveMoney(thePlayer, 25) 
    if getElementData(thePlayer,"pizzaStop") == #pizzaRoute[getElementData(thePlayer,"pizzaRoute")] then 
        setElementData(thePlayer,"pizzaStop",1) 
    else 
        setElementData(thePlayer,"pizzaStop",tonumber(getElementData(thePlayer,"pizzaStop"))+1) 
    end 
    GGgetNewDDestination(thePlayer, getElementData(thePlayer,"pizzaStop")) 
end) 

Link to comment

It's suppose to be a string, I have this script set up with other vehicles, but it just won't work with the Pizza Boy :/

But here's the second part of the script, maybe I did something wrong on it...

addEventHandler("onVehicleEnter", getRootElement(), 
function (thePlayer) 
    theVehicle = getPedOccupiedVehicle(thePlayer) 
    if  getVehicleName(theVehicle) == "pizzaboy" then 
        if getPedOccupiedVehicleSeat(thePlayer) == 0 then 
            setElementData(thePlayer,"pizzaStop",1 ) 
            setElementData(thePlayer,"pizzaRoute",math.random(1, 5)) 
            thepizzaRoute = getElementData(thePlayer,"pizzaRoute") 
            outputChatBox("Drive to the Flag Blips and drive through the Blue Markers to deliver the pizzas, and receive your pay.", thePlayer, 255, 194, 15) 
            outputChatBox("*If you exit the vehicle, you'll have to restart the whole route over again*", thePlayer, 255, 0, 0) 
            outputDebugString("Driving on route ".. tonumber(pizzaRoute[thepizzaRoute][0][1]) .. " towards " .. pizzaRoute[thepizzaRoute][0][2]) 
            local name, size, x, y, z = GGgetNewDDestination(thePlayer, 1) 
        end 
    end 
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...