pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <YSI\y_ini>
#include <zcmd>
#include <sscanf2>
#define D_RADIO 601
#define D_RADIOMUSIC 602
#define D_RADIO_PINPUT 603
#define D_RADIO_PLAYER 604
#pragma tabsize 0
#define PATH "/PlayerStream/%s.ini"
enum pInfo
{
pStream
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Stream",PlayerInfo[playerid][pStream]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
public OnPlayerConnect(playerid)
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SavePlayerFiles(playerid);
return 1;
}
public OnPlayerUpdate(playerid)
{
SavePlayerFiles(playerid);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
SavePlayerFiles(playerid);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == D_RADIO && response)
{
switch(listitem)
{
case 0:
{
StopAudioStreamForPlayer(playerid);
return SendClientMessage(playerid,-1,"You may have to exit/re-enter vehicle for stereo to work again");
}
case 1: ShowPlayerDialog(playerid, D_RADIO_PLAYER,DIALOG_STYLE_INPUT,"Enter stream URL","If you hear nothing, its a bad URL!","Play URL","Cancel");
case 2: ShowPlayerDialog(playerid, D_RADIO_PINPUT,DIALOG_STYLE_INPUT,"Enter stream URL","If you hear nothing, its a bad URL!","Play URL","Cancel");
case 3: ShowPlayerDialog(playerid, D_RADIOMUSIC, DIALOG_STYLE_LIST, "Choose Music Radio",".977 Hitz\n90s Alternative\nTop 40\nDub Step\nHip Hop\nUnderground Rap\nRock and Roll\nOpera\nClassical\nBlues\nTechno\nTrip Hop\nBollywood\nVideo Game\nMovie\nMetal\nNews\n50s and 60s Oldies\nThe 70s\nThe 80s\nCrazyBob's CnR SAMP Radio\nBeat Basement ","Listen","Exit");
}
return 1;
}
else if (dialogid == D_RADIO_PLAYER && response)
{
if(strlen(inputtext) > 0)
{
PlayAudioStreamForPlayer(playerid,inputtext);
}
else
{
SendClientMessage(playerid,-1,"Your input was too short.");
}
}
else if (dialogid == D_RADIO_PINPUT && response)
{
if(PlayerInfo[playerid][pStream] < 1) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You are not atleast Admin Level 1!"); //This will make Admin LVL 1 + Cmd. If you're not admin
{
PlayAudioStreamForAll(inputtext);
}
}
else if(dialogid == D_RADIOMUSIC && response)
{
switch(listitem) //music stations
{
case 0: PlayAudioStreamForPlayer(playerid,"http://7609.live.streamtheworld.com:80/977_HITS_SC"); //.977 hitz
case 1: PlayAudioStreamForPlayer(playerid, "http://7639.live.streamtheworld.com:80/977_ALTERN_SC"); // alternative
case 2: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=38370"); // top 40
case 3: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=319038"); //dubstep
case 4: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=71829"); // hip-hop / rap
case 5: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=9054"); // underground rap
case 6: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=29469"); //rock
case 7: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=1269951"); //opera
case 8: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=403280"); //classical
case 9: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=205177"); //blues
case 10: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=1377200"); // techno
case 11: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=82343"); //trip hop
case 12: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=817801"); //bollywood
case 13: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=15706"); //video game music
case 14: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=5266"); //movie soundtracks
case 15: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=318248"); //metal
case 16: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=1279013"); //world news
case 17: PlayAudioStreamForPlayer(playerid,"http://7659.live.streamtheworld.com:80/977_OLDIES_SC"); //50s 60s oldies
case 18: PlayAudioStreamForPlayer(playerid,"http://7649.live.streamtheworld.com:80/977_CLASSROCK_SC"); //70s
case 19: PlayAudioStreamForPlayer(playerid,"http://7649.live.streamtheworld.com:80/977_80_SC"); //80s
case 20: PlayAudioStreamForPlayer(playerid,"http://cnr-radio.com/listen.m3u"); //CBs CnR
case 21: PlayAudioStreamForPlayer(playerid,"http://yp.shoutcast.com/sbin/tunein-station.pls?id=1377877");
}
}
return 1;
}
stock SavePlayerFiles(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Stream",PlayerInfo[playerid][pStream]);
INI_Close(File);
return 1;
}
stock PlayAudioStreamForAll(url[])
{
for(new i = 0, e = GetMaxPlayers(); i < e; i++)
{
if(IsPlayerConnected(i))
{
PlayAudioStreamForPlayer(i, url);
}
}
return 1;
}
CMD:setstream(playerid, params[])
{
if(!IsPlayerAdmin( playerid ) ) return SendClientMessage(playerid, -1,"You must be a higher level admin to use this command");
new level, aname[MAX_PLAYER_NAME];
new targetid;
if(sscanf(params, "ri", targetid, level)) return SendClientMessage(playerid, -1,"ERROR: /setstream <playerid> <1> allow stream <0> disallow");
if (level > 1 || level < 0) return SendClientMessage(playerid, -1,"ERROR: invalid stream lol");
if(!IsPlayerConnected( targetid )) return SendClientMessage(playerid, -1,"ERROR: player isn't connected");
new string1[130], tname[MAX_PLAYER_NAME], string2[130];
new INI:File = INI_Open(UserPath(targetid ));// here error line :/
INI_SetTag(File,"data");
INI_WriteInt(File,"Stream", pStream);
INI_Close(File);
PlayerInfo[targetid][pStream] = level;
GetPlayerName(playerid, aname, sizeof(aname));
GetPlayerName(targetid, tname, sizeof(tname));
format(string1, sizeof(string1), "Admin %s has set your Stream level to %i ", aname, level);
SendClientMessage(targetid, -1, string1);
format(string2, sizeof(string1), "Admin %s has set %s's Stream Level to %i", aname, tname, level);
SendClientMessageToAll(-1, string2);
return 1;
}