undefined Posted June 28, 2014 Posted June 28, 2014 Hi guys. Im work on the spawn system. But i have a problem. When he died two players simultaneously, in one player "spawnbribe" and "corona" can not be destroyed. How to fix it? function afterTaskSpawn ( player ) local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) local playerAccount = getPlayerAccount( player ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false if not isElement( player ) then return end showChat( player, true ) if isAccount and getAccountData( playerAccount, "task" ) then if isObjectInACLGroup ( "user.".. getAccountName( getPlayerAccount( player ) ), aclGetGroup ( "Admin" ) ) then spawnPlayer( 306, 2020, 17.6, 90, 285 ) spawnBribe = createObject(1247, x, y, z, rx, ry, rz) attachElements( spawnBribe, player, 0, 0, 1.1 ) setElementCollisionsEnabled (spawnBribe, false) setObjectScale ( spawnBribe, 0.7) corona = createMarker( x, y, z, "corona", 0.2, 255, 255, 0, 255 ) attachElements( corona, player, 0, 0, 1.1 ) timer = setTimer( function () if isElement(corona) then destroyElement(corona) corona = nil end if isElement(spawnBribe) then destroyElement(spawnBribe) spawnBribe = nil end end, 15000, 1) end end end addEventHandler( "onPlayerWasted", root, function( ) if (spawnBribe) then if isElement(spawnBribe) then destroyElement(spawnBribe) spawnBribe = nil if isTimer(timer) then killTimer(timer) end end end if (corona) then if isElement(corona) then destroyElement(corona) corona = nil if isTimer(timer) then killTimer(timer) end end end local playerAccount = getPlayerAccount( source ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false if ( isAccount ) and ( getAccountData( playerAccount, "task" ) ) then triggerClientEvent(source, "onWasted" , source) setTimer(afterTaskSpawn, 13500, 1, source ) end end )
Castillo Posted June 28, 2014 Posted June 28, 2014 You are using the same variable names for each player, I recommend you to store them in a table, using the player userdata as index. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
xXMADEXx Posted June 29, 2014 Posted June 29, 2014 Try this local collection = { } function afterTaskSpawn ( player ) local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) local playerAccount = getPlayerAccount( player ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false showChat( player, true ) if isAccount and getAccountData( playerAccount, "task" ) then if isObjectInACLGroup ( "user.".. getAccountName( getPlayerAccount( player ) ), aclGetGroup ( "Admin" ) ) then spawnPlayer( 306, 2020, 17.6, 90, 285 ) local spawnBribe = createObject(1247, x, y, z, rx, ry, rz) attachElements( spawnBribe, player, 0, 0, 1.1 ) setElementCollisionsEnabled (spawnBribe, false) setObjectScale ( spawnBribe, 0.7 ) corona = createMarker( x, y, z, "corona", 0.2, 255, 255, 0, 255 ) attachElements( corona, player, 0, 0, 1.1 ) collection[player].spawnBribe = spawnBribe collection[player].corna = corona spawnBribe = nil corona = nil timer = setTimer( function ( player ) if isElement(collection[player].corna) then destroyElement(collection[player].corna) collection[player].corna = nil end if isElement( collection[player].spawnBribe) then destroyElement( collection[player].spawnBribe) collection[player].spawnBribe = nil end end, 15000, 1, player ) end end end addEventHandler( "onPlayerWasted", root, function( ) local player = source if isElement( collection[player].spawnBribe) then destroyElement( collection[player].spawnBribe) collection[player].spawnBribe = nil if isTimer( collection[player].timer ) then killTimer( collection[player].timer ) end end end if isElement(collection[player].corona ) then destroyElement(collection[player].corona) collection[player].corona = nil if isTimer(collection[player].timer) then killTimer(collection[player].timer) end end local playerAccount = getPlayerAccount( source ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false if ( isAccount ) and ( getAccountData( playerAccount, "task" ) ) then triggerClientEvent(source, "onWasted" , source) setTimer(afterTaskSpawn, 13500, 1, source ) end end ) The Ultimate Lua Tutorial! | MTA PHP SDK
undefined Posted June 29, 2014 Author Posted June 29, 2014 (edited) It's not work. The player isn't spawn and it's not give error or warning on debug. Edited June 29, 2014 by Guest
Castillo Posted June 29, 2014 Posted June 29, 2014 Try this local collection = { } function afterTaskSpawn ( player ) local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) local playerAccount = getPlayerAccount( player ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false showChat( player, true ) if isAccount and getAccountData( playerAccount, "task" ) then if isObjectInACLGroup ( "user.".. getAccountName( getPlayerAccount( player ) ), aclGetGroup ( "Admin" ) ) then spawnPlayer( 306, 2020, 17.6, 90, 285 ) local spawnBribe = createObject(1247, x, y, z, rx, ry, rz) attachElements( spawnBribe, player, 0, 0, 1.1 ) setElementCollisionsEnabled (spawnBribe, false) setObjectScale ( spawnBribe, 0.7 ) corona = createMarker( x, y, z, "corona", 0.2, 255, 255, 0, 255 ) attachElements( corona, player, 0, 0, 1.1 ) collection[player].spawnBribe = spawnBribe collection[player].corna = corona spawnBribe = nil corona = nil timer = setTimer( function ( player ) if isElement(collection[player].corna) then destroyElement(collection[player].corna) collection[player].corna = nil end if isElement( collection[player].spawnBribe) then destroyElement( collection[player].spawnBribe) collection[player].spawnBribe = nil end end, 15000, 1, player ) end end end addEventHandler( "onPlayerWasted", root, function( ) local player = source if isElement( collection[player].spawnBribe) then destroyElement( collection[player].spawnBribe) collection[player].spawnBribe = nil if isTimer( collection[player].timer ) then killTimer( collection[player].timer ) end end end if isElement(collection[player].corona ) then destroyElement(collection[player].corona) collection[player].corona = nil if isTimer(collection[player].timer) then killTimer(collection[player].timer) end end local playerAccount = getPlayerAccount( source ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false if ( isAccount ) and ( getAccountData( playerAccount, "task" ) ) then triggerClientEvent(source, "onWasted" , source) setTimer(afterTaskSpawn, 13500, 1, source ) end end ) Typo there: collection[player].corna = corona San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
undefined Posted June 29, 2014 Author Posted June 29, 2014 Typo there: collection[player].corna = corona Yes. Im fixed it. And, There is an error in debugscript. Error; It's first error. This error occurs when I remove the following code: if isElement(koleksiyon[player].spawnBribe) then -- Line 260 destroyElement(koleksiyon[player].spawnBribe) koleksiyon[player].spawnBribe = nil if isTimer(koleksiyon[player].timer) then killTimer(koleksiyon[player].timer) end end if isElement(koleksiyon[player].corona) then destroyElement(koleksiyon[player].corona) koleksiyon[player].corona = nil if isTimer(koleksiyon[player].timer) then killTimer(koleksiyon[player].timer) end end Code: koleksiyon = { } function afterTaskSpawn ( player ) randomspawnA69 = math.random( 1, #area69) randomspawnSK = math.random( 1, #sillentKillers) local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) local playerAccount = getPlayerAccount( player ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false if not isElement( player ) then return end showChat( player, true ) if isAccount and getAccountData( playerAccount, "task" ) then if isObjectInACLGroup ( "user.".. getAccountName( getPlayerAccount( player ) ), aclGetGroup ( "Admin" ) ) then spawnPlayer( player, area69 [randomspawnA69][1], area69 [randomspawnA69][2], area69 [randomspawnA69][3], area69 [randomspawnA69][4], area69 [randomspawnA69][5], area69 [randomspawnA69][6], area69 [randomspawnA69][7] ) setPedAnimation( player, "ped" , "WALK_gang1" ) setTimer( function () setPedAnimation(player,nil,nil) end, 5000, 1) spawnBribe = createObject(1247, x, y, z, rx, ry, rz) attachElements( spawnBribe, player, 0, 0, 1.1 ) setElementCollisionsEnabled (spawnBribe, false) setObjectScale ( spawnBribe, 0.7) corona = createMarker( x, y, z, "corona", 0.2, 255, 255, 0, 255 ) attachElements( corona, player, 0, 0, 1.1 ) koleksiyon[player].spawnBribe = spawnBribe -- Line 173 koleksiyon[player].corona = corona spawnBribe = nil corona = nil timer = setTimer( function () if isElement(koleksiyon[player].corona) then destroyElement(koleksiyon[player].corona) koleksiyon[player].corona = nil end if isElement(koleksiyon[player].spawnBribe) then destroyElement(koleksiyon[player].spawnBribe) koleksiyon[player].spawnBribe = nil end end, 15000, 1) end end fadeCamera( player, true ) setCameraTarget( player, player ) end addEventHandler( "onPlayerWasted", root, function( ) if isElement(koleksiyon[player].spawnBribe) then -- Line 260 destroyElement(koleksiyon[player].spawnBribe) koleksiyon[player].spawnBribe = nil if isTimer(koleksiyon[player].timer) then killTimer(koleksiyon[player].timer) end end if isElement(koleksiyon[player].corona) then destroyElement(koleksiyon[player].corona) koleksiyon[player].corona = nil if isTimer(koleksiyon[player].timer) then killTimer(koleksiyon[player].timer) end end local playerAccount = getPlayerAccount( source ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false if ( isAccount ) and ( getAccountData( playerAccount, "task" ) ) then triggerClientEvent(source, "onWasted" , source) setTimer(afterTaskSpawn, 13500, 1, source ) end end )
Max+ Posted June 29, 2014 Posted June 29, 2014 This means you tried to index a table that does not exist , you need to make a table before indexing it , - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
undefined Posted June 29, 2014 Author Posted June 29, 2014 Thank you Max+. Im fixed it. And thank you xXMADEXx and Solidsnake14.
Max+ Posted June 30, 2014 Posted June 30, 2014 your , welcome - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
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