Advertisement
Guest User

Untitled

a guest
Jul 7th, 2011
1,317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.80 KB | None | 0 0
  1. /*
  2. CB Radio System; By Ash (funky1234)
  3. Do what you want with it, I don't really care.
  4. */
  5.  
  6. #include <a_samp>
  7.  
  8. new pChannel[MAX_PLAYERS];
  9.  
  10. #define COLOUR_RED 0xFF0000FF
  11. #define COLOUR_YELLOW 0xFFFF00FF
  12.  
  13. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  14.  
  15. public OnPlayerDisconnect(playerid, reason)
  16. {
  17.     #pragma unused reason
  18.     pChannel[playerid] = 0;
  19.     return 1;
  20. }
  21.  
  22. public OnPlayerSpawn(playerid)
  23. {
  24.     pChannel[playerid] = 1;
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerCommandText(playerid, cmdtext[])
  29. {
  30.     dcmd(cbchannel, 9, cmdtext);
  31.     dcmd(cb, 2, cmdtext);
  32.     return 0;
  33. }
  34.  
  35. dcmd_cbchannel(playerid, params[])
  36. {
  37.     if(!strlen(params) /*&& !IsNumeric(params)*/) return SendClientMessage(playerid, COLOUR_RED, "No parameters (Usage: /cbchannel [1-40]");
  38.     //If the length of params is 0 (non existent) - it returns an error message
  39.     //I have commeneted our "IsNumeric" because I am not supplying it with the tutorial (because I can't find it!)
  40.     if(strval(params) < 1 || strval(params) > 40) return SendClientMessage(playerid, COLOUR_RED, "Only channels 1 upto 40 exist");
  41.     //If the integer value of the parameters string is lower than 1 or bigger than 40 then it returns another error message
  42.     pChannel[playerid] = strval(params);
  43.     //Set the players channel
  44.         //You may also want to add a "Your channel is now %i" message.
  45.     return 1;
  46.     //Return 1 (command complete)
  47. }
  48.  
  49. dcmd_cb(playerid, params[])
  50. {
  51.     if(!strlen(params)) return SendClientMessage(playerid, COLOUR_RED, "No parameters (Usage: /cb [message]");
  52.     //Error message if the player did not specify any parameters
  53.     static str[128];
  54.     //Why static? It stops it being created more than once (in fact if you decompiled an AMX script you would find the "static" variable has become GLOBAL)
  55.     format(str, sizeof(str), "[CB]%s: %s", ReturnName(playerid), params);
  56.     //Format the output message (str)
  57.     //ReturnName, is a function to return a players name - I will include it toward the end of this post
  58.     //You could use colour embedding here!
  59.     for(new i; i < GetMaxPlayers(); i++)
  60.     {
  61.         //Start the loop (GetMaxPlayers will return the MAXIMUM player slots on your server - you could use Foreach here instead)
  62.         if(!IsPlayerConnected(i)) continue;
  63.         //If the player is not connected, skip to the next one
  64.         if(pChannel[i] == pChannel[playerid])
  65.         {
  66.             //If the player channel matches the other players channel
  67.             SendClientMessage(i, COLOUR_YELLOW, str);
  68.         }
  69.     }
  70.     return 1;
  71.     //End the command (return 1)
  72. }
  73.  
  74. stock ReturnName(playerid)
  75. {
  76.     static name[24];
  77.     GetPlayerName(playerid, name, 24);
  78.     return name;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement