Turbe$Z

Why not working warp disable in freeroam?

Recommended Posts

---server
 

function warpMe(targetPlayer) 
    local interior = getElementInterior(targetPlayer) 
    setElementInterior(source, interior) 
    setCameraInterior(source, interior) 
  
    if getElementData(targetPlayer, "IsWarpLocked") then 
        outputChatBox("Ez a játékos nem engedte meg, hogy rá warpoljanak!", source, r, g, b, 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 

function(player) 
    setElementData(player, "IsWarpLocked", true) 
	else
	removeElementData(player, "IsWarpLocked") 
end
addEvent( "warponoff", true )
addEventHandler( "warponoff", root, giveWeaponsOnSpawn )

---client

function warponoff ( 	)
    triggerServerEvent("warponoff", getLocalPlayer(), group)
end
		{'chk', id='Warp', onclick=warponoff, width=60},

 

  • Like 1

Share this post


Link to post

Try this in client :

 

function warponoff ( 	)
    if guiCheckBoxGetSelected ( getControl ( wndMain,'Warp' ) ) then
    		setElementData ( localPlayer,'IsWarpLocked',true )
    else
    		setElementData ( localPlayer,'IsWarpLocked',false )
    end
end

 

Don't put this under the main window table put it in the top or some where in there.

 

In server side : 

 


function warpMe(targetPlayer)
	if isPedDead(source) then
		spawnMe()
	end
    if getElementData ( targetPlayer,'IsWarpLocked' ) == true then 
        outputChatBox ( 'Ez a játékos nem engedte meg, hogy rá warpoljanak!', source,255,0,0 ) return
     
    end 
	local vehicle = getPedOccupiedVehicle(targetPlayer)
	local interior = getElementInterior(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)
		setElementInterior(source, interior)
		setCameraInterior(source, interior)
	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
				setElementInterior(source, interior)
				setCameraInterior(source, interior)
				warpPedIntoVehicle(source, vehicle, i)
				return
			end
		end
		outputChatBox('No free seats left in ' .. getPlayerName(targetPlayer) .. '\'s vehicle.', source, 255, 0, 0)
	end
end

 

 

There's no need for the trigger and remove element data just do as what i say and it should work fine.

  • Like 1

Share this post


Link to post
23 minutes ago, FaHaD said:

Try this in client :

 


function warponoff ( 	)    if guiCheckBoxGetSelected ( getControl ( wndMain,'Warp' ) ) then    		setElementData ( localPlayer,'IsWarpLocked',true )    else    		setElementData ( localPlayer,'IsWarpLocked',false )    end
end

 

Don't put this under the main window table put it in the top or some where in there.

 

In server side : 

 


function warpMe(targetPlayer)	if isPedDead(source) then		spawnMe()	end    if getElementData ( targetPlayer,'IsWarpLocked' ) == true then         outputChatBox ( 'Ez a játékos nem engedte meg, hogy rá warpoljanak!', source,255,0,0 ) return
     
    end 
	local vehicle = getPedOccupiedVehicle(targetPlayer)
	local interior = getElementInterior(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)
		setElementInterior(source, interior)
		setCameraInterior(source, interior)
	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
				setElementInterior(source, interior)
				setCameraInterior(source, interior)
				warpPedIntoVehicle(source, vehicle, i)
				return
			end
		end
		outputChatBox('No free seats left in ' .. getPlayerName(targetPlayer) .. '\'s vehicle.', source, 255, 0, 0)
	end
end

 

 

There's no need for the trigger and remove element data just do as what i say and it should work fine.

thanks, working fine:D but i tried this in client side, and doesn't working setselected, why?

function warponoff ( 	)
    if guiCheckBoxGetSelected ( getControl ( wndMain,'Warp' ) ) then
			guiCheckBoxSetSelected(getControl ( wndMain,'Warp',true))
			setElementData ( localPlayer,'IsWarpLocked',false )
    else
    		setElementData ( localPlayer,'IsWarpLocked',true )
	end
end

 

  • Like 1

Share this post


Link to post
1 minute ago, Turbo777 said:

thanks, working fine:D but i tried this in client side, and doesn't working setselected, why?


function warponoff ( 	)
    if guiCheckBoxGetSelected ( getControl ( wndMain,'Warp' ) ) then
			guiCheckBoxSetSelected(getControl ( wndMain,'Warp',true))
			setElementData ( localPlayer,'IsWarpLocked',false )
    else
    		setElementData ( localPlayer,'IsWarpLocked',true )
	end
end

 

 

 

Why are you doing this? for what? if you check the box it will stay checked?

  • Like 1

Share this post


Link to post
1 minute ago, FaHaD said:

 

 

Why are you doing this? for what? if you check the box it will stay checked?

when a player join to the server, can disable warp, like fall of bike 

/sorry for my bad english/

  • Like 1

Share this post


Link to post
Just now, Turbo777 said:

guiCheckBoxSetSelected(getControl ( wndMain,'Warp',true))

Does getControl(wndMain, 'Warp', true) return a check box element? If no, then use this:

guiCheckBoxSetSelected(chechkbox, true)

 

Share this post


Link to post

open fr_client.lua > search for bindKey for the freeroam which will be like this maybe in your file between line 1500-1650 you will find this function :

 

addEventHandler('onClientResourceStart', g_ResRoot,
	function()
		fadeCamera(true)
		setTimer(getPlayers, 1000, 1)
		
		bindKey('f1', 'down', toggleFRWindow)
		createWindow(wndMain)
		hideAllWindows()
		guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me))
		  guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(g_Me))
		setJetpackMaxHeight ( 9001 )
		triggerServerEvent('onLoadedAtClient', g_ResRoot)
	end
)

