AlphaMark Posted September 15, 2013 Posted September 15, 2013 How can i cancel a function if the player is in a vehicle?
isa_Khamdan Posted September 15, 2013 Posted September 15, 2013 Check if the Player is in Vehicle and if yes then Return the Function.
AlphaMark Posted September 15, 2013 Author Posted September 15, 2013 Yes but how do i check if he is in a vehicle
isa_Khamdan Posted September 15, 2013 Posted September 15, 2013 Yes but how do i check if he is in a vehicle ----------- local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then Return --------- Use isPedInVehicle if the script in Client side.
AlphaMark Posted September 15, 2013 Author Posted September 15, 2013 Bad argument @ 'getPedOccupiedVehicle'
isa_Khamdan Posted September 15, 2013 Posted September 15, 2013 Bad argument @ 'getPedOccupiedVehicle' Post the full code.
AlphaMark Posted September 15, 2013 Author Posted September 15, 2013 I have this atm. (Im not an good scripter) function checkforVehicle ( thePlayer ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then function createExplosionForPlayer ( thePlayer, command ) timer = setTimer ( createJihadForPlayer, 2500, 1, thePlayer, x, y, z ) triggerClientEvent ( "playTheSound", getRootElement(), thePlayer ) setPedAnimation ( thePlayer, "BOMBER","BOM_Plant" ) function createJihadForPlayer ( thePlayer, x, y, z ) local x, y, z = getElementPosition ( thePlayer ) local createdExplosion = createExplosion ( x, y, z, 2 ) local createdExplosion = createExplosion ( x, y, z, 3 ) local createdExplosion = createExplosion ( x, y, z, 10 ) if ( createdExplosion == true ) then outputChatBox ( getPlayerName ( thePlayer ) .." comitted a Jihad!" ) else outputChatBox ("You cant commit a Jihad in a vehicle!") end end end addCommandHandler ( "Jihad", createExplosionForPlayer ) addCommandHandler ( "jihad", createExplosionForPlayer )
isa_Khamdan Posted September 15, 2013 Posted September 15, 2013 I have this atm. (Im not an good scripter) function checkforVehicle ( thePlayer ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then function createExplosionForPlayer ( thePlayer, command ) timer = setTimer ( createJihadForPlayer, 2500, 1, thePlayer, x, y, z ) triggerClientEvent ( "playTheSound", getRootElement(), thePlayer ) setPedAnimation ( thePlayer, "BOMBER","BOM_Plant" ) function createJihadForPlayer ( thePlayer, x, y, z ) local x, y, z = getElementPosition ( thePlayer ) local createdExplosion = createExplosion ( x, y, z, 2 ) local createdExplosion = createExplosion ( x, y, z, 3 ) local createdExplosion = createExplosion ( x, y, z, 10 ) if ( createdExplosion == true ) then outputChatBox ( getPlayerName ( thePlayer ) .." comitted a Jihad!" ) else outputChatBox ("You cant commit a Jihad in a vehicle!") end end end addCommandHandler ( "Jihad", createExplosionForPlayer ) addCommandHandler ( "jihad", createExplosionForPlayer ) function createExplosionForPlayer ( thePlayer, command ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then return else timer = setTimer ( createJihadForPlayer, 2500, 1, thePlayer, x, y, z ) triggerClientEvent ( "playTheSound", getRootElement(), thePlayer ) setPedAnimation ( thePlayer, "BOMBER","BOM_Plant" ) end end addCommandHandler ( "c1", createExplosionForPlayer ) function createJihadForPlayer ( thePlayer, x, y, z ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then return else local x, y, z = getElementPosition ( thePlayer ) local createdExplosion = createExplosion ( x, y, z, 2 ) local createdExplosion = createExplosion ( x, y, z, 3 ) local createdExplosion = createExplosion ( x, y, z, 10 ) if ( createdExplosion == true ) then outputChatBox ( getPlayerName ( thePlayer ) .." comitted a Jihad!" ) else outputChatBox ("You cant commit a Jihad in a vehicle!") end end end addCommandHandler ( "c2", createJihadForPlayer )
AlphaMark Posted September 15, 2013 Author Posted September 15, 2013 Its working but it doesnt show the "You cant commit a Jihad in a vehicle!"
isa_Khamdan Posted September 15, 2013 Posted September 15, 2013 Its working but it doesnt show the "You cant commit a Jihad in a vehicle!" function createExplosionForPlayer ( thePlayer, command ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then return else timer = setTimer ( createJihadForPlayer, 2500, 1, thePlayer, x, y, z ) triggerClientEvent ( "playTheSound", getRootElement(), thePlayer ) setPedAnimation ( thePlayer, "BOMBER","BOM_Plant" ) end end addCommandHandler ( "c1", createExplosionForPlayer ) function createJihadForPlayer ( thePlayer, x, y, z ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then return else local x, y, z = getElementPosition ( thePlayer ) local createdExplosion = createExplosion ( x, y, z, 2 ) local createdExplosion = createExplosion ( x, y, z, 3 ) local createdExplosion = createExplosion ( x, y, z, 10 ) if not ( createdExplosion == true ) then outputChatBox ("You cant commit a Jihad in a vehicle!") else outputChatBox ( getPlayerName ( thePlayer ) .." comitted a Jihad!" ) end end end addCommandHandler ( "c2", createJihadForPlayer )
AlphaMark Posted September 15, 2013 Author Posted September 15, 2013 Still doesnt work. Btw why al those enters?
myonlake Posted September 15, 2013 Posted September 15, 2013 (edited) The output was in the wrong place. function createExplosionForPlayer(thePlayer, command) if (isPedInVehicle(thePlayer)) then outputChatBox("You can't commit a Jihad in a vehicle!", thePlayer) return end setTimer(createJihadForPlayer, 2500, 1, thePlayer, x, y, z) triggerClientEvent("playTheSound", root, thePlayer) setPedAnimation(thePlayer, "BOMBER", "BOM_Plant") end addCommandHandler("c1", createExplosionForPlayer) function createJihadForPlayer(thePlayer, x, y, z) if (isPedInVehicle(thePlayer)) then outputChatBox("You can't commit a Jihad in a vehicle!", thePlayer) return end local x, y, z = getElementPosition(thePlayer) createExplosion(x, y, z, 2) createExplosion(x, y, z, 3) createExplosion(x, y, z, 10) outputChatBox(getPlayerName(thePlayer) .. " committed a Jihad!", root) end addCommandHandler("c2", createJihadForPlayer) Edited September 15, 2013 by Guest
GamerDeMTA Posted September 15, 2013 Posted September 15, 2013 Hey, isn't it easier to use isPedInVehicle function?
myonlake Posted September 15, 2013 Posted September 15, 2013 Hey, isn't it easier to use isPedInVehicle function? Not that much of a difference as both do the same thing, except isPedInVehicle returns only a boolean while getPedOccupiedVehicle returns a boolean or element. Either way works, but as there is a function for isPedInVehicle I edited it to that.
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