SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/03/2012, 02:09 PM   #1
Cheleber_Pausini
Big Clucker
 
Cheleber_Pausini's Avatar
 
Join Date: Jul 2011
Location: Porto, Portugal
Posts: 138
Reputation: 5
Default [AJUDA] Perder vida quando está na area.

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...
Code:
#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 (;
Cheleber_Pausini is offline   Reply With Quote
Old 04/03/2012, 02:21 PM   #2
Cheleber_Pausini
Big Clucker
 
Cheleber_Pausini's Avatar
 
Join Date: Jul 2011
Location: Porto, Portugal
Posts: 138
Reputation: 5
Default Respuesta: [AJUDA] Perder vida quando está na area.

UP (;
Cheleber_Pausini is offline   Reply With Quote
Old 04/03/2012, 03:22 PM   #3
Cheleber_Pausini
Big Clucker
 
Cheleber_Pausini's Avatar
 
Join Date: Jul 2011
Location: Porto, Portugal
Posts: 138
Reputation: 5
Default Re: [AJUDA] Perder vida quando está na area.

UP UP UP Ajuda!
Cheleber_Pausini is offline   Reply With Quote
Old 04/03/2012, 03:23 PM   #4
Faisal_khan
High-roller
 
Faisal_khan's Avatar
 
Join Date: Feb 2012
Location: Nagpur, India
Posts: 1,826
Reputation: 208
Default Re: [AJUDA] Perder vida quando está na area.

Translation please!
__________________
Not a SAMP Dev. anymore.
Hire me for teaching any programming langauge.
Interested? Hit me up on Skype: pfk3325
Faisal_khan is offline   Reply With Quote
Old 04/03/2012, 03:25 PM   #5
Faisal_khan
High-roller
 
Faisal_khan's Avatar
 
Join Date: Feb 2012
Location: Nagpur, India
Posts: 1,826
Reputation: 208
Default Re: [AJUDA] Perder vida quando está na area.

Try this it may help you.
http://forum.sa-mp.com/showthread.php?t=276352
__________________
Not a SAMP Dev. anymore.
Hire me for teaching any programming langauge.
Interested? Hit me up on Skype: pfk3325
Faisal_khan is offline   Reply With Quote
Old 04/03/2012, 03:37 PM   #6
Cheleber_Pausini
Big Clucker
 
Cheleber_Pausini's Avatar
 
Join Date: Jul 2011
Location: Porto, Portugal
Posts: 138
Reputation: 5
Default Re: [AJUDA] Perder vida quando está na area.

I'm not looking for it, faisal..
Cheleber_Pausini is offline   Reply With Quote
Old 04/03/2012, 04:02 PM   #7
OPremium
Big Clucker
 
OPremium's Avatar
 
Join Date: Oct 2010
Posts: 153
Reputation: 59
Default Respuesta: [AJUDA] Perder vida quando está na area.

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 Code:
#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));
}
OPremium is offline   Reply With Quote
Old 04/03/2012, 04:40 PM   #8
Cheleber_Pausini
Big Clucker
 
Cheleber_Pausini's Avatar
 
Join Date: Jul 2011
Location: Porto, Portugal
Posts: 138
Reputation: 5
Default Re: [AJUDA] Perder vida quando está na area.

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
Cheleber_Pausini is offline   Reply With Quote
Old 04/03/2012, 06:34 PM   #9
OPremium
Big Clucker
 
OPremium's Avatar
 
Join Date: Oct 2010
Posts: 153
Reputation: 59
Default Respuesta: [AJUDA] Perder vida quando está na area.

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

pawn Code:
#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));
}
OPremium is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[AJUDA] Como fazer para o player não perder vida Gustavo_xP Português/Portuguese 9 11/07/2016 06:43 PM
[AJUDA]Quando uso /gmx não está salvando :( Nake01 Português/Portuguese 14 21/10/2011 07:38 PM
[Ajuda] Quando o player morre nao perder dinheiro iacocesar123 Português/Portuguese 18 10/05/2011 06:12 PM
[AJUDA] Pessoa Bater o Carro e Perder Vida Kasura Português/Portuguese 9 19/07/2010 05:29 PM


All times are GMT. The time now is 06:12 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.