їCуmo deberнa hacerlo?
#1

Hola. Realicй un sistema de daсo de armas, que tambiйn indica cuando se disparу cada una con por ejemplo un mensaje '%s disparу con SPAS-12'.

Estб bien, esto ya estб hecho, pero el tema es el mensaje para cada disparo, y si se habla de varios disparos como se podrнan efectuar desde una ametralladora, se floodea todo el chat.

Es posible desarrollar algъn script que detecte sуlamente un disparo de los tantos que se podrнan hacer en un tiempo determinado?

No sй si me explico, pero supongamos que yo tengo un Desert. Entonces yo disparo 6 veces, y el mensaje que sale es este:

jwalker ha disparado con Desert.
jwalker ha disparado con Desert.
jwalker ha disparado con Desert.
jwalker ha disparado con Desert.
jwalker ha disparado con Desert.
jwalker ha disparado con Desert.


їCуmo podrнa hacer para que en vez de esos seis salga solamente uno?
Reply
#2

con una restricciуn y Gettime.
puedes usar esto.
Reply
#3

para quй va a usar eso? le dijiste bien las cosas y es usar gettime en OnPlayerWeaponShot cual al disparar cuando el gettime, incluyendo eso sуlo ocuparб memoria y molestias que no necesita.. de hecho yo tenнa esto en mi servidor, asн, sin mбs de 3 lineas.
Reply
#4

Quote:
Originally Posted by _Zume
Посмотреть сообщение
para quй va a usar eso? le dijiste bien las cosas y es usar gettime en OnPlayerWeaponShot cual al disparar cuando el gettime, incluyendo eso sуlo ocuparб memoria y molestias que no necesita.. de hecho yo tenнa esto en mi servidor, asн, sin mбs de 3 lineas.
de hecho se lo dije para que se basa por si no sabe aplicar el mйtodo que le dije.
para que resaltas lo de tu servidor?, era innecesario. -.-
Reply
#5

Algъn pequeсo ejemplo de como se aplicarнa?
Reply
#6

pawn Код:
#include <a_samp>
new NO_Repetir[MAX_PLAYERS];

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ){
    if(playerid != INVALID_PLAYER_ID){
        if(hittype==BULLET_HIT_TYPE_PLAYER){
            #define SEGUNDO_NO_REPETIR ( 30 ) //30 segundos
            if( NO_Repetir[playerid] < gettime() ){
                NO_Repetir[playerid] = gettime() + SEGUNDO_NO_REPETIR;
                // tu funcion
            }
        }
    }
    return true;
}
pawn Код:
#include <a_samp>
#include <SetTimerCMD_V3>

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ){
    if(playerid != INVALID_PLAYER_ID){
        if(hittype==BULLET_HIT_TYPE_PLAYER){
            #define SEGUNDO_NO_REPETIR ( 30 ) //30 segundos
            #define SLOT_FUNCTION ( 0 )
            if( !GetTimerCMD(playerid,SLOT_FUNCTION) ){
                SetTimerCMD(playerid,SLOT_FUNCTION,SEGUNDO_NO_REPETIR);
                // tu funcion
            }
        }
    }
    return true;
}
Reply
#7

El uso de SetTimer o SetTimerEx en una callback que se puede llamar mas de 100 veces por segundo, es totalmente innecesario.

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    static
        deteccion[MAX_PLAYERS];

    if(playerid != INVALID_PLAYER_ID)
    {
        if(hittype == BULLET_HIT_TYPE_PLAYER)
        {
            if(weaponid != deteccion[playerid])
            {
                // Enviar el mensaje una vez
            }
            deteccion[playerid] = weaponid;
        }
    }
    return true;
}
Reply
#8

Quote:
Originally Posted by DesingMyCry
Посмотреть сообщение
El uso de SetTimer o SetTimerEx en una callback que se puede llamar mas de 100 veces por segundo, es totalmente innecesario.

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    static
        deteccion[MAX_PLAYERS];

    if(playerid != INVALID_PLAYER_ID)
    {
        if(hittype == BULLET_HIT_TYPE_PLAYER)
        {
            if(weaponid != deteccion[playerid])
            {
                // Enviar el mensaje una vez
            }
            deteccion[playerid] = weaponid;
        }
    }
    return true;
}
no se esta utilizando ni SetTimer ni SetTimerEx. -.-
Reply
#9

pawn Код:
new
    _tWeapon[MAX_PLAYERS];

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(playerid != INVALID_PLAYER_ID)
    {
        if(weaponid != WEAPON_SILENCED && _tWeapon[playerid] < gettime())
        {
            ProxDetectorEx(playerid, ((weaponid == WEAPON_AK47  || weaponid == WEAPON_M4 || weaponid == WEAPON_RIFLE || weaponid == WEAPON_SNIPER) ? (45.0) : (30.0)), COLOR_DO, "* %s ha disparado con %s.", _Name(playerid), GetWeaponNameEx(weaponid));
            _tWeapon[playerid] = gettime()+15;
        }
    }
    return 1;
}
Para la funciуn de GetWeaponNameEx fнjate en el fix de la funciуn: https://sampwiki.blast.hk/wiki/GetWeaponName

Sй el punto que le vas a dar por eso le puse con ProxDetector, ProxDetectorEx es una ediciуn que le apliquй nada mбs.
Reply
#10

Quote:
Originally Posted by _Zume
Посмотреть сообщение
pawn Код:
new
    _tWeapon[MAX_PLAYERS];

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(playerid != INVALID_PLAYER_ID)
    {
        if(weaponid != WEAPON_SILENCED && _tWeapon[playerid] < gettime())
        {
            ProxDetectorEx(playerid, ((weaponid == WEAPON_AK47  || weaponid == WEAPON_M4 || weaponid == WEAPON_RIFLE || weaponid == WEAPON_SNIPER) ? (45.0) : (30.0)), COLOR_DO, "* %s ha disparado con %s.", _Name(playerid), GetWeaponNameEx(weaponid));
            _tWeapon[playerid] = gettime()+15;
        }
    }
    return 1;
}
Para la funciуn de GetWeaponNameEx fнjate en el fix de la funciуn: https://sampwiki.blast.hk/wiki/GetWeaponName

Sй el punto que le vas a dar por eso le puse con ProxDetector, ProxDetectorEx es una ediciуn que le apliquй nada mбs.
Obtengo error con el ProxDetector, no lo tengo definido, y las definiciones que encontre no funcionan.

Los demбs cуdigos me funcionan, pero sуlo cuando el disparo impacta en otro jugador, lo que yo quiero es que el mensaje salga por mбs que el disparo vaya al suelo, al aire, etcйtera.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)