-- JUST ADD THIS LINE UNDER THE FALLOFF CHECKBOX SET SELECTED LIKE THIS :

guiCheckBoxSetSelected(getControl(wndMain, 'Warp'),true)

addEventHandler('onClientResourceStart', g_ResRoot,
	function()
		fadeCamera(true)
		setTimer(getPlayers, 1000, 1)
		
		bindKey('f1', 'down', toggleFRWindow)
		createWindow(wndMain)
		hideAllWindows()
		guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me))
		guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(g_Me))
   	    guiCheckBoxSetSelected(getControl(wndMain, 'Warp'),true)
		setJetpackMaxHeight ( 9001 )
		triggerServerEvent('onLoadedAtClient', g_ResRoot)
	end
)

 

And replace this function : 

 

function warponoff ( 	)
    if guiCheckBoxGetSelected ( getControl ( wndMain,'Warp' ) ) then
			setElementData ( localPlayer,'IsWarpLocked',false )
    else
    		setElementData ( localPlayer,'IsWarpLocked',true )
	end
end


-- To

function warponoff ( 	)
    if guiCheckBoxGetSelected ( getControl ( wndMain,'Warp' ) ) then
			setElementData ( localPlayer,'IsWarpLocked',true )
    else
    		setElementData ( localPlayer,'IsWarpLocked',false )
	end
end

-- JUST Change the data false to true and true to false replace between them.

EDIT + Add :

 

addEventHandler('onClientResourceStart', g_ResRoot,
	function()
		fadeCamera(true)
		setTimer(getPlayers, 1000, 1)
		bindKey('f1', 'down', toggleFRWindow)
		createWindow(wndMain)
		hideAllWindows()
		guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me))
		guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(g_Me))
		setJetpackMaxHeight ( 9001 )
		guiCheckBoxSetSelected(getControl(wndMain, 'Warp'),true)
		setElementData ( localPlayer,'IsWarpLocked',true )
		triggerServerEvent('onLoadedAtClient', g_ResRoot)
	end
)

 

You have to do this to set the data to true so they can't warp when the resource start.

  • Like 1

Share this post


Link to post
4 minutes ago, FaHaD said:

open fr_client.lua > search for bindKey for the freeroam which will be like this maybe in your file between line 1500-1650 you will find this function :

 


addEventHandler('onClientResourceStart', g_ResRoot,
	function()
		fadeCamera(true)
		setTimer(getPlayers, 1000, 1)
		
		bindKey('f1', 'down', toggleFRWindow)
		createWindow(wndMain)
		hideAllWindows()
		guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me))
		  guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(g_Me))
		setJetpackMaxHeight ( 9001 )
		triggerServerEvent('onLoadedAtClient', g_ResRoot)
	end
)

-- JUST ADD THIS LINE UNDER THE FALLOFF CHECKBOX SET SELECTED LIKE THIS :

guiCheckBoxSetSelected(getControl(wndMain, 'Warp'),true)

addEventHandler('onClientResourceStart', g_ResRoot,
	function()
		fadeCamera(true)
		setTimer(getPlayers, 1000, 1)
		
		bindKey('f1', 'down', toggleFRWindow)
		createWindow(wndMain)
		hideAllWindows()
		guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me))
		guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(g_Me))
   	    guiCheckBoxSetSelected(getControl(wndMain, 'Warp'),true)
		setJetpackMaxHeight ( 9001 )
		triggerServerEvent('onLoadedAtClient', g_ResRoot)
	end
)

 

And replace this function : 

 


function warponoff ( 	)
    if guiCheckBoxGetSelected ( getControl ( wndMain,'Warp' ) ) then
			setElementData ( localPlayer,'IsWarpLocked',false )
    else
    		setElementData ( localPlayer,'IsWarpLocked',true )
	end
end


-- To

function warponoff ( 	)
    if guiCheckBoxGetSelected ( getControl ( wndMain,'Warp' ) ) then
			setElementData ( localPlayer,'IsWarpLocked',true )
    else
    		setElementData ( localPlayer,'IsWarpLocked',false )
	end
end

-- JUST Change the data false to true and true to false replace between them.

thanks man:DD

  • Like 1

Share this post


Link to post
Just now, Turbo777 said:

thanks man:DD

 

You are welcome please check my post again i have added a setElementData when the resource start to set the data to true so the players can't warp.

  • Like 2

Share this post


Link to post

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.