Advertisement
Guest User

[FS] RconCall

a guest
May 8th, 2010
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.61 KB | None | 0 0
  1. /**
  2.     Данный ФС работает только с ZCMD
  3.    
  4.     Описание:
  5.         Позволяет использовать через RCON консоль
  6.         команды из игрового мода.
  7.        
  8.     Copyright © 2010 Fro
  9. **/
  10.  
  11. #include <a_samp>
  12.  
  13. #define VERSION "0.2"
  14.  
  15. #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  16.  
  17. public OnFilterScriptInit()
  18. {
  19.     print(" ");
  20.     print("_____________________________________");
  21.     printf(" Сервер использует RconCall v %s\n", VERSION);
  22.     print("_____________________________________");
  23.     print(" By: Fro (c) Copyright 2009-2010, TBG\n");
  24.     return 1;
  25. }
  26.  
  27. public OnFilterScriptExit()
  28. {
  29.     printf("\n RconCall v %s выгружен\n", VERSION);
  30.     return 1;
  31. }
  32.  
  33. public OnRconCommand(cmd[])
  34. {
  35.     new
  36.         command[32],
  37.         result[64];
  38.        
  39.     sparam(command, 32, cmd, 0);
  40.     if(!strcmp(command, "cmd"))
  41.     {
  42.         sparam(command, 32, cmd, 1);
  43.         sparam(result, 64, cmd, 2, 1);
  44.         if(isnull(result)) result = " ";
  45.         format(command, 32, "cmd_%s", command);
  46.         CallRemoteFunction(command, "is", -1, result);
  47.     }
  48.     return 1;
  49. }
  50.  
  51. stock sparam
  52. (
  53.     dest[],             maxSize     = sizeof(dest),
  54.     const source[],     substrIndex = 0,
  55.     withRest = 0,       delimiter   = ' '
  56. )
  57. {
  58.     dest[0] = 0; // очистим строку назначения
  59.  
  60.     for ( new cur, pre, i = -1; ; cur++ ) // пробежимся по каждому символу в строке source
  61.     {
  62.         if ( source[cur] == 0 ) // если текущий символ в source - это символ конца строки
  63.         {
  64.             if ( ++i == substrIndex ) // если индекс текущей подстроки и есть sourceIndex
  65.                 // скопируем в dest нужную подстроку из source
  66.                 strmid( dest, source, pre, ( withRest ? strlen(source) : cur ), maxSize );
  67.  
  68.             goto sparam_end;
  69.         }
  70.  
  71.         if ( source[cur] == delimiter ) // если текущий символ в source - это символ для разделения строки
  72.         {
  73.             if ( ++i == substrIndex ) // если индекс текущей подстроки и есть sourceIndex
  74.             {
  75.                 // скопируем в dest нужную подстроку из source
  76.                 strmid( dest, source, pre, ( withRest ? strlen(source) : cur ), maxSize );
  77.                 goto sparam_end;
  78.             }
  79.  
  80.             pre = cur + 1;
  81.         }
  82.     }
  83.  
  84.     sparam_end:
  85.     return 1; // завершим работу функции
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement