Jump to content

Freezing


xyz

Recommended Posts

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
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 by Guest
Link to comment
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

@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

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

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

fP1i9AA.jpg

mSIT9Le.jpg

rO1r0nf.jpg

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