xyz Posted March 14, 2016 Share Posted March 14, 2016 function freeze(player) local occveh = getPedOccupiedVehicle(player) if isPedInVehicle(player) == true then if isElementFrozen(occveh) == false then outputChatBox("Your vehicle has been frozen!", player, 79, 226, 249) setElementFrozen(occveh, true) else setElementFrozen(occveh, false) outputChatBox("Your vehicle has been unfrozen!", player, 79, 226, 249) elseif isElementFrozen(player) == true then outputChatBox("You have been unfrozen!", player, 79, 226, 249) else outputChatBox("You have been frozen!", player, 79, 226, 249) setElementFrozen(player, true) end end end addCommandHandler("freeze", freeze) Whats wrong here? I tried to fix it but it won't work. 61: 'end' expected to (to close 'if' at line 55) near 'elseif' Link to comment
Dimos7 Posted March 14, 2016 Share Posted March 14, 2016 (edited) function freeze(thePlayer) local occveh = getPedOccupiedVehicle(thePlayer) if isPedInVehicle(thePlayer) then if isElementFrozen(occveh) == false then outputChatBox("Your vehicle has been frozen!", thePlayer, 79, 226, 249) setElementFrozen(occveh, true) else outputChatBox("Your vehicle has been unfrozen!", thePlayer, 79, 226, 249) setElementFrozen(occveh, false) elseif isElementFrozen(thePlayer) == true then outputChatBox("You have been unfrozen!", thePlayer, 79, 226, 249) setElementFrozen(thePlayer, false) else outputChatBox("You have been frozen!", thePlayer, 79, 226, 249) setElementFrozen(thePlayer, true) end end end addCommandHandler("freeze", freeze) Edited March 14, 2016 by Guest Link to comment
EstrategiaGTA Posted March 14, 2016 Share Posted March 14, 2016 function freeze(player) local occveh = getPedOccupiedVehicle(player) if isPedInVehicle(player) == true then if isElementFrozen(occveh) == false then outputChatBox("Your vehicle has been frozen!", player, 79, 226, 249) setElementFrozen(occveh, true) else setElementFrozen(occveh, false) outputChatBox("Your vehicle has been unfrozen!", player, 79, 226, 249) elseif isElementFrozen(player) == true then outputChatBox("You have been unfrozen!", player, 79, 226, 249) else outputChatBox("You have been frozen!", player, 79, 226, 249) setElementFrozen(player, true) end end end end addCommandHandler("freeze", freeze) Link to comment
KariiiM Posted March 14, 2016 Share Posted March 14, 2016 @Estratigia, your code will returns with some errors ! Try this: function freeze(player) local occveh = getPedOccupiedVehicle(player) if isPedInVehicle(player) == true then if isElementFrozen(occveh) == false then outputChatBox("Your vehicle has been frozen!", player, 79, 226, 249) setElementFrozen(occveh, true) elseif isElementFrozen(player) == true then outputChatBox("You have been unfrozen!", player, 79, 226, 249) else outputChatBox("You have been frozen!", player, 79, 226, 249) setElementFrozen(player, true) end else setElementFrozen(occveh, false) outputChatBox("Your vehicle has been unfrozen!", player, 79, 226, 249) end end addCommandHandler("freeze", freeze) Link to comment
DBY Posted March 14, 2016 Share Posted March 14, 2016 Use this: addCommandHandler("freeze", function(player) local element = (isPedInVehicle(player) and getPedOccupiedVehicle(player) or player) local state = not isElementFrozen(element) setElementFrozen(element, state) outputChatBox((getElementType(element) == "vehicle" and "Your vehicle has" or "You have") .. " been " .. (state and "frozen" or "unfrozen"), player, 9, 226, 249) end ) Link to comment
xyz Posted March 14, 2016 Author Share Posted March 14, 2016 None of these work like intended Link to comment
0m4r Posted March 14, 2016 Share Posted March 14, 2016 function freeze(player) if not isPedInVehicle(player) and isElementFrozen(player) then setElementFrozen(player,false) outputChatBox("You have been unfrozen!", player, 79, 226, 249) else setElementFrozen(player,true) outputChatBox("You have been frozen!", player, 79, 226, 249) end local occveh = getPedOccupiedVehicle(player) if isPedInVehicle(player) and isElementFrozen(occveh) then setElementFrozen (occveh,false) outputChatBox("Your vehicle has been unfrozen!", player, 79, 226, 249) else setElementFrozen(occveh,true) outputChatBox("Your vehicle has been frozen!", player, 79, 226, 249) end end addCommandHandler("freeze",freeze) Link to comment
DBY Posted March 15, 2016 Share Posted March 15, 2016 None of these work like intended What? I tested my code and works perfectly with sero erros in debugscript. Use this: addCommandHandler("freeze", function(player) local element = (isPedInVehicle(player) and getPedOccupiedVehicle(player) or player) local state = not isElementFrozen(element) setElementFrozen(element, state) outputChatBox((getElementType(element) == "vehicle" and "Your vehicle has" or "You have") .. " been " .. (state and "frozen" or "unfrozen"), player, 9, 226, 249) end ) Screenshots: 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