SA-MP Forums Archive
OnPlayerWeaponShot problem ! - 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: OnPlayerWeaponShot problem ! (/showthread.php?tid=589377)



OnPlayerWeaponShot problem ! - CoachCarter - 18.09.2015

When I hit the object function isn't working (sound isn't playing and object isn't getting destroyed) what's the problem ?

Код:
	if(hittype == 3)
	{
	    if(hitid == slotb1[playerid])
		{
		    switch(IsTraining[playerid])
		    {
		    	case 1:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 809.6979,1645.6659,4.4826, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 2:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 807.9756,1645.3145,4.4826, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 3:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 806.5139,1645.0021,4.4826, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 4:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 805.0288,1645.0342,4.4826, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 5:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 803.3965,1645.0092,4.4826, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 6:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 801.6772,1644.6831,4.4826, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 7:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 800.4271,1644.5623,4.4826, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 8:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 798.6858,1644.7762,4.4826, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 9:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 797.1193,1644.7615,4.4826, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 10:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 795.4224,1644.7452,4.4826, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb1[playerid]);
				}
				case 11:
				{
				    slotb2[playerid] = CreatePlayerObject(playerid, 1486, 793.9834,1644.4231,4.4826, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb1[playerid]);
				}
			}
			PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0);
		}
	    if(hitid == slotb2[playerid])
		{
		    switch(IsTraining[playerid])
		    {
		        case 1:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 810.3208,1618.1469,4.4813, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 2:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 809.3016,1618.1086,4.4813, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 3:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 808.1950,1618.0488,4.4813, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 4:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 806.1711,1617.9402,4.4813, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 5:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 805.2635,1617.8916,4.4813, 0.0, 0.0, 0.0, 100.00);
		            DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 6:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 804.1240,1617.8302,4.4813, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 7:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 802.3339,1617.7347,4.4813, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 8:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 800.9711,1617.6616,4.4813, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 9:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486, 798.8643,1617.5491,4.4813, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 10:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486,  796.9112,1617.4443,4.4813, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
		        case 11:
		        {
		            slotb3[playerid] = CreatePlayerObject(playerid, 1486,  793.8408,1617.3242,4.4813, 0.0, 0.0, 0.0, 100.00);
	            	DestroyPlayerObject(playerid, slotb2[playerid]);
		        }
			}
			PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0);
		}
		if(hitid == slotb3[playerid])
		{
			PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0);
		    DestroyPlayerObject(playerid, slotb3[playerid]);
		    DestroyPlayerObject(playerid, slotb2[playerid]);
		    DestroyPlayerObject(playerid, slotb1[playerid]);
		    slotb1[playerid] = 0;
		    slotb2[playerid] = 0;
		    slotb3[playerid] = 0;
		    TerminateTimer[playerid] = SetTimerEx("TerminateTraining", 3000, 0, "d", playerid);
	        GameTextForPlayer(playerid, "~b~Training Session ~g~Finished!", 3000, 6);
		}
	}



Re: OnPlayerWeaponShot problem ! - Jefff - 18.09.2015

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


Re: OnPlayerWeaponShot problem ! - Crayder - 18.09.2015

You are using `BULLET_HIT_TYPE_OBJECT` (3) instead of `BULLET_HIT_TYPE_PLAYER_OBJECT` (4).

Change:
if(hittype == 3)
To:
if(hittype == BULLET_HIT_TYPE_PLAYER_OBJECT)