Jump to content

Spoiler [HELP]


Recommended Posts

Hi, I tried to making spoiler after loading map (5 sec ).

Here is my function:

-- define the handler function for our command 
function consoleAddUpgrade ( thePlayer, addupgrade, 1139 ) 
        -- make sure the player is in a vehicle 
        if ( isPedInVehicle ( thePlayer ) ) then 
            -- convert the given ID from a string to a number 
            local id = tonumber ( 1139 ) 
            -- get the player's vehicle 
            local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
            -- add the requested upgrade to the vehicle 
            local success = addVehicleUpgrade ( theVehicle, 1139 ) 
            -- inform the player of whether the upgrade was added successfully 
            if ( success ) then 
               -- outputConsole ( getVehicleUpgradeSlotName ( id ) .. " upgrade added.", thePlayer ) 
            else 
               -- outputConsole ( "Failed to add upgrade.", thePlayer ) 
            end 
        else 
            --outputConsole ( "You must be in a vehicle!", thePlayer ) 
        end 
end 
-- add the function as a handler for the "addupgrade" command 
addCommandHandler ( "addupgrade", consoleAddUpgrade ) 
  

Please help me with that.

Link to comment

If you are using race gamemode

local seconds = 5 
  
function consoleAddUpgrade ( thePlayer ) 
    if ( isPedInVehicle ( thePlayer ) ) then 
        local id = tonumber ( 1139 ) 
        local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
        if ( theVehicle ) then 
            addVehicleUpgrade ( theVehicle, id ) 
        end 
    end 
end 
  
addEventHandler ( "onMapStarting", root, 
    function ( ) 
        setTimer ( 
            function ( ) 
                for _, player in pairs ( getElementsByType ( "player" ) ) do 
                    consoleAddUpgrade ( player ) 
                end, 
            seconds * 1000, 1 
        ) 
    end 
); 

Link to comment
If you are using race gamemode
local seconds = 5 
  
function consoleAddUpgrade ( thePlayer ) 
    if ( isPedInVehicle ( thePlayer ) ) then 
        local id = tonumber ( 1139 ) 
        local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
        if ( theVehicle ) then 
            addVehicleUpgrade ( theVehicle, id ) 
        end 
    end 
end 
  
addEventHandler ( "onMapStarting", root, 
    function ( ) 
        setTimer ( 
            function ( ) 
                for _, player in pairs ( getElementsByType ( "player" ) ) do 
                    consoleAddUpgrade ( player ) 
                end, 
            seconds * 1000, 1 
        ) 
    end 
); 

Yes I using race gamemode, but.

Debug script: imgur.com/U6VmGSH

I fixed this 19 lines but in 20 idk what is bad.

Link to comment
local seconds = 5 
  
function consoleAddUpgrade ( thePlayer ) 
    if ( isPedInVehicle ( thePlayer ) ) then 
        local id = tonumber ( 1139 ) 
        local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
        if ( theVehicle ) then 
            addVehicleUpgrade ( theVehicle, id ) 
        end 
    end 
end 
  
addEventHandler ( "onMapStarting", root, 
    function ( ) 
        setTimer ( 
            function ( ) 
                for _, player in pairs ( getElementsByType ( "player" ) ) do 
                    consoleAddUpgrade ( player ) 
                end 
            end, 
        seconds * 1000, 1 ) 
    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...