[Include] Dynamic Radio in Vehicles
#1

Hello,

Today I release another script I made, the "Dynamic Radio in Vehicles". This script is designed to easily add real existing radio stations to the game. It simply replaces the old radio.

pawn Код:
stock AddRadioStation(name[NAME_SIZE], link[LINK_SIZE])
// name: The name of the radio station (which will show ingame when changing stations).
// link: The link to the audio stream.
You can install this by putting...

pawn Код:
#include "DynamicRadioStations"
... at the top of your gamemode or filterscript (filterscript since R2)

Using it ingame
There are three new buttons added in SA-MP 0.3d, and we will use two of them: Y and N.
Y -> Station Next
N -> Station Back

You can also choose different styles for the textdraw (since R5)
pawn Код:
#define USE_TEXTDRAW_SET [ID]
For those who are interested in how te styles look; I uploaded a picture of them.
ID 0: http://i.imgur.com/zqqCi.png
ID 1: http://i.imgur.com/hIsYh.png
ID 2: http://i.imgur.com/vSjoj.png

I can only say, check it out!

Credits
Jochemd - Creating this script (not too hard)
****** - y_hooks
Jakku - I asked him for help when the hooks didn't work well.

Changelog
Код:
R7
- The textdraw is now per-player instead of per-vehicle, which saves A LOT of textdraws. Note: I did not use PlayerTextDraws, but a loop with normal textdraws.
R6
- Added GetRadioStationsString() which returns all names of the stations (NAME1\nNAME2\nNAME3). This allows you to create command like /setstation (see example) and /allstations.
- Bugfix in SetRadioStation.
R5
- Fixed a bug: People were able to switch radio stations on foot.
- Changed the hooks OnGameModeInit and OnFilterScriptInit to stocks to save script space.
- Added GetVehicleRadioStation(vehicleid) and SetVehicleRadioStation(vehicleid, stationid) (useful if you want to make a 'favourites' script, for example).
- Rewrote almost whole code in another style.
- Added several textdraw styles. You can now choose one you prefer using a define! Credits to Jakku for creating some styles
- The radio stations are now synced per vehicle. When a passenger changes the radio station, the driver sees it and the same goes for when the driver changes it.
R4
- Fixed bug: When you spawn, server crashes. Update strongly recommended!
R3
- Fixed bug: Array sizes do not match (error 47).
- Fixed bug: Music doesn't stop when you exit the vehicle.
- Fixed bug: "symbol" has been truncated to "size". I have just shrinked the hooks.
R2: 
- Now you can use this in an filterscript as well!
- Fixed a bug where the last one wouldn't be called because the cell assignment starts from 0. Thanks to CyNiC!
Download
http://pastebin.com/5yKug2wj (R7)
Example for GetRadioStationsString() http://pastebin.com/raw.php?i=m45qNVeR (note: copy it to your PAWN editor for a better reading experience with syntax highlighting.)

Please note this is not a filterscript, but an include! You have to use "AddRadioStation" in your gamemode/filterscript!
Reply
#2

Looks good i will check it out later
Reply
#3

Nice job.

Thanks for this.
Reply
#4

Looks useful I believe that many people want to create their own radio stations.

However,
pawn Код:
if(RadioCount <= MAX_RADIO_STATIONS)
If RadioCount is equal to MAX_RADIO_STATIONS, some problems will happen, you can't acess this array cell because the cell assignment starts from 0.
Reply
#5

Quote:
Originally Posted by CyNiC
Посмотреть сообщение
Looks useful I believe that many people want to create their own radio stations.

However,
pawn Код:
if(RadioCount <= MAX_RADIO_STATIONS)
If RadioCount is equal to MAX_RADIO_STATIONS, some problems will happen, you can't acess this array cell because the cell assignment starts from 0.
I have tested it and it worked fine, but if you think you find a bug when it's equal, please report it. It's pretty easy to fix.

pawn Код:
if(RadioCount < MAX_RADIO_STATIONS)
Reply
#6

Good work, I might use it.
Reply
#7

Ow:

Код:
C:\Users\Michael2\Downloads\GTA\Destruction Derby 0.3d\pawno\include\RadioStation.inc(110) : warning 200: symbol "@yH_PlayerKeyStateChange1DRadio" is truncated to 31 characters
C:\Users\Michael2\Downloads\GTA\Destruction Derby 0.3d\pawno\include\RadioStation.inc(110) : warning 200: symbol "@yH_PlayerKeyStateChange1DRadio" is truncated to 31 characters
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
x) I want to use it in my derby server.

EDIT: but it works..
Reply
#8

I seriously don't understand why you get it. I also have the same callback and it works! In the next update, I will shrink the hook names so it works!

Btw, I appreciate it you use it =D

Update: R3!
Reply
#9

It crashes my server ..
Reply
#10

Nice job.

Thank you
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)