Predator Posted February 7, 2012 Share Posted February 7, 2012 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
Castillo Posted February 7, 2012 Share Posted February 7, 2012 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
Predator Posted February 7, 2012 Author Share Posted February 7, 2012 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
Castillo Posted February 7, 2012 Share Posted February 7, 2012 That's part of the freeroam resource. Link to comment
Predator Posted February 7, 2012 Author Share Posted February 7, 2012 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 : ) Link to comment
Castillo Posted February 7, 2012 Share Posted February 7, 2012 Does that script spawn the player and show's the map? Link to comment
Predator Posted February 7, 2012 Author Share Posted February 7, 2012 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.. Link to comment
Castillo Posted February 7, 2012 Share Posted February 7, 2012 Ok, I found the error, copy my script again, it should spawn you. Link to comment
Predator Posted February 7, 2012 Author Share Posted February 7, 2012 Still, the same thing happens.. Link to comment
Kenix Posted February 7, 2012 Share Posted February 7, 2012 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
Predator Posted February 7, 2012 Author Share Posted February 7, 2012 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.. Link to comment
drk Posted February 7, 2012 Share Posted February 7, 2012 Type /debugscript 3 in the chat and see if you get any error. Link to comment
Predator Posted February 8, 2012 Author Share Posted February 8, 2012 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
drk Posted February 8, 2012 Share Posted February 8, 2012 "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
Predator Posted February 8, 2012 Author Share Posted February 8, 2012 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
drk Posted February 8, 2012 Share Posted February 8, 2012 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
Predator Posted February 8, 2012 Author Share Posted February 8, 2012 WOW! Works! Thank you a lot! You made me really happy : ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now