Ultimo Jugador que entro a CT
#1
hola buenas
primero que nada he vuelto y en forma de fichas
2do: Catolica

y tercero me gustaría saber como obtener el ultimo usuario que entro al equipo y si me dejan un ejemplo mejor aun espero su pronta ayuda porfavorTriste

Pd: estoy realizando un chequeo alfinal de la ronda y necesito obtenerlo

graciasss
Responder
#2
Supongo que con esto ya tenes todo:

https://forums.alliedmods.net/showpost.p...ostcount=2
(03/07/2016, 11:24 PM)meTaLiCroSS escribió: Como lo hizo sasske es como lo estipule de un principio Proud
Responder
#3
2do Catolica jajajajaja

Cita:Estaba bueno el morande pacman
Responder
#4
(01/07/2016, 08:21 PM)sasske escribió: Supongo que con esto ya tenes todo:

https://forums.alliedmods.net/showpost.p...ostcount=2

no se me ocurre como tomar al ultimo que entro solo puedo ver a que equipo entro Triste
Responder
#5
(03/07/2016, 06:09 PM)timidop escribió:
(01/07/2016, 08:21 PM)sasske escribió: Supongo que con esto ya tenes todo:

https://forums.alliedmods.net/showpost.p...ostcount=2

no se me ocurre como tomar al ultimo que entro solo puedo ver a que equipo entro Triste

Cuando entra, guardas en una variable el ID del chabon, ya sabes que ese es el ultimo.

El único problema que le veo es que cuando se vaya el que entro ultimo, va a quedar un ID que no existe, para guardar todo en un orden no se me ocurre una manera sencilla de hacerlo.
(03/07/2016, 11:24 PM)meTaLiCroSS escribió: Como lo hizo sasske es como lo estipule de un principio Proud
Responder
#6
Es lo que se me ocurrió, debe haber mejores formas.
Código PHP:
new Wea[33]
new 
UltimoPlayer

// Cuando se conecta alguien
Wea[id] = 0
for (1<= gMaxPlayersi++)
{
    if (
== id)
        continue;
    
Wea[i]++;
}

// Cuando se va alguien
for (1<= gMaxPlayersi++)
    
Wea[i]--;


fun EncuentraUltimo
for (1<= gMaxPlayersi++)
    if (
Wea[i] == 0)
        return 
i;

// Cuando finaliza la ronda
UltimoPlayer EncuentraUltimo 

PD: Hace mil que no toco esto xD... Otra cosa hace los chequeos necesarios
Responder
#7
Sean inteligentes, guarden en una array el tiempo en el cual el usuario ingreso al equipo CT. get_gametime(), un array, listo
Responder
#8
Siguiendo lo que dijo Metal, este a mí, me funciona bien.

Código PHP:
#include <amxmodx>

#define PLUGIN "Team join info"
#define VERSION "1.0"
#define AUTHOR "AMXX Community"

new Float:flLastEnter 0.0;
new 
LastCT = -1;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event"TeamInfo""join_team""a");

    
register_clcmd"say /last""last");
}


public 
join_team()
{    
    new 
id read_data(1);
    static 
user_team[32];
    
    
read_data(2user_team31)  ;  
    
    if(!
is_user_connected(id))
        return 
PLUGIN_CONTINUE;
    
    switch(
user_team[0])
    {
        case 
'C':  
        {
            
// player join to ct's
            
if ( get_gametime() >= flLastEnter ) {
                
LastCT id;
                
flLastEnter get_gametime();
            }
        }
        
        case 
'T'
        {
            
// player join to terrorist
        
}
        
        case 
'S':  
        {
            
// player join to spectators
        
}
    }
    return 
PLUGIN_CONTINUE;
}

public 
last(id)
{
    if ( !( 
LastCT ) ) return PLUGIN_HANDLED;

    static 
szPlayerName[33];

    
get_user_nameLastCTszPlayerNamecharsmaxszPlayerName ) );

    
client_printidprint_chat"Last player CT was %s"szPlayerName )

    return 
