CHEF491

[HELP]Team Spawn

Recommended Posts

Hi buddies ,

We tried to set team spawn but we can't make it. We writed some codes. Where did we do wrong ? If you help me, I feel be happy. Thanks for reading...

local spawnpoint

addEventHandler("onResourceStart", resourceRoot,
    function()
        spawnpoint = getRandomSpawnPoint()
        resetMapInfo()
        for i,player in ipairs(getElementsByType("player")) do
            spawn(player)
        end
    end
)

function spawn(player)
    --if not isElement(player) then return end
    if get("spawnreset") == "onSpawn" then
        spawnpoint = getRandomSpawnPoint()
    end
    exports.spawnmanager:spawnPlayerAtSpawnpoint(player,spawnpoint,false)
    repeat until setElementModel(player,math.random(312))
    fadeCamera(player, true)
    setCameraTarget(player, player)
    showChat(player, true)
end

function getRandomSpawnPoint ()
    local spawnpoints = getElementsByType("spawnpoint")
    return spawnpoints[math.random(1,#spawnpoints)]
end

addEventHandler("onPlayerJoin", root, --oyuncu servera girdiğinde
    function()
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("**^HYDRA^**")) then --eğer oyuncu **^HYDRA^** grubunda ise
    setTimer(spawnPlayer, 2000, 1, source, 1437.5341796875, 734.0068359375, 10.8203125) --oyuncuyu burda spawnla
    else    
        spawn(source)
    end
    
end)

addEventHandler("onPlayerLogin", root, --oyuncu hesabına giriş yaptığında
    function()
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("**^HYDRA^**")) then --eğer oyuncu **^HYDRA^** grubunda ise
    setTimer(spawnPlayer, 2000, 1, source, 1437.5341796875, 734.0068359375, 10.8203125) --oyuncuyu burda spawnla
    end
    
end)

addEventHandler("onPlayerQuit",root,
    function ()
        if getPlayerCount() == 1 and get("spawnreset") == "onServerEmpty" then
            spawnpoint = getRandomSpawnPoint()
        end
    end
)

addEventHandler("onPlayerWasted", root, -- oyuncu öldüğünde
    function()
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("**^HYDRA^**")) then --eğer oyuncu **^HYDRA^** grubunda ise
    setTimer(spawnPlayer, 2000, 1, source, 1448.7550048828, 708.31512451172, 10.8203125) --oyuncuyu burda spawnla
    else
        setTimer(spawn, 2000, 1, source)
    end    
end)

Share this post


Link to post

Hello. It would help us to help with your issue, if you would put that code in a code box which this text editor on this forum offers, you click on it, and it looks like
< >
It's easier to look the code when it's inside that code box as it makes it look better to diagnose. Also, use /debugscript 3 and tell us if you have any errors there when you start the resource.
(/debugscript 3 info is also essential in helping us to help you with your problem when asking about script fixes)

 

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.