PDA

View Full Version : Onplayershootweapon


nickstar
29/01/2014, 03:02 AM
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;
}

Excelize
29/01/2014, 03:08 AM
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:


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

nickstar
29/01/2014, 03:15 AM
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;
}

[FSaF]Jarno
29/01/2014, 04:44 AM
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);

Excelize
29/01/2014, 08:53 PM
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..

nickstar
30/01/2014, 01:01 AM
Thanks guys I got it to work with your help. Rep for both of you.