Jump to content

Spawn help


Predator

Recommended Posts

Posted

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 
) 

Posted
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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Posted

That's part of the freeroam resource.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Ok, then what should I do with the freeroam resource to make do what I want? Should I change a file in the freeroam resource?

Sorry, I am new : )

Posted

Does that script spawn the player and show's the map?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Posted

Ok, I found the error, copy my script again, it should spawn you.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

Still, the same shit happens.. Also what should I do with that /debugscript3 ? If you mean just type it in chat while logged in asw admin, still nothing changes..

Posted

Type /debugscript 3 in the chat and see if you get any error.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

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

Posted

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

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

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) 
  

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

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

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