PLUGIN_CONTINUE;

TFD ------ 10% (proyecto parado)

[Imagen: 76561198053053139.png]
Responder
#9
Y si se desconecta... ?
Responder
#10
(03/07/2016, 10:34 PM)Matians escribió: Siguiendo lo que dijo Metal, este a mí, me funciona bien.

Código PHP:
#include <amxmodx>

#define PLUGIN "Team join info"
#define VERSION "1.0"
#define AUTHOR "AMXX Community"

new Float:flLastEnter 0.0;
new 
LastCT = -1;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event"TeamInfo""join_team""a");

    
register_clcmd"say /last""last");
}


public 
join_team()
{    
    new 
id read_data(1);
    static 
user_team[32];
    
    
read_data(2user_team31)  ;  
    
    if(!
is_user_connected(id))
        return 
PLUGIN_CONTINUE;
    
    switch(
user_team[0])
    {
        case 
'C':  
        {
            
// player join to ct's
            
if ( get_gametime() >= flLastEnter ) {
                
LastCT id;
                
flLastEnter get_gametime();
            }
        }
        
        case 
'T'
        {
            
// player join to terrorist
        
}
        
        case 
'S':  
        {
            
// player join to spectators
        
}
    }
    return 
PLUGIN_CONTINUE;
}

public 
last(id)
{
    if ( !( 
LastCT ) ) return PLUGIN_HANDLED;

    static 
szPlayerName[33];

    
get_user_nameLastCTszPlayerNamecharsmaxszPlayerName ) );

    
client_printidprint_chat"Last player CT was %s"szPlayerName )

    return 
PLUGIN_CONTINUE;


Si el player que es last CT se va del sv, algo ahí no andará pacman

De hecho ni hace falta el tiempo ahí, no cambia nada Roflmao

Seria asi con lo que dijo metal, que me iluminó:

Código PHP:
/* First, save the file !   -   Sublime AMXX Editor v1.7 */

#include <amxmodx>
// #include <amxmisc>
// #include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new Float:g_TimeLastCT[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event"TeamInfo""join_team""a")

    
register_clcmd("say /test""TestFunc")
}

public 
join_team()
{
    new 
id read_data(1)
    static 
team[32]
    
read_data(2team31)

    if(
equal(team"CT"))
        
g_TimeLastCT[id] = get_gametime()
}

public 
TestFunc(id)
{
    new 
LastCtID=-1Float:TempTime=0.0;
    for(new 
i=1<= get_maxplayers(); i++)
    {
        if(
g_TimeLastCT[i] > TempTime)
        {
            
TempTime g_TimeLastCT[i]
            
LastCtID i
        
}
    }

    if(
LastCtID == -1)
        
client_print(idprint_chat"No hay ultimo CT")
    else
        
client_print(idprint_chat"El ID del ultimo CT es %d"LastCtID)
    
    return 
PLUGIN_HANDLED

(03/07/2016, 11:24 PM)meTaLiCroSS escribió: Como lo hizo sasske es como lo estipule de un principio Proud
Responder
#11
Como lo hizo sasske es como lo estipule de un principio Proud
Responder
#12
(03/07/2016, 10:43 PM)sasske escribió:
(03/07/2016, 10:34 PM)Matians escribió: Siguiendo lo que dijo Metal, este a mí, me funciona bien.

Código PHP:
#include <amxmodx>

#define PLUGIN "Team join info"
#define VERSION "1.0"
#define AUTHOR "AMXX Community"

new Float:flLastEnter 0.0;
new 
LastCT = -1;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event"TeamInfo""join_team""a");

    
register_clcmd"say /last""last");
}


