public OnPlayerGiveDamage(playerid,damagedid,Float:amount,weaponid)
{
new Float:Vida; new Float:Colete; new Float:Dano;
if(weaponid == 16 || weaponid == 34 || weaponid == 35 || weaponid == 38)
{
ApplyAnimation(damagedid,"PED","DAM_STOMACH_FRMFT" ,4.1,0,1,1,0,1,1);
Tiros[damagedid] = 0;
}
if(weaponid == 24 || weaponid == 25 || weaponid == 27)
{
Tiros[damagedid]++;
if(Tiros[damagedid] > 4)
{
ApplyAnimation(damagedid,"PED","DAM_STOMACH_FRMFT" ,4.1,0,1,1,0,1,1);
Tiros[damagedid] = 0;
}
}
if(weaponid == 29 || weaponid == 30 || weaponid == 31)
{
Tiros[damagedid]++;
if(Tiros[damagedid] > 9)
{
ApplyAnimation(damagedid,"PED","DAM_STOMACH_FRMFT" ,4.1,0,1,1,0,1,1);
Tiros[damagedid] = 0;
}
}
GetPlayerArmour(damagedid,Colete);
GetPlayerHealth(damagedid,Vida);
if(Colete > 0)
{
if(amount/2 > Colete)
{
Dano = amount/2 - Colete;
Vida = Vida - Dano;
SetPlayerArmour(damagedid,0.0);
SetPlayerHealth(damagedid,Vida);
return 1;
}
Colete = Colete - amount/2;
SetPlayerArmour(damagedid,Colete);
}
if(Colete < 1)
{
Vida = Vida - amount/2;
SetPlayerHealth(damagedid,Vida);
}
return 1;
}
Seguinte: Passe a armazenar a Life e o Colete do Player em uma variбvel, assim vocк nгo precisarб usar o Get, pois o Get geralmente deixa o processamento do cуdigo mais lento..
Se precisar de uma base do cуdigo eu faзo pra vocк :3 Qualquer coisa sу avisar. |
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
new Float: Dano;
if (weaponid == 16 || weaponid == 34 || weaponid == 35 || weaponid == 38)
{
ApplyAnimation(damagedid, "PED", "DAM_STOMACH_FRMFT", 4.1, 0, 1, 1, 0, 1, 1);
Tiros[damagedid] = 0;
}
if (weaponid == 24 || weaponid == 25 || weaponid == 27)
{
Tiros[damagedid]++;
if (Tiros[damagedid] > 4)
{
ApplyAnimation(damagedid, "PED", "DAM_STOMACH_FRMFT", 4.1, 0, 1, 1, 0, 1, 1);
Tiros[damagedid] = 0;
}
}
if (weaponid == 29 || weaponid == 30 || weaponid == 31)
{
Tiros[damagedid]++;
if (Tiros[damagedid] > 9)
{
ApplyAnimation(damagedid, "PED", "DAM_STOMACH_FRMFT", 4.1, 0, 1, 1, 0, 1, 1);
Tiros[damagedid] = 0;
}
}
amount /= 2; // Isso й o mesmo que amount = amount / 2;
if (Colete[playerid] > 0)
{
if (amount > Colete[playerid])
{
Dano = amount - Colete[playerid];
Vida[playerid] -= Dano; // Isso й o mesmo que Vida[playerid] = Vida[playerid] - Dano;
SetPlayerArmour(damagedid, 0.0);
SetPlayerHealth(damagedid, Vida[playerid]);
return 1;
}
Colete[playerid] -= amount; // Isso й o mesmo que Colete[playerid] = Colete[playerid] - amount;
SetPlayerArmour(damagedid, Colete[playerid]);
}
if (Colete[playerid] < 1)
{
Vida[playerid] -= amount; // Isso й o mesmo que Vida[playerid] = Vida[playerid] - amount;
SetPlayerHealth(damagedid, Vida[playerid]);
}
return 1;
}
new Float:Vida[MAX_PLAYERS]; // Esta variбvel armazenarб a Life do Player
new Float:Colete[MAX_PLAYERS]; // Esta variбvel armazenarб o Colete do Player
public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 100); // Setamos a vida do cara pra 100, portando, temos de setar a variбvel da vida tambйm.
Vida[playerid] = 100; // Setamos a variбvel da vida.
SetPlayerArmour(playerid, 100); // Setamos o colete do cara pra 100, portando, temos de setar a variбvel do colete tambйm.
Colete[playerid] = 100; // Setamos a variбvel do colete.
}