Guest User

Untitled

a guest
Jan 22nd, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #define fcmd(%1,%2) \
  2. forward fcmd_%1(%2); \
  3. public fcmd_%1(%2)
  4.  
  5. #define MaxFrequence (025)
  6. #define MaxParameter (064)
  7. #define MaxFunctions (032)
  8. #define MaxLenString (128)
  9.  
  10. new
  11. sIndex = 0,
  12. iLenPart = 0,
  13. iPosPart = 0,
  14. iStrMid = 0,
  15. iLenght = 0,
  16. iParams[ MaxFrequence ][ MaxParameter ],
  17. cmds[ MaxFunctions ]
  18. ;
  19.  
  20. new iTotalParams[MaxLenString];
  21.  
  22. public OnPlayerCommandText(playerid, cmdtext[])
  23. {
  24. return DelimiterCommand(playerid,cmdtext);
  25. }
  26.  
  27. stock DelimiterCommand(playerid,sStringSource[])
  28. {
  29. iLenght = strlen(sStringSource);
  30. sIndex = 0;
  31. iLenPart = 0;
  32. iPosPart = 0;
  33. iStrMid = 0;
  34. for(new aIndex = 1; aIndex < MaxFrequence; ++aIndex) iParams[aIndex][0] = '\0';
  35. iTotalParams[0] = '\0';
  36. while(sIndex <= iLenght)
  37. {
  38.  
  39. if(sStringSource[sIndex] == ' ' && sStringSource[sIndex - 1] != ' ' || sIndex == iLenght)
  40. {
  41. iStrMid = strmid(iParams[iPosPart], sStringSource, iLenPart, sIndex, 128);
  42. iParams[iPosPart][iStrMid] = 0,iLenPart = (sIndex + 1), ++iPosPart;
  43. if(iPosPart == 1)
  44. format(iTotalParams,MaxLenString, "%s",sStringSource[sIndex]);
  45. }
  46. ++sIndex;
  47. }
  48. format(cmds, sizeof cmds,"fcmd_%s",iParams[0][1]);
  49. return CallLocalFunction(cmds,"i",playerid);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment