daily pastebin goal
76%
SHARE
TWEET

Untitled

a guest May 26th, 2016 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <core>
  3. #include <float>
  4.  
  5.  
  6. public OnFilterScriptInit()
  7. {
  8.     new Array[5][32];
  9.     new string[64];
  10.     new string2[64];
  11.     strcat(string, "Pasta#lol#Zupa#lol#Kisiel#lol#Budyn#lol#Igrekzet");
  12.     printf("String = %s", string);
  13.     printf("Array[][] = pusty", string);
  14.     print("Function: explode(string, array, \"#lol#\");");
  15.     explode(string, Array, "#lol#");
  16.     printf("Array[0] = %s", Array[0]);
  17.     printf("Array[1] = %s", Array[1]);
  18.     printf("Array[2] = %s", Array[2]);
  19.     printf("Array[3] = %s", Array[3]);
  20.     printf("Array[4] = %s", Array[4]);
  21.     print("Function: implode(string2, array, \", \");");
  22.     implode(string2, Array, ", ");
  23.     printf("String2 = %s", string2);
  24.     return 1;
  25. }
  26.  
  27. explode(const string[], array[][], separator[], bool:caseignore = true, maxarray = sizeof array, maxarray2 = sizeof array[])
  28. {
  29.     new pos = -1, pos2, idx, len = strlen(separator);
  30.     while((pos = strfind(string, separator, caseignore, pos + 1)) && -1 != pos)
  31.     {
  32.         if(idx == maxarray)
  33.             return 1;
  34.  
  35.         strmid(array[idx], string, pos2, pos, maxarray2);
  36.         pos2 = pos + len;
  37.         idx++;
  38.     }
  39.     if(!pos2)
  40.     {
  41.         strcat(array[0], string, maxarray2);
  42.         return 1;
  43.     }
  44.     if(idx == maxarray)
  45.     {
  46.         return 1;
  47.     }
  48.     strmid(array[idx], string, pos2, strlen(string), maxarray2);
  49.     return 1;
  50. }
  51.  
  52. implode(string[], const array[][], separator[], maxstring = sizeof string, maxarray = sizeof array)
  53. {
  54.     string[0] = EOS;
  55.     for(new i = 0; i < maxarray; i++)
  56.     {
  57.         strcat(string, array[i], maxstring);
  58.         if(i != maxarray - 1)
  59.         {
  60.             strcat(string, separator, maxstring);
  61.         }
  62.     }
  63.     return 1;
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top