public 
join_team()
{    
    new 
id read_data(1);
    static 
user_team[32];
    
    
read_data(2user_team31)  ;  
    
    if(!
is_user_connected(id))
        return 
PLUGIN_CONTINUE;
    
    switch(
user_team[0])
    {
        case 
'C':  
        {
            
// player join to ct's
            
if ( get_gametime() >= flLastEnter ) {
                
LastCT id;
                
flLastEnter get_gametime();
            }
        }
        
        case 
'T'
        {
            
// player join to terrorist
        
}
        
        case 
'S':  
        {
            
// player join to spectators
        
}
    }
    return 
PLUGIN_CONTINUE;
}

public 
last(id)
{
    if ( !( 
LastCT ) ) return PLUGIN_HANDLED;

    static 
szPlayerName[33];

    
get_user_nameLastCTszPlayerNamecharsmaxszPlayerName ) );

    
client_printidprint_chat"Last player CT was %s"szPlayerName )

    return 
PLUGIN_CONTINUE;


Si el player que es last CT se va del sv, algo ahí no andará pacman

De hecho ni hace falta el tiempo ahí, no cambia nada Roflmao

Seria asi con lo que dijo metal, que me iluminó:

Código PHP:
/* First, save the file !   -   Sublime AMXX Editor v1.7 */

#include <amxmodx>
// #include <amxmisc>
// #include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new Float:g_TimeLastCT[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event"TeamInfo""join_team""a")

    
register_clcmd("say /test""TestFunc")
}

public 
join_team()
{
    new 
id read_data(1)
    static 
team[32]
    
read_data(2team31)

    if(
equal(team"CT"))
        
g_TimeLastCT[id] = get_gametime()
}

public 
TestFunc(id)
{
    new 
LastCtID=-1Float:TempTime=0.0;
    for(new 
i=1<= get_maxplayers(); i++)
    {
        if(
g_TimeLastCT[i] > TempTime)
        {
            
TempTime g_TimeLastCT[i]
            
LastCtID i
        
}
    }

    if(
LastCtID == -1)
        
client_print(idprint_chat"No hay ultimo CT")
    else
        
client_print(idprint_chat"El ID del ultimo CT es %d"LastCtID)
    
    return 
PLUGIN_HANDLED


gracias por el aporte!, pero estoy yo de ultimo ct, mi id es 1, entra mi amigo con id 2, y me dice que el ultimo CT es el BRAVO!

pero cuando empieza una nueva ronda se buguea :/ y dice que el ultimo ct es el primero

(03/07/2016, 10:34 PM)Matians escribió: Siguiendo lo que dijo Metal, este a mí, me funciona bien.

Código PHP:
#include <amxmodx>

#define PLUGIN "Team join info"
#define VERSION "1.0"
#define AUTHOR "AMXX Community"

new Float:flLastEnter 0.0;
new 
LastCT = -1;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event"TeamInfo""join_team""a");

    
register_clcmd"say /last""last");
}


public 
join_team()
{    
    new 
id read_data(1);
    static 
user_team[32];
    
    
read_data(2user_team31)  ;  
    
    if(!
is_user_connected(id))
        return 
PLUGIN_CONTINUE;
    
    switch(
user_team[0])
    {
        case 
'C':  
        {
            
// player join to ct's
            
if ( get_gametime() >= flLastEnter ) {
                
LastCT id;
                
flLastEnter get_gametime();
            }
        }
        
        case 
'T'
        {
            
// player join to terrorist
        
}
        
        case 
'S':  
        {
            
// player join to spectators
        
}
    }
    return 
PLUGIN_CONTINUE;
}

public 
last(id)
{
    if ( !( 
LastCT ) ) return PLUGIN_HANDLED;

    static 
szPlayerName[33];

    
get_user_nameLastCTszPlayerNamecharsmaxszPlayerName ) );

    
client_printidprint_chat"Last player CT was %s"szPlayerName )

    return 
PLUGIN_CONTINUE;


