SA-MP Forums Archive
Onplayershootweapon - 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: Onplayershootweapon (/showthread.php?tid=491027)



Onplayershootweapon - nickstar - 29.01.2014

I having a problem and i doubt this code is correct

What is the problem and how can i fix it? Thanks What i want is when the play get shot with a silenced pistol i want it to play a sound.

Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	new Float:x, Float:y, Float:z;
	new Float:x2, Float:y2, Float:z2;
 	GetPlayerPos(playerid, x, y, z);
 	GetPlayerPos(hitid, x2, y2, z2);
	if(playerid, 23, 1, BULLET_HIT_TYPE_PLAYER, hitid, x2, y2, z2)
	{
	    PlaySoundForPlayersInRange(6003, 14.0, x, y, z);
	}
	return 1;
}



Re: Onplayershootweapon - Excelize - 29.01.2014

The script should be right from what I see in the code. Maybe the sound ID you're using is quiet?


I thought this might be useful:
Oh, and If you're trying to play the sound when he hit another player, then use this:

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0); // Ding Sound
    return 1;
}
PS:Make sure to use the or When you're pasting code here

Hope I could Help,

Excelize


Re: Onplayershootweapon - nickstar - 29.01.2014

What i'm trying to do is make it play a noise with only a certain weapon so... would i do this

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    if(GetPlayerWeapon(playerid) == 23)
    {
	    PlaySoundForPlayersInRange(6003, 14.0, x, y, z);
    }
    return 1;
}



Re: Onplayershootweapon - [FSaF]Jarno - 29.01.2014

Quote:
Originally Posted by nickstar
Посмотреть сообщение
What i'm trying to do is make it play a noise with only a certain weapon so... would i do this

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    if(GetPlayerWeapon(playerid) == 23)
    {
	    PlaySoundForPlayersInRange(6003, 14.0, x, y, z);
    }
    return 1;
}
Just put 0s into all of the co-ordinate parameters, like this:
PlaySoundForPlayersInRange(6003, 14.0, 0, 0, 0);


Re: Onplayershootweapon - Excelize - 29.01.2014

Quote:
Originally Posted by nickstar
Посмотреть сообщение
What i'm trying to do is make it play a noise with only a certain weapon so... would i do this

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    if(GetPlayerWeapon(playerid) == 23)
    {
	    PlaySoundForPlayersInRange(6003, 14.0, x, y, z);
    }
    return 1;
}
Yes, you'd just put the 0's in on the x,y,z axis as mentioned above. That should work, tried it in a blank GM and it did for me. If it doesn't, then something in your GM might be muting it..


Re: Onplayershootweapon - nickstar - 30.01.2014

Thanks guys I got it to work with your help. Rep for both of you.