Jump to content

Spawn help


Predator

Recommended Posts

Hi, guys.

So, my problem is that: I am trying to add something more to the play resource(play/broph.lua), so when a player dies, connects, or when play resource starts spawns at different places depending on the ACL group he is in. For example, when X player dies and he's in x ACL group he spawns at (x, y, z), if the Y player dies, he should spawn at a different (x, y, z).

The errors I get when I load the play resource are:

SCRIPT ERROR: play/broph.lua:48: 'end' expected

But I'm pretty sure there are lots of other errors too.

If anyone could possibly tell me what to do to make it work, I would really appreciate it. I have tried to do what the error says, mta documents etc. but I'm pretty noobish and new in the whole scripting thing, so I don't understand a lot.

So what I have done until now is that:

addEventHandler("onResourceStart", resourceRoot, 
    function() 
        resetMapInfo() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
local accountName = getAccountName(account) 
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "DanWesson" ) ) ) then 
if not isElement(player) then return end 
    repeat until spawnPlayer ( player, -49.161193847656, -225.46385192871, 5.4296875, 90, 287, 0, 0) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    showChat(player, true) 
end 
  
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "SWAT" ) ) ) then 
if not isElement(player) then return end 
    repeat until spawnPlayer ( player, -550.86010742188, 2594.9943847656, 53.93478012085, 90, 285, 0, 0) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    showChat(player, true) 
  
end 
  
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "GBO" ) ) ) then 
if not isElement(player) then return end 
    repeat until spawnPlayer ( player, 1058.5606689453, 1279.9813232422, 10.8203125, 90, 120, 0, 0) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    showChat(player, true) 
  
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        spawn(source) 
    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
        setTimer(spawn, 1800, 1, source) 
    end 
) 

Link to comment
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        resetMapInfo() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
if not isElement(player) then return end 
local accountName = getAccountName(getPlayerAccount(player)) 
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "DanWesson" ) ) ) then 
    repeat until spawnPlayer ( player, -49.161193847656, -225.46385192871, 5.4296875, 90, 287, 0, 0) 
elseif ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "SWAT" ) ) ) then 
    repeat until spawnPlayer ( player, -550.86010742188, 2594.9943847656, 53.93478012085, 90, 285, 0, 0) 
elseif ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "GBO" ) ) ) then 
    repeat until spawnPlayer ( player, 1058.5606689453, 1279.9813232422, 10.8203125, 90, 120, 0, 0) 
end 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    showChat(player, true) 
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        spawn(source) 
    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
        setTimer(spawn, 1800, 1, source) 
    end 
) 

Link to comment

Thanks for the help Castillo, indeed, now the resource is running but it's doing what I want it to.. For example when I die it shows me the map to choose a location to spawn at, instead of auto-spawning me at a specific location depending on the group, which is what I want..

Link to comment

This should work

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 ( "DanWesson" ) ) then 
            repeat until spawnPlayer ( player, -49.161193847656, -225.46385192871, 5.4296875, 90, 287, 0, 0 ) 
        elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "SWAT" ) ) then 
            repeat until spawnPlayer ( player, -550.86010742188, 2594.9943847656, 53.93478012085, 90, 285, 0, 0 ) 
        elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "GBO" ) ) then 
            repeat until spawnPlayer ( player, 1058.5606689453, 1279.9813232422, 10.8203125, 90, 120, 0, 0 ) 
        end 
    else 
        outputChatBox( 'guest account' ) 
    end  
    fadeCamera( player, true ) 
    setCameraTarget( player, player ) 
end 
  
addEventHandler( "onPlayerJoin", root, 
    function( ) 
        spawn( source ) 
    end 
) 
  
addEventHandler( "onPlayerWasted", root, 
    function( ) 
        setTimer( spawn, 1800, 1, source ) 
    end 
) 

You need be a logged.

And not forgot about /debugscript 3.

Link to comment

Well, I don't see any erros, but still it doesn't work.. The only I see when typing /debugscript 3 is this:

INFO: votemanager recreate GuiElemens

INFO: modloader client: Finished downloading, requesting server for mods

INFO: modloader client: Replacing mods! #vehicles:4 | #weapons:0 | #skins:0

Link to comment

"what currently happens is that when I die I see my dead body, the map, and the camera doing some movements getting away from the body, when i choose a location, I just spawn there.." this is your problem?

Try:

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 ( "DanWesson" ) ) then 
            spawnPlayer ( player, -49.161193847656, -225.46385192871, 5.4296875, 90, 287, 0, 0 ) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "SWAT" ) ) then 
            spawnPlayer ( player, -550.86010742188, 2594.9943847656, 53.93478012085, 90, 285, 0, 0 ) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "GBO" ) ) then 
            spawnPlayer ( player, 1058.5606689453, 1279.9813232422, 10.8203125, 90, 120, 0, 0 ) 
       end 
      else 
         outputChatBox( 'You are not logged in!' ) 
     end  
      fadeCamera( player, true ) 
      setCameraTarget( player, player ) 
end 
      
addEventHandler( "onPlayerJoin", root, 
  function( ) 
    spawn( source ) 
end) 
      
addEventHandler( "onPlayerWasted", root, 
  function( ) 
     setTimer( spawn, 1800, 1, source ) 
end) 
  

It work for me.

Link to comment

Wow! Thanks! Works like a charm...

But, if someone can make it that when a player(guest, not logged in) joins, he spawns at ( player, -702.6533203125, 962.88671875, 12.393084526062, 90, 293, 0, 0 ), and when he logs in he dies, I would really appreciate it : )

Once again the script that worked:

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 ( "DanWesson" ) ) then 
            spawnPlayer ( player, -49.161193847656, -225.46385192871, 5.4296875, 90, 287, 0, 0 ) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "SWAT" ) ) then 
            spawnPlayer ( player, -550.86010742188, 2594.9943847656, 53.93478012085, 90, 285, 0, 0 ) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "GBO" ) ) then 
            spawnPlayer ( player, 1058.5606689453, 1279.9813232422, 10.8203125, 90, 120, 0, 0 ) 
       end 
      else 
         outputChatBox( 'You are not logged in!' ) 
     end 
      fadeCamera( player, true ) 
      setCameraTarget( player, player ) 
end 
      
addEventHandler( "onPlayerJoin", root, 
  function( ) 
    spawn( source ) 
end) 
      
addEventHandler( "onPlayerWasted", root, 
  function( ) 
     setTimer( spawn, 1800, 1, source ) 
end) 
  

Link to comment
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 ( "DanWesson" ) ) then 
            spawnPlayer ( player, -49.161193847656, -225.46385192871, 5.4296875, 90, 287, 0, 0 ) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "SWAT" ) ) then 
            spawnPlayer ( player, -550.86010742188, 2594.9943847656, 53.93478012085, 90, 285, 0, 0 ) 
         elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "GBO" ) ) then 
            spawnPlayer ( player, 1058.5606689453, 1279.9813232422, 10.8203125, 90, 120, 0, 0 ) 
       end 
      else 
         spawnPlayer( player, -702.6533203125, 962.88671875, 12.393084526062, 90, 293, 0, 0 ) 
     end 
      fadeCamera( player, true ) 
      setCameraTarget( player, player ) 
end 
      
addEventHandler( "onPlayerJoin", root, 
  function( ) 
    spawn( source ) 
end) 
      
addEventHandler( "onPlayerWasted", root, 
  function( ) 
     setTimer( spawn, 1800, 1, source ) 
end) 
  
addEventHandler('onPlayerLogin', root, 
  function() 
     killPed(source) 
end) 

I think it will work...

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