funcionaa, pero se actualiza al ultimo ct, al inicio del siguiente round, necesito que lo chequee al final de la ronda
Responder
#13
Prueba este:

Código PHP:
/* First, save the file !   -   Sublime AMXX Editor v1.8 */

#include <amxmodx>
// #include <amxmisc>
// #include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new g_iJoinTeam[33];
new 
g_sJoinTeam[33];

new 
g_iMaxUsers 0;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_logevent("logevent__RoundEnd"2"1=Round_End");
    
    
register_message(get_user_msgid("TeamInfo"), "message__TeamInfo");

    
register_clcmd("say /test""ClientCommand__Test");

    
g_iMaxUsers get_maxplayers();
}

public 
logevent__RoundEnd() {
    static 
Float:fLastEndTime;
    static 
Float:fCurrentTime;
    
    
fCurrentTime get_gametime();
    
    if((
fCurrentTime fLastEndTime) < 0.5) {
        return;
    }
    
    
fLastEndTime fCurrentTime;

    
ClientCommand__Test(0);
}

public 
message__TeamInfo(const msg_id, const msg_dest){
    if(
msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) {
        return;
    }

    static 
id;
    
id get_msg_arg_int(1);

    static 
sTeam[2];
    
get_msg_arg_string(2sTeam1);

    
g_iJoinTeam[id] = 0;
    
g_sJoinTeam[id] = EOS;

    if(
sTeam[0] == 'C') {
        
g_iJoinTeam[id] = get_systime();
        
g_sJoinTeam[id] = 'C';
    }
}

public 
ClientCommand__Test(const id) {
    new 
i;
    new 
iLast 0;
    new 
iUserId 0;

    for(
1<= g_iMaxUsers; ++i) {
        if(
is_user_connected(i)) {
            if(
g_sJoinTeam[i] == 'C') {
                if(!
iUserId) {
                    
iUserId i;
                    
iLast g_iJoinTeam[i];
                }

                if(
g_iJoinTeam[i] > iLast) {
                    
iUserId i;
                    
iLast g_iJoinTeam[i];
                }
            }
        }
    }

    if(!
iUserId) {
        
client_print(idprint_chat"No hay ningun ultimo CT");
    } else {
        new 
sName[32];
        
get_user_name(iUserIdsNamecharsmax(sName));

        
client_print(idprint_chat"El ID del ultimo CT es: %d (%s)"iUserIdsName);
    }

Believe, be yourself and don't hold on to just one dream ❤

https://github.com/FEDERICOMB96
Responder
#14
(04/07/2016, 03:18 AM)Federicomb escribió: Prueba este:

Código PHP:
/* First, save the file !   -   Sublime AMXX Editor v1.8 */

#include <amxmodx>
// #include <amxmisc>
// #include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new g_iJoinTeam[33];
new 
g_sJoinTeam[33];

new 
g_iMaxUsers 0;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_logevent("logevent__RoundEnd"2"1=Round_End");
    
    
register_message(get_user_msgid("TeamInfo"), "message__TeamInfo");

    
register_clcmd("say /test""ClientCommand__Test");

    
g_iMaxUsers get_maxplayers();
}

public 
logevent__RoundEnd() {
    static 
Float:fLastEndTime;
    static 
Float:fCurrentTime;
    
    
fCurrentTime get_gametime();
    
    if((
fCurrentTime fLastEndTime) < 0.5) {
        return;
    }
    
    
fLastEndTime fCurrentTime;

    
ClientCommand__Test(0);
}

public 
message__TeamInfo(const msg_id, const msg_dest){
    if(
msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) {
        return;
    }

    static 
id;
    
id get_msg_arg_int(1);

    static 
sTeam[2];
    
get_msg_arg_string(2sTeam1);

    
g_iJoinTeam[id] = 0;
    
g_sJoinTeam[id] = EOS;

    if(
sTeam[0] == 'C') {
        
g_iJoinTeam[id] = get_systime();
        
g_sJoinTeam[id] = 'C';
    }
}

