Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum SongEnum
- {
- LongSong,
- Seconds,
- UrlSong[128],
- };
- new SongInfo[MAX_PLAYERS][SongEnum];
- stock StopMusicEx(playerid)
- {
- SongInfo[playerid][LongSong] = -1;
- StopAudioStreamForPlayer(playerid);
- return 0;
- }
- stock PlayMusicEx(playerid, str[], longsong)
- {
- strmid(SongInfo[playerid][UrlSong], str, 0, 128, 128);
- PlayAudioStreamForPlayer(playerid, SongInfo[playerid][UrlSong]);
- SongInfo[playerid][Seconds] = longsong;
- SongInfo[playerid][LongSong] = gettime()+SongInfo[playerid][Seconds];
- return 1;
- }
- forward RepeatSong(); public RepeatSong()
- {
- for(new x = 0; x < MAX_PLAYERS; x++)
- {
- if(IsPlayerConnected(x))
- {
- if(SongInfo[x][LongSong] > 0)
- {
- if(SongInfo[x][LongSong] < gettime())
- {
- SongInfo[x][LongSong] = gettime()+SongInfo[x][Seconds];
- PlayMusicEx(x, SongInfo[x][UrlSong], SongInfo[x][LongSong]);
- }
- }
- }
- }
- return 1;
- }
- public OnGameModeInit()
- {
- SetTimer("RepeatSong", 1000, true);
- return 1;
- }
- /* Example
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/playsound", cmdtext, true, 10) == 0)
- {
- PlayMusicEx(playerid, "Url", Duration of the song);
- return 1;
- }
- return 0;
- }
- */
Add Comment
Please, Sign In to add comment