SA-MP Train Airhorn
#1

In some sa-mp servers I have realized that an airhorn sound is used (for example: It is used to start a race, or a deathmatch after countdown is finished).
Im wondering if there is a way to make this a train horn.

For Example:
When driving a train, you press a certain key and the airhorn sound is played, and only nearby players can hear it.
Reply
#2

Yes it is possible.

under public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 537 || 538)
    {
    if((newkeys & KEY_CROUCH) && !(oldkeys & KEY_CROUCH))
        {
         for(new i = 0; i < MAX_PLAYERS; i++)
             {
              new Float:X, Float:Y, Float:Z;
              GetVehiclePos(vehicleid, X, Y, Z);
              if(IsPlayerInRangeOfPoint(i, 40, X, Y, Z);
                  {
                   PlayerPlaySound(i, 3201, 0, 0, 0);
                  }
              }
         }
   return 1;
   }
Note: This is untested, and this little chat box makes it hard to see what you're doing. I reccomend making something similar to this and not just copy+paste.
Reply
#3

Thanks, I will try it
Reply
#4

You can use PlayerPlaySound to hear any sound you would like to hear
Visit SA-MP Wiki for more info: https://sampwiki.blast.hk/wiki/PlayerPlaySound
And to know some sound ID's & hear 'em use SA-MP Sound ID Browser from here: https://sampforum.blast.hk/showthread.php?tid=373017
Reply
#5

It works as I expected MattaKil, I want to give you +reputation but Ive given out MAX reputations today
Reply
#6

Quote:
Originally Posted by Sewayne
Посмотреть сообщение
It works as I expected MattaKil, I want to give you +reputation but Ive given out MAX reputations today
lol no prob man, anyhow you can change the 40 to whatever you want, basically if you are within 40 units of the vehicle you will hear the noise
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)