Advertisement
Hauke

WBB_Connect 2.0 - Filterscript

May 18th, 2012
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 21.93 KB | None | 0 0
  1. // WBB_Connect 2.0 filterscript by Hauke Marquardt alias |-|auke - 19.05.2012
  2. /*
  3. License:
  4.         This code is free: you can redistribute it and/or modify
  5.         it under the terms of the GNU General Public License as published by
  6.         the Free Software Foundation, either version 3 of the License, or
  7.         (at your option) any later version.
  8.  
  9.         This code is distributed in the hope that it will be useful,
  10.         but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.         GNU General Public License for more details.
  13.  
  14.         You should have received a copy of the GNU General Public License
  15.         along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16.         You´re not allowed to copy any code from this, into your code without
  17.         naming authors name in credits!
  18.        
  19. CallBack List:
  20.     WBB_GotPostUser ( Index , Username[ ] )
  21.     WBB_GotThreadStarter ( Index , Username[ ] )
  22.     WBB_GotUserActivationCode ( Index , ActivationCode[ ] )
  23.     WBB_GotUserActivationState ( Index , State )
  24.     WBB_GotUserAge ( Index , Age )
  25.     WBB_GotUserFriendState ( Index , State )
  26.     WBB_GotUserGroupState ( Index , State )
  27.     WBB_GotUserID ( Index , UserID )
  28.     WBB_GotUserOnlineState ( Index , State )
  29.     WBB_GotUserPasswordCheckState ( Index , State )
  30.     WBB_GotUserTitle ( Index , Title[ ] )
  31.     WBB_GotUserValidState ( Index , State )
  32.     WBB_OnInitialize ( State )
  33.     WBB_PostAdded ( Index )
  34.     WBB_PostDeleted ( Index )
  35.     WBB_PostEdited ( Index )
  36.     WBB_PostTrashed ( Index )
  37.     WBB_ThreadAdded ( Index , ThreadID )
  38.     WBB_ThreadDeleted ( Index )
  39.     WBB_ThreadSticked ( Index )
  40.     WBB_ThreadUnsticked ( Index )
  41.     WBB_UserAdded ( Index )
  42.     WBB_UserAvatarDisabled ( Index )
  43.     WBB_UserAvatarEnabled ( Index )
  44.     WBB_UserBanned ( Index )
  45.     WBB_UserDisabled ( Index )
  46.     WBB_UserEnabled ( Index )
  47.     WBB_UserRemovedFromGroup ( Index )
  48.     WBB_UserSettedToGroup ( Index )
  49.     WBB_UserSignaturDisabled ( Index )
  50.     WBB_UserSignaturEnabled ( Index )
  51.     WBB_UserUnbanned ( Index )
  52. */
  53.  
  54. #include <a_samp>
  55. #include <a_http>
  56.  
  57. #define WBB_CONNECT_VERSION                 "v. 2.0"
  58.  
  59. #define HTTP_REQUEST_NO_DATA                0xE9BA
  60. #define HTTP_REQUEST_ADD_THREAD             0xE9BB
  61. #define HTTP_REQUEST_GET_POST_USER          0xE9BC
  62. #define HTTP_REQUEST_GET_THREAD_USER        0xE9BD
  63. #define HTTP_REQUEST_IS_USER_ONLINE         0xE9BE
  64. #define HTTP_REQUEST_GET_USER_TITLE         0xE9BF
  65. #define HTTP_REQUEST_GET_USER_AGE           0xE9C0
  66. #define HTTP_REQUEST_IS_USER_FRIEND         0xE9C1
  67. #define HTTP_REQUEST_IS_USER_IN_GROUP       0xE9C2
  68. #define HTTP_REQUEST_CHECK_USER_PASSWORD    0xE9C3
  69. #define HTTP_REQUEST_IS_VALID_USER          0xE9C4
  70. #define HTTP_REQUEST_IS_USER_ACTIVATED      0xE9C5
  71. #define HTTP_REQUEST_GET_USER_ACTIVATION    0xE9C6
  72. #define HTTP_REQUEST_GET_USER_ID            0xE9C7
  73.  
  74. #define TRASH_THREAD_SUCCESS                0x7D1
  75. #define DELETE_THREAD_SUCCESS               0x7D2
  76. #define STICK_THREAD_SUCCESS                0x7D3
  77. #define UNSTICK_THREAD_SUCCESS              0x7D4
  78. #define ADD_POST_SUCCESS                    0x7D5
  79. #define EDIT_POST_SUCCESS                   0x7D6
  80. #define TRASH_POST_SUCCESS                  0x7D8
  81. #define DELETE_POST_SUCCESS                 0x7D9
  82. #define SET_USER_TO_GROUP_SUCCESS           0x7DA
  83. #define REMOVE_USER_FROM_GROUP_SUCCESS      0x7DB
  84. #define DISABLE_USER_AVATAR_SUCCESS         0x7DC
  85. #define ENABLE_USER_AVATAR_SUCCESS          0x7DD
  86. #define DISABLE_USER_SIGNATUR_SUCCESS       0x7DE
  87. #define ENABLE_USER_SIGNATUR_SUCCESS        0x7DF
  88. #define DISABLE_USER_SUCCESS                0x7E0
  89. #define ENABLE_USER_SUCCESS                 0x7E1
  90. #define BAN_USER_SUCCESS                    0x7E2
  91. #define UNBAN_USER_SUCCESS                  0x7E3
  92. #define USER_ADD_SUCCESS                    0x7E4
  93. #define INITIALIZE_SUCCESS                  0x7E5
  94.  
  95. forward _WBB_Initialize ( Adress[ ] , AuthKey[ ] );
  96. forward HTTP_Response ( index , response_code , data[ ] );
  97.  
  98. forward _WBB_AddPost ( Username[ ] , Thread , Subject[ ] , Content[ ] , Closed , Smilies , HTML , BBCodes , Signature , Index );
  99. forward _WBB_AddThread ( Username[ ] , Board , Prefix[ ] , Subject[ ] , Content[ ] , State , Closed , Disabled , Smilies , HTML , BBCodes , Signature , Index );
  100. forward _WBB_AddUser ( Username[ ] , Email[ ] , Password[ ] , Index );
  101. forward _WBB_BanUser ( Username[ ] , Reason[ ] , Index );
  102. forward _WBB_CheckUserPassword ( Username[ ] , Password[ ] , Index );
  103. forward _WBB_DeletePost ( Post , Index );
  104. forward _WBB_DeleteThread ( ThreadID , Index );
  105. forward _WBB_DisableUser ( Username[ ] , Index );
  106. forward _WBB_DisableUserAvatar ( Username[ ] , Index );
  107. forward _WBB_DisableUserSignatur ( Username[ ] , Index );
  108. forward _WBB_EditPost ( Username[ ] , Post , Subject[ ] , Content[ ] , ShowEditInformation , EditReason[ ] , Smilies , HTML , BBCodes , Signature , Index );
  109. forward _WBB_EnableUser ( Username[ ] , Index );
  110. forward _WBB_EnableUserAvatar ( Username[ ] , Index );
  111. forward _WBB_EnableUserSignatur ( Username[ ] , Index );
  112. forward _WBB_GetPostUser ( Post , Index );
  113. forward _WBB_GetThreadUser ( Thread , Index );
  114. forward _WBB_GetUserActivationCode ( Username[ ] , Index );
  115. forward _WBB_GetUserAge ( Username[ ] , Index );
  116. forward _WBB_GetUserID ( Username[ ] , Index );
  117. forward _WBB_GetUserTitle( Username[ ] , Index );
  118. forward _WBB_IsUserActivated ( Username[ ] , Index );
  119. forward _WBB_IsUserFriendOfUser ( Username[ ] , Friend[ ] , Index );
  120. forward _WBB_IsUserInGroup ( Username[ ] , Group , Index );
  121. forward _WBB_IsUserOnline ( Username[ ] , Index );
  122. forward _WBB_IsValidUser ( Username[ ] , Index );
  123. forward _WBB_RemoveUserFromGroup ( Username[ ] , Group , Index );
  124. forward _WBB_SetUserToGroup ( Username[ ] , Group , Index );
  125. forward _WBB_StickThread ( ThreadID , Index );
  126. forward _WBB_TrashPost ( Post , Index );
  127. forward _WBB_TrashThread ( ThreadID , Index );
  128. forward _WBB_UnBanUser ( Username[ ] , Index );
  129. forward _WBB_UnstickThread ( ThreadID , Index );
  130.  
  131. new GlobalIndex = -1;
  132. new GlobalAdress[ 64 ] = { };
  133. new GlobalAuthKey[ 32 ] = { };
  134. new bool:WBB_Connect_Initialized = false;
  135.  
  136. public OnFilterScriptInit() {
  137.     WBB_ConnectPrintf ( "WBB_Connect %s\nwas successfully loaded!\n\nCopyright (c) by Hauke Marquardt" , WBB_CONNECT_VERSION );
  138.     return 1;
  139. }
  140.  
  141. public _WBB_Initialize ( Adress[ ] , AuthKey[ ] ) {
  142.     format ( GlobalAdress , 64 , Adress );
  143.     format ( GlobalAuthKey , 32 , AuthKey );
  144.     SendRequest ( "Initialize" , "" , HTTP_REQUEST_NO_DATA );
  145. }
  146.  
  147. public _WBB_AddUser ( Username[ ] , Email[ ] , Password[ ] , Index ) {
  148.     new PostData[ 128 ];
  149.     format ( PostData , 128 , "Username=%s&Email=%s&Password=%s" , Username , Email , Password );
  150.     SendRequest ( "AddUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
  151. }
  152.  
  153. public _WBB_UnBanUser ( Username[ ] , Index ) {
  154.     new PostData[ 128 ];
  155.     format ( PostData , 128 , "Username=%s" , Username );
  156.     SendRequest ( "UnBanUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
  157. }
  158.  
  159. public _WBB_BanUser ( Username[ ] , Reason[ ] , Index ) {
  160.     new PostData[ 128 ];
  161.     format ( PostData , 128 , "Username=%s&Reason=%s" , Username , Reason );
  162.     SendRequest ( "BanUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
  163. }
  164.  
  165. public _WBB_EnableUser ( Username[ ] , Index ) {
  166.     new PostData[ 128 ];
  167.     format ( PostData , 128 , "Username=%s" , Username );
  168.     SendRequest ( "EnableUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
  169. }
  170.  
  171. public _WBB_DisableUser ( Username[ ] , Index ) {
  172.     new PostData[ 128 ];
  173.     format ( PostData , 128 , "Username=%s" , Username );
  174.     SendRequest ( "DisableUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
  175. }
  176.  
  177. public _WBB_GetUserID ( Username[ ] , Index ) {
  178.     new PostData[ 128 ];
  179.     format ( PostData , 128 , "Username=%s" , Username );
  180.     SendRequest ( "GetUserID" , PostData , HTTP_REQUEST_GET_USER_ID , Index );
  181. }
  182.  
  183. public _WBB_GetUserActivationCode ( Username[ ] , Index ) {
  184.     new PostData[ 128 ];
  185.     format ( PostData , 128 , "Username=%s" , Username );
  186.     SendRequest ( "GetUserActivationCode" , PostData , HTTP_REQUEST_GET_USER_ACTIVATION , Index );
  187. }
  188.  
  189. public _WBB_IsUserActivated ( Username[ ] , Index ) {
  190.     new PostData[ 128 ];
  191.     format ( PostData , 128 , "Username=%s" , Username );
  192.     SendRequest ( "IsUserActivated" , PostData , HTTP_REQUEST_IS_USER_ACTIVATED , Index );
  193. }
  194.  
  195. public _WBB_IsValidUser ( Username[ ] , Index ) {
  196.     new PostData[ 128 ];
  197.     format ( PostData , 128 , "Username=%s" , Username );
  198.     SendRequest ( "IsValidUser" , PostData , HTTP_REQUEST_IS_VALID_USER , Index );
  199. }
  200. public _WBB_CheckUserPassword ( Username[ ] , Password[ ] , Index ) {
  201.     new PostData[ 256 ];
  202.     format ( PostData , 256 , "Username=%s&Password=%s" , Username , Password );
  203.     SendRequest ( "CheckUserPassword" , PostData , HTTP_REQUEST_CHECK_USER_PASSWORD , Index );
  204. }
  205.  
  206. public _WBB_DisableUserSignatur ( Username[ ] , Index ) {
  207.     new PostData[ 128 ];
  208.     format ( PostData , 128 , "Username=%s" , Username );
  209.     SendRequest ( "DisableUserSignatur" , PostData , HTTP_REQUEST_NO_DATA , Index );
  210. }
  211.  
  212. public _WBB_EnableUserSignatur ( Username[ ] , Index ) {
  213.     new PostData[ 128 ];
  214.     format ( PostData , 128 , "Username=%s" , Username );
  215.     SendRequest ( "EnableUserSignatur" , PostData , HTTP_REQUEST_NO_DATA , Index );
  216. }
  217.  
  218. public _WBB_EnableUserAvatar ( Username[ ] , Index ) {
  219.     new PostData[ 128 ];
  220.     format ( PostData , 128 , "Username=%s" , Username );
  221.     SendRequest ( "EnableUserAvatar" , PostData , HTTP_REQUEST_NO_DATA , Index );
  222. }
  223.  
  224. public _WBB_DisableUserAvatar ( Username[ ] , Index ) {
  225.     new PostData[ 128 ];
  226.     format ( PostData , 128 , "Username=%s" , Username );
  227.     SendRequest ( "DisableUserAvatar" , PostData , HTTP_REQUEST_NO_DATA , Index );
  228. }
  229.  
  230. public _WBB_IsUserInGroup ( Username[ ] , Group , Index ) {
  231.     new PostData[ 256 ];
  232.     format ( PostData , 256 , "Username=%s&Group=%d" , Username , Group );
  233.     SendRequest ( "IsUserInGroup" , PostData , HTTP_REQUEST_IS_USER_IN_GROUP , Index );
  234. }
  235.  
  236. public _WBB_RemoveUserFromGroup ( Username[ ] , Group , Index ) {
  237.     new PostData[ 256 ];
  238.     format ( PostData , 256 , "Username=%s&Group=%d" , Username , Group );
  239.     SendRequest ( "RemoveUserFromGroup" , PostData , HTTP_REQUEST_NO_DATA , Index );
  240. }
  241.  
  242. public _WBB_SetUserToGroup ( Username[ ] , Group , Index ) {
  243.     new PostData[ 256 ];
  244.     format ( PostData , 256 , "Username=%s&Group=%d" , Username , Group );
  245.     SendRequest ( "SetUserToGroup" , PostData , HTTP_REQUEST_NO_DATA , Index );
  246. }
  247.  
  248. public _WBB_IsUserFriendOfUser ( Username[ ] , Friend[ ] , Index ) {
  249.     new PostData[ 256 ];
  250.     format ( PostData , 256 , "Username=%s&Friend=%s" , Username , Friend );
  251.     SendRequest ( "IsUserFriendOfUser" , PostData , HTTP_REQUEST_IS_USER_FRIEND , Index );
  252. }
  253.  
  254. public _WBB_GetUserAge ( Username[ ] , Index ) {
  255.     new PostData[ 128 ];
  256.     format ( PostData , 128 , "Username=%s" , Username );
  257.     SendRequest ( "GetUserAge" , PostData , HTTP_REQUEST_GET_USER_AGE , Index );
  258. }
  259.  
  260. public _WBB_GetUserTitle ( Username[ ] , Index ) {
  261.     new PostData[ 128 ];
  262.     format ( PostData , 128 , "Username=%s" , Username );
  263.     SendRequest ( "GetUserTitle" , PostData , HTTP_REQUEST_GET_USER_TITLE , Index );
  264. }
  265.  
  266. public _WBB_IsUserOnline ( Username[ ] , Index ) {
  267.     new PostData[ 128 ];
  268.     format ( PostData , 128 , "Username=%s" , Username );
  269.     SendRequest ( "IsUserOnline" , PostData , HTTP_REQUEST_IS_USER_ONLINE , Index );
  270. }
  271.  
  272. public _WBB_TrashPost ( Post , Index ) {
  273.     new PostData[ 32 ];
  274.     format ( PostData , 32 , "Post=%d" , Post );
  275.     SendRequest ( "TrashPost" , PostData , HTTP_REQUEST_NO_DATA , Index );
  276. }
  277.  
  278. public _WBB_DeletePost ( Post , Index ) {
  279.     new PostData[ 32 ];
  280.     format ( PostData , 32 , "Post=%d" , Post );
  281.     SendRequest ( "DeletePost" , PostData , HTTP_REQUEST_NO_DATA , Index );
  282. }
  283.  
  284. public _WBB_GetThreadUser ( Thread , Index ) {
  285.     new PostData[ 32 ];
  286.     format ( PostData , 32 , "Thread=%d" , Thread );
  287.     SendRequest ( "GetThreadUser" , PostData , HTTP_REQUEST_GET_THREAD_USER , Index );
  288. }
  289.  
  290. public _WBB_GetPostUser ( Post , Index ) {
  291.     new PostData[ 32 ];
  292.     format ( PostData , 32 , "Post=%d" , Post );
  293.     SendRequest ( "GetPostUser" , PostData , HTTP_REQUEST_GET_POST_USER , Index );
  294. }
  295.  
  296. public _WBB_EditPost ( Username[ ] , Post , Subject[ ] , Content[ ] , ShowEditInformation , EditReason[ ] , Smilies , HTML , BBCodes , Signature , Index ) {
  297.     new PostData[ 2000 ];
  298.     format ( PostData , 2000 , "Username=%s&Post=%d&Subject=%s&Content=%s&ShowEditInformation=%d&EditReason=%s&Smilies=%d&HTML=%d&BBCodes=%d&Signature=%d" , Username , Post , Subject , Content , ShowEditInformation , EditReason , Smilies , HTML , BBCodes , Signature );
  299.     SendRequest ( "EditPost" , PostData , HTTP_REQUEST_NO_DATA , Index );
  300. }
  301.  
  302. public _WBB_AddPost ( Username[ ] , Thread , Subject[ ] , Content[ ] , Closed , Smilies , HTML , BBCodes , Signature , Index ) {
  303.     new PostData[ 2000 ];
  304.     format ( PostData , 2000 , "Username=%s&Thread=%d&Subject=%s&Content=%s&Closed=%d&Smilies=%d&HTML=%d&BBCodes=%d&Signature=%d" , Username , Thread , Subject , Content , Closed , Smilies , HTML , BBCodes , Signature );
  305.     SendRequest ( "AddPost" , PostData , HTTP_REQUEST_NO_DATA , Index );
  306. }
  307.  
  308. public _WBB_StickThread ( ThreadID , Index ) {
  309.     new PostData[ 32 ];
  310.     format ( PostData , 32 , "Thread=%d" , ThreadID );
  311.     SendRequest ( "StickThread" , PostData , HTTP_REQUEST_NO_DATA , Index );
  312. }
  313.  
  314. public _WBB_UnstickThread ( ThreadID , Index ) {
  315.     new PostData[ 32 ];
  316.     format ( PostData , 32 , "Thread=%d" , ThreadID );
  317.     SendRequest ( "UnstickThread" , PostData , HTTP_REQUEST_NO_DATA , Index );
  318. }
  319.  
  320. public _WBB_DeleteThread ( ThreadID , Index ) {
  321.     new PostData[ 32 ];
  322.     format ( PostData , 32 , "Thread=%d" , ThreadID );
  323.     SendRequest ( "DeleteThread" , PostData , HTTP_REQUEST_NO_DATA , Index );
  324. }
  325.  
  326. public _WBB_TrashThread ( ThreadID , Index ) {
  327.     new PostData[ 32 ];
  328.     format ( PostData , 32 , "Thread=%d" , ThreadID );
  329.     SendRequest ( "TrashThread" , PostData , HTTP_REQUEST_NO_DATA , Index );
  330. }
  331.  
  332. public _WBB_AddThread ( Username[ ] , Board , Prefix[ ] , Subject[ ] , Content[ ] , State , Closed , Disabled , Smilies , HTML , BBCodes , Signature , Index ) {
  333.     new PostData[ 2000 ];
  334.     format ( PostData , 2000 , "Username=%s&Board=%d&Prefix=%s&Subject=%s&Content=%s&State=%d&Closed=%d&Disabled=%d&Smilies=%d&HTML=%d&BBCodes=%d&Signature=%d" , Username , Board , Prefix , Subject , Content , State , Closed , Disabled , Smilies , HTML , BBCodes , Signature );
  335.     SendRequest ( "AddThread" , PostData , HTTP_REQUEST_ADD_THREAD , Index );
  336. }
  337.  
  338. SendRequest ( Operation[ ] , PostData[ ] , Index , Idx = 0 ) {
  339.     if ( !WBB_Connect_Initialized && strcmp ( Operation , "Initialize" ) ) {
  340.         WBB_ConnectPrintf ( "WBB_Connect is not initialized!" );
  341.         return -1;
  342.     }
  343.     GlobalIndex = Idx;
  344.     new Adress[ 128 ];
  345.     format ( Adress , 128 , "%s/wbb_connect_api.php?op=%s&authKey=%s" , GlobalAdress , Operation , GlobalAuthKey );
  346.     return HTTP ( Index , HTTP_POST , Adress , PostData , "HTTP_Response" );
  347. }
  348.  
  349. public HTTP_Response ( index , response_code , data[ ] ) {
  350.     if ( response_code == 200 ) {
  351.         if ( strfind ( data , "true" , true ) != -1 || strfind ( data , "return" , true ) != -1 ) {
  352.             switch ( index ) {
  353.                 case HTTP_REQUEST_NO_DATA : {
  354.                     strdel ( data , 0 , 6 );
  355.                     switch ( ConvertResponse ( data ) ) {
  356.                         case INITIALIZE_SUCCESS : {
  357.                             WBB_ConnectPrintf ( "WBB_Connect %s successfully initialized" , WBB_CONNECT_VERSION );
  358.                             WBB_Connect_Initialized = true;
  359.                             return CallRemoteFunction ( "WBB_OnInitialize" , "d" , 1 );
  360.                         }
  361.                         case TRASH_THREAD_SUCCESS :
  362.                             return CallRemoteFunction ( "WBB_ThreadTrashed" , "d" , GlobalIndex );
  363.                         case DELETE_THREAD_SUCCESS :
  364.                             return CallRemoteFunction ( "WBB_ThreadDeleted" , "d" , GlobalIndex );
  365.                         case STICK_THREAD_SUCCESS :
  366.                             return CallRemoteFunction ( "WBB_ThreadSticked" , "d" , GlobalIndex );
  367.                         case UNSTICK_THREAD_SUCCESS :
  368.                             return CallRemoteFunction ( "WBB_ThreadUnsticked" , "d" , GlobalIndex );
  369.                         case ADD_POST_SUCCESS :
  370.                             return CallRemoteFunction ( "WBB_PostAdded" , "d" , GlobalIndex );
  371.                         case EDIT_POST_SUCCESS :
  372.                             return CallRemoteFunction ( "WBB_PostEdited" , "d" , GlobalIndex );
  373.                         case TRASH_POST_SUCCESS :
  374.                             return CallRemoteFunction ( "WBB_PostTrashed" , "d" , GlobalIndex );
  375.                         case DELETE_POST_SUCCESS :
  376.                             return CallRemoteFunction ( "WBB_PostDeleted" , "d" , GlobalIndex );
  377.                         case SET_USER_TO_GROUP_SUCCESS :
  378.                             return CallRemoteFunction ( "WBB_UserSettedToGroup" , "d" , GlobalIndex );
  379.                         case REMOVE_USER_FROM_GROUP_SUCCESS :
  380.                             return CallRemoteFunction ( "WBB_UserRemovedFromGroup" , "d" , GlobalIndex );
  381.                         case DISABLE_USER_AVATAR_SUCCESS :
  382.                             return CallRemoteFunction ( "WBB_UserAvatarDisabled" , "d" , GlobalIndex );
  383.                         case ENABLE_USER_AVATAR_SUCCESS :
  384.                             return CallRemoteFunction ( "WBB_UserAvatarEnabled" , "d" , GlobalIndex );
  385.                         case DISABLE_USER_SIGNATUR_SUCCESS :
  386.                             return CallRemoteFunction ( "WBB_UserSignaturDisabled" , "d" , GlobalIndex );
  387.                         case ENABLE_USER_SIGNATUR_SUCCESS :
  388.                             return CallRemoteFunction ( "WBB_UserSignaturEnabled" , "d" , GlobalIndex );
  389.                         case DISABLE_USER_SUCCESS :
  390.                             return CallRemoteFunction ( "WBB_UserDisabled" , "d" , GlobalIndex );
  391.                         case ENABLE_USER_SUCCESS :
  392.                             return CallRemoteFunction ( "WBB_UserEnabled" , "d" , GlobalIndex );
  393.                         case BAN_USER_SUCCESS :
  394.                             return CallRemoteFunction ( "WBB_UserBanned" , "d" , GlobalIndex );
  395.                         case UNBAN_USER_SUCCESS :
  396.                             return CallRemoteFunction ( "WBB_UserUnbanned" , "d" , GlobalIndex );
  397.                         case USER_ADD_SUCCESS :
  398.                             return CallRemoteFunction ( "WBB_UserAdded" , "d" , GlobalIndex );
  399.                     }
  400.                 }
  401.                 case HTTP_REQUEST_ADD_THREAD : {        // Returns id of new thread
  402.                     strdel ( data , 0 , 8 );
  403.                     return CallRemoteFunction ( "WBB_ThreadAdded" , "dd" , GlobalIndex , strval ( data ) );
  404.                 }
  405.                 case HTTP_REQUEST_GET_POST_USER : {
  406.                     strdel ( data , 0 , 8 );
  407.                     return CallRemoteFunction ( "WBB_GotPostUser" , "ds" , GlobalIndex , data );
  408.                 }
  409.                 case HTTP_REQUEST_GET_THREAD_USER : {
  410.                     strdel ( data , 0 , 8 );
  411.                     return CallRemoteFunction ( "WBB_GotThreadStarter" , "ds" , GlobalIndex , data );
  412.                 }
  413.                 case HTTP_REQUEST_IS_USER_ONLINE : {
  414.                     strdel ( data , 0 , 8 );
  415.                     return CallRemoteFunction ( "WBB_GotUserOnlineState" , "dd" , GlobalIndex , strval ( data ) );
  416.                 }
  417.                 case HTTP_REQUEST_GET_USER_TITLE : {
  418.                     strdel ( data , 0 , 8 );
  419.                     return CallRemoteFunction ( "WBB_GotUserTitle" , "ds" , GlobalIndex , data );
  420.                 }
  421.                 case HTTP_REQUEST_GET_USER_AGE : {
  422.                     strdel ( data , 0 , 8 );
  423.                     return CallRemoteFunction ( "WBB_GotUserAge" , "dd" , GlobalIndex , strval ( data ) );
  424.                 }
  425.                 case HTTP_REQUEST_IS_USER_FRIEND : {
  426.                     strdel ( data , 0 , 8 );
  427.                     return CallRemoteFunction ( "WBB_GotUserFriendState" , "dd" , GlobalIndex , strval ( data ) );
  428.                 }
  429.                 case HTTP_REQUEST_IS_USER_IN_GROUP : {
  430.                     strdel ( data , 0 , 8 );
  431.                     return CallRemoteFunction ( "WBB_GotUserGroupState" , "dd" , GlobalIndex , strval ( data ) );
  432.                 }
  433.                 case HTTP_REQUEST_CHECK_USER_PASSWORD : {
  434.                     strdel ( data , 0 , 8 );
  435.                     return CallRemoteFunction ( "WBB_GotUserPasswordCheckState" , "dd" , GlobalIndex , strval ( data ) );
  436.                 }
  437.                 case HTTP_REQUEST_IS_VALID_USER : {
  438.                     strdel ( data , 0 , 8 );
  439.                     return CallRemoteFunction ( "WBB_GotUserValidState" , "dd" , GlobalIndex , strval ( data ) );
  440.                 }
  441.                 case HTTP_REQUEST_IS_USER_ACTIVATED : {
  442.                     strdel ( data , 0 , 8 );
  443.                     return CallRemoteFunction ( "WBB_GotUserActivationState" , "dd" , GlobalIndex , strval ( data ) );
  444.                 }
  445.                 case HTTP_REQUEST_GET_USER_ACTIVATION : {
  446.                     strdel ( data , 0 , 8 );
  447.                     return CallRemoteFunction ( "WBB_GotUserActivationCode" , "ds" , GlobalIndex , data );
  448.                 }
  449.                 case HTTP_REQUEST_GET_USER_ID : {
  450.                     strdel ( data , 0 , 8 );
  451.                     return CallRemoteFunction ( "WBB_GotUserID" , "dd" , GlobalIndex , strval ( data ) );
  452.                 }
  453.             }
  454.             return WBB_ConnectPrintf ( "An error occurred!\n\nWBB_Connect interface response: %s" , data );
  455.         }
  456.         else
  457.             return WBB_ConnectPrintf ( "An error occurred!\n\nWBB_Connect interface response: %s" , data );
  458.     }
  459.     else if ( ConvertResponse ( data ) == INITIALIZE_SUCCESS )
  460.         return CallRemoteFunction ( "WBB_OnInitialize" , "d" , 0 );
  461.     else
  462.         return WBB_ConnectPrintf ( "An error occurred!\n\nWBB_Connect interface response: %d at %s" , response_code , data );
  463. }
  464.  
  465. WBB_ConnectPrintf ( output[ 256 ] , { Float , _ } : ... ) {
  466.     new Count = numargs ( ) , idx;
  467.     for ( new i = 1; i < Count; i ++ ) {
  468.         new Arg[ 32 ] , Pos , bool:IsInt , bool:IsFloat;
  469.         for ( new x; x < strlen ( output ); x ++ ) {
  470.             if ( output[ x ] == '%' ) {
  471.                 if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
  472.                     IsInt = true;
  473.                 if ( output[ x + 1 ] == 'f' )
  474.                     IsFloat = true;
  475.                 strdel ( output , x , x + 2 );
  476.                 Pos = x;
  477.                 break;
  478.             }
  479.         }
  480.         while ( getarg ( i , idx ) ) {
  481.             Arg[ idx ] = getarg ( i , idx );
  482.             idx ++;
  483.         }
  484.         if ( IsInt == true )
  485.             format ( Arg , 32 , "%d" , Arg );
  486.         if ( IsFloat == true )
  487.             format ( Arg , 32 , "%f" , Arg );
  488.         idx = 0;
  489.         strins ( output , Arg , Pos );
  490.     }
  491.     return printf ( "\n=== WBB_Connect: ===\n%s\n====================%s\n" , output );
  492. }
  493.  
  494. ConvertResponse ( Str[ ] ) {
  495.     new OP_Response;
  496.     for ( new Idx; Idx < strlen ( Str ); Idx ++ ) {
  497.         if ( Str[ Idx ] == '0' && Str[ Idx + 1 ] == 'x' ) {
  498.             Idx += 2;
  499.             while ( ( 'a' <= Str[ Idx ] <= 'f' || 'A' <= Str[ Idx ] <= 'F' || '0' <= Str[ Idx ] <= '9' ) ) {
  500.                 switch ( Str[ Idx++ ] ) {
  501.                     case 'a' .. 'f': {
  502.                        OP_Response = ( OP_Response << 4 ) + ( 10 + Str[ Idx - 1 ] - 'a' );
  503.                     }
  504.                     case 'A' .. 'F': {
  505.                        OP_Response = ( OP_Response << 4 ) + ( 10 + Str[ Idx - 1 ] - 'A' );
  506.                     }
  507.                     case '0' .. '9': {
  508.                        OP_Response = ( OP_Response << 4 ) + ( Str[ Idx - 1 ] - '0' );
  509.                     }
  510.                 }
  511.             }
  512.         }
  513.     }
  514.     return OP_Response;
  515. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement