MitnickP56 Posted May 23, 2015 Share Posted May 23, 2015 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
ALw7sH Posted May 23, 2015 Share Posted May 23, 2015 What's the errors on debugscript Link to comment
MitnickP56 Posted May 23, 2015 Author Share Posted May 23, 2015 Command working, I need function : 5 sec after loading map write /addupgrade . Idk how do it. Link to comment
Bilal135 Posted May 24, 2015 Share Posted May 24, 2015 Command working, I need function : 5 sec after loading map write /addupgrade . Idk how do it. Use: setTimer Link to comment
WhoAmI Posted May 24, 2015 Share Posted May 24, 2015 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
MitnickP56 Posted May 25, 2015 Author Share Posted May 25, 2015 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
WhoAmI Posted May 25, 2015 Share Posted May 25, 2015 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
MitnickP56 Posted May 25, 2015 Author Share Posted May 25, 2015 Script working, really thanks Master Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now