Miika Posted December 25, 2014 Posted December 25, 2014 I start coding the boat sinking script. First i want add rotation. But I have problem. WANRNING: restart/restart.lua:9: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument, 1 got nil] Code: function commandX(thePlayer) vehicle = getPedOccupiedVehicle ( thePlayer ) if (getVehicleType(vehicle) == "Boat") then setTimer (timerA, 1000, 1) else outputChatBox("You don't have a boat!", thePlayer, 255, 255, 0, true) end end addCommandHandler("sink", commandX) function timerA() theVehicle = getPedOccupiedVehicle ( source ) if theVehicle then local rotX, rotY, rotZ = getElementRotation( theVehicle ) local posX, posY, posZ = getElementPosition( theVehicle ) setElementRotation(theVehicle, 0, 0, rotZ+0.01) setTimer (timerB, 1, 1) else return end end function timerB( thePlayer ) theBoat = getPedOccupiedVehicle ( source ) if theVehicle then local rotX, rotY, rotZ = getElementRotation( theBoat ) local posX, posY, posZ = getElementPosition( theBoat ) setElementRotation(theBoat, 0, 0, rotZ+0.01) setTimer (timerA, 1, 1) else return end end Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Castillo Posted December 25, 2014 Posted December 25, 2014 Is it a client side script? if so, then the first parameter of addCommandHandler is the command name, use 'localPlayer'. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Miika Posted December 25, 2014 Author Posted December 25, 2014 Is it a client side script? if so, then the first parameter of addCommandHandler is the command name, use 'localPlayer'. It is serverside script Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Castillo Posted December 25, 2014 Posted December 25, 2014 Ah wait, I thought it was the first getPedOccupiedVehicle, but it was the one inside function "timerA". The problem is that 'source' is nothing, you need to pass the player/vehicle element in the timer arguments. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Miika Posted December 25, 2014 Author Posted December 25, 2014 Ah wait, I thought it was the first getPedOccupiedVehicle, but it was the one inside function "timerA".The problem is that 'source' is nothing, you need to pass the player/vehicle element in the timer arguments. The timer works, but the boat begins to vibrate, but does not turn function commandX(thePlayer) vehicle = getPedOccupiedVehicle ( thePlayer ) rotX, rotY, rotZ = getElementRotation(vehicle) if (getVehicleType(vehicle) == "Boat") then setTimer (timerA, 1000, 1) else outputChatBox("You don't have a boat!", thePlayer, 255, 255, 0, true) end end addCommandHandler("sink", commandX) function timerA( thePlayer ) setElementRotation(vehicle, 0, 0, rotZ+0.1) setTimer (timerB, 50, 1) end function timerB( thePlayer ) setElementRotation(vehicle, 0, 0, rotZ+0.1) setTimer (timerA, 50, 1) end Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Castillo Posted December 26, 2014 Posted December 26, 2014 Doing that, you are just defining a global variable, meaning this script will only work with a single player. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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