Jump to content

[Help] Script.


Killer...

Recommended Posts

Hello, i have got problems whit a Vehicle Upgrade script.

function consoleAddUpgrade ( thePlayer, commandName, id ) 
        if ( isPedInVehicle ( thePlayer ) ) then 
            local id = tonumber ( id ) 
            local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
            local success = addVehicleUpgrade ( theVehicle, id ) 
            if ( success ) then 
                outputConsole ( getVehicleUpgradeSlotName ( id ) .. " modificacion anadida.", thePlayer ) 
            else 
                outputConsole ( "((Fallo al tunear)).", thePlayer ) 
            end 
        else 
            outputConsole ( "((Tienes que estar en un vehiculo!))", thePlayer ) 
        end 
end 
-- add the function as a handler for the "addupgrade" command 
addCommandHandler ( "tunear", consoleAddUpgrade ) 

Te problem is that,

[2014-11-08 19:34:44] WARNING: mechanic/mechanic-s.lua:10: Bad argument @ 'addVehicleUpgrade' [Expected number at argument 2, got nil] 

Link to comment

fixed..

function consoleAddUpgrade ( thePlayer, commandName, id ) 
        if ( isPlayerInVehicle ( thePlayer ) ) then 
            local id = tonumber ( id ) 
            if not tonumber (id) then return end 
            local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
            local success = addVehicleUpgrade ( theVehicle, id ) 
            if ( success ) then   
                outputConsole ( getVehicleUpgradeSlotName ( id ) .. " modificacion anadida.", thePlayer ) 
  
            else 
                outputConsole ( "((Fallo al tunear)).", thePlayer ) 
            end 
        else 
            outputConsole ( "((Tienes que estar en un vehiculo!))", thePlayer )              
        end  
end 
-- add the function as a handler for the "addupgrade" command 
addCommandHandler ( "tunear", consoleAddUpgrade ) 

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