Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2011
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 17.47 KB | None | 0 0
  1. #define COLOR_RED (0xFF0000FF)
  2. #define COLOR_YELLOW (0xFFFF00FF)
  3. #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 // Courtesy of DracoBlue
  4.  
  5. #include <a_samp>
  6. #include <audio>
  7.  
  8. public
  9.     OnFilterScriptInit()
  10. {
  11.     // Set the audio pack when the filterscript loads
  12.     Audio_SetPack("default_pack", true);
  13.     return 1;
  14. }
  15.  
  16. /*
  17.     Here are some testing commands.
  18. */
  19.  
  20. public
  21.     OnPlayerCommandText(playerid, cmdtext[])
  22. {
  23.     dcmd(createsequence, 14, cmdtext);
  24.     dcmd(destroysequence, 15, cmdtext);
  25.     dcmd(addtosequence, 13, cmdtext);
  26.     dcmd(removefromsequence, 18, cmdtext);
  27.     dcmd(play, 4, cmdtext);
  28.     dcmd(playsequence, 12, cmdtext);
  29.     dcmd(playstreamed, 12, cmdtext);
  30.     dcmd(pause, 5, cmdtext);
  31.     dcmd(resume, 6, cmdtext);
  32.     dcmd(stop, 4, cmdtext);
  33.     dcmd(restart, 7, cmdtext);
  34.     dcmd(seek, 4, cmdtext);
  35.     dcmd(setvolume, 9, cmdtext);
  36.     dcmd(set3dposition, 13, cmdtext);
  37.     dcmd(set3doffsets, 12, cmdtext);
  38.     dcmd(seteax, 6, cmdtext);
  39.     dcmd(removeeax, 9, cmdtext);
  40.     dcmd(setfx, 5, cmdtext);
  41.     dcmd(removefx, 8, cmdtext);
  42.     dcmd(connected, 9, cmdtext);
  43.     dcmd(setpack, 7, cmdtext);
  44.     return 0;
  45. }
  46.  
  47. dcmd_createsequence(playerid, params[])
  48. {
  49.     #pragma unused playerid, params
  50.     new
  51.         sequenceid,
  52.         string[64];
  53.     sequenceid = Audio_CreateSequence();
  54.     if (sequenceid)
  55.     {
  56.         format(string, sizeof(string), "Sequence ID %d created", sequenceid);
  57.     }
  58.     else
  59.     {
  60.         format(string, sizeof(string), "Error creating sequence ID %d", sequenceid);
  61.     }
  62.     SendClientMessageToAll(COLOR_YELLOW, string);
  63.     return 1;
  64. }
  65.  
  66. dcmd_destroysequence(playerid, params[])
  67. {
  68.     #pragma unused playerid
  69.     new
  70.         sequenceid = strval(params);
  71.     if (!sequenceid)
  72.     {
  73.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /destroysequence <sequenceid>");
  74.         return 1;
  75.     }
  76.     new
  77.         string[64];
  78.     if (Audio_DestroySequence(sequenceid))
  79.     {
  80.         format(string, sizeof(string), "Sequence ID %d destroyed", sequenceid);
  81.     }
  82.     else
  83.     {
  84.         format(string, sizeof(string), "Error destroying sequence ID %d", sequenceid);
  85.     }
  86.     SendClientMessageToAll(COLOR_YELLOW, string);
  87.     return 1;
  88. }
  89.  
  90. dcmd_addtosequence(playerid, params[])
  91. {
  92.     #pragma unused playerid
  93.     new
  94.         audioid,
  95.         sequenceid;
  96.     if (sscanf(params, "dd", sequenceid, audioid))
  97.     {
  98.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /addtosequence <sequenceid> <audioid>");
  99.         return 1;
  100.     }
  101.     new
  102.         string[64];
  103.     if (Audio_AddToSequence(sequenceid, audioid))
  104.     {
  105.         format(string, sizeof(string), "Audio ID %d added to sequence ID %d", audioid, sequenceid);
  106.     }
  107.     else
  108.     {
  109.         format(string, sizeof(string), "Error adding audio ID %d to sequence ID %d", audioid, sequenceid);
  110.     }
  111.     SendClientMessageToAll(COLOR_YELLOW, string);
  112.     return 1;
  113. }
  114.  
  115. dcmd_removefromsequence(playerid, params[])
  116. {
  117.     #pragma unused playerid
  118.     new
  119.         audioid,
  120.         sequenceid;
  121.     if (sscanf(params, "dd", sequenceid, audioid))
  122.     {
  123.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /removefromsequence <sequenceid> <audioid>");
  124.         return 1;
  125.     }
  126.     new
  127.         string[64];
  128.     if (Audio_RemoveFromSequence(sequenceid, audioid))
  129.     {
  130.         format(string, sizeof(string), "Audio ID %d removed from sequence ID %d", audioid, sequenceid);
  131.     }
  132.     else
  133.     {
  134.         format(string, sizeof(string), "Error removing audio ID %d from sequence ID %d", audioid, sequenceid);
  135.     }
  136.     SendClientMessageToAll(COLOR_YELLOW, string);
  137.     return 1;
  138. }
  139.  
  140. dcmd_play(playerid, params[])
  141. {
  142.     #pragma unused playerid
  143.     new
  144.         audioid,
  145.         bool:downmix,
  146.         bool:loop,
  147.         bool:pause;
  148.     if (sscanf(params, "dddd", audioid, pause, loop, downmix))
  149.     {
  150.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /play <audioid> <pause (0/1)> <loop (0/1)> <downmix (0/1)>");
  151.         return 1;
  152.     }
  153.     Audio_Play(playerid, audioid, pause, loop, downmix);
  154.     return 1;
  155. }
  156.  
  157. dcmd_playsequence(playerid, params[])
  158. {
  159.     #pragma unused playerid
  160.     new
  161.         audioid,
  162.         bool:downmix,
  163.         bool:loop,
  164.         bool:pause;
  165.     if (sscanf(params, "dddd", audioid, pause, loop, downmix))
  166.     {
  167.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /playsequence <sequenceid> <pause (0/1)> <loop (0/1)> <downmix (0/1)>");
  168.         return 1;
  169.     }
  170.     Audio_PlaySequence(playerid, audioid, pause, loop, downmix);
  171.     return 1;
  172. }
  173.  
  174. dcmd_playstreamed(playerid, params[])
  175. {
  176.     #pragma unused playerid
  177.     new
  178.         bool:downmix,
  179.         bool:loop,
  180.         bool:pause,
  181.         url[256];
  182.     if (sscanf(params, "sddd", url, pause, loop, downmix))
  183.     {
  184.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /playstreamed <url> <pause (0/1)> <loop (0/1)> <downmix (0/1)>");
  185.         return 1;
  186.     }
  187.     Audio_PlayStreamed(playerid, url, pause, loop, downmix);
  188.     return 1;
  189. }
  190.  
  191. dcmd_pause(playerid, params[])
  192. {
  193.     #pragma unused playerid
  194.     new
  195.         handleid = strval(params);
  196.     if (!handleid)
  197.     {
  198.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /pause <handleid>");
  199.         return 1;
  200.     }
  201.     new
  202.         string[64];
  203.     format(string, sizeof(string), "Audio playback paused for handle ID %d", handleid);
  204.     SendClientMessage(playerid, COLOR_YELLOW, string);
  205.     Audio_Pause(playerid, handleid);
  206.     return 1;
  207. }
  208.  
  209. dcmd_resume(playerid, params[])
  210. {
  211.     #pragma unused playerid
  212.     new
  213.         handleid = strval(params);
  214.     if (!handleid)
  215.     {
  216.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /resume <handleid>");
  217.         return 1;
  218.     }
  219.     new
  220.         string[64];
  221.     format(string, sizeof(string), "Audio playback resumed for handle ID %d", handleid);
  222.     SendClientMessage(playerid, COLOR_YELLOW, string);
  223.     Audio_Resume(playerid, handleid);
  224.     return 1;
  225. }
  226.  
  227. dcmd_stop(playerid, params[])
  228. {
  229.     #pragma unused playerid
  230.     new
  231.         handleid = strval(params);
  232.     if (!handleid)
  233.     {
  234.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /stop <handleid>");
  235.         return 1;
  236.     }
  237.     Audio_Stop(playerid, handleid);
  238.     return 1;
  239. }
  240.  
  241. dcmd_restart(playerid, params[])
  242. {
  243.     #pragma unused playerid
  244.     new
  245.         handleid = strval(params);
  246.     if (!handleid)
  247.     {
  248.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /restart <handleid>");
  249.         return 1;
  250.     }
  251.     new
  252.         string[64];
  253.     format(string, sizeof(string), "Audio playback restarted for handle ID %d", handleid);
  254.     SendClientMessage(playerid, COLOR_YELLOW, string);
  255.     Audio_Restart(playerid, handleid);
  256.     return 1;
  257. }
  258.  
  259. dcmd_seek(playerid, params[])
  260. {
  261.     #pragma unused playerid
  262.     new
  263.         handleid,
  264.         seconds;
  265.     if (sscanf(params, "dd", handleid, seconds))
  266.     {
  267.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /seek <handleid> <seconds>");
  268.         return 1;
  269.     }
  270.     new
  271.         string[64];
  272.     format(string, sizeof(string), "Audio seeked to %d seconds for handle ID %d", seconds, handleid);
  273.     SendClientMessage(playerid, COLOR_YELLOW, string);
  274.     Audio_Seek(playerid, handleid, seconds);
  275.     return 1;
  276. }
  277.  
  278. dcmd_setvolume(playerid, params[])
  279. {
  280.     #pragma unused playerid
  281.     new
  282.         handleid,
  283.         volume;
  284.     if (sscanf(params, "dd", handleid, volume))
  285.     {
  286.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setvolume <handleid> <volume (0-100)>");
  287.         return 1;
  288.     }
  289.     new
  290.         string[64];
  291.     format(string, sizeof(string), "Audio volume set to %d for handle ID %d", volume, handleid);
  292.     SendClientMessage(playerid, COLOR_YELLOW, string);
  293.     Audio_SetVolume(playerid, handleid, volume);
  294.     return 1;
  295. }
  296.  
  297. dcmd_set3dposition(playerid, params[])
  298. {
  299.     #pragma unused playerid
  300.     new
  301.         handleid,
  302.         Float:distance,
  303.         Float:x,
  304.         Float:y,
  305.         Float:z;
  306.     if (sscanf(params, "dffff", handleid, x, y, z, distance))
  307.     {
  308.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /set3dposition <handleid> <x> <y> <z> <distance>");
  309.         return 1;
  310.     }
  311.     new
  312.         string[128];
  313.     format(string, sizeof(string), "Audio 3D position set to %.01f, %.01f, %.01f (distance: %.01f) for handle ID %d", x, y, z, distance, handleid);
  314.     SendClientMessage(playerid, COLOR_YELLOW, string);
  315.     Audio_Set3DPosition(playerid, handleid, x, y, z, distance);
  316.     return 1;
  317. }
  318.  
  319. dcmd_set3doffsets(playerid, params[])
  320. {
  321.     #pragma unused playerid
  322.     new
  323.         handleid,
  324.         Float:x,
  325.         Float:y,
  326.         Float:z;
  327.     if (sscanf(params, "dfff", handleid, x, y, z))
  328.     {
  329.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /set3doffsets <handleid> <x> <y> <z>");
  330.         return 1;
  331.     }
  332.     new
  333.         string[128];
  334.     format(string, sizeof(string), "Audio 3D offsets set to %.01f, %.01f, %.01f for handle ID %d", x, y, z, handleid);
  335.     SendClientMessage(playerid, COLOR_YELLOW, string);
  336.     Audio_Set3DOffsets(playerid, handleid, x, y, z);
  337.     return 1;
  338. }
  339.  
  340. dcmd_seteax(playerid, params[])
  341. {
  342.     #pragma unused playerid
  343.     new
  344.         environment;
  345.     if (sscanf(params, "d", environment))
  346.     {
  347.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /seteax <environment (0-25)>");
  348.         return 1;
  349.     }
  350.     new
  351.         string[64];
  352.     format(string, sizeof(string), "Audio EAX environment set to %d", environment);
  353.     SendClientMessage(playerid, COLOR_YELLOW, string);
  354.     Audio_SetEAX(playerid, environment);
  355.     return 1;
  356. }
  357.  
  358. dcmd_removeeax(playerid, params[])
  359. {
  360.     #pragma unused params, playerid
  361.     new
  362.         string[32];
  363.     format(string, sizeof(string), "Audio EAX environment removed");
  364.     SendClientMessage(playerid, COLOR_YELLOW, string);
  365.     Audio_RemoveEAX(playerid);
  366.     return 1;
  367. }
  368.  
  369. dcmd_setfx(playerid, params[])
  370. {
  371.     #pragma unused playerid
  372.     new
  373.         handleid,
  374.         type;
  375.     if (sscanf(params, "dd", handleid, type))
  376.     {
  377.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setfx <handleid> <type (0-8)>");
  378.         return 1;
  379.     }
  380.     new
  381.         string[64];
  382.     format(string, sizeof(string), "Audio FX type %d applied to handle ID %d", type, handleid);
  383.     SendClientMessage(playerid, COLOR_YELLOW, string);
  384.     Audio_SetFX(playerid, handleid, type);
  385.     return 1;
  386. }
  387.  
  388. dcmd_removefx(playerid, params[])
  389. {
  390.     #pragma unused playerid
  391.     new
  392.         handleid,
  393.         type;
  394.     if (sscanf(params, "dd", handleid, type))
  395.     {
  396.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /removefx <handleid> <type (0-8)>");
  397.         return 1;
  398.     }
  399.     new
  400.         string[64];
  401.     format(string, sizeof(string), "Audio FX type %d removed from handle ID %d", type, handleid);
  402.     SendClientMessage(playerid, COLOR_YELLOW, string);
  403.     Audio_RemoveFX(playerid, handleid, type);
  404.     return 1;
  405. }
  406.  
  407. dcmd_connected(playerid, params[])
  408. {
  409.     new
  410.         clientMsg[32];
  411.     if (Audio_IsClientConnected(strval(params)))
  412.     {
  413.         format(clientMsg, sizeof(clientMsg), "Client ID %d is connected", strval(params));
  414.         SendClientMessage(playerid, COLOR_YELLOW, clientMsg);
  415.     }
  416.     else
  417.     {
  418.         format(clientMsg, sizeof(clientMsg), "Client ID %d is not connected", strval(params));
  419.         SendClientMessage(playerid, COLOR_YELLOW, clientMsg);
  420.     }
  421.     return 1;
  422. }
  423.  
  424. dcmd_setpack(playerid, params[])
  425. {
  426.     if (!IsPlayerAdmin(playerid))
  427.     {
  428.         SendClientMessage(playerid, COLOR_RED, "ERROR: You do not have permission to use this command.");
  429.         return 1;
  430.     }
  431.     new
  432.         audiopack[32],
  433.         bool:transferable;
  434.     if (sscanf(params, "sd", audiopack, transferable))
  435.     {
  436.         SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setpack <audiopack> <transferable (0/1)>");
  437.         return 1;
  438.     }
  439.     Audio_SetPack(audiopack, transferable);
  440.     return 1;
  441. }
  442.  
  443. public
  444.     Audio_OnClientConnect(playerid)
  445. {
  446.     new
  447.         string[128];
  448.     format(string, sizeof(string), "Audio client ID %d connected", playerid);
  449.     SendClientMessageToAll(COLOR_YELLOW, string);
  450.     // Transfer the audio pack when the player connects
  451.     Audio_TransferPack(playerid);
  452.     return 1;
  453. }
  454.  
  455. public
  456.     Audio_OnClientDisconnect(playerid)
  457. {
  458.     new
  459.         string[128];
  460.     format(string, sizeof(string), "Audio client ID %d disconnected", playerid);
  461.     SendClientMessageToAll(COLOR_YELLOW, string);
  462.     return 1;
  463. }
  464.  
  465. public
  466.     Audio_OnPlay(playerid, handleid)
  467. {
  468.     new
  469.         string[64];
  470.     format(string, sizeof(string), "Audio playback started for handle ID %d", handleid);
  471.     SendClientMessage(playerid, COLOR_YELLOW, string);
  472.     return 1;
  473. }
  474.  
  475. public
  476.     Audio_OnStop(playerid, handleid)
  477. {
  478.     new
  479.         string[64];
  480.     format(string, sizeof(string), "Audio playback stopped for handle ID %d", handleid);
  481.     SendClientMessage(playerid, COLOR_YELLOW, string);
  482.     return 1;
  483. }
  484.  
  485. public
  486.     Audio_OnSetPack(audiopack[])
  487. {
  488.     new
  489.         string[64];
  490.     format(string, sizeof(string), "Audio pack \"%s\" set", audiopack);
  491.     for (new i = 0; i < MAX_PLAYERS; i++)
  492.     {
  493.         // Transfer the audio pack to all players when it is set
  494.         Audio_TransferPack(i);
  495.     }
  496.     return 1;
  497. }
  498.  
  499. public
  500.     Audio_OnTransferFile(playerid, file[], current, total, result)
  501. {
  502.     new
  503.         string[128];
  504.     switch (result)
  505.     {
  506.         case 0:
  507.         {
  508.             format(string, sizeof(string), "Audio file \"%s\" (%d of %d) finished local download", file, current, total);
  509.         }
  510.         case 1:
  511.         {
  512.             format(string, sizeof(string), "Audio file \"%s\" (%d of %d) finished remote download", file, current, total);
  513.         }
  514.         case 2:
  515.         {
  516.             format(string, sizeof(string), "Audio archive \"%s\" (%d of %d) finished extraction", file, current, total);
  517.         }
  518.         case 3:
  519.         {
  520.             format(string, sizeof(string), "Audio file/archive \"%s\" (%d of %d) passed check", file, current, total);
  521.         }
  522.         case 4:
  523.         {
  524.             format(string, sizeof(string), "Audio file/archive \"%s\" (%d of %d) could not be downloaded or extracted", file, current, total);
  525.         }
  526.     }
  527.     SendClientMessage(playerid, COLOR_YELLOW, string);
  528.     if (current == total)
  529.     {
  530.         SendClientMessage(playerid, COLOR_YELLOW, "All files have been processed");
  531.     }
  532.     return 1;
  533. }
  534.  
  535. public
  536.     Audio_OnTrackChange(playerid, handleid, track[])
  537. {
  538.     new
  539.         string[128];
  540.     format(string, sizeof(string), "Now playing \"%s\" for handle ID %d", track, handleid);
  541.     SendClientMessage(playerid, COLOR_YELLOW, string);
  542. }
  543.  
  544. stock
  545.     sscanf(string[], format[], {Float,_}:...)
  546. {
  547.     #if defined isnull
  548.         if (isnull(string))
  549.     #else
  550.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  551.     #endif
  552.         {
  553.             return format[0];
  554.         }
  555.     #pragma tabsize 4
  556.     new
  557.         formatPos = 0,
  558.         stringPos = 0,
  559.         paramPos = 2,
  560.         paramCount = numargs(),
  561.         delim = ' ';
  562.     while (string[stringPos] && string[stringPos] <= ' ')
  563.     {
  564.         stringPos++;
  565.     }
  566.     while (paramPos < paramCount && string[stringPos])
  567.     {
  568.         switch (format[formatPos++])
  569.         {
  570.             case '\0':
  571.             {
  572.                 return 0;
  573.             }
  574.             case 'i', 'd':
  575.             {
  576.                 new
  577.                     neg = 1,
  578.                     num = 0,
  579.                     ch = string[stringPos];
  580.                 if (ch == '-')
  581.                 {
  582.                     neg = -1;
  583.                     ch = string[++stringPos];
  584.                 }
  585.                 do
  586.                 {
  587.                     stringPos++;
  588.                     if ('0' <= ch <= '9')
  589.                     {
  590.                         num = (num * 10) + (ch - '0');
  591.                     }
  592.                     else
  593.                     {
  594.                         return -1;
  595.                     }
  596.                 }
  597.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  598.                 setarg(paramPos, 0, num * neg);
  599.             }
  600.             case 'h', 'x':
  601.             {
  602.                 new
  603.                     num = 0,
  604.                     ch = string[stringPos];
  605.                 do
  606.                 {
  607.                     stringPos++;
  608.                     switch (ch)
  609.                     {
  610.                         case 'x', 'X':
  611.                         {
  612.                             num = 0;
  613.                             continue;
  614.                         }
  615.                         case '0' .. '9':
  616.                         {
  617.                             num = (num << 4) | (ch - '0');
  618.                         }
  619.                         case 'a' .. 'f':
  620.                         {
  621.                             num = (num << 4) | (ch - ('a' - 10));
  622.                         }
  623.                         case 'A' .. 'F':
  624.                         {
  625.                             num = (num << 4) | (ch - ('A' - 10));
  626.                         }
  627.                         default:
  628.                         {
  629.                             return -1;
  630.                         }
  631.                     }
  632.                 }
  633.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  634.                 setarg(paramPos, 0, num);
  635.             }
  636.             case 'c':
  637.             {
  638.                 setarg(paramPos, 0, string[stringPos++]);
  639.             }
  640.             case 'f':
  641.             {
  642.                 setarg(paramPos, 0, _:floatstr(string[stringPos]));
  643.             }
  644.             case 'p':
  645.             {
  646.                 delim = format[formatPos++];
  647.                 continue;
  648.             }
  649.             case '\'':
  650.             {
  651.                 new
  652.                     end = formatPos - 1,
  653.                     ch;
  654.                 while ((ch = format[++end]) && ch != '\'') {}
  655.                 if (!ch)
  656.                 {
  657.                     return -1;
  658.                 }
  659.                 format[end] = '\0';
  660.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  661.                 {
  662.                     if (format[end + 1])
  663.                     {
  664.                         return -1;
  665.                     }
  666.                     return 0;
  667.                 }
  668.                 format[end] = '\'';
  669.                 stringPos = ch + (end - formatPos);
  670.                 formatPos = end + 1;
  671.             }
  672.             case 'u':
  673.             {
  674.                 new
  675.                     end = stringPos - 1,
  676.                     id = 0,
  677.                     bool:num = true,
  678.                     ch;
  679.                 while ((ch = string[++end]) && ch != delim)
  680.                 {
  681.                     if (num)
  682.                     {
  683.                         if ('0' <= ch <= '9')
  684.                         {
  685.                             id = (id * 10) + (ch - '0');
  686.                         }
  687.                         else
  688.                         {
  689.                             num = false;
  690.                         }
  691.                     }
  692.                 }
  693.                 if (num && IsPlayerConnected(id))
  694.                 {
  695.                     setarg(paramPos, 0, id);
  696.                 }
  697.                 else
  698.                 {
  699.                     #if !defined foreach
  700.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  701.                         #define __SSCANF_FOREACH__
  702.                     #endif
  703.                     string[end] = '\0';
  704.                     num = false;
  705.                     new
  706.                         name[MAX_PLAYER_NAME];
  707.                     id = end - stringPos;
  708.                     foreach (Player, playerid)
  709.                     {
  710.                         GetPlayerName(playerid, name, sizeof (name));
  711.                         if (!strcmp(name, string[stringPos], true, id))
  712.                         {
  713.                             setarg(paramPos, 0, playerid);
  714.                             num = true;
  715.                             break;
  716.                         }
  717.                     }
  718.                     if (!num)
  719.                     {
  720.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  721.                     }
  722.                     string[end] = ch;
  723.                     #if defined __SSCANF_FOREACH__
  724.                         #undef foreach
  725.                         #undef __SSCANF_FOREACH__
  726.                     #endif
  727.                 }
  728.                 stringPos = end;
  729.             }
  730.             case 's', 'z':
  731.             {
  732.                 new
  733.                     i = 0,
  734.                     ch;
  735.                 if (format[formatPos])
  736.                 {
  737.                     while ((ch = string[stringPos++]) && ch != delim)
  738.                     {
  739.                         setarg(paramPos, i++, ch);
  740.                     }
  741.                     if (!i)
  742.                     {
  743.                         return -1;
  744.                     }
  745.                 }
  746.                 else
  747.                 {
  748.                     while ((ch = string[stringPos++]))
  749.                     {
  750.                         setarg(paramPos, i++, ch);
  751.                     }
  752.                 }
  753.                 stringPos--;
  754.                 setarg(paramPos, i, '\0');
  755.             }
  756.             default:
  757.             {
  758.                 continue;
  759.             }
  760.         }
  761.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  762.         {
  763.             stringPos++;
  764.         }
  765.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  766.         {
  767.             stringPos++;
  768.         }
  769.         paramPos++;
  770.     }
  771.     do
  772.     {
  773.         if ((delim = format[formatPos++]) > ' ')
  774.         {
  775.             if (delim == '\'')
  776.             {
  777.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  778.             }
  779.             else if (delim != 'z')
  780.             {
  781.                 return delim;
  782.             }
  783.         }
  784.     }
  785.     while (delim > ' ');
  786.     return 0;
  787. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement