Advertisement
Guest User

MSG System by Biker09

a guest
Mar 24th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.75 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3.  
  4. #if defined FILTERSCRIPT
  5.  
  6. //DMCD
  7. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  8.  
  9. public OnFilterScriptInit()
  10. {
  11.     print("\n--------------------------------------");
  12.     print(" MSGSystem by Biker09");
  13.     print("--------------------------------------\n");
  14.     return 1;
  15. }
  16.  
  17. public OnFilterScriptExit()
  18. {
  19.     return 1;
  20. }
  21.  
  22. #else
  23.  
  24. main()
  25. {
  26.     print("\n----------------------------------");
  27.     print(" Blank Gamemode by your name here");
  28.     print("----------------------------------\n");
  29. }
  30.  
  31. #endif
  32.  
  33. public OnGameModeInit()
  34. {
  35.     // Don't use these lines if it's a filterscript
  36.     SetGameModeText("Blank Script");
  37.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  38.     return 1;
  39. }
  40.  
  41. public OnGameModeExit()
  42. {
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerRequestClass(playerid, classid)
  47. {
  48.     return 1;
  49. }
  50.  
  51. public OnPlayerConnect(playerid)
  52. {
  53.     return 1;
  54. }
  55.  
  56. public OnPlayerDisconnect(playerid, reason)
  57. {
  58.     return 1;
  59. }
  60.  
  61. public OnPlayerSpawn(playerid)
  62. {
  63.     return 1;
  64. }
  65.  
  66. public OnPlayerDeath(playerid, killerid, reason)
  67. {
  68.     return 1;
  69. }
  70.  
  71. public OnVehicleSpawn(vehicleid)
  72. {
  73.     return 1;
  74. }
  75.  
  76. public OnVehicleDeath(vehicleid, killerid)
  77. {
  78.     return 1;
  79. }
  80.  
  81. public OnPlayerText(playerid, text[])
  82. {
  83.     return 1;
  84. }
  85.  
  86. public OnPlayerCommandText(playerid, cmdtext[])
  87. {
  88.     dcmd(msg, 3, cmdtext);
  89.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  90.     {
  91.         // Do something here
  92.         return 1;
  93.     }
  94.     return 0;
  95. }
  96.  
  97. dcmd_msg(playerid,params[])
  98. {
  99.     new name,msg[128],str[128],str2[128];
  100.     if(sscanf(params,"us",name,msg))return SendClientMessage(playerid,0x0000FFFF,"Benutze:/msg [Name] [Text]");
  101.     if(IsPlayerConnected(name))
  102.     {
  103.         format(str,sizeof(str),"MSG von %s : %s",SpielerName(playerid),msg);
  104.         format(str2,sizeof(str2),"MSG zu %s : %s",SpielerName(name),msg);
  105.         SendClientMessage(playerid,0x0000FFFF,str2);
  106.         SendClientMessage(name,0x0000FFFF,str);
  107.     }
  108.     else
  109.     {
  110.         SendClientMessage(playerid,0x6E6E6EFF,"Der Spieler ist nicht online!");
  111.     }
  112.     return 1;
  113. }
  114.  
  115. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  116. {
  117.     return 1;
  118. }
  119.  
  120. public OnPlayerExitVehicle(playerid, vehicleid)
  121. {
  122.     return 1;
  123. }
  124.  
  125. public OnPlayerStateChange(playerid, newstate, oldstate)
  126. {
  127.     return 1;
  128. }
  129.  
  130. public OnPlayerEnterCheckpoint(playerid)
  131. {
  132.     return 1;
  133. }
  134.  
  135. public OnPlayerLeaveCheckpoint(playerid)
  136. {
  137.     return 1;
  138. }
  139.  
  140. public OnPlayerEnterRaceCheckpoint(playerid)
  141. {
  142.     return 1;
  143. }
  144.  
  145. public OnPlayerLeaveRaceCheckpoint(playerid)
  146. {
  147.     return 1;
  148. }
  149.  
  150. public OnRconCommand(cmd[])
  151. {
  152.     return 1;
  153. }
  154.  
  155. public OnPlayerRequestSpawn(playerid)
  156. {
  157.     return 1;
  158. }
  159.  
  160. public OnObjectMoved(objectid)
  161. {
  162.     return 1;
  163. }
  164.  
  165. public OnPlayerObjectMoved(playerid, objectid)
  166. {
  167.     return 1;
  168. }
  169.  
  170. public OnPlayerPickUpPickup(playerid, pickupid)
  171. {
  172.     return 1;
  173. }
  174.  
  175. public OnVehicleMod(playerid, vehicleid, componentid)
  176. {
  177.     return 1;
  178. }
  179.  
  180. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  181. {
  182.     return 1;
  183. }
  184.  
  185. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  186. {
  187.     return 1;
  188. }
  189.  
  190. public OnPlayerSelectedMenuRow(playerid, row)
  191. {
  192.     return 1;
  193. }
  194.  
  195. public OnPlayerExitedMenu(playerid)
  196. {
  197.     return 1;
  198. }
  199.  
  200. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  201. {
  202.     return 1;
  203. }
  204.  
  205. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  206. {
  207.     return 1;
  208. }
  209.  
  210. public OnRconLoginAttempt(ip[], password[], success)
  211. {
  212.     return 1;
  213. }
  214.  
  215. public OnPlayerUpdate(playerid)
  216. {
  217.     return 1;
  218. }
  219.  
  220. public OnPlayerStreamIn(playerid, forplayerid)
  221. {
  222.     return 1;
  223. }
  224.  
  225. public OnPlayerStreamOut(playerid, forplayerid)
  226. {
  227.     return 1;
  228. }
  229.  
  230. public OnVehicleStreamIn(vehicleid, forplayerid)
  231. {
  232.     return 1;
  233. }
  234.  
  235. public OnVehicleStreamOut(vehicleid, forplayerid)
  236. {
  237.     return 1;
  238. }
  239.  
  240. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  241. {
  242.     return 1;
  243. }
  244.  
  245. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  246. {
  247.     return 1;
  248. }
  249.  
  250. stock SpielerName(playerid)
  251. {
  252.      new name[MAX_PLAYER_NAME];
  253.      GetPlayerName(playerid, name, sizeof(name));
  254.      return name;
  255. }
  256.  
  257. stock sscanf(string[], format[], {Float,_}:...)
  258. {
  259.     #if defined isnull
  260.         if (isnull(string))
  261.     #else
  262.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  263.     #endif
  264.         {
  265.             return format[0];
  266.         }
  267.     #pragma tabsize 4
  268.     new
  269.         formatPos = 0,
  270.         stringPos = 0,
  271.         paramPos = 2,
  272.         paramCount = numargs(),
  273.         delim = ' ';
  274.     while (string[stringPos] && string[stringPos] <= ' ')
  275.     {
  276.         stringPos++;
  277.     }
  278.     while (paramPos < paramCount && string[stringPos])
  279.     {
  280.         switch (format[formatPos++])
  281.         {
  282.             case '\0':
  283.             {
  284.                 return 0;
  285.             }
  286.             case 'i', 'd':
  287.             {
  288.                 new
  289.                     neg = 1,
  290.                     num = 0,
  291.                     ch = string[stringPos];
  292.                 if (ch == '-')
  293.                 {
  294.                     neg = -1;
  295.                     ch = string[++stringPos];
  296.                 }
  297.                 do
  298.                 {
  299.                     stringPos++;
  300.                     if ('0' <= ch <= '9')
  301.                     {
  302.                         num = (num * 10) + (ch - '0');
  303.                     }
  304.                     else
  305.                     {
  306.                         return -1;
  307.                     }
  308.                 }
  309.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  310.                 setarg(paramPos, 0, num * neg);
  311.             }
  312.             case 'h', 'x':
  313.             {
  314.                 new
  315.                     num = 0,
  316.                     ch = string[stringPos];
  317.                 do
  318.                 {
  319.                     stringPos++;
  320.                     switch (ch)
  321.                     {
  322.                         case 'x', 'X':
  323.                         {
  324.                             num = 0;
  325.                             continue;
  326.                         }
  327.                         case '0' .. '9':
  328.                         {
  329.                             num = (num << 4) | (ch - '0');
  330.                         }
  331.                         case 'a' .. 'f':
  332.                         {
  333.                             num = (num << 4) | (ch - ('a' - 10));
  334.                         }
  335.                         case 'A' .. 'F':
  336.                         {
  337.                             num = (num << 4) | (ch - ('A' - 10));
  338.                         }
  339.                         default:
  340.                         {
  341.                             return -1;
  342.                         }
  343.                     }
  344.                 }
  345.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  346.                 setarg(paramPos, 0, num);
  347.             }
  348.             case 'c':
  349.             {
  350.                 setarg(paramPos, 0, string[stringPos++]);
  351.             }
  352.             case 'f':
  353.             {
  354.  
  355.                 new changestr[16], changepos = 0, strpos = stringPos;
  356.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  357.                 {
  358.                     changestr[changepos++] = string[strpos++];
  359.                     }
  360.                 changestr[changepos] = '\0';
  361.                 setarg(paramPos,0,_:floatstr(changestr));
  362.             }
  363.             case 'p':
  364.             {
  365.                 delim = format[formatPos++];
  366.                 continue;
  367.             }
  368.             case '\'':
  369.             {
  370.                 new
  371.                     end = formatPos - 1,
  372.                     ch;
  373.                 while ((ch = format[++end]) && ch != '\'') {}
  374.                 if (!ch)
  375.                 {
  376.                     return -1;
  377.                 }
  378.                 format[end] = '\0';
  379.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  380.                 {
  381.                     if (format[end + 1])
  382.                     {
  383.                         return -1;
  384.                     }
  385.                     return 0;
  386.                 }
  387.                 format[end] = '\'';
  388.                 stringPos = ch + (end - formatPos);
  389.                 formatPos = end + 1;
  390.             }
  391.             case 'u':
  392.             {
  393.                 new
  394.                     end = stringPos - 1,
  395.                     id = 0,
  396.                     bool:num = true,
  397.                     ch;
  398.                 while ((ch = string[++end]) && ch != delim)
  399.                 {
  400.                     if (num)
  401.                     {
  402.                         if ('0' <= ch <= '9')
  403.                         {
  404.                             id = (id * 10) + (ch - '0');
  405.                         }
  406.                         else
  407.                         {
  408.                             num = false;
  409.                         }
  410.                     }
  411.                 }
  412.                 if (num && IsPlayerConnected(id))
  413.                 {
  414.                     setarg(paramPos, 0, id);
  415.                 }
  416.                 else
  417.                 {
  418.                     #if !defined foreach
  419.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  420.                         #define __SSCANF_FOREACH__
  421.                     #endif
  422.                     string[end] = '\0';
  423.                     num = false;
  424.                     new
  425.                         name[MAX_PLAYER_NAME];
  426.                     id = end - stringPos;
  427.                     foreach (Player, playerid)
  428.                     {
  429.                         GetPlayerName(playerid, name, sizeof (name));
  430.                         if (!strcmp(name, string[stringPos], true, id))
  431.                         {
  432.                             setarg(paramPos, 0, playerid);
  433.                             num = true;
  434.                             break;
  435.                         }
  436.                     }
  437.                     if (!num)
  438.                     {
  439.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  440.                     }
  441.                     string[end] = ch;
  442.                     #if defined __SSCANF_FOREACH__
  443.                         #undef foreach
  444.                         #undef __SSCANF_FOREACH__
  445.                     #endif
  446.                 }
  447.                 stringPos = end;
  448.             }
  449.             case 's', 'z':
  450.             {
  451.                 new
  452.                     i = 0,
  453.                     ch;
  454.                 if (format[formatPos])
  455.                 {
  456.                     while ((ch = string[stringPos++]) && ch != delim)
  457.                     {
  458.                         setarg(paramPos, i++, ch);
  459.                     }
  460.                     if (!i)
  461.                     {
  462.                         return -1;
  463.                     }
  464.                 }
  465.                 else
  466.                 {
  467.                     while ((ch = string[stringPos++]))
  468.                     {
  469.                         setarg(paramPos, i++, ch);
  470.                     }
  471.                 }
  472.                 stringPos--;
  473.                 setarg(paramPos, i, '\0');
  474.             }
  475.             default:
  476.             {
  477.                 continue;
  478.             }
  479.         }
  480.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  481.         {
  482.             stringPos++;
  483.         }
  484.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  485.         {
  486.             stringPos++;
  487.         }
  488.         paramPos++;
  489.     }
  490.     do
  491.     {
  492.         if ((delim = format[formatPos++]) > ' ')
  493.         {
  494.             if (delim == '\'')
  495.             {
  496.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  497.             }
  498.             else if (delim != 'z')
  499.             {
  500.                 return delim;
  501.             }
  502.         }
  503.     }
  504.     while (delim > ' ');
  505.     return 0;
  506. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement