Turbe$Z Posted October 26, 2016 Share Posted October 26, 2016 ---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}, 1 Link to comment
Gravestone Posted October 26, 2016 Share Posted October 26, 2016 21 minutes ago, Turbo777 said: function(player) setElementData(player, "IsWarpLocked", true) else removeElementData(player, "IsWarpLocked") end addEvent( "warponoff", true ) addEventHandler( "warponoff", root, giveWeaponsOnSpawn ) This function doesn't have a name nor does it have an 'if' statement that you're using 'else' at line 3. Link to comment
iPrestege Posted October 26, 2016 Share Posted October 26, 2016 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. 1 Link to comment
Turbe$Z Posted October 26, 2016 Author Share Posted October 26, 2016 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 1 Link to comment
iPrestege Posted October 26, 2016 Share Posted October 26, 2016 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? 1 Link to comment
Turbe$Z Posted October 26, 2016 Author Share Posted October 26, 2016 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/ 1 Link to comment
Gravestone Posted October 26, 2016 Share Posted October 26, 2016 Use onClientResourceStart and then guiCheckBoxSetSelected. Link to comment
Turbe$Z Posted October 26, 2016 Author Share Posted October 26, 2016 4 minutes ago, Gravestone said: Use onClientResourceStart and then guiCheckBoxSetSelected. doesn't working addEventHandler( "onClientResourceStart", getRootElement( ), function () guiCheckBoxSetSelected(getControl ( wndMain,'Warp',true)) end ) 1 Link to comment
Gravestone Posted October 26, 2016 Share Posted October 26, 2016 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) Link to comment
iPrestege Posted October 26, 2016 Share Posted October 26, 2016 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. 1 Link to comment
Turbe$Z Posted October 26, 2016 Author Share Posted October 26, 2016 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 1 Link to comment
iPrestege Posted October 26, 2016 Share Posted October 26, 2016 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. 2 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