Taser and Rubber Bullets giving damage
#1

Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
	new Float:HP;
	GetPlayerHealth(Target, HP);
	if(PlayerStat[Shooter][FactionID] == 1)
	{
		if(HasTaser{Shooter} && IsPlayerInAnyVehicle(Shooter) == 0)
		{
			if(IsPlayerInAnyVehicle(Target) && !IsBike(GetPlayerVehicleID(Target))) return true;

			new Float:pos[3];
			GetPlayerPos(Target, pos[0], pos[1], pos[2]);
			if(PlayerStat[Target][Bagged] == 0 && PlayerStat[Target][Tased] == 0 && GetPlayerDistanceFromPoint(Shooter, pos[0], pos[1], pos[2]) < 25)
			{
				if(IsPlayerInAnyVehicle(Target)) RemovePlayerFromVehicle(Target);
				OnePlayAnim(Target, "CRACK", "crckdeth2", 4.0, 1, 1, 1, -1, 0);
				SetTimerEx("SetUnTazed", 10000, false, "i", Target);
				GameTextForPlayer(Target, "You have been tased!", 60000, 4);
				PlayerStat[Target][Tased] = 1;
				SendClientMessage(Shooter, COLOR_WHITE, "You have tased the suspect.");
				SendNearByMessage(Target, 20.0, COLOR_PURPLE, "** %s falls on the ground after being hit by %s taser.", ReturnName(Target, 0), ReturnName(Shooter, 0));
				SetHealth(Target, HP+HealthLost);
				PlayerPlaySound(Target, 4400, 0, 0, 0);
				PlayerPlaySound(Shooter, 4400, 0, 0, 0);
				return true;
			}
		}
		if(HasRubberBullets{Shooter} && IsPlayerInAnyVehicle(Target) == 0 && IsPlayerInAnyVehicle(Shooter) == 0)
		{
			if(IsPlayerInAnyVehicle(Target) && !IsBike(GetPlayerVehicleID(Target))) return true;

			new Float:pos[3];
			GetPlayerPos(Target, pos[0], pos[1], pos[2]);
			if(PlayerStat[Target][Bagged] == 0 && PlayerStat[Target][Tased] == 0  && GetPlayerDistanceFromPoint(Shooter, pos[0], pos[1], pos[2]) < 25)
			{
				if(IsPlayerInAnyVehicle(Target)) RemovePlayerFromVehicle(Target);
				GameTextForPlayer(Target, "You have been hit by a beanbag!", 60000, 4);
				SetTimerEx("SetUnBagged", 10000, false, "i", Target);
				OnePlayAnim(Target, "SWEET", "Sweet_injuredloop", 4.0, 1, 0, 0, 0, 0);
				SetPlayerDrunkLevel(Target, 4000);
				SetHealth(Target, HP+HealthLost);
				PlayerStat[Target][Bagged] = 1;
				SendNearByMessage(Target, 20.0, COLOR_PURPLE, "** %s was hit by a rubber bullet and falls on the ground.", ReturnName(Target, 0));
				return true;
			}
		}
	}
    return true;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
	if(HasTaser{issuerid}) return true;
	if(HasRubberBullets{issuerid}) return true;
	new Float:HP;
	GetPlayerHealth(playerid, HP);
	if(ADuty[playerid] == 1 && PlayerStat[playerid][AdminLevel] >= 1)
	{
		SetHealth(playerid, 100);
		SetArmour(playerid, 100);
		return true;
	}
    if(issuerid != INVALID_PLAYER_ID)
    {
		switch(weaponid)
		{
			case 0:
			{
        		if(PlayerStat[issuerid][StatPWR] >= 16)
				{
					SetHealth(playerid, HP - 8.0);
					return 1;
				}
				else if(PlayerStat[issuerid][StatPWR] >= 5)
				{
					SetHealth(playerid, HP - 6.0);
					return 1;
				}
				else if(PlayerStat[issuerid][StatPWR] <= 4)
				{
					SetHealth(playerid, HP - 4.0);
					return 1;
				}
			}
			case 1:
			{
        		if(PlayerStat[issuerid][StatPWR] >= 16)
				{
					SetHealth(playerid, HP - 12.0);
					return 1;
				}
				else if(PlayerStat[issuerid][StatPWR] >= 5)
				{
					SetHealth(playerid, HP - 8.0);
					return 1;
				}
				else if(PlayerStat[issuerid][StatPWR] <= 4)
				{
					SetHealth(playerid, HP - 6.0);
					return 1;
				}
			}
			case 3:
			{
        		if(PlayerStat[issuerid][StatPWR] >= 16)
				{
					SetHealth(playerid, HP - 16.0);
					return 1;
				}
				else if(PlayerStat[issuerid][StatPWR] >= 5)
				{
					SetHealth(playerid, HP - 12.0);
					return 1;
				}
				else if(PlayerStat[issuerid][StatPWR] <= 4)
				{
					SetHealth(playerid, HP - 6.0);
					return 1;
				}
			}
			case 5:
			{
        		if(PlayerStat[issuerid][StatPWR] >= 16)
				{
					SetHealth(playerid, HP - 24.0);
					return 1;
				}
				else if(PlayerStat[issuerid][StatPWR] >= 5)
				{
					SetHealth(playerid, HP - 20.0);
					return 1;
				}
				else if(PlayerStat[issuerid][StatPWR] <= 4)
				{
					SetHealth(playerid, HP - 16.0);
					return 1;
				}
			}
			case 4: //Knife
			{
				new Random1 = random(5);
				if(!(Random1 == 3))
				{
					PlayerStat[playerid][BleedingWound]++;
				}
				if(PlayerStat[playerid][BleedingWound] >= 1)
				{
					new Random2 = random(2);
					if(Random2 == 2)
					{
						SetTimerEx("BleedingWoundTimer", 10000, true, "i", playerid);
					}
				}
			}
		    case 22:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-13); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-8); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-26); // Head
				}
			}
		    case 23:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-15); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-12); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-25); // Head
				}
			}
		    case 24:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-23); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-20); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-15); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-15); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-15); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-15); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-67); // Head
				}
			}
		    case 25:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-30); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-27); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-23); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-23); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-22); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-22); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-70); // Head
				}
			}
		    case 27:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-20); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-14); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-10); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-10); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-9); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-9); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-70); // Head
				}
			}
		    case 28:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-10); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-8); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-20); // Head
				}
			}
		    case 29:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-10); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-8); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-20); // Head
				}
			}
		    case 30:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-21); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-14); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-9); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-9); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-8); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-8); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-40); // Head
				}
			}
		    case 31:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-21); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-14); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-9); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-9); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-8); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-8); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-40); // Head
				}
			}
		    case 32:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-10); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-8); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-20); // Head
				}
			}
		    case 33:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-26); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-15); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-10); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-14); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-10); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-14); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-40); // Head
				}
			}
		    case 34:
			{
			    switch(bodypart)
				{
					case 3: SetPlayerHealth(playerid, HP-33); // Torso
				 	case 4:	SetPlayerHealth(playerid, HP-28); // Groin
				 	case 5: SetPlayerHealth(playerid, HP-20); // Left ARM
				 	case 6: SetPlayerHealth(playerid, HP-20); // Right ARM
				 	case 7: SetPlayerHealth(playerid, HP-20); // Left Leg
				 	case 8: SetPlayerHealth(playerid, HP-20); // Right Leg
				 	case 9: SetPlayerHealth(playerid, HP-100); // Head
				}
			}
		}
    }
	return 1;
}
Please help, if you need more information post below
Reply
#2

I did not read anything, but if you need a weapon to not do damage at all, you can use this callback

https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot

and return 0 if the player meets the requirements (if he's using a taser)

If it's not what you need, sorry, i'm off to sleep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)