PlayerPlaySound
#1

hEY, i want do when i shot player and is hit him is do that sound
Код:
PlayerPlaySound(playerid, 1142, X, Y, Z);
Reply
#2

Use this

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
   PlayerPlaySound(playerid, 1142, 0.0,0.0,0.0);
   return 1;
}
if it dont works or if sound plays for other player then use this
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
   PlayerPlaySound(issuerid, 1142, 0.0,0.0,0.0);
   return 1;
}
Reply
#3

error
Код:
C:\Documents and Settings\CT\Desktop\HUYA TDM\pawno\new.pwn(83) : warning 235: public function lacks forward declaration (symbol "OnPlayerTakeDamage")
Reply
#4

what version of same are u using
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
https://sampwiki.blast.hk/wiki/PlayerPlaySound
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
   new Float: X, Float:Y, Float:z;
   GetPlayerPos(playerid, X,Y,Z);
   PlayerPlaySound(playerid, 1142, X,Y,Z);
   return 1;
}
Reply
#5

I really don't wanna do this but...

PlayerPlaySound uses X, Y and Z parameters, but when set to 0, they will just play for the player, rather than at his location as suggested in https://sampwiki.blast.hk/wiki/PlayerPlaySound

* Threshold regrets everything.

xD

EDIT: @Below Post - Yes he means SA-MP. OnPlayerTakeDamage was added in 0.3d

Alternative is OnPlayerShootPlayer, https://sampwiki.blast.hk/wiki/OnPlayerShootPlayer as suggested in this post somewhat down, maybe 2-3 posts. If you don't want to change functions, check if the issuerid is not invalid, then continue.

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID && issuerid != playerid) //playerid for bug fixes
    {
        PlayPlayerSound...
        //code continues.
Reply
#6

"same" you mean samp?
Reply
#7

Quote:
Originally Posted by HUYA
Посмотреть сообщение
error
Код:
C:\Documents and Settings\CT\Desktop\HUYA TDM\pawno\new.pwn(83) : warning 235: public function lacks forward declaration (symbol "OnPlayerTakeDamage")
You need to forward onplayertakedemage.

On top, where you have all forwards put this:

pawn Код:
forward OnPlayerTakeDemage();
or this:

pawn Код:
forward OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid);

This should work.

When you get more errors then put these errors here. And the code, where is the error!
Reply
#8

1.) Update your server to 0.3e and use the OnPlayerTakeDamage callback.
OR
2.) Download the OPSP include and try this code:
pawn Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    new Float: X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X,Y,Z);
    PlayerPlaySound(playerid, 1142, X,Y,Z);
    return 1;
}
Reply
#9

Which is already done in the latest a_samp include which comes with the latest server package: http://www.sa-mp.com/download

So we'd recommend updating to the latest SA-MP Version if possible rather than tampering with the include or creating your own OnPlayerTakeDamage function.
Reply
#10

Quote:
Originally Posted by martin3644
Посмотреть сообщение
You need to forward onplayertakedemage.

On top, where you have all forwards put this:

pawn Код:
forward OnPlayerTakeDemage();
or this:

pawn Код:
forward OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid);

This should work.

When you get more errors then put these errors here. And the code, where is the error!
No. OnPlayerTakeDamage is a function included in the SA-MP thingy, you do not need to forward it. Means either you are using an older version, most probably.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)