[Release] esx_teleports, easy configurable teleport script, you can specify jobs


#1

This script was just made because i had nothing to do, if you want teleporters to interiors etc. You could use this script and specify a job if you would like only an certain job to access it, easy configurable in config.lua.

If you find any bug feel free to comment down below.

Download

esx_teleports Download


#2

:thinking:



#3

Previews? Screenshots? Gifs? Video? Would make it easier so people can see what they are downloading lol. Even if it is a basic script.


#4

There is redundant code in this script.

In the first part you do the following

PlayerData = ESX.GetPlayerData()

But a bit further down with esx:playerLoaded

PlayerData = xPlayer

So that code is very very redundant to be honest, you do the same thing 2 times

What you could do insted is move LoadMarkers() down in to esx:playerLoaded, and clean up the first part.

It makes more sence to me using the build in function thats called when data is loaded esx:playerLoaded.

You avoid setting the same variable twice, and avoid the check to se if ESX.GetPlayerData() is not nil.

Citizen.CreateThread(function ()
    while ESX == nil do
        TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
        Citizen.Wait(1)
    end
end) 

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
    PlayerData = xPlayer
    LoadMarkers()
end)

Original code

Citizen.CreateThread(function ()
    while ESX == nil do
        TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
        Citizen.Wait(1)
    end

    while ESX.GetPlayerData() == nil do
        Citizen.Wait(10)
    end

    PlayerData = ESX.GetPlayerData()

    LoadMarkers()
end) 

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
    PlayerData = xPlayer
end)

#5

It’s for restarting the script if you restart it it wont do esx:playerLoaded


#6

True. but why keep esx:playerLoaded then ? if you load it the other way, there should be no need for playerLoaded