public 
ClientCommand__Test(const id) {
    new 
i;
    new 
iLast 0;
    new 
iUserId 0;

    for(
1<= g_iMaxUsers; ++i) {
        if(
is_user_connected(i)) {
            if(
g_sJoinTeam[i] == 'C') {
                if(!
iUserId) {
                    
iUserId i;
                    
iLast g_iJoinTeam[i];
                }

                if(
g_iJoinTeam[i] > iLast) {
                    
iUserId i;
                    
iLast g_iJoinTeam[i];
                }
            }
        }
    }

    if(!
iUserId) {
        
client_print(idprint_chat"No hay ningun ultimo CT");
    } else {
        new 
sName[32];
        
get_user_name(iUserIdsNamecharsmax(sName));

        
client_print(idprint_chat"El ID del ultimo CT es: %d (%s)"iUserIdsName);
    }


FUNCIONA!,
ahora solo el ultimo problema no agarra a los qe son transferidos por set_user_team o cs_set_user_team

de verdad estoy muy agradecido por su ayuda seria estoy el tema estaria solucionado
Responder
#15
Los dramas que estas comentando son cosas que puedes solucionar a mano, el boceto esta listo, moldealo tu.

Si tienes dramas con la actualizacion mediante cs_set_user_team vas a tener que hacer una adaptacion a tu codigo ya que no es directamente hookeable.
Responder
#16
(04/07/2016, 01:13 PM)meTaLiCroSS escribió: Los dramas que estas comentando son cosas que puedes solucionar a mano, el boceto esta listo, moldealo tu.

Si tienes dramas con la actualizacion mediante cs_set_user_team vas a tener que hacer una adaptacion a tu codigo ya que no es directamente hookeable.

va mas alla a "la adaptacion de mi codigo" ya que lo digo por el plmenu que viene default en el amxx en el team menu ocupa la funcion cs_set_user_team, y no tengo idea como obtener al jugador si fue pasado por cs_set_user_team por algo lo estoy preguntando no? , y yo creo que muchos igual pueden tener la duda
aqui el code del plmenu.

Código PHP:
if (is_user_alive(player))
                {
                    new 
deaths cs_get_user_deaths(player)
                    
user_kill(player1)
                    
cs_set_user_deaths(playerdeaths)
                }
                
// This modulo math just aligns the option to the CsTeams-corresponding number
                
cs_set_user_team(player, (g_menuOption[id] % 3) + 1)
                
cs_reset_user_model(player
Responder
#17
Cita:Si tienes dramas con la actualizacion mediante cs_set_user_team vas a tener que hacer una adaptacion a tu codigo ya que no es directamente hookeable.

Código PHP:
cs_set_user_team(player, (g_menuOption[id] % 3) + 1

El jugador = player
El team = (g_menuOption[id] % 3) + 1

Costoso no es, es cosa de pensarlo.

Y te lo repetire con otras palabras con las que quizas entiendas, no llegare a dibujos tampoco.

El uso de cs_set_user_team no es hookeable por ningun metodo, tampoco por TeamInfo (debido que usa los engfunc que no generan callback)

O alguien edita el modulo CStrike, o tendras que cerdamente hookear frame por frame a ver si el team se cambio, lo que es altamente "no" recomendable

Por eso, recalco, reitero, renombro

Cita:vas a tener que hacer una adaptacion a tu codigo

Puedes usar natives, callbacks, como quieras. En la experiencia personal de esto, todo el codigo de mis modificaciones las dejo en 1 solo plugin ya que todo esta conectado de una u otra manera. En caso de tenerlo separado (como ya me fijé), recurra a los 2 mencionados arriba.

Y ahi esta la respuesta a los ""muchos"" que tienen la duda (no he visto ningún hasta el momento, que se pronuncien)
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)