Jump to content

Acl Spawnpoint | SOLVED


Recommended Posts

addEventHandler( "onResourceStart", resourceRoot, 
  function() 
      resetMapInfo() 
       for _,player in ipairs( getElementsByType 'player' ) do 
        spawn( player ) 
      end 
   end 
) 
      
function spawn( player ) 
  if not isElement( player ) then return end 
     showChat( player, true ) 
     local acc = getPlayerAccount( player ) 
      if acc and not isGuestAccount( acc ) then 
         if isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Forever" ) ) then 
            spawnPlayer ( player, 220.19960021973, 1825.8579101563, 6.4140625, 0, 45 ) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Monster Energy" ) ) then 
            spawnPlayer ( player, 1146.5582509766, 2334.53515625, 10.829927444458 , 90, 228) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Saint Rows" ) ) then 
            spawnPlayer ( player, 2481.5187988281, 2356.2329101563, 4.2109375, 90, 17) 
 elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Iron Weasel" ) ) then 
            spawnPlayer ( player, 1075.8477783203, 1252.1403808594, 10.8203125, 90, 17) 
       end 
      
     end 
      fadeCamera( player, true ) 
      setCameraTarget( player, player ) 
end 
      
addEventHandler( "onPlayerJoin", root, 
  function( ) 
    spawn( source ) 
end) 
      
addEventHandler( "onPlayerWasted", root, 
  function( ) 
     setTimer( spawn, 500, 1, source ) 
end) 

The trouble is when a default player join the game he dont spawn at the locations of spawn like groove or ganton or missionary hills or pirate ship, Help please

Edited by Guest
Link to comment

you have a lot mistakes

addEventHandler( "onResourceStart", resourceRoot, 
  function( player ) 
      resetMapInfo() 
       for _,player in ipairs( getElementsByType ("player") ) do 
        spawn( player ) 
      end 
   end 
) 
      
function spawn( player ) 
  if not isElement( player ) then return end 
     showChat( player, true ) 
     local acc = getPlayerAccount( player ) 
      if acc and not isGuestAccount( acc ) then 
         if isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Forever" ) ) then 
            spawnPlayer ( player, 220.19960021973, 1825.8579101563, 6.4140625, 0, 45 ) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Monster Energy" ) ) then 
            spawnPlayer ( player, 1146.5582509766, 2334.53515625, 10.829927444458 , 90, 228) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Saint Rows" ) ) then 
            spawnPlayer ( player, 2481.5187988281, 2356.2329101563, 4.2109375, 90, 17) 
 elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Iron Weasel" ) ) then 
            spawnPlayer ( player, 1075.8477783203, 1252.1403808594, 10.8203125, 90, 17) 
       end 
      
     end 
      fadeCamera( player, true ) 
      setCameraTarget( player, player ) 
end 
      
addEventHandler( "onPlayerLogin", root, 
  function( ) 
    spawn( source ) 
end) 
      
addEventHandler( "onPlayerWasted", root, 
  function( ) 
     setTimer( spawn, 500, 1, source ) 
end) 
Link to comment

Replace the content of "play/broph.lua" with:

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 
    local acc = getPlayerAccount( player ) 
    if acc and not isGuestAccount( acc ) then 
        if isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Forever" ) ) then 
            spawnPlayer ( player, 220.19960021973, 1825.8579101563, 6.4140625, 0, 45 ) 
        elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Monster Energy" ) ) then 
            spawnPlayer ( player, 1146.5582509766, 2334.53515625, 10.829927444458 , 90, 228) 
        elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Saint Rows" ) ) then 
            spawnPlayer ( player, 2481.5187988281, 2356.2329101563, 4.2109375, 90, 17) 
        elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "Iron Weasel" ) ) then 
            spawnPlayer ( player, 1075.8477783203, 1252.1403808594, 10.8203125, 90, 17) 
        else 
            if get("spawnreset") == "onSpawn" then 
                spawnpoint = getRandomSpawnPoint() 
            end 
            exports.spawnmanager:spawnPlayerAtSpawnpoint(player,spawnpoint,false) 
            repeat until setElementModel(player,math.random(312)) 
        end 
    end 
  
    showChat(player, true) 
    fadeCamera( player, true ) 
    setCameraTarget( player, player ) 
end 
  
function getRandomSpawnPoint () 
    local spawnpoints = getElementsByType("spawnpoint") 
    return spawnpoints[math.random(1,#spawnpoints)] 
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        spawn(source) 
    end 
) 
  
addEventHandler("onPlayerQuit",root, 
    function () 
        if getPlayerCount() == 1 and get("spawnreset") == "onServerEmpty" then 
            spawnpoint = getRandomSpawnPoint() 
        end 
    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
        setTimer(spawn, 1800, 1, source) 
    end 
) 

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