Jump to content

no warp!


Timiimit

Recommended Posts

  • Other Languages Moderators

what gamemode are you using?

anyway you can use something like this

addCommandHandler("lockwarp", 
function(playe) 
setElementData(player,"IsWarpLocked",true) 
end) 
  
addCommandHandler("unlockwarp", 
function(playe) 
setElementData(player,"IsWarpLocked",false) 
end) 

if getElementData(player,"IsWarpLocked") then 
outputChatBox("Not allowed Warp to this player, he is locked warp.") 
return end 

Link to comment
  • Other Languages Moderators

I'M Not IN YOUR HEAD

put this

if getElementData(targetPlayer,"IsWarpLocked") then 
outputChatBox("Not allowed Warp to this player, he is locked warp.") 
return end 

in file 'fr_server' line '250'

it will be

function warpMe(targetPlayer) 
if getElementData(targetPlayer,"IsWarpLocked") then 
outputChatBox("Not allowed Warp to this player, he is locked warp.",source) 
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 
    local interior = getElementInterior(targetPlayer) 
    setElementInterior(source, interior) 
    setCameraInterior(source, interior) 
end 

Link to comment

it says:

  
[2011-12-30 10:59:08] SCRIPT ERROR: freeroam\fr_server.lua:280: ')' expected near 's' 
[2011-12-30 10:59:08] WARNING: Loading script failed: freeroam\fr_server.lua:280: ')' expected near 's' 
[2011-12-30 10:59:09] WARNING: myscripts\lockwarp.lua:11: Bad argument @ 'getElementData' [Expected element at argument 1, got nil] 
  

script file:

  
addCommandHandler("lockwarp", 
function(player) 
    setElementData(player,"IsWarpLocked",true) 
end) 
  
addCommandHandler("unlockwarp", 
function(player) 
setElementData(player,"IsWarpLocked",false) 
end) 
  
if getElementData(targetPlayer,"IsWarpLocked") then 
outputChatBox("Not allowed Warp to this player, he is locked warp.") 
return end 
  

Link to comment
  • Other Languages Moderators

show the function warpMe

and this is Server-Side

addCommandHandler("lockwarp", 
function(player) 
    setElementData(player,"IsWarpLocked",true) 
end) 
  
addCommandHandler("unlockwarp", 
function(player) 
setElementData(player,"IsWarpLocked",false) 
end) 

if you want it client side

addCommandHandler("lockwarp", 
function() 
    setElementData(localPlayer,"IsWarpLocked",true) 
end) 
  
addCommandHandler("unlockwarp", 
function() 
setElementData(localPlayer,"IsWarpLocked",false) 
end) 

and don't put this code in any other resources, only in file 'fr_server' and line '250'

if getElementData(targetPlayer,"IsWarpLocked") then 
outputChatBox("Not allowed Warp to this player, he is locked warp.") 
return end 

Link to comment

fr_server:

  
function warpMe(targetPlayer) 
if getElementData(targetPlayer,"IsWarpLocked") then 
outputChatBox("Not allowed Warp to this player, he is locked warp.",source) 
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 
    local interior = getElementInterior(targetPlayer) 
    setElementInterior(source, interior) 
    setCameraInterior(source, interior) 
end 
  
 

whole 'fr_server':

  
g_Root = getRootElement()
g_ResRoot = getResourceRootElement(getThisResource())
g_PlayerData = {}
g_VehicleData = {}
 
g_ArmedVehicles = {
    [425] = true,
    [447] = true,
    [520] = true,
    [430] = true,
    [464] = true,
    [432] = true
}
g_Trailers = {
    [606] = true,
    [607] = true,
    [610] = true,
    [590] = true,
    [569] = true,
    [611] = true,
    [584] = true,
    [608] = true,
    [435] = true,
    [450] = true,
    [591] = true
}
 
g_RPCFunctions = {
    addPedClothes = { option = 'clothes', descr = 'Modifying clothes' },
    addVehicleUpgrade = { option = 'upgrades', descr = 'Adding/removing upgrades' },
    fadeVehiclePassengersCamera = true,
    fixVehicle = { option = 'repair', descr = 'Repairing vehicles' },
    giveMeVehicles = { option = 'createvehicle', descr = 'Creating vehicles' },
    giveMeWeapon = { option = 'weapons.enabled', descr = 'Getting weapons' },
    givePedJetPack = { option = 'jetpack', descr = 'Getting a jetpack' },
    killPed = { option = 'kill', descr = 'Killing yourself' },
    removePedClothes = { option = 'clothes', descr = 'Modifying clothes' },
    removePedFromVehicle = true,
    removePedJetPack = { option = 'jetpack', descr = 'Removing a jetpack' },
    removeVehicleUpgrade = { option = 'upgrades', descr = 'Adding/removing upgrades' },
    setElementAlpha = { option = 'alpha', descr = 'Changing your alpha' },
    setElementPosition = true,
    setElementInterior = true,
    setMyGameSpeed = { option = 'gamespeed.enabled', descr = 'Setting game speed' },
    setMySkin = { option = 'setskin', descr = 'Setting skin' },
    setPedAnimation = { option = 'anim', descr = 'Setting an animation' },
    setPedFightingStyle = { option = 'setstyle', descr = 'Setting fighting style' },
    setPedGravity = { option = 'gravity.enabled', descr = 'Setting gravity' },
    setPedStat = { option = 'stats', descr = 'Changing stats' },
    setTime = { option = 'time.set', descr = 'Changing time' },
    setTimeFrozen = { option = 'time.freeze', descr = 'Freezing time' },
    setVehicleColor = true,
    setVehicleHeadLightColor = true,
    setVehicleOverrideLights = { option = 'lights', descr = 'Forcing lights' },
    setVehiclePaintjob = { option = 'paintjob', descr = 'Applying paintjobs' },
    setVehicleRotation = true,
    setWeather = { option = 'weather', descr = 'Setting weather' },
    spawnMe = false,
    warpMe = { option = 'warp', descr = 'Warping' }
}
 
g_OptionDefaults = {
    alpha = true,
    anim = true,
    clothes = true,
    createvehicle = true,
    gamespeed = {
        enabled = false,
        min = 0.0,
        max = 3
    },
    gravity = {
        enabled = false,
        min = 0,
        max = 0.1
    },
    jetpack = true,
    kill = true,
    lights = true,
    paintjob = true,
    repair = true,
    setskin = true,
    setstyle = true,
    spawnmaponstart = true,
    spawnmapondeath = true,
    stats = true,
    time = {
        set = false,
        freeze = true
    },
    upgrades = true,
    warp = true,
    weapons = {
        enabled = false,
        vehiclesenabled = true,
        disallowed = {}
    },
    weather = false,
    welcometextonstart = true,
    vehicles = {
        maxidletime = 60000,
        idleexplode = true,
        maxperplayer = 1,
        disallowed = {dumper}
    }
}
 
function getOption(optionName)
    local option = get(optionName:gsub('%.', '/'))
    if option then
        if option == 'true' then
            option = true
        elseif option == 'false' then
            option = false
        end
        return option
    end
    option = g_OptionDefaults
    for i,part in ipairs(optionName:split('.')) do
        option = option[part]
    end
    return option
end
 
addEventHandler('onResourceStart', g_ResRoot,
    function()
        table.each(getElementsByType('player'), joinHandler)
    end
)
 
function joinHandler(player)
    if not player then
        player = source
    end
    local r, g, b = math.random(50, 255), math.random(50, 255), math.random(50, 255)
    setPlayerNametagColor(player, r, g, b)
    g_PlayerData[player] = { vehicles = {} }
    g_PlayerData[player].blip = createBlipAttachedTo(player, 0, 2, r, g, b)
    if g_FrozenTime then
        clientCall(player, 'setTimeFrozen', true, g_FrozenTime[1], g_FrozenTime[2], g_FrozenWeather)
    end
    if getOption('welcometextonstart') then
        outputChatBox('Welcome to Freeroam', player, 0, 255, 0)
        outputChatBox('Press F1 to show/hide controls', player, 0, 255, 0)
    end
end
addEventHandler('onPlayerJoin', g_Root, joinHandler)
 
addEvent('onLoadedAtClient', true)
addEventHandler('onLoadedAtClient', g_ResRoot,
    function(player)
        if getOption('spawnmaponstart') and isPedDead(player) then
            clientCall(player, 'showWelcomeMap')
        end
    end,
    false
)
 
addEventHandler('onPlayerWasted', g_Root,
    function()
        if not getOption('spawnmapondeath') then
            return
        end
        local player = source
        setTimer(
            function()
                if isPedDead(player) then
                    clientCall(player, 'showMap')
                end
            end,
            2000,
            1
        )
    end
)
 
addEvent('onClothesInit', true)
addEventHandler('onClothesInit', g_Root,
    function()
        local result = {}
        local texture, model
        -- get all clothes
        result.allClothes = {}
        local typeGroup, index
        for type=0,17 do
            typeGroup = {'group', type = type, name = getClothesTypeName(type), children = {}}
            table.insert(result.allClothes, typeGroup)
            index = 0
            texture, model = getClothesByTypeIndex(type, index)
            while texture do
                table.insert(typeGroup.children, {id = index, texture = texture, model = model})
                index = index + 1
                texture, model = getClothesByTypeIndex(type, index)
            end
        end
        -- get current player clothes { type = {texture=texture, model=model} }
        result.playerClothes = {}
        for type=0,17 do
            texture, model = getPedClothes(source, type)
            if texture then
                result.playerClothes[type] = {texture = texture, model = model}
            end
        end
        triggerClientEvent(source, 'onClientClothesInit', source, result)
    end
)
 
addEvent('onPlayerGravInit', true)
addEventHandler('onPlayerGravInit', g_Root,
    function()
        triggerClientEvent('onClientPlayerGravInit', source, getPedGravity(source))
    end
)
 
function setMySkin(skinid)
    if isPedDead(source) then
        local x, y, z = getElementPosition(source)
        if isPedTerminated(source) then
            x = 0
            y = 0
            z = 3
        end
        local r = getPedRotation(source)
        local interior = getElementInterior(source)
        spawnPlayer(source, x, y, z, r, skinid)
        setElementInterior(source, interior)
        setCameraInterior(source, interior)
    else
        setElementModel(source, skinid)
        setElementHealth(source, 100)
    end
    setCameraTarget(source, source)
    setCameraInterior(source, getElementInterior(source))
end
 
function spawnMe(x, y, z)
    if not x then
        x, y, z = getElementPosition(source)
    end
    if isPedTerminated(source) then
        repeat until spawnPlayer(source, x, y, z, 0, math.random(9, 288))
    else
        spawnPlayer(source, x, y, z, 0, getPedSkin(source))
    end
    setCameraTarget(source, source)
    setCameraInterior(source, getElementInterior(source))
end
 
function warpMe(targetPlayer)
if
Link to comment
  • MTA Team
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) 

Link to comment
  • 3 years later...
  • Other Languages Moderators

There's two check boxs in freeroam window, one for the "jetpack" and the other for "fall off", you can see how they work and apply the same code in the topic without using the commands.

Link to comment
There's two check boxs in freeroam window, one for the "jetpack" and the other for "fall off", you can see how they work and apply the same code in the topic without using the commands.

Yes bro! I was working on that for long and even referred Scripting tutorials. Still it didn't help me.

Link to comment
  • Other Languages Moderators

Actually removeElementData is server side only, you should use setElementData to remove the data client side. Also player not defined you should use g_Me or localPlayer.

function disableWarp() 
    if guiCheckBoxGetSelected(getControl(wndMain, 'disablewarp')) then 
        setElementData(g_Me, "IsWarpLocked", true) 
    else 
        setElementData(g_Me, "IsWarpLocked", false)       
    end 
end 

Link to comment
Actually removeElementData is server side only, you should use setElementData to remove the data client side. Also player not defined you should use g_Me or localPlayer.
function disableWarp() 
    if guiCheckBoxGetSelected(getControl(wndMain, 'disablewarp')) then 
        setElementData(g_Me, "IsWarpLocked", true) 
    else 
        setElementData(g_Me, "IsWarpLocked", false)       
    end 
end 

Works like a charm! :D .... thank you so much bro...

Link to comment
You're welcome.

I am very sorry bro. But later came to know I get errors and it is not working properly. Tested with 2 players. Here is the list of errors.

  • [2015-04-22 22:24:28] ERROR: Client (tuaos_2) triggered serverside event onPlayerCheckForHexCodes, but event is not added serverside
    [2015-04-22 22:24:28] ERROR: Client (tuaos_2) triggered serverside event onLoadedAtClient, but event is not added serverside
    [2015-04-22 22:24:41] ERROR: Client (tuaos_2) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:24:44] ERROR: Client (tuaos_2) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:24:52] ERROR: Client (tuaos_2) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:01] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:07] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:14] ERROR: Client (tuaos_2) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:19] ERROR: Client (tuaos_2) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:33] ERROR: Client (tuaos_2) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:36] ERROR: Client (tuaos_2) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:38] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:40] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:40] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:42] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:47] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:50] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:51] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:51] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:51] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:53] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:53] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:53] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:54] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:25:57] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:26:01] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:26:10] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside
    [2015-04-22 22:29:18] ERROR: Client (tuaos_1) triggered serverside event onServerCall, but event is not added serverside

fr_client

  

fr_server

  

Edited by Guest
Link to comment
I guess it because you're using old file util.lua and util_server.lua

Try those:

https://github.com/multitheftauto/mtasa ... m/util.lua

https://github.com/multitheftauto/mtasa ... server.lua

I did it and now it doesn't give any me errors. But there is a problem,I can only warp to players with no hexadecimal color code tags on (Warp to player) GUI (only /wt /warpto function works perfectly with all). I think there should be a fix for Freeroam-GUI regarding playernametag.

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