if(strcmp(cmd, "/dshild", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (IsPlayerInRangeOfPoint(playerid, 6, 257.1108,78.0250,1003.6406))
{
if(!IsANg(playerid))
{
SendClientMessage(playerid,COLOR_GREY," Only army deltaforce can use this equipment.");
return 1;
}
shild = SetPlayerAttachedObject(playerid, 8, 18637, 4, 0.3, 0, 0, 0, 170, 270, 1, 1, 1);
return 1;
}
}
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype == 4)
{
if(hitid == shild)
{
return 0;
}
}
return 1;
}
new
bool:Shielded[MAX_PLAYERS]
;
public OnPlayerConnect(playerid)
{
Shielded[playerid] = false;
return 1;
}
if(strcmp(cmd, "/dshild", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (IsPlayerInRangeOfPoint(playerid, 6, 257.1108,78.0250,1003.6406))
{
if(!IsANg(playerid))
{
SendClientMessage(playerid,COLOR_GREY," Only army deltaforce can use this equipment.");
return 1;
}
SetPlayerAttachedObject(playerid, 8, 18637, 4, 0.3, 0, 0, 0, 170, 270, 1, 1, 1);
Shielded[playerid] = true;
return 1;
}
}
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype == BULLET_HIT_TYPE_PLAYER)
{
if(Shielded[hitid]) return 0; //desync the bullet if the player has a shield.
}
return 1;
}
|
It is not like i wanted it to be... you gave me script which will make you god if you are shielded... i only need dmg to not be done when player hit shield. if he get shot anywhere else it would take his HP down.
|
|
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{ if(hittype == BULLET_HIT_TYPE_PLAYER) { if(Shielded[hitid]) return 0; //desync the bullet if the player has a shield. } return 1; }[/code] |
|
^^ That needs revising. It's not doing what you think it does at all.
This doesn't even check if that the bullet hit the shield. Doesn't matter which bodypart it's connected to, it's about the bullets hitting the shield. |
// in command...
ShieldObject[playerid] = CreateObject(18637, 0, 0, 0, 0, 0, 0);
AttachObjectToPlayer(objectid, .....
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float: fX, Float: fY, Float: fZ)
{
if(hittype == BULLET_HIT_TYPE_PLAYER && Shield[hitid] == true)
{
new Float: pos[4];
GetObjectOffset(ShieldObject[playerid], playerid, EXTRA_TYPE_PLAYER, pos[0], pos[1], pos[2], pos[3]);
if(GetDistance(x, y, z, pos[0], pos[1], pos[2], pos[3] < 5.0)
{
return 0;
}
}
return 1;
}
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 )
{
return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) );
}