SA-MP Forums Archive
[AJUDA] Perder vida quando estб na area. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [AJUDA] Perder vida quando estб na area. (/showthread.php?tid=323027)



[AJUDA] Perder vida quando estб na area. - Cheleber_Pausini - 04.03.2012

Bem, eu e o meu amigo Edu_Pausini estamos a fazer um GM de RP e temos uma pequena dъvida, bem aqui vai:
- Eu queria que uma certa бrea em que o player entrasse ficasse infectado com uma doenзa e fosse morrendo aos poucos, aqui vai o cуdigo...
Код:
#include <a_samp>
#include <a_players>




new INFEC;
new INFEC2;
new INFEC3;
new INFEC4;
new INFEC5;
new INFEC6;

forward Infectados(playerid);

#define VERMELHO 0xE61D06FF
#define AZUL  0x0080FFFF
#define AMARELO 0xF2F200FF
#define ROXO 0x8080FFFF
#define BRANCO 0xFFFFFFFF
#define CINZA 0xC0C0C0FF
#define COR_GROOVE 0x008000FF
#define COR_BALLAS 0x930093FF
#define COR_VAGOS 0xD9D900FF
#define COR_AZTECAS 0x00CACAFF

public OnFilterScriptInit()
{
INFEC = GangZoneCreate(-2987.5754,-2986.1350,3002.7341,452.8182),
INFEC2 = GangZoneCreate(-2986.6272,447.4655,-1070.0516,2997.9810),
INFEC3 = GangZoneCreate(917.9335,443.6140,1534.3945,604.9423),
INFEC4 = GangZoneCreate(-1103.6216,427.1572,-529.2606,1367.6926),
INFEC5 = GangZoneCreate(-1081.2606,1361.6926,-606.2606,2109.6926),
INFEC6 = GangZoneCreate(-1082.2606,2089.6926,-930.2606,2525.6926);
return 1;
}

public OnPlayerSpawn(playerid)

GangZoneShowForPlayer(playerid,INFEC,BRANCO),
GangZoneShowForPlayer(playerid,INFEC2,BRANCO),
GangZoneShowForPlayer(playerid,INFEC3,BRANCO),
GangZoneShowForPlayer(playerid,INFEC4,BRANCO),
GangZoneShowForPlayer(playerid,INFEC5,BRANCO),
GangZoneShowForPlayer(playerid,INFEC6,BRANCO);









stock IsPlayerInPlace(playerid,Float:XMin,Float:YMin,Float:XMax,Float:YMax )
{
new RetValue = 0;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z );

if( X >= XMin && Y >= YMin && X < XMax && Y < YMax )
{
  RetValue = 1;
}
return RetValue;
}
Eu gostaria que mesmo o player estando de carro, perdesse vida.
Obrigado gente (;


Respuesta: [AJUDA] Perder vida quando estб na area. - Cheleber_Pausini - 04.03.2012

UP (;


Re: [AJUDA] Perder vida quando estб na area. - Cheleber_Pausini - 04.03.2012

UP UP UP Ajuda!


Re: [AJUDA] Perder vida quando estб na area. - Faisal_khan - 04.03.2012

Translation please!


Re: [AJUDA] Perder vida quando estб na area. - Faisal_khan - 04.03.2012

Try this it may help you.
https://sampforum.blast.hk/showthread.php?tid=276352


Re: [AJUDA] Perder vida quando estб na area. - Cheleber_Pausini - 04.03.2012

I'm not looking for it, faisal..


Respuesta: [AJUDA] Perder vida quando estб na area. - OPremium - 04.03.2012

You will need a timer that checks if the player is in one of the areas and changes his health. Also an array with all the "infected" areas. Read the comments for more info!

pawn Код:
#include <a_samp>

#define VERMELHO 0xE61D06FF
#define AZUL  0x0080FFFF
#define AMARELO 0xF2F200FF
#define ROXO 0x8080FFFF
#define BRANCO 0xFFFFFFFF
#define CINZA 0xC0C0C0FF
#define COR_GROOVE 0x008000FF
#define COR_BALLAS 0x930093FF
#define COR_VAGOS 0xD9D900FF
#define COR_AZTECAS 0x00CACAFF

new InfecAreas[6]; //If you want to add more areas you need to change the size of this array and then add the coords in the other array
new Float:AreaInfo[][] = //List with the areas where the player will lose health
{
    {-2987.5754, -2986.1350, 3002.7341, 452.8182},
    {-2986.6272, 447.4655, -1070.0516, 2997.9810},
    {917.9335, 443.6140, 1534.3945, 604.9423},
    {-1103.6216, 427.1572, -529.2606, 1367.6926},
    {-1081.2606, 1361.6926, -606.2606, 2109.6926},
    {-1082.2606, 2089.6926, -930.2606, 2525.6926}
};

public OnFilterScriptInit()
{
    for(new i; i < sizeof(InfecAreas); i++)
    {
        InfecAreas[i] = GangZoneCreate(AreaInfo[i][0], AreaInfo[i][1], AreaInfo[i][2], AreaInfo[i][3]);
    }
    SetTimer("Infectados", 1000, true); //Sets a 1 sec timer that will check all players
    return 1;
}

public OnPlayerSpawn(playerid)
{
    for(new i; i < sizeof(InfecAreas); i++)
    {
        GangZoneShowForPlayer(playerid, InfecAreas[i], BRANCO);
    }
    return 1;
}

forward Infectados();
public Infectados()
{
    new Float:tmphealth;
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        for(new e; e < sizeof(InfecAreas); e++)
        {
            if(IsPlayerInPlace(i, AreaInfo[e][0], AreaInfo[e][1], AreaInfo[e][2], AreaInfo[e][3]))
            {
                GetPlayerHealth(i, tmphealth);
                tmphealth -= 1.0; //Change it to the amount that you want, the player will lose this amount of health while he is in the area
                SetPlayerHealth(i, tmphealth);
                break; //Stops the areas loop
            }
        }
    }
    return 1;
}

stock IsPlayerInPlace(playerid, Float:XMin, Float:YMin, Float:XMax, Float:YMax)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    #pragma unused Z
    return ((XMin <= X <= XMax) && (YMin <= Y <= YMax));
}



Re: [AJUDA] Perder vida quando estб na area. - Cheleber_Pausini - 04.03.2012

O'Premium works very well, when I go to the infected area, he dies and so on ...
But when I'm choosing the skin I'm being infected, even in OnPlayerRuequestClass being away from the infected area, and when I click to spawn the player dies.
Help me please


Respuesta: [AJUDA] Perder vida quando estб na area. - OPremium - 04.03.2012

woops... I forgot about checking the player's state -.-

pawn Код:
#include <a_samp>

#define VERMELHO 0xE61D06FF
#define AZUL  0x0080FFFF
#define AMARELO 0xF2F200FF
#define ROXO 0x8080FFFF
#define BRANCO 0xFFFFFFFF
#define CINZA 0xC0C0C0FF
#define COR_GROOVE 0x008000FF
#define COR_BALLAS 0x930093FF
#define COR_VAGOS 0xD9D900FF
#define COR_AZTECAS 0x00CACAFF

new InfecAreas[6]; //If you want to add more areas you need to change the size of this array and then add the coords in the other array
new Float:AreaInfo[][] = //List with the areas where the player will lose health
{
    {-2987.5754, -2986.1350, 3002.7341, 452.8182},
    {-2986.6272, 447.4655, -1070.0516, 2997.9810},
    {917.9335, 443.6140, 1534.3945, 604.9423},
    {-1103.6216, 427.1572, -529.2606, 1367.6926},
    {-1081.2606, 1361.6926, -606.2606, 2109.6926},
    {-1082.2606, 2089.6926, -930.2606, 2525.6926}
};

public OnFilterScriptInit()
{
    for(new i; i < sizeof(InfecAreas); i++)
    {
        InfecAreas[i] = GangZoneCreate(AreaInfo[i][0], AreaInfo[i][1], AreaInfo[i][2], AreaInfo[i][3]);
    }
    SetTimer("Infectados", 1000, true); //Sets a 1 sec timer that will check all players
    return 1;
}

public OnPlayerSpawn(playerid)
{
    for(new i; i < sizeof(InfecAreas); i++)
    {
        GangZoneShowForPlayer(playerid, InfecAreas[i], BRANCO);
    }
    return 1;
}

forward Infectados();
public Infectados()
{
    new Float:tmphealth;
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(!(PLAYER_STATE_ONFOOT <= GetPlayerState(i) <= PLAYER_STATE_PASSENGER)) continue; //Ignores players that are dead, spectating or in class-selection
        for(new e; e < sizeof(InfecAreas); e++)
        {
            if(IsPlayerInPlace(i, AreaInfo[e][0], AreaInfo[e][1], AreaInfo[e][2], AreaInfo[e][3]))
            {
                GetPlayerHealth(i, tmphealth);
                tmphealth -= 1.0; //Change it to the amount that you want, the player will lose this amount of health while he is in the area
                SetPlayerHealth(i, tmphealth);
                break; //Stops the areas loop
            }
        }
    }
    return 1;
}

stock IsPlayerInPlace(playerid, Float:XMin, Float:YMin, Float:XMax, Float:YMax)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    #pragma unused Z
    return ((XMin <= X <= XMax) && (YMin <= Y <= YMax));
}