Dentos Posted September 27, 2014 Share Posted September 27, 2014 tengo este resource que quiero que se de restart automaticamente cada 10 seg inente agregando esto setTimer( addTeamBlip, 100,true ) pero no funciono heres el script local pBlips = { } addEventHandler("onResourceStart", resourceRoot, function() for index, player in ipairs(getElementsByType("player")) do addTeamBlip(player) end end ) function addTeamBlip(player) if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips local theGang = getElementData ( player, "gang" ) if ( theGang and theGang ~= "None" ) then local r, g, b = getPlayerNametagColor( player ) local theBlip = createBlipAttachedTo( player, 0, 2, 0, 255, 0 ) -- Change visibility to only the team members setElementVisibleTo( theBlip, root, false ) for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS setElementVisibleTo( theBlip, value, true ) end pBlips[player] = theBlip end end function destroyBlip(element) local theElement = source or element if ( theElement ) then destroyElement(pBlips[theElement]) pBlips[theElement] = nil -- Just in-case... end end -- Events addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) addEventHandler ( "onPlayerQuit", root, destroyBlip ) addEventHandler ( "onPlayerWasted", root, destroyBlip ) function getPlayersByGang ( gang ) local players = { } for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "gang" ) == gang ) then table.insert ( players, player ) end end return players end setTimer( addTeamBlip, 100,true ) -- agregue esto Link to comment
Tomas Posted September 27, 2014 Share Posted September 27, 2014 No se si podrás hacer lo que quieres, te dejo los argumentos de la función setTimer setTimer(función,tiempo en mili segundos,veces que se ejecutará,[argumentos opcionales]) Tu código sería: setTimer(addTeamBlip,10000,0) En veces que se ejecutará se usa también el 0 para representar el infinito. Link to comment
Dentos Posted September 27, 2014 Author Share Posted September 27, 2014 me podrias explicar donde poner eso porfa esq soy nuevo con lua Link to comment
Tomas Posted September 27, 2014 Share Posted September 27, 2014 local pBlips = { } addEventHandler("onResourceStart", resourceRoot, function() for index, player in ipairs(getElementsByType("player")) do addTeamBlip(player) end end ) function addTeamBlip(player) if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips local theGang = getElementData ( player, "gang" ) if ( theGang and theGang ~= "None" ) then local r, g, b = getPlayerNametagColor( player ) local theBlip = createBlipAttachedTo( player, 0, 2, 0, 255, 0 ) -- Change visibility to only the team members setElementVisibleTo( theBlip, root, false ) for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS setElementVisibleTo( theBlip, value, true ) end pBlips[player] = theBlip end end function destroyBlip(element) local theElement = source or element if ( theElement ) then destroyElement(pBlips[theElement]) pBlips[theElement] = nil -- Just in-case... end end -- Events addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) addEventHandler ( "onPlayerQuit", root, destroyBlip ) addEventHandler ( "onPlayerWasted", root, destroyBlip ) function getPlayersByGang ( gang ) local players = { } for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "gang" ) == gang ) then table.insert ( players, player ) end end return players end setTimer(addTeamBlip,10000,0) Link to comment
Dentos Posted September 27, 2014 Author Share Posted September 27, 2014 el script no se actualiza cada 10 seg algo creo esta mal talvez algo como restartresource envez de addTeamBlip? Link to comment
alex17 Posted September 27, 2014 Share Posted September 27, 2014 explicate bien que es lo que quieres para que quieres que se reinicie cada 10 s Link to comment
Dentos Posted September 27, 2014 Author Share Posted September 27, 2014 es es un script que te muestra tus companeros de gang en el mapa pero solo sirve cuando le doy restart xk si mueres o te desconectas ya no sales para tus companeros en el mapa o viceversa o cuando te sales del clan no se actualiza sino hasta q le des restart otra vez Link to comment
Tomas Posted September 27, 2014 Share Posted September 27, 2014 Ten, con esto ya no desapareceran los blips al morir. local pBlips = { } function blipsRestart() for index, player in ipairs(getElementsByType("player")) do addTeamBlip(player) end end setTimer(blipsRestart,10000,0) addEventHandler("onResourceStart", resourceRoot, blipsRestart) function addTeamBlip(player) if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips local theGang = getElementData ( player, "gang" ) if ( theGang and theGang ~= "None" ) then local r, g, b = getPlayerNametagColor( player ) local theBlip = createBlipAttachedTo( player, 0, 2, 0, 255, 0 ) -- Change visibility to only the team members setElementVisibleTo( theBlip, root, false ) for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS setElementVisibleTo( theBlip, value, true ) end pBlips[player] = theBlip end end function destroyBlip(element) local theElement = source or element if ( theElement ) then destroyElement(pBlips[theElement]) pBlips[theElement] = nil -- Just in-case... end end -- Events addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) addEventHandler ( "onPlayerQuit", root, destroyBlip ) function getPlayersByGang ( gang ) local players = { } for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "gang" ) == gang ) then table.insert ( players, player ) end end return players end setTimer( addTeamBlip, 100,true ) -- agregue esto Link to comment
Dentos Posted September 28, 2014 Author Share Posted September 28, 2014 muchas gracias ahora solo queda un problema cuando reconecto yo no los veo pero ellos si ami Link to comment
Tomas Posted September 28, 2014 Share Posted September 28, 2014 local pBlips = { } function blipsRestart() for index, player in ipairs(getElementsByType("player")) do addTeamBlip(player) end end setTimer(blipsRestart,10000,0) addEventHandler("onResourceStart", resourceRoot, blipsRestart) function blipJoin() addTeamBlip(source) end addEventHandler("onPlayerJoin",getRootElement(),blipJoin) function addTeamBlip(player) if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips local theGang = getElementData ( player, "gang" ) if ( theGang and theGang ~= "None" ) then local r, g, b = getPlayerNametagColor( player ) local theBlip = createBlipAttachedTo( player, 0, 2, 0, 255, 0 ) -- Change visibility to only the team members setElementVisibleTo( theBlip, root, false ) for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS setElementVisibleTo( theBlip, value, true ) end pBlips[player] = theBlip end end function destroyBlip(element) local theElement = source or element if ( theElement ) then destroyElement(pBlips[theElement]) pBlips[theElement] = nil -- Just in-case... end end -- Events addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) addEventHandler ( "onPlayerQuit", root, destroyBlip ) function getPlayersByGang ( gang ) local players = { } for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "gang" ) == gang ) then table.insert ( players, player ) end end return players end Link to comment
Dentos Posted September 29, 2014 Author Share Posted September 29, 2014 Sigue igual -Prendes el resource todo esta bien -reconnectas -la gente en tu gang aun te ve pero voz no a ellos -alguien de tu gang reconnecta le comienzas aver al de tu gang pero solo el que reconnecto quiero hacer para q ni bien reconnectes puedas ver tdos de tu gang (por cierto Tomas muchas gracias por tu ayuda no sabes cuanto tiempo estado sin poder resolver este problema) Link to comment
Tomas Posted September 29, 2014 Share Posted September 29, 2014 Cuando reconectas te logueas, no? Link to comment
Dentos Posted September 29, 2014 Author Share Posted September 29, 2014 si cuando reconectas tienes que logear Link to comment
Recommended Posts