Advertisement
Glint

CB Radio System By Glint

Oct 19th, 2012
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.47 KB | None | 0 0
  1. //==============================================================================
  2. #include        <a_samp>
  3. #include        <YSI\y_commands>
  4. //==============================================================================
  5. #define             MyTime(%0,%1,%2)    (((%0)*3600+(%1)*60+(%2))*1000)
  6. //==============================================================================
  7. enum CBInfo
  8. {
  9.     pCB,
  10.     pChannel,
  11.     pStatus,
  12.     pLevel,
  13.     pOwner,
  14.     pCBChannel
  15. }
  16. new RadioInfo[MAX_PLAYERS][CBInfo];
  17. //==============================================================================
  18. public OnFilterScriptInit()
  19. {
  20.     print("\t\t\t-> Scripter : Glint");
  21.     print("\t\t\t-> Script Name : CBRadio");
  22.     print("\t\t\t-> Script Version : 0.1");
  23.     return 1;
  24. }
  25. //==============================================================================
  26. public OnPlayerConnect(playerid)
  27. {
  28.     return 1;
  29. }
  30. //==============================================================================
  31. COMMAND:joinchannel(playerid, params[])
  32. {
  33.     if(RadioInfo[playerid][pCB] == 0) return SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} You {FF0000}Don't Have{FFFFFF} A Radio You Need To Buy One First {FF0000}(/cbhelp)");
  34.     if(RadioInfo[playerid][pStatus] == 0) return SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} Your Radio Is Turned Off Turn It On Using {FF0000}(/setcb)");
  35.     if(isnull(params)) return SendClientMessage(playerid, -1, "{1A80E6}USAGE: {FFFFFF}/joinchannel [1 - 1000]");
  36.     if(strval(params) < 1 || strval(params) > 1000) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}The Channel Must Be Between {FF0000}(1 - 1000)");
  37.     RadioInfo[playerid][pChannel] = strval(params);
  38.     new Str[128], pName[MAX_PLAYER_NAME];
  39.     GetPlayerName(playerid, pName, sizeof(pName));
  40.     format(Str, sizeof(Str), "{FF0000}>>{FFFFFF} You Have Joined Channel {FF0000}(%s)", params);
  41.     SendClientMessage(playerid, -1, Str);
  42.     for(new i = 0; i < MAX_PLAYERS; i++)
  43.     {
  44.         if(RadioInfo[i][pChannel] == RadioInfo[playerid][pChannel])
  45.         {
  46.             format(Str, sizeof(Str), "{FF0000}>>{C0C0C0} %s Has Joined The Channel", pName);
  47.             SendClientMessage(i, -1, Str);
  48.         }
  49.     }
  50.     return 1;
  51. }
  52. //==============================================================================
  53. COMMAND:buycb(playerid, params[])
  54. {
  55.     if(RadioInfo[playerid][pCB] == 1) return SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} You {00FF00}Already Have{FFFFFF} A Radio");
  56.     RadioInfo[playerid][pCB] = 1;
  57.     SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} You Have {00FF00}Bought{FFFFFF} A Citizens Band (CB) Radio For Help Use {FF0000}(/cbhelp)");
  58.     return 1;
  59. }
  60. //==============================================================================
  61. COMMAND:setcb(playerid, params[])
  62. {
  63.     if(isnull(params)) return SendClientMessage(playerid, -1, "{1A80E6}USAGE: {FFFFFF}/setcb [0 = Off] [1 = On]");
  64.     if(strval(params) == 1)
  65.     {
  66.         if(RadioInfo[playerid][pStatus] == 1)
  67.         {
  68.             SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} Your Radio Is Already {00FF00}On");
  69.         }
  70.         else
  71.         {
  72.             SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} You Have {00FF00}Successfully{FFFFFF} Turned {00FF00}On{FFFFFF} Your Radio");
  73.             RadioInfo[playerid][pStatus] = 1;
  74.         }
  75.     }
  76.     else if(strval(params) == 0)
  77.     {
  78.         if(RadioInfo[playerid][pStatus] == 0)
  79.         {
  80.             SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} Your Radio Is Already {FF0000}Off");
  81.         }
  82.         else
  83.         {
  84.             SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} You Have {00FF00}Successfully{FFFFFF} Turned {FF0000}Off{FFFFFF} Your Radio");
  85.             RadioInfo[playerid][pStatus] = 0;
  86.         }
  87.     }
  88.     return 1;
  89. }
  90. //==============================================================================
  91. COMMAND:cb(playerid, params[])
  92. {
  93.     if(RadioInfo[playerid][pCB] == 0) return SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} You {FF0000}Don't Have{FFFFFF} A Radio You Need To Buy One First {FF0000}(/cbhelp)");
  94.     if(RadioInfo[playerid][pStatus] == 0) return SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} Your Radio Is Turned Off Turn It On Using {FF0000}(/setcb)");
  95.     if(isnull(params)) return SendClientMessage(playerid, -1, "{1A80E6}USAGE: {FFFFFF}/cb [Your Message]");
  96.     new pName[MAX_PLAYER_NAME], Str[200];
  97.     GetPlayerName(playerid, pName, sizeof(pName));
  98.     format(Str, sizeof(Str), "{00FF00}[CB]{FF8000} %s: {FFFFFF}%s", pName, params);
  99.     for(new i = 0; i < MAX_PLAYERS; i++)
  100.     {
  101.         if(!IsPlayerConnected(i)) continue;
  102.         if(RadioInfo[i][pChannel] == RadioInfo[playerid][pChannel])
  103.         {
  104.             SendClientMessage(i, -1, Str);
  105.         }
  106.     }
  107.     return 1;
  108. }
  109. //==============================================================================
  110. COMMAND:cbalert(playerid, params[])
  111. {
  112.     if(RadioInfo[playerid][pCB] == 0) return SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} You {FF0000}Don't Have{FFFFFF} A Radio You Need To Buy One First {FF0000}(/cbhelp)");
  113.     if(RadioInfo[playerid][pStatus] == 0) return SendClientMessage(playerid, -1, "{FF0000}>>{FFFFFF} Your Radio Is Turned Off Turn It On Using {FF0000}(/setcb)");
  114.     if(isnull(params)) return SendClientMessage(playerid, -1, "{1A80E6}USAGE: {FFFFFF}/cbalert [Your Message]");
  115.     new pName[MAX_PLAYER_NAME], Str[128];
  116.     GetPlayerName(playerid, pName, sizeof(pName));
  117.     format(Str, sizeof(Str), "{00FF00}[CB ALERT]{FF8000} %s", pName);
  118.     for(new i = 0; i < MAX_PLAYERS; i++)
  119.     {
  120.         if(!IsPlayerConnected(i)) continue;
  121.         if(RadioInfo[i][pChannel] == RadioInfo[playerid][pChannel])
  122.         {
  123.             GameTextForPlayer(i, params, MyTime(0, 0, 5), 6);
  124.             SendClientMessage(i, -1, Str);
  125.         }
  126.     }
  127.     return 1;
  128. }
  129. //==============================================================================
  130. COMMAND:cbhelp(playerid, params[])
  131. {
  132.     new Str[1500];
  133.     strcat(Str, "\t\t{FF0000} - Citizens Band Radio System (CB) - \n{FFFFFF}A CB Radio Is A Communication Tool Used To Communicate In A Business Or \n{FFFFFF}Personally It Has A Max Of 1000 Channels You Can Choose From And Tell Your\n{FFFFFF}Gang For Example To Join That Specific Channel And You Can Talk Togeather\n\n", sizeof(Str));
  134.     strcat(Str, "{FFFF00}Commands : \n{FF8000}\t\t- /joinchannel (To Join A Channel)\n\t\t{FF8000}- /buycb (To Buy A CB)\n\t\t{FF8000}- /setcb (To Turn Your CB On / Off", sizeof(Str));
  135.     strcat(Str, "\n\t\t{FF8000}- /cb (To Talk Through The CB\n\t\t{FF8000}- /cbalert (To Send An Alert To All Users In The Channel\n\n{FFFF00}Credits :\n\t\t{FF8000}- Glint <3 For Creating This System\n\t\t{FF8000}- Y_Less For The YSI Library\n\n\n", sizeof(Str));
  136.     ShowPlayerDialog(playerid, 1212, DIALOG_STYLE_MSGBOX, "Citizens Band Radio", Str, "Close", "");
  137.     return 1;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement