Jump to content

Why not working toggle warp?


Turbe$Z

Recommended Posts

Posted

fr_server.lua:

function warpMe(targetPlayer) 
    local interior = getElementInterior(targetPlayer) 
    setElementInterior(source, interior) 
    setCameraInterior(source, interior) 
  
    if getElementData(targetPlayer, "IsWarpLocked") then 
        outputChatBox("The player you want to warp to has locked warping.", source, 255, 0, 0, false) 
        return 
    end 
     
    if isPedDead(source) then 
        spawnMe() 
    end 
  
    local vehicle = getPedOccupiedVehicle(targetPlayer) 
    if not vehicle then 
        -- target player is not in a vehicle - just warp next to him 
        local x, y, z = getElementPosition(targetPlayer) 
        clientCall(source, 'setPlayerPosition', x + 2, y, z) 
    else 
        -- target player is in a vehicle - warp into it if there's space left 
        if getPedOccupiedVehicle(source) then 
            --removePlayerFromVehicle(source) 
            outputChatBox('Get out of your vehicle first.', source) 
            return 
        end 
        local numseats = getVehicleMaxPassengers(vehicle) 
        for i=0,numseats do 
            if not getVehicleOccupant(vehicle, i) then 
                if isPedDead(source) then 
                    local x, y, z = getElementPosition(vehicle) 
                    spawnMe(x + 4, y, z + 1) 
                end 
                warpPedIntoVehicle(source, vehicle, i) 
                return 
            end 
        end 
        outputChatBox("No free seats left in " .. getPlayerName(targetPlayer) .. "'s vehicle.", source, 255, 0, 0) 
    end 
end 
addCommandHandler("lockwarp", 
function(player) 
    setElementData(player, "IsWarpLocked", true) 
end) 
  
addCommandHandler("unlockwarp", 
function(player) 
    removeElementData(player, "IsWarpLocked") 
end) 

fr_client.lua:

		{'chk', id='IsWarpLocked', text='Warp', onclick=toggleWarp, width=60},

 

Posted

Try to put outputChatBox as debug method or outputDebugString for seeing until where the code arrives, and if the code doesn't execute in some part search for connected things to that part.

Posted
17 minutes ago, Simple01 said:

Try to put outputChatBox as debug method or outputDebugString for seeing until where the code arrives, and if the code doesn't execute in some part search for connected things to that part.

How ? O.o

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