Guest User

Untitled

a guest
Jul 20th, 2010
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.09 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. public OnPlayerCommandText(playerid, cmdtext[])
  4. {
  5.         new cmd[128], idx;
  6.         cmd = strtok(cmdtext, idx);
  7.    
  8.         if(strcmp(cmd, "/mensagembot", true) == 0)
  9.     {
  10.         new length = strlen(cmdtext);
  11.         while ((idx < length) && (cmdtext[idx] <= ' '))
  12.         {
  13.             idx++;
  14.         }
  15.         new offset = idx;
  16.         new result[64];
  17.         while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  18.         {
  19.             result[idx - offset] = cmdtext[idx];
  20.             idx++;
  21.         }
  22.         result[idx - offset] = EOS;
  23.  
  24.         if(!strlen(result))
  25.         {
  26.             SendClientMessage(playerid,COR, "/mensagembot [MENSAGEM]");
  27.             return 1;
  28.         }
  29.  
  30.         new string[128];
  31.         format(string, sizeof(string), "Chuck Nóia:%s", (result));
  32.         return 1;
  33.     }
  34.  
  35.         return 0;
  36. }
  37.  
  38. strtok(const string[], &index)
  39. {
  40.     new length = strlen(string);
  41.     while ((index < length) && (string[index] <= ' '))
  42.     {
  43.         index++;
  44.     }
  45.  
  46.     new offset = index;
  47.     new result[20];
  48.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  49.     {
  50.         result[index - offset] = string[index];
  51.         index++;
  52.     }
  53.     result[index - offset] = EOS;
  54.     return result;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment