Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // WBB_Connect 2.0 filterscript by Hauke Marquardt alias |-|auke - 19.05.2012
- /*
- License:
- This code is free: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This code is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- You´re not allowed to copy any code from this, into your code without
- naming authors name in credits!
- CallBack List:
- WBB_GotPostUser ( Index , Username[ ] )
- WBB_GotThreadStarter ( Index , Username[ ] )
- WBB_GotUserActivationCode ( Index , ActivationCode[ ] )
- WBB_GotUserActivationState ( Index , State )
- WBB_GotUserAge ( Index , Age )
- WBB_GotUserFriendState ( Index , State )
- WBB_GotUserGroupState ( Index , State )
- WBB_GotUserID ( Index , UserID )
- WBB_GotUserOnlineState ( Index , State )
- WBB_GotUserPasswordCheckState ( Index , State )
- WBB_GotUserTitle ( Index , Title[ ] )
- WBB_GotUserValidState ( Index , State )
- WBB_OnInitialize ( State )
- WBB_PostAdded ( Index )
- WBB_PostDeleted ( Index )
- WBB_PostEdited ( Index )
- WBB_PostTrashed ( Index )
- WBB_ThreadAdded ( Index , ThreadID )
- WBB_ThreadDeleted ( Index )
- WBB_ThreadSticked ( Index )
- WBB_ThreadUnsticked ( Index )
- WBB_UserAdded ( Index )
- WBB_UserAvatarDisabled ( Index )
- WBB_UserAvatarEnabled ( Index )
- WBB_UserBanned ( Index )
- WBB_UserDisabled ( Index )
- WBB_UserEnabled ( Index )
- WBB_UserRemovedFromGroup ( Index )
- WBB_UserSettedToGroup ( Index )
- WBB_UserSignaturDisabled ( Index )
- WBB_UserSignaturEnabled ( Index )
- WBB_UserUnbanned ( Index )
- */
- #include <a_samp>
- #include <a_http>
- #define WBB_CONNECT_VERSION "v. 2.0"
- #define HTTP_REQUEST_NO_DATA 0xE9BA
- #define HTTP_REQUEST_ADD_THREAD 0xE9BB
- #define HTTP_REQUEST_GET_POST_USER 0xE9BC
- #define HTTP_REQUEST_GET_THREAD_USER 0xE9BD
- #define HTTP_REQUEST_IS_USER_ONLINE 0xE9BE
- #define HTTP_REQUEST_GET_USER_TITLE 0xE9BF
- #define HTTP_REQUEST_GET_USER_AGE 0xE9C0
- #define HTTP_REQUEST_IS_USER_FRIEND 0xE9C1
- #define HTTP_REQUEST_IS_USER_IN_GROUP 0xE9C2
- #define HTTP_REQUEST_CHECK_USER_PASSWORD 0xE9C3
- #define HTTP_REQUEST_IS_VALID_USER 0xE9C4
- #define HTTP_REQUEST_IS_USER_ACTIVATED 0xE9C5
- #define HTTP_REQUEST_GET_USER_ACTIVATION 0xE9C6
- #define HTTP_REQUEST_GET_USER_ID 0xE9C7
- #define TRASH_THREAD_SUCCESS 0x7D1
- #define DELETE_THREAD_SUCCESS 0x7D2
- #define STICK_THREAD_SUCCESS 0x7D3
- #define UNSTICK_THREAD_SUCCESS 0x7D4
- #define ADD_POST_SUCCESS 0x7D5
- #define EDIT_POST_SUCCESS 0x7D6
- #define TRASH_POST_SUCCESS 0x7D8
- #define DELETE_POST_SUCCESS 0x7D9
- #define SET_USER_TO_GROUP_SUCCESS 0x7DA
- #define REMOVE_USER_FROM_GROUP_SUCCESS 0x7DB
- #define DISABLE_USER_AVATAR_SUCCESS 0x7DC
- #define ENABLE_USER_AVATAR_SUCCESS 0x7DD
- #define DISABLE_USER_SIGNATUR_SUCCESS 0x7DE
- #define ENABLE_USER_SIGNATUR_SUCCESS 0x7DF
- #define DISABLE_USER_SUCCESS 0x7E0
- #define ENABLE_USER_SUCCESS 0x7E1
- #define BAN_USER_SUCCESS 0x7E2
- #define UNBAN_USER_SUCCESS 0x7E3
- #define USER_ADD_SUCCESS 0x7E4
- #define INITIALIZE_SUCCESS 0x7E5
- forward _WBB_Initialize ( Adress[ ] , AuthKey[ ] );
- forward HTTP_Response ( index , response_code , data[ ] );
- forward _WBB_AddPost ( Username[ ] , Thread , Subject[ ] , Content[ ] , Closed , Smilies , HTML , BBCodes , Signature , Index );
- forward _WBB_AddThread ( Username[ ] , Board , Prefix[ ] , Subject[ ] , Content[ ] , State , Closed , Disabled , Smilies , HTML , BBCodes , Signature , Index );
- forward _WBB_AddUser ( Username[ ] , Email[ ] , Password[ ] , Index );
- forward _WBB_BanUser ( Username[ ] , Reason[ ] , Index );
- forward _WBB_CheckUserPassword ( Username[ ] , Password[ ] , Index );
- forward _WBB_DeletePost ( Post , Index );
- forward _WBB_DeleteThread ( ThreadID , Index );
- forward _WBB_DisableUser ( Username[ ] , Index );
- forward _WBB_DisableUserAvatar ( Username[ ] , Index );
- forward _WBB_DisableUserSignatur ( Username[ ] , Index );
- forward _WBB_EditPost ( Username[ ] , Post , Subject[ ] , Content[ ] , ShowEditInformation , EditReason[ ] , Smilies , HTML , BBCodes , Signature , Index );
- forward _WBB_EnableUser ( Username[ ] , Index );
- forward _WBB_EnableUserAvatar ( Username[ ] , Index );
- forward _WBB_EnableUserSignatur ( Username[ ] , Index );
- forward _WBB_GetPostUser ( Post , Index );
- forward _WBB_GetThreadUser ( Thread , Index );
- forward _WBB_GetUserActivationCode ( Username[ ] , Index );
- forward _WBB_GetUserAge ( Username[ ] , Index );
- forward _WBB_GetUserID ( Username[ ] , Index );
- forward _WBB_GetUserTitle( Username[ ] , Index );
- forward _WBB_IsUserActivated ( Username[ ] , Index );
- forward _WBB_IsUserFriendOfUser ( Username[ ] , Friend[ ] , Index );
- forward _WBB_IsUserInGroup ( Username[ ] , Group , Index );
- forward _WBB_IsUserOnline ( Username[ ] , Index );
- forward _WBB_IsValidUser ( Username[ ] , Index );
- forward _WBB_RemoveUserFromGroup ( Username[ ] , Group , Index );
- forward _WBB_SetUserToGroup ( Username[ ] , Group , Index );
- forward _WBB_StickThread ( ThreadID , Index );
- forward _WBB_TrashPost ( Post , Index );
- forward _WBB_TrashThread ( ThreadID , Index );
- forward _WBB_UnBanUser ( Username[ ] , Index );
- forward _WBB_UnstickThread ( ThreadID , Index );
- new GlobalIndex = -1;
- new GlobalAdress[ 64 ] = { };
- new GlobalAuthKey[ 32 ] = { };
- new bool:WBB_Connect_Initialized = false;
- public OnFilterScriptInit() {
- WBB_ConnectPrintf ( "WBB_Connect %s\nwas successfully loaded!\n\nCopyright (c) by Hauke Marquardt" , WBB_CONNECT_VERSION );
- return 1;
- }
- public _WBB_Initialize ( Adress[ ] , AuthKey[ ] ) {
- format ( GlobalAdress , 64 , Adress );
- format ( GlobalAuthKey , 32 , AuthKey );
- SendRequest ( "Initialize" , "" , HTTP_REQUEST_NO_DATA );
- }
- public _WBB_AddUser ( Username[ ] , Email[ ] , Password[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s&Email=%s&Password=%s" , Username , Email , Password );
- SendRequest ( "AddUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_UnBanUser ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "UnBanUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_BanUser ( Username[ ] , Reason[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s&Reason=%s" , Username , Reason );
- SendRequest ( "BanUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_EnableUser ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "EnableUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_DisableUser ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "DisableUser" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_GetUserID ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "GetUserID" , PostData , HTTP_REQUEST_GET_USER_ID , Index );
- }
- public _WBB_GetUserActivationCode ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "GetUserActivationCode" , PostData , HTTP_REQUEST_GET_USER_ACTIVATION , Index );
- }
- public _WBB_IsUserActivated ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "IsUserActivated" , PostData , HTTP_REQUEST_IS_USER_ACTIVATED , Index );
- }
- public _WBB_IsValidUser ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "IsValidUser" , PostData , HTTP_REQUEST_IS_VALID_USER , Index );
- }
- public _WBB_CheckUserPassword ( Username[ ] , Password[ ] , Index ) {
- new PostData[ 256 ];
- format ( PostData , 256 , "Username=%s&Password=%s" , Username , Password );
- SendRequest ( "CheckUserPassword" , PostData , HTTP_REQUEST_CHECK_USER_PASSWORD , Index );
- }
- public _WBB_DisableUserSignatur ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "DisableUserSignatur" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_EnableUserSignatur ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "EnableUserSignatur" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_EnableUserAvatar ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "EnableUserAvatar" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_DisableUserAvatar ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "DisableUserAvatar" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_IsUserInGroup ( Username[ ] , Group , Index ) {
- new PostData[ 256 ];
- format ( PostData , 256 , "Username=%s&Group=%d" , Username , Group );
- SendRequest ( "IsUserInGroup" , PostData , HTTP_REQUEST_IS_USER_IN_GROUP , Index );
- }
- public _WBB_RemoveUserFromGroup ( Username[ ] , Group , Index ) {
- new PostData[ 256 ];
- format ( PostData , 256 , "Username=%s&Group=%d" , Username , Group );
- SendRequest ( "RemoveUserFromGroup" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_SetUserToGroup ( Username[ ] , Group , Index ) {
- new PostData[ 256 ];
- format ( PostData , 256 , "Username=%s&Group=%d" , Username , Group );
- SendRequest ( "SetUserToGroup" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_IsUserFriendOfUser ( Username[ ] , Friend[ ] , Index ) {
- new PostData[ 256 ];
- format ( PostData , 256 , "Username=%s&Friend=%s" , Username , Friend );
- SendRequest ( "IsUserFriendOfUser" , PostData , HTTP_REQUEST_IS_USER_FRIEND , Index );
- }
- public _WBB_GetUserAge ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "GetUserAge" , PostData , HTTP_REQUEST_GET_USER_AGE , Index );
- }
- public _WBB_GetUserTitle ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "GetUserTitle" , PostData , HTTP_REQUEST_GET_USER_TITLE , Index );
- }
- public _WBB_IsUserOnline ( Username[ ] , Index ) {
- new PostData[ 128 ];
- format ( PostData , 128 , "Username=%s" , Username );
- SendRequest ( "IsUserOnline" , PostData , HTTP_REQUEST_IS_USER_ONLINE , Index );
- }
- public _WBB_TrashPost ( Post , Index ) {
- new PostData[ 32 ];
- format ( PostData , 32 , "Post=%d" , Post );
- SendRequest ( "TrashPost" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_DeletePost ( Post , Index ) {
- new PostData[ 32 ];
- format ( PostData , 32 , "Post=%d" , Post );
- SendRequest ( "DeletePost" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_GetThreadUser ( Thread , Index ) {
- new PostData[ 32 ];
- format ( PostData , 32 , "Thread=%d" , Thread );
- SendRequest ( "GetThreadUser" , PostData , HTTP_REQUEST_GET_THREAD_USER , Index );
- }
- public _WBB_GetPostUser ( Post , Index ) {
- new PostData[ 32 ];
- format ( PostData , 32 , "Post=%d" , Post );
- SendRequest ( "GetPostUser" , PostData , HTTP_REQUEST_GET_POST_USER , Index );
- }
- public _WBB_EditPost ( Username[ ] , Post , Subject[ ] , Content[ ] , ShowEditInformation , EditReason[ ] , Smilies , HTML , BBCodes , Signature , Index ) {
- new PostData[ 2000 ];
- 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 );
- SendRequest ( "EditPost" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_AddPost ( Username[ ] , Thread , Subject[ ] , Content[ ] , Closed , Smilies , HTML , BBCodes , Signature , Index ) {
- new PostData[ 2000 ];
- 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 );
- SendRequest ( "AddPost" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_StickThread ( ThreadID , Index ) {
- new PostData[ 32 ];
- format ( PostData , 32 , "Thread=%d" , ThreadID );
- SendRequest ( "StickThread" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_UnstickThread ( ThreadID , Index ) {
- new PostData[ 32 ];
- format ( PostData , 32 , "Thread=%d" , ThreadID );
- SendRequest ( "UnstickThread" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_DeleteThread ( ThreadID , Index ) {
- new PostData[ 32 ];
- format ( PostData , 32 , "Thread=%d" , ThreadID );
- SendRequest ( "DeleteThread" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_TrashThread ( ThreadID , Index ) {
- new PostData[ 32 ];
- format ( PostData , 32 , "Thread=%d" , ThreadID );
- SendRequest ( "TrashThread" , PostData , HTTP_REQUEST_NO_DATA , Index );
- }
- public _WBB_AddThread ( Username[ ] , Board , Prefix[ ] , Subject[ ] , Content[ ] , State , Closed , Disabled , Smilies , HTML , BBCodes , Signature , Index ) {
- new PostData[ 2000 ];
- 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 );
- SendRequest ( "AddThread" , PostData , HTTP_REQUEST_ADD_THREAD , Index );
- }
- SendRequest ( Operation[ ] , PostData[ ] , Index , Idx = 0 ) {
- if ( !WBB_Connect_Initialized && strcmp ( Operation , "Initialize" ) ) {
- WBB_ConnectPrintf ( "WBB_Connect is not initialized!" );
- return -1;
- }
- GlobalIndex = Idx;
- new Adress[ 128 ];
- format ( Adress , 128 , "%s/wbb_connect_api.php?op=%s&authKey=%s" , GlobalAdress , Operation , GlobalAuthKey );
- return HTTP ( Index , HTTP_POST , Adress , PostData , "HTTP_Response" );
- }
- public HTTP_Response ( index , response_code , data[ ] ) {
- if ( response_code == 200 ) {
- if ( strfind ( data , "true" , true ) != -1 || strfind ( data , "return" , true ) != -1 ) {
- switch ( index ) {
- case HTTP_REQUEST_NO_DATA : {
- strdel ( data , 0 , 6 );
- switch ( ConvertResponse ( data ) ) {
- case INITIALIZE_SUCCESS : {
- WBB_ConnectPrintf ( "WBB_Connect %s successfully initialized" , WBB_CONNECT_VERSION );
- WBB_Connect_Initialized = true;
- return CallRemoteFunction ( "WBB_OnInitialize" , "d" , 1 );
- }
- case TRASH_THREAD_SUCCESS :
- return CallRemoteFunction ( "WBB_ThreadTrashed" , "d" , GlobalIndex );
- case DELETE_THREAD_SUCCESS :
- return CallRemoteFunction ( "WBB_ThreadDeleted" , "d" , GlobalIndex );
- case STICK_THREAD_SUCCESS :
- return CallRemoteFunction ( "WBB_ThreadSticked" , "d" , GlobalIndex );
- case UNSTICK_THREAD_SUCCESS :
- return CallRemoteFunction ( "WBB_ThreadUnsticked" , "d" , GlobalIndex );
- case ADD_POST_SUCCESS :
- return CallRemoteFunction ( "WBB_PostAdded" , "d" , GlobalIndex );
- case EDIT_POST_SUCCESS :
- return CallRemoteFunction ( "WBB_PostEdited" , "d" , GlobalIndex );
- case TRASH_POST_SUCCESS :
- return CallRemoteFunction ( "WBB_PostTrashed" , "d" , GlobalIndex );
- case DELETE_POST_SUCCESS :
- return CallRemoteFunction ( "WBB_PostDeleted" , "d" , GlobalIndex );
- case SET_USER_TO_GROUP_SUCCESS :
- return CallRemoteFunction ( "WBB_UserSettedToGroup" , "d" , GlobalIndex );
- case REMOVE_USER_FROM_GROUP_SUCCESS :
- return CallRemoteFunction ( "WBB_UserRemovedFromGroup" , "d" , GlobalIndex );
- case DISABLE_USER_AVATAR_SUCCESS :
- return CallRemoteFunction ( "WBB_UserAvatarDisabled" , "d" , GlobalIndex );
- case ENABLE_USER_AVATAR_SUCCESS :
- return CallRemoteFunction ( "WBB_UserAvatarEnabled" , "d" , GlobalIndex );
- case DISABLE_USER_SIGNATUR_SUCCESS :
- return CallRemoteFunction ( "WBB_UserSignaturDisabled" , "d" , GlobalIndex );
- case ENABLE_USER_SIGNATUR_SUCCESS :
- return CallRemoteFunction ( "WBB_UserSignaturEnabled" , "d" , GlobalIndex );
- case DISABLE_USER_SUCCESS :
- return CallRemoteFunction ( "WBB_UserDisabled" , "d" , GlobalIndex );
- case ENABLE_USER_SUCCESS :
- return CallRemoteFunction ( "WBB_UserEnabled" , "d" , GlobalIndex );
- case BAN_USER_SUCCESS :
- return CallRemoteFunction ( "WBB_UserBanned" , "d" , GlobalIndex );
- case UNBAN_USER_SUCCESS :
- return CallRemoteFunction ( "WBB_UserUnbanned" , "d" , GlobalIndex );
- case USER_ADD_SUCCESS :
- return CallRemoteFunction ( "WBB_UserAdded" , "d" , GlobalIndex );
- }
- }
- case HTTP_REQUEST_ADD_THREAD : { // Returns id of new thread
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_ThreadAdded" , "dd" , GlobalIndex , strval ( data ) );
- }
- case HTTP_REQUEST_GET_POST_USER : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotPostUser" , "ds" , GlobalIndex , data );
- }
- case HTTP_REQUEST_GET_THREAD_USER : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotThreadStarter" , "ds" , GlobalIndex , data );
- }
- case HTTP_REQUEST_IS_USER_ONLINE : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserOnlineState" , "dd" , GlobalIndex , strval ( data ) );
- }
- case HTTP_REQUEST_GET_USER_TITLE : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserTitle" , "ds" , GlobalIndex , data );
- }
- case HTTP_REQUEST_GET_USER_AGE : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserAge" , "dd" , GlobalIndex , strval ( data ) );
- }
- case HTTP_REQUEST_IS_USER_FRIEND : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserFriendState" , "dd" , GlobalIndex , strval ( data ) );
- }
- case HTTP_REQUEST_IS_USER_IN_GROUP : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserGroupState" , "dd" , GlobalIndex , strval ( data ) );
- }
- case HTTP_REQUEST_CHECK_USER_PASSWORD : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserPasswordCheckState" , "dd" , GlobalIndex , strval ( data ) );
- }
- case HTTP_REQUEST_IS_VALID_USER : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserValidState" , "dd" , GlobalIndex , strval ( data ) );
- }
- case HTTP_REQUEST_IS_USER_ACTIVATED : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserActivationState" , "dd" , GlobalIndex , strval ( data ) );
- }
- case HTTP_REQUEST_GET_USER_ACTIVATION : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserActivationCode" , "ds" , GlobalIndex , data );
- }
- case HTTP_REQUEST_GET_USER_ID : {
- strdel ( data , 0 , 8 );
- return CallRemoteFunction ( "WBB_GotUserID" , "dd" , GlobalIndex , strval ( data ) );
- }
- }
- return WBB_ConnectPrintf ( "An error occurred!\n\nWBB_Connect interface response: %s" , data );
- }
- else
- return WBB_ConnectPrintf ( "An error occurred!\n\nWBB_Connect interface response: %s" , data );
- }
- else if ( ConvertResponse ( data ) == INITIALIZE_SUCCESS )
- return CallRemoteFunction ( "WBB_OnInitialize" , "d" , 0 );
- else
- return WBB_ConnectPrintf ( "An error occurred!\n\nWBB_Connect interface response: %d at %s" , response_code , data );
- }
- WBB_ConnectPrintf ( output[ 256 ] , { Float , _ } : ... ) {
- new Count = numargs ( ) , idx;
- for ( new i = 1; i < Count; i ++ ) {
- new Arg[ 32 ] , Pos , bool:IsInt , bool:IsFloat;
- for ( new x; x < strlen ( output ); x ++ ) {
- if ( output[ x ] == '%' ) {
- if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
- IsInt = true;
- if ( output[ x + 1 ] == 'f' )
- IsFloat = true;
- strdel ( output , x , x + 2 );
- Pos = x;
- break;
- }
- }
- while ( getarg ( i , idx ) ) {
- Arg[ idx ] = getarg ( i , idx );
- idx ++;
- }
- if ( IsInt == true )
- format ( Arg , 32 , "%d" , Arg );
- if ( IsFloat == true )
- format ( Arg , 32 , "%f" , Arg );
- idx = 0;
- strins ( output , Arg , Pos );
- }
- return printf ( "\n=== WBB_Connect: ===\n%s\n====================%s\n" , output );
- }
- ConvertResponse ( Str[ ] ) {
- new OP_Response;
- for ( new Idx; Idx < strlen ( Str ); Idx ++ ) {
- if ( Str[ Idx ] == '0' && Str[ Idx + 1 ] == 'x' ) {
- Idx += 2;
- while ( ( 'a' <= Str[ Idx ] <= 'f' || 'A' <= Str[ Idx ] <= 'F' || '0' <= Str[ Idx ] <= '9' ) ) {
- switch ( Str[ Idx++ ] ) {
- case 'a' .. 'f': {
- OP_Response = ( OP_Response << 4 ) + ( 10 + Str[ Idx - 1 ] - 'a' );
- }
- case 'A' .. 'F': {
- OP_Response = ( OP_Response << 4 ) + ( 10 + Str[ Idx - 1 ] - 'A' );
- }
- case '0' .. '9': {
- OP_Response = ( OP_Response << 4 ) + ( Str[ Idx - 1 ] - '0' );
- }
- }
- }
- }
- }
- return OP_Response;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement