Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* *****************************************************************************
- ____ _ _ _ _____ ____
- / ___|___| | |_ __ | |__ ___ _ __ ___ | ___/ ___|
- | | / _ \ | | '_ \| '_ \ / _ \| '_ \ / _ \ | |_ \___ \
- | |__| __/ | | |_) | | | | (_) | | | | __/ | _| ___) |
- \____\___|_|_| .__/|_| |_|\___/|_| |_|\___| |_| |____/
- |_|
- This script was made entirely by LarzI aka zCourge.
- Shoutout to:
- * Y_Less for y_ini, sscanf, whirlpool and foreach (y_iterate)
- * Zeex for zcmd
- * Slice for bit-flags tutorial
- ***************************************************************************** */
- #include <a_samp>
- #define FILTERSCRIPT
- #include <sscanf2>
- #include <zcmd>
- #define MAX_INI_TAGS (500) //this has to be before y_ini for using as many tags as we do in our files.
- #include <YSI\y_ini>
- #include <YSI\y_iterate>
- // -------------------------------------------------------------------------- //
- #define PHONE_NUMBER_LENGTH (9)
- #define MAX_CONTACTS (24) // <- You may change this value if you want to allow more contacts than 24 (6 contacts per page = 4 full pages)
- #define DIALOG_DIALING (0)
- #define DIALOG_INCOMING_CALL (1)
- #define DIALOG_MESSAGE (2)
- #define DIALOG_PHONEBOOK (3)
- #define DIALOG_ADD_OR_REMOVE_CONTACTS (4)
- #define DIALOG_ADD_CONTACT (5)
- #define DIALOG_REMOVE_CONTACT (6)
- #define DIALOG_CONTACT_CHANGES_MESSAGE (7)
- #define DIALOG_VERIFY_REMOVAL (8)
- #define PHONE_BOOK_PATH "cellphone\\phonebooks\\%s.ini"
- #define PHONE_NUMBERS_PATH "cellphone\\numbers.ini"
- #define CONFIG_PATH "cellphone\\filterscript.cfg"
- // -------------------------------------------------------------------------- //
- #define CheckFlag(%0,%1) ((%0)&(%1))
- #define SetFlag(%0,%1) ((%0)|=(%1))
- #define ResetFlag(%0,%1) ((%0)&=(~(%1)))
- // -------------------------------------------------------------------------- //
- // -------------------------------------------------------------------------- //
- native WP_Hash(buffer[], len, const str[]);
- // -------------------------------------------------------------------------- //
- // -------------------------------------------------------------------------- //
- enum pbInfo //pb = phonebook
- {
- pbName[ MAX_PLAYER_NAME ],
- pbNumber[ 10 ]
- };
- enum Flags:( <<= 1 )
- {
- PLAYER_IS_IN_PHONECALL = 1, //0000001
- PLAYER_IS_ADDING_CONTACT, //0000010
- PLAYER_IS_REMOVING_CONTACT, //0000100
- PLAYER_HAS_CELLPHONE, //0001000
- PLAYER_PHONE_IS_PRIVATE, //0010000
- };
- // -------------------------------------------------------------------------- //
- new
- g_PlayerPhone[ MAX_PLAYERS ][ PHONE_NUMBER_LENGTH ],
- g_PhoneNumbers[ MAX_PLAYERS ][ MAX_PLAYER_NAME ],
- g_TempContactNumber[ MAX_PLAYERS ][ PHONE_NUMBER_LENGTH ],
- g_DialogString[ MAX_PLAYERS ][ MAX_PLAYER_NAME * MAX_CONTACTS + ( MAX_CONTACTS - 1 ) ];
- new
- g_PhoneBook[ MAX_PLAYERS ][ MAX_CONTACTS ][ pbInfo ]; //each contact has his own name, and we need to put \n between every name;
- new
- Flags: g_PlayerFlag[ MAX_PLAYERS ],
- g_Dialer[ MAX_PLAYERS ],
- g_TargetDial[ MAX_PLAYERS ],
- g_DialTimer[ MAX_PLAYERS ],
- g_ExtraContacts[ MAX_PLAYERS ],
- g_ExtraPages[ MAX_PLAYERS ],
- g_CurrentPage[ MAX_PLAYERS ],
- g_Contacts[ MAX_PLAYERS ],
- g_RemovingContact[ MAX_PLAYERS ];
- new
- bool: g_PrivatePhones_Enabled,
- bool: g_TabClickCall_Enabled;
- // -------------------------------------------------------------------------- //
- // -------------------------------------------------------------------------- //
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" ");
- print(" Cellphone FS - by LarzI aka. zCourge");
- print(" Loaded");
- print(" ");
- print("--------------------------------------\n");
- if( !fexist( PHONE_NUMBERS_PATH ))
- {
- new
- INI:pnFile = INI_Open( PHONE_NUMBERS_PATH ),
- number[ 9 ];
- for( new i = 0; i < MAX_PLAYERS; i ++ )
- {
- format( number, sizeof( number ), "555-%04d", i );
- INI_SetTag( pnFile, valstr2( i ));
- INI_WriteString( pnFile, "number", number );
- INI_WriteString( pnFile, "owner", "" );
- }
- INI_Close( pnFile );
- }
- if( !fexist( CONFIG_PATH ))
- {
- new
- INI:confFile = INI_Open( CONFIG_PATH );
- INI_SetTag( confFile, "preferences" );
- INI_WriteBool( confFile, "privatenumbers_enabled", true );
- INI_WriteBool( confFile, "tabclickcall_enabled", true ); //OnPlayerClickPlayer
- INI_Close( confFile );
- }
- INI_ParseFile( CONFIG_PATH, "FS_Config", .bPassTag = true );
- return true;
- }
- // -------------------------------------------------------------------------- //
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" ");
- print(" Cellphone FS - by LarzI aka. zCourge");
- print(" Unloaded");
- print(" ");
- print("--------------------------------------\n");
- return true;
- }
- // -------------------------------------------------------------------------- //
- public OnPlayerConnect(playerid)
- {
- g_PlayerFlag[ playerid ] = Flags: 0;
- g_Dialer[ playerid ] = INVALID_PLAYER_ID;
- g_TargetDial[ playerid ] = INVALID_PLAYER_ID;
- if( !fexist( PhoneBookPath( playerid )))
- {
- new
- INI:pbFile = INI_Open( PhoneBookPath( playerid ));
- INI_SetTag( pbFile, "statistics" );
- INI_WriteInt( pbFile, "contacts", 0 );
- INI_Close( pbFile );
- }
- else
- {
- INI_ParseFile( PhoneBookPath( playerid ), "PhoneBook", .bExtra = true, .extra = playerid, .bPassTag = true );
- for( new i = 0; i < MAX_CONTACTS; i ++ )
- {
- if( isnull( g_PhoneBook[ playerid ][ i ][ pbName ] ))
- {
- format( g_PhoneBook[ playerid ][ i ][ pbName ], MAX_PLAYER_NAME, "- empty -" );
- }
- }
- }
- g_ExtraContacts[ playerid ] = g_Contacts[ playerid ];
- return true;
- }
- // -------------------------------------------------------------------------- //
- public OnPlayerDisconnect(playerid, reason)
- {
- if( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_HAS_CELLPHONE ))
- {
- fremove( PhoneBookPath( playerid ));
- new
- INI:File = INI_Open( PhoneBookPath( playerid )); //MAX_CONTACTS' digits + 1.
- INI_SetTag( File, "statistics" );
- INI_WriteInt( File, "contacts", g_Contacts[ playerid ] );
- for( new i = 0; i < g_Contacts[ playerid ]; i ++ )
- {
- if( !strcmp( g_PhoneBook[ playerid ][ i ][ pbName ], "- empty -" ))
- {
- INI_DeleteTag( File, valstr2( i ));
- }
- else
- {
- INI_SetTag( File, valstr2( i ));
- INI_WriteString( File, "name", g_PhoneBook[ playerid ][ i ][ pbName ] );
- INI_WriteString( File, "number", g_PhoneBook[ playerid ][ i ][ pbNumber ] );
- }
- }
- INI_Close( File );
- File = INI_Open( PHONE_NUMBERS_PATH );
- INI_SetTag( File, "data" );
- INI_WriteString( File, g_PlayerPhone[ playerid ], PlayerName( playerid ));
- INI_Close( File );
- g_Contacts[ playerid ] = 0;
- for( new i = 0; i < MAX_CONTACTS; i ++ )
- {
- format( g_PhoneBook[ playerid ][ i ][ pbName ], MAX_PLAYER_NAME, "" );
- format( g_PhoneBook[ playerid ][ i ][ pbNumber ], PHONE_NUMBER_LENGTH, "" );
- }
- }
- return true;
- }
- // -------------------------------------------------------------------------- //
- public OnPlayerSpawn(playerid)
- {
- new
- firstAvailableNumber,
- bool:fan_Found;
- INI_ParseFile( PHONE_NUMBERS_PATH, "PhoneNumbers", .bPassTag = true );
- for( new i = 0; i < MAX_PLAYERS; i ++ )
- {
- if( isnull( g_PhoneNumbers[ i ] ) && !fan_Found )
- {
- firstAvailableNumber = i;
- fan_Found = true;
- }
- else if( !strcmp( PlayerName( playerid ), g_PhoneNumbers[ i ] ))
- {
- format( g_PlayerPhone[ playerid ], PHONE_NUMBER_LENGTH, "555-%04d", i + 1 );
- SetFlag( g_PlayerFlag[ playerid ], PLAYER_HAS_CELLPHONE );
- break;
- }
- }
- fan_Found = false;
- if( !CheckFlag( g_PlayerFlag[ playerid ], PLAYER_HAS_CELLPHONE ))
- {
- new
- INI:pnFile = INI_Open( PHONE_NUMBERS_PATH );
- INI_SetTag( pnFile, valstr2( firstAvailableNumber ));
- INI_WriteString( pnFile, "owner", PlayerName( playerid ));
- INI_Close( pnFile );
- format( g_PhoneNumbers[ firstAvailableNumber ], MAX_PLAYER_NAME, "%s", PlayerName( playerid ));
- format( g_PlayerPhone[ playerid ], PHONE_NUMBER_LENGTH, "555-%04d", ( firstAvailableNumber + 1 ));
- new
- message[ 40 ];
- SendClientMessage( playerid, 0xFFFF00FF, "[INFO] {FFFFFF}You've been given a personal cellphone." );
- format( message, sizeof( message ), " * {FFFFFF}Your number is: %s.", g_PlayerPhone[ playerid ] );
- SendClientMessage( playerid, 0xFFFF00FF, message );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}You can add contacts to your phonebook by entering /phonebook then press Add Contact - or do /addcontact." );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}to do so, you'll need their number; ask them!" );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}You can \"call\" players by either entering /call [contact/number], accessing your /phonebook" );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}or press tab and doubleclick a player (only if enabled)." );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}Your cellphone is public - this means that any player can call you by doubleclicking your name." );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}to disable this, simply enter /privatephone (toggle - only if enabled)." );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}You may type /phonehelp anytime to re-read these messages." );
- }
- return true;
- }
- // -------------------------------------------------------------------------- //
- public OnPlayerText(playerid, text[])
- {
- if( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_IN_PHONECALL ))
- {
- format( text, 128 , "%s [phone]: {FFFFFF}%s", PlayerName( playerid ), text );
- if( g_TargetDial[ playerid ] != INVALID_PLAYER_ID )
- {
- SendClientMessage( playerid, 0xFFFFFFFF, text );
- SendClientMessage( g_TargetDial[ playerid ], 0xFFFF00FF, text );
- }
- else
- {
- SendClientMessage( playerid, 0xFFFFFFFF, text );
- SendClientMessage( g_Dialer[ playerid ], 0xFFFF00FF, text );
- }
- return false;
- }
- return true;
- }
- // -------------------------------------------------------------------------- //
- public OnPlayerClickPlayer(playerid, clickedplayerid)
- {
- if( g_TabClickCall_Enabled )
- {
- if( playerid == clickedplayerid )
- {
- SendClientMessage( playerid, 0xFF0000FF, "[ERROR] {FFFFFF}You can't call yourself" );
- }
- else if( CheckFlag( g_PlayerFlag[ clickedplayerid ], PLAYER_PHONE_IS_PRIVATE ))
- {
- SendClientMessage( playerid, 0xFF0000FF, "[ERROR] {FFFFFF}The player you're trying to call has set his phone to private." );
- }
- else if( g_Dialer[ clickedplayerid ] != INVALID_PLAYER_ID || g_TargetDial[ clickedplayerid ] != INVALID_PLAYER_ID )
- {
- SendClientMessage( playerid, 0xFF0000FF, "[ERROR] {FFFFFF}The player you're trying to call is currently in a call" );
- }
- else if( g_Dialer[ playerid ] != INVALID_PLAYER_ID || g_TargetDial[ playerid ] != INVALID_PLAYER_ID )
- {
- SendClientMessage( playerid, 0xFF0000FF, "[ERROR] {FFFFFF}End your current call first." );
- }
- else
- {
- TryPhoneCall( playerid, clickedplayerid );
- }
- }
- return true;
- }
- // -------------------------------------------------------------------------- //
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch( dialogid )
- {
- case DIALOG_DIALING:
- {
- if( response ) //Cancel
- {
- KillTimer( g_DialTimer[ playerid ] );
- ShowPlayerDialog( g_TargetDial[ playerid ], DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Missed call from", PlayerName( playerid ), "OK", "" );
- g_Dialer[ g_TargetDial[ playerid ]] = INVALID_PLAYER_ID;
- g_TargetDial[ playerid ] = INVALID_PLAYER_ID;
- return true;
- }
- }
- case DIALOG_INCOMING_CALL:
- {
- if( response ) //Accept
- {
- KillTimer( g_DialTimer[ g_Dialer[ playerid ]] );
- SetFlag( g_PlayerFlag[ playerid ], PLAYER_IS_IN_PHONECALL );
- SetFlag( g_PlayerFlag[ g_Dialer[ playerid ]], PLAYER_IS_IN_PHONECALL );
- SetPlayerAttachedObject( playerid, 0, 330, 6 );
- SetPlayerSpecialAction( playerid, SPECIAL_ACTION_USECELLPHONE );
- ShowPlayerDialog( playerid, DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Call accepted", "Type /hangup any time to end the call", "OK", "" );
- ShowPlayerDialog( g_Dialer[ playerid ], DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Call accepted", "Type /hangup any time to end the call", "OK", "" );
- }
- else //Decline
- {
- KillTimer( g_DialTimer[ g_Dialer[ playerid ]] );
- ShowPlayerDialog( g_Dialer[ playerid ], DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Missed call from", PlayerName( playerid ), "OK", "" );
- g_TargetDial[ g_Dialer[ playerid ]] = INVALID_PLAYER_ID;
- g_Dialer[ playerid ] = INVALID_PLAYER_ID;
- }
- return true;
- }
- case DIALOG_MESSAGE:
- {
- if( response ) //OK
- {
- return true;
- }
- }
- case DIALOG_PHONEBOOK:
- {
- new
- tempContacts = g_ExtraContacts[ playerid ];
- if( !response )
- {
- return true;
- }
- switch( listitem )
- {
- case 0:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 0 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_PHONEBOOK, DIALOG_STYLE_LIST, "Contacts", g_DialogString[ playerid ], "Select", "Close" );
- return true;
- }
- TryPhoneCall( playerid, PhoneNumberToPlayerid( g_PhoneBook[ playerid ][ ( 0 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbNumber ] ));
- }
- case 1:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 1 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_PHONEBOOK, DIALOG_STYLE_LIST, "Contacts", g_DialogString[ playerid ], "Select", "Close" );
- return true;
- }
- TryPhoneCall( playerid, PhoneNumberToPlayerid( g_PhoneBook[ playerid ][ ( 1 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbNumber ] ));
- }
- case 2:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 2 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_PHONEBOOK, DIALOG_STYLE_LIST, "Contacts", g_DialogString[ playerid ], "Select", "Close" );
- return true;
- }
- TryPhoneCall( playerid, PhoneNumberToPlayerid( g_PhoneBook[ playerid ][ ( 2 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbNumber ] ));
- }
- case 3:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 3 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_PHONEBOOK, DIALOG_STYLE_LIST, "Contacts", g_DialogString[ playerid ], "Select", "Close" );
- return true;
- }
- TryPhoneCall( playerid, PhoneNumberToPlayerid( g_PhoneBook[ playerid ][ ( 3 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbNumber ] ));
- }
- case 4:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 4 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_PHONEBOOK, DIALOG_STYLE_LIST, "Contacts", g_DialogString[ playerid ], "Select", "Close" );
- return true;
- }
- TryPhoneCall( playerid, PhoneNumberToPlayerid( g_PhoneBook[ playerid ][ ( 4 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbNumber ] ));
- }
- case 5:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 5 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_PHONEBOOK, DIALOG_STYLE_LIST, "Contacts", g_DialogString[ playerid ], "Select", "Close" );
- return true;
- }
- TryPhoneCall( playerid, PhoneNumberToPlayerid( g_PhoneBook[ playerid ][ ( 5 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbNumber ] ));
- }
- case 6:
- {
- ShowPlayerDialog( playerid, DIALOG_ADD_OR_REMOVE_CONTACTS, DIALOG_STYLE_LIST, "Add/Remove contacts", "Add\nRemove", "Select", "Go back" );
- }
- case 7:
- {
- g_DialogString[ playerid ][ 0 ] = EOS;
- if( g_CurrentPage[ playerid ] == g_ExtraPages[ playerid ] )
- {
- g_CurrentPage[ playerid ] --;
- }
- else
- {
- g_CurrentPage[ playerid ] ++;
- }
- g_ExtraContacts[ playerid ] = tempContacts;
- OpenPhoneBook( playerid );
- }
- case 8: //g_CurrentPage != 0 && != g_Pages
- {
- g_CurrentPage[ playerid ] --;
- g_ExtraContacts[ playerid ] = tempContacts;
- OpenPhoneBook( playerid );
- }
- }
- return true;
- }
- case DIALOG_ADD_OR_REMOVE_CONTACTS:
- {
- if( !response )
- {
- OpenPhoneBook( playerid );
- return true;
- }
- else if( listitem == 0 )
- {
- if( g_Contacts[ playerid ] == MAX_CONTACTS )
- {
- new
- errorString[ 49 ];
- format( errorString, sizeof( errorString ), "You can only have %d contacts in your phonebook", MAX_CONTACTS );
- ShowPlayerDialog( playerid, DIALOG_CONTACT_CHANGES_MESSAGE, DIALOG_STYLE_MSGBOX, "Error", errorString, "OK", "" );
- }
- else
- {
- ShowPlayerDialog( playerid, DIALOG_ADD_CONTACT, DIALOG_STYLE_INPUT, "Add new contact", "Enter phone number", "Next", "Cancel" );
- }
- }
- else
- {
- if( g_Contacts[ playerid ] < 1 )
- {
- ShowPlayerDialog( playerid, DIALOG_CONTACT_CHANGES_MESSAGE, DIALOG_STYLE_MSGBOX, "Error", "You don't have any entries in your phonebook", "OK", "" );
- }
- else
- {
- SetFlag( g_PlayerFlag[ playerid ], PLAYER_IS_REMOVING_CONTACT );
- OpenPhoneBook( playerid );
- }
- }
- return true;
- }
- case DIALOG_ADD_CONTACT:
- {
- if( !response )
- {
- if( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_ADDING_CONTACT ))
- {
- ShowPlayerDialog( playerid, DIALOG_ADD_CONTACT, DIALOG_STYLE_INPUT, "Add new contact", "Enter phone number", "Next", "Cancel" );
- }
- else
- {
- OpenPhoneBook( playerid );
- }
- }
- else
- {
- if( !CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_ADDING_CONTACT ))
- {
- if( !IsPhoneNumber( inputtext ))
- {
- ShowPlayerDialog( playerid, DIALOG_ADD_CONTACT, DIALOG_STYLE_INPUT, "Add new contact", "Not valid - try again", "Next", "Cancel" );
- }
- else
- {
- format( g_TempContactNumber[ playerid ], sizeof( g_TempContactNumber[] ), "%s", inputtext );
- SetFlag( g_PlayerFlag[ playerid ], PLAYER_IS_ADDING_CONTACT );
- ShowPlayerDialog( playerid, DIALOG_ADD_CONTACT, DIALOG_STYLE_INPUT, "Add new contact", "Enter chosen name", "Add", "Go back" );
- }
- }
- else
- {
- TryAddingContact( playerid, inputtext, g_TempContactNumber[ playerid ] );
- }
- }
- return true;
- }
- case DIALOG_REMOVE_CONTACT:
- {
- new
- tempContacts = g_ExtraContacts[ playerid ];
- if( !response )
- {
- ResetFlag( g_PlayerFlag[ playerid ], PLAYER_IS_REMOVING_CONTACT );
- OpenPhoneBook( playerid );
- return true;
- }
- switch( listitem )
- {
- case 0:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 0 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_REMOVE_CONTACT, DIALOG_STYLE_LIST, "Remove contacts", g_DialogString[ playerid ], "Select", "Go back" );
- return true;
- }
- g_RemovingContact[ playerid ] = ( 0 + ( 6 * g_CurrentPage[ playerid ] ));
- ShowPlayerDialog( playerid, DIALOG_VERIFY_REMOVAL, DIALOG_STYLE_MSGBOX, "Confirm", "Are you sure you want to remove this contact?", "Yes", "No" );
- }
- case 1:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 1 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_REMOVE_CONTACT, DIALOG_STYLE_LIST, "Remove contacts", g_DialogString[ playerid ], "Select", "Go back" );
- return true;
- }
- g_RemovingContact[ playerid ] = ( 1 + ( 6 * g_CurrentPage[ playerid ] ));
- ShowPlayerDialog( playerid, DIALOG_VERIFY_REMOVAL, DIALOG_STYLE_MSGBOX, "Confirm", "Are you sure you want to remove this contact?", "Yes", "No" );
- }
- case 2:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 2 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_REMOVE_CONTACT, DIALOG_STYLE_LIST, "Remove contacts", g_DialogString[ playerid ], "Select", "Go back" );
- return true;
- }
- g_RemovingContact[ playerid ] = ( 2 + ( 6 * g_CurrentPage[ playerid ] ));
- ShowPlayerDialog( playerid, DIALOG_VERIFY_REMOVAL, DIALOG_STYLE_MSGBOX, "Confirm", "Are you sure you want to remove this contact?", "Yes", "No" );
- }
- case 3:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 3 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_REMOVE_CONTACT, DIALOG_STYLE_LIST, "Remove contacts", g_DialogString[ playerid ], "Select", "Go back" );
- return true;
- }
- g_RemovingContact[ playerid ] = ( 3 + ( 6 * g_CurrentPage[ playerid ] ));
- ShowPlayerDialog( playerid, DIALOG_VERIFY_REMOVAL, DIALOG_STYLE_MSGBOX, "Confirm", "Are you sure you want to remove this contact?", "Yes", "No" );
- }
- case 4:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 4 + ( 6 * g_CurrentPage[ playerid ] ) )][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_REMOVE_CONTACT, DIALOG_STYLE_LIST, "Remove contacts", g_DialogString[ playerid ], "Select", "Go back" );
- return true;
- }
- g_RemovingContact[ playerid ] = ( 4 + ( 6 * g_CurrentPage[ playerid ] ));
- ShowPlayerDialog( playerid, DIALOG_VERIFY_REMOVAL, DIALOG_STYLE_MSGBOX, "Confirm", "Are you sure you want to remove this contact?", "Yes", "No" );
- }
- case 5:
- {
- if( !strcmp( g_PhoneBook[ playerid ][ ( 5 + ( 6 * g_CurrentPage[ playerid ] )) ][ pbName ], "- empty -" ))
- {
- ShowPlayerDialog( playerid, DIALOG_REMOVE_CONTACT, DIALOG_STYLE_LIST, "Remove contacts", g_DialogString[ playerid ], "Select", "Go back" );
- return true;
- }
- g_RemovingContact[ playerid ] = ( 5 + ( 6 * g_CurrentPage[ playerid ] ));
- ShowPlayerDialog( playerid, DIALOG_VERIFY_REMOVAL, DIALOG_STYLE_MSGBOX, "Confirm", "Are you sure you want to remove this contact?", "Yes", "No" );
- }
- case 6:
- {
- g_DialogString[ playerid ][ 0 ] = EOS;
- if( g_CurrentPage[ playerid ] == g_ExtraPages[ playerid ] )
- {
- g_CurrentPage[ playerid ] --;
- }
- else
- {
- g_CurrentPage[ playerid ] ++;
- }
- g_ExtraContacts[ playerid ] = tempContacts;
- OpenPhoneBook( playerid );
- }
- case 7: //g_CurrentPage != 0 && != g_Pages
- {
- g_CurrentPage[ playerid ] --;
- g_ExtraContacts[ playerid ] = tempContacts;
- OpenPhoneBook( playerid );
- }
- }
- }
- case DIALOG_VERIFY_REMOVAL:
- {
- if( response )
- {
- TryRemovingContact( playerid, g_PhoneBook[ playerid ][ g_RemovingContact[ playerid ]][ pbName ] );
- }
- else
- {
- OpenPhoneBook( playerid );
- }
- return true;
- }
- case DIALOG_CONTACT_CHANGES_MESSAGE:
- {
- if( response )
- {
- if( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_ADDING_CONTACT ))
- {
- ResetFlag( g_PlayerFlag[ playerid ], PLAYER_IS_ADDING_CONTACT );
- }
- else if( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_REMOVING_CONTACT ))
- {
- ResetFlag( g_PlayerFlag[ playerid ], PLAYER_IS_REMOVING_CONTACT );
- }
- OpenPhoneBook( playerid );
- }
- return true;
- }
- }
- return false;
- }
- // -------------------------------------------------------------------------- //
- // -------------------------------------------------------------------------- //
- CMD:phonebook(playerid, params[])
- {
- OpenPhoneBook( playerid );
- return true;
- }
- CMD:call(playerid, params[])
- {
- new
- target[ MAX_PLAYER_NAME ];
- if( sscanf( params, "s[24]", target ))
- {
- SendClientMessage( playerid, 0xFFFF00FF, "[USAGE] {FFFFFF}/call [phone number or contact-name]" );
- SendClientMessage( playerid, 0xFFFF00FF, " * [phone number] {FFFFFF}= An exisiting - and public - phone number" );
- SendClientMessage( playerid, 0xFFFF00FF, " * [contact-name] {FFFFFF}= An entry from your /phonebook" );
- return SendClientMessage( playerid, 0xFFFF00FF, "[/USAGE]" );
- }
- if( IsPhoneNumber( target ))
- {
- if( !IsPlayerConnected( PhoneNumberToPlayerid( target )) )
- {
- SendClientMessage( playerid, 0xFF0000FF, "[ERROR] {FFFFFF}Not found" );
- }
- else
- {
- TryPhoneCall( playerid, PhoneNumberToPlayerid( target ));
- }
- }
- else
- {
- for( new i = 0; i < g_Contacts[ playerid ]; i ++ )
- {
- if( !strcmp( g_PhoneBook[ playerid ][ i ][ pbName ], target, true ))
- {
- TryPhoneCall( playerid, PhoneNumberToPlayerid( g_PhoneBook[ playerid ][ i ][ pbNumber ] ));
- return true;
- }
- }
- SendClientMessage( playerid, 0xFF0000FF, "[ERROR] {FFFFFF}Not found" );
- }
- return true;
- }
- CMD:hangup(playerid, params[])
- {
- if( g_Dialer[ playerid ] == INVALID_PLAYER_ID || g_TargetDial[ playerid ] == INVALID_PLAYER_ID )
- {
- SendClientMessage( playerid, 0xFF000FF, "[ERROR] {FFFFFF}You can't end a call you're not in" );
- return true;
- }
- if( !CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_IN_PHONECALL ) && g_Dialer[ playerid ] != INVALID_PLAYER_ID )
- {
- KillTimer( g_DialTimer[ g_Dialer[ playerid ]] );
- ShowPlayerDialog( g_Dialer[ playerid ], DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Missed call from", PlayerName( playerid ), "OK", "" );
- }
- else if( !CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_IN_PHONECALL ) && g_TargetDial[ playerid ] != INVALID_PLAYER_ID )
- {
- KillTimer( g_DialTimer[ playerid ] );
- ShowPlayerDialog( g_TargetDial[ playerid ], DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Missed call from", PlayerName( playerid ), "OK", "" );
- }
- else
- {
- ShowPlayerDialog( playerid, DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Call ended", "", "OK", "" );
- ShowPlayerDialog(( (g_TargetDial[ playerid ] == INVALID_PLAYER_ID) ? (g_Dialer[ playerid ]) : (g_TargetDial[ playerid ]) ), DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Call ended", "", "OK", "" );
- }
- if( g_Dialer[ playerid ] == INVALID_PLAYER_ID )
- {
- g_Dialer[ g_TargetDial[ playerid ]] = INVALID_PLAYER_ID;
- g_TargetDial[ playerid ] = INVALID_PLAYER_ID;
- RemovePlayerAttachedObject( g_TargetDial[ playerid ], 0 );
- SetPlayerSpecialAction( g_TargetDial[ playerid ], SPECIAL_ACTION_STOPUSECELLPHONE );
- }
- else
- {
- g_Dialer[ playerid ] = INVALID_PLAYER_ID;
- g_TargetDial[ g_Dialer[ playerid ]] = INVALID_PLAYER_ID;
- RemovePlayerAttachedObject( g_Dialer[ playerid ], 0 );
- SetPlayerSpecialAction( g_Dialer[ playerid ], SPECIAL_ACTION_STOPUSECELLPHONE );
- }
- RemovePlayerAttachedObject( playerid, 0 );
- SetPlayerSpecialAction( playerid, SPECIAL_ACTION_STOPUSECELLPHONE );
- return true;
- }
- CMD:addcontact(playerid, params[])
- {
- new
- number[ PHONE_NUMBER_LENGTH ],
- name[ MAX_PLAYER_NAME ];
- if( sscanf( params, "s[8]s[24]", number, name ))
- {
- SendClientMessage( playerid, 0xFFFF00FF, "[USAGE] {FFFFFF}/addcontact [phone number] [contact-name]" );
- SendClientMessage( playerid, 0xFFFF00FF, " * [phone number] {FFFFFF}= A player's phone number - ask them to get it" );
- SendClientMessage( playerid, 0xFFFF00FF, " * [contact-name] {FFFFFF}= Chosen name for the contact" );
- return SendClientMessage( playerid, 0xFFFF00FF, "[/USAGE]" );
- }
- if( !IsPhoneNumber( number ))
- {
- return SendClientMessage( playerid, 0xFF0000FF, "[ERROR] {FFFFFF}Phone numbers can only contain digits" );
- }
- TryAddingContact( playerid, name, number );
- return true;
- }
- CMD:removecontact(playerid, params[])
- {
- new
- name[ MAX_PLAYER_NAME ];
- if( sscanf( params, "s[MAX_PLAYER_NAME]", name ))
- {
- SendClientMessage( playerid, 0xFFFF00FF, "[USAGE] {FFFFFF}/removecontact [contact-name]" );
- SendClientMessage( playerid, 0xFFFF00FF, " * [contact-name] {FFFFFF}= Chosen name for the contact" );
- return SendClientMessage( playerid, 0xFFFF00FF, "[/USAGE]" );
- }
- TryRemovingContact( playerid, name );
- return true;
- }
- CMD:privatephone(playerid, params[])
- {
- if( !g_PrivatePhones_Enabled )
- {
- return false;
- }
- new
- str[ 45 ];
- if( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_PHONE_IS_PRIVATE ))
- {
- ResetFlag( g_PlayerFlag[ playerid ], PLAYER_PHONE_IS_PRIVATE );
- }
- else
- {
- SetFlag( g_PlayerFlag[ playerid ], PLAYER_PHONE_IS_PRIVATE );
- }
- format( str, sizeof( str ), "[INFO] {FFFFFF}Phone number set to %s", ( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_PHONE_IS_PRIVATE ) ? ("private") : ("public") ));
- SendClientMessage( playerid, 0xFFFF00FF, str);
- return true;
- }
- CMD:phonehelp(playerid, params[])
- {
- new
- message[ 40 ];
- format( message, sizeof( message ), " * {FFFFFF}Your number is: %s.", g_PlayerPhone[ playerid ] );
- SendClientMessage( playerid, 0xFFFF00FF, message );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}You can add contacts to your phonebook by entering /phonebook then press Add Contact - or do /addcontact." );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}to do so, you'll need their number; ask them!" );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}You can \"call\" players by either entering /call [contact/number], accessing your /phonebook" );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}or press tab and doubleclick a player (only if enabled)." );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}Your cellphone is public - this means that any player can call you by doubleclicking your name." );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}to disable this, simply enter /privatephone (toggle - only if enabled)." );
- SendClientMessage( playerid, 0xFFFF00FF, " * {FFFFFF}You may type /phonehelp anytime to re-read these messages." );
- return true;
- }
- // -------------------------------------------------------------------------- //
- // -------------------------------------------------------------------------- //
- forward DialTimer(caller, reciever);
- public DialTimer(caller, reciever)
- {
- g_TargetDial[ caller ] = INVALID_PLAYER_ID;
- g_Dialer[ reciever ] = INVALID_PLAYER_ID;
- ShowPlayerDialog( reciever, DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "Missed call from", PlayerName( caller ), "OK", "" );
- ShowPlayerDialog( caller, DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "No answer", "The person you tried to call did not pick up.", "OK", "" );
- RemovePlayerAttachedObject( caller, 0 );
- SetPlayerSpecialAction( caller, SPECIAL_ACTION_STOPUSECELLPHONE );
- return true;
- }
- forward FS_Config(tag[], name[], value[]);
- public FS_Config(tag[], name[], value[])
- {
- INI_Bool( "privatenumbers_enabled", g_PrivatePhones_Enabled );
- INI_Bool( "tabclickcall_enabled", g_TabClickCall_Enabled );
- return true;
- }
- forward PhoneNumbers(tag[], name[], value[]);
- public PhoneNumbers(tag[], name[], value[])
- {
- INI_String( "owner", g_PhoneNumbers[ strval( tag ) ], sizeof( g_PhoneNumbers[] ));
- return true;
- }
- forward PhoneBook(playerid, tag[], name[], value[]);
- public PhoneBook(playerid, tag[], name[], value[])
- {
- if( !strcmp( tag, "statistics", true ))
- {
- INI_Int( "contacts", g_Contacts[ playerid ] );
- }
- else
- {
- INI_String( "name", g_PhoneBook[ playerid ][ ( strval( tag )) ][ pbName ], MAX_PLAYER_NAME );
- INI_String( "number", g_PhoneBook[ playerid ][ ( strval( tag )) ][ pbNumber ], 9 );
- }
- return true;
- }
- // -------------------------------------------------------------------------- //
- // -------------------------------------------------------------------------- //
- OpenPhoneBook(playerid)
- {
- g_DialogString[ playerid ][ 0 ] = EOS;
- while( g_ExtraContacts[ playerid ] > 6 )
- {
- g_ExtraPages[ playerid ] ++;
- g_ExtraContacts[ playerid ] -= 6;
- }
- new
- tempContacts = g_ExtraContacts[ playerid ];
- if( g_CurrentPage[ playerid ] == 0 )
- {
- if( g_ExtraPages[ playerid ] > 0 )
- {
- if( g_ExtraContacts[ playerid ] < 6 )
- {
- g_ExtraContacts[ playerid ] = 6;
- }
- for( new i = 0; i < 6; i ++ )
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%s%s\n", g_DialogString[ playerid ][ playerid ], g_PhoneBook[ playerid ][ i ][ pbName ] );
- }
- if( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_REMOVING_CONTACT ))
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%sNext page", g_DialogString[ playerid ] );
- }
- else
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%s\nAdd/Remove Contact\nNext page", g_DialogString[ playerid ] );
- }
- }
- else
- {
- if( g_ExtraContacts[ playerid ] < 6 )
- {
- g_ExtraContacts[ playerid ] = 6;
- }
- for( new i = 0; i < g_ExtraContacts[ playerid ]; i ++ )
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%s%s\n", g_DialogString[ playerid ], g_PhoneBook[ playerid ][ i ][ pbName ] );
- }
- if( !CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_REMOVING_CONTACT ))
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%s\nAdd/Remove Contact", g_DialogString[ playerid ] );
- }
- }
- }
- else if( g_CurrentPage[ playerid ] == g_ExtraPages[ playerid ] )
- {
- if( g_ExtraContacts[ playerid ] < 6 )
- {
- g_ExtraContacts[ playerid ] = 6;
- }
- for( new i = 0; i < g_ExtraContacts[ playerid ]; i ++ )
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%s%s\n", g_DialogString[ playerid ], g_PhoneBook[ playerid ][ i + ( 6 * g_CurrentPage[ playerid ] ) ][ pbName ] );
- }
- if( g_ExtraPages[ playerid ] < 2 ) // if( g_ExtraPages[ playerid ] == 1 )
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%sAdd/Remove Contact\nPrevious", g_DialogString[ playerid ] );
- }
- else // if( g_ExtraPages[ playerid ] >= 2 )
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%sAdd/Remove Contact\nNext page\nPrevious page", g_DialogString[ playerid ] );
- }
- }
- else
- {
- if( g_ExtraContacts[ playerid ] < 6 )
- {
- g_ExtraContacts[ playerid ] = 6;
- }
- for( new i = 0; i < g_ExtraContacts[ playerid ]; i ++ )
- {
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%s%s\n", g_DialogString, g_PhoneBook[ playerid ][ i + ( 6 * g_CurrentPage[ playerid ] ) ][ pbName ] );
- }
- format( g_DialogString[ playerid ], sizeof( g_DialogString[] ), "%sAdd/Remove Contact\nNext page\nPrevious page", g_DialogString[ playerid ] );
- }
- g_ExtraContacts[ playerid ] = tempContacts;
- if( CheckFlag( g_PlayerFlag[ playerid ], PLAYER_IS_REMOVING_CONTACT ))
- {
- ShowPlayerDialog( playerid, DIALOG_REMOVE_CONTACT, DIALOG_STYLE_LIST, "Remove contacts", g_DialogString[ playerid ], "Select", "Go back" );
- }
- else
- {
- ShowPlayerDialog( playerid, DIALOG_PHONEBOOK, DIALOG_STYLE_LIST, "Contacts", g_DialogString[ playerid ], "Select", "Close" );
- }
- return true;
- }
- TryAddingContact(playerid, name[], number[])
- {
- format( g_PhoneBook[ playerid ][ g_Contacts[ playerid ]][ pbName ], MAX_PLAYER_NAME, "%s", name );
- format( g_PhoneBook[ playerid ][ g_Contacts[ playerid ]][ pbNumber ], PHONE_NUMBER_LENGTH, "%s", number );
- g_Contacts[ playerid ] ++;
- g_ExtraContacts[ playerid ] ++;
- if( g_ExtraContacts[ playerid ] > 6 )
- {
- g_ExtraContacts[ playerid ] -= 6;
- g_ExtraPages[ playerid ] ++;
- }
- ShowPlayerDialog( playerid, DIALOG_CONTACT_CHANGES_MESSAGE, DIALOG_STYLE_MSGBOX, "Success", "Contact added!", "OK", "" );
- return true;
- }
- TryRemovingContact(playerid, name[])
- {
- new
- bool:found;
- for( new i = 0; i < g_Contacts[ playerid ]; i ++ )
- {
- new
- j = ( i + 1 );
- if( found )
- {
- if( g_Contacts[ playerid ] == j )
- {
- format( g_PhoneBook[ playerid ][ j ][ pbName ], MAX_PLAYER_NAME, "- empty -" );
- g_PhoneBook[ playerid ][ j ][ pbNumber ][ 0 ] = EOS;
- }
- else
- {
- if( strcmp( g_PhoneBook[ playerid ][ j ][ pbName ], "- empty -" ))
- {
- format( g_PhoneBook[ playerid ][ i ][ pbName ], MAX_PLAYER_NAME, "%s", g_PhoneBook[ playerid ][ j ][ pbName ] );
- format( g_PhoneBook[ playerid ][ i ][ pbNumber ], MAX_PLAYER_NAME, "%s", g_PhoneBook[ playerid ][ j ][ pbNumber ] );
- format( g_PhoneBook[ playerid ][ j ][ pbName ], MAX_PLAYER_NAME, "- empty -" );
- g_PhoneBook[ playerid ][ j ][ pbNumber ][ 0 ] = EOS;
- }
- }
- }
- if( !strcmp( g_PhoneBook[ playerid ][ i ][ pbName ], name, true ) && !found )
- {
- if( g_Contacts[ playerid ] == j )
- {
- format( g_PhoneBook[ playerid ][ i ][ pbName ], MAX_PLAYER_NAME, "- empty -" );
- g_PhoneBook[ playerid ][ i ][ pbNumber ][ 0 ] = EOS;
- }
- else
- {
- if( strcmp( g_PhoneBook[ playerid ][ j ][ pbName ], "- empty -" ))
- {
- format( g_PhoneBook[ playerid ][ i ][ pbName ], MAX_PLAYER_NAME, "%s", g_PhoneBook[ playerid ][ j ][ pbName ] );
- format( g_PhoneBook[ playerid ][ i ][ pbNumber ], MAX_PLAYER_NAME, "%s", g_PhoneBook[ playerid ][ j ][ pbNumber ] );
- format( g_PhoneBook[ playerid ][ j ][ pbName ], MAX_PLAYER_NAME, "- empty -" );
- g_PhoneBook[ playerid ][ j ][ pbNumber ][ 0 ] = EOS;
- }
- }
- found = true;
- }
- else if( i == ( g_Contacts[ playerid ] - 1 ) && !found )
- {
- SendClientMessage( playerid, 0xFF0000FF, "[ERROR] {FFFFFF}The contact could not be found in your phonebook" );
- return false;
- }
- }
- g_Contacts[ playerid ] --;
- g_ExtraContacts[ playerid ] --;
- if( g_ExtraContacts[ playerid ] == 0 && g_ExtraPages[ playerid ] > 0 )
- {
- g_ExtraContacts[ playerid ] = 6;
- g_ExtraPages[ playerid ] --;
- }
- ShowPlayerDialog( playerid, DIALOG_CONTACT_CHANGES_MESSAGE, DIALOG_STYLE_MSGBOX, "Success", "Contact removed!", "OK", "" );
- return true;
- }
- TryPhoneCall(caller, reciever)
- {
- g_CurrentPage[ caller ] = 0;
- if( reciever == INVALID_PLAYER_ID )
- {
- SendClientMessage( caller, 0xFF0000FF, "[ERROR] {FFFFFF}This player isn't online" );
- return false;
- }
- else if( caller == reciever )
- {
- SendClientMessage( caller, 0xFF0000FF, "[ERROR] {FFFFFF}You cannot call yourself." );
- return false;
- }
- else if( CheckFlag( g_PlayerFlag[ reciever ], PLAYER_PHONE_IS_PRIVATE ))
- {
- for( new i = 0; i < g_Contacts[ caller ]; i ++ )
- {
- if( !strcmp( g_PhoneBook[ caller ][ i ][ pbNumber ], g_PlayerPhone[ reciever ], true ))
- {
- break;
- }
- else if( i == ( g_Contacts[ caller ] - 1 ))
- {
- SendClientMessage( caller, 0xFF0000FF, "[ERROR] {FFFFFF}The player you're trying to call has set his phone to private." );
- return false;
- }
- }
- }
- else if( g_TargetDial[ caller ] != INVALID_PLAYER_ID || g_Dialer[ caller ] != INVALID_PLAYER_ID )
- {
- SendClientMessage( caller, 0xFF0000FF, "[ERROR] {FFFFFF}You need to end your current phone call before starting a new one." );
- return false;
- }
- else if( g_Dialer[ reciever ] != INVALID_PLAYER_ID || g_TargetDial[ reciever ] != INVALID_PLAYER_ID )
- {
- SendClientMessage( caller, 0xFF0000FF, "[ERROR] {FFFFFF}The person you are calling is unavailable." );
- return false;
- }
- g_TargetDial[ caller ] = reciever;
- g_Dialer[ reciever ] = caller;
- SetPlayerAttachedObject( caller, 0, 330, 6 );
- SetPlayerSpecialAction( caller, SPECIAL_ACTION_USECELLPHONE );
- PlayerPlaySound( caller, 16001, 0.0, 0.0, 0.0 );
- PlayerPlaySound( reciever, 20600, 0.0, 0.0, 0.0 );
- ShowPlayerDialog( caller, DIALOG_DIALING, DIALOG_STYLE_MSGBOX, "Calling...", PlayerName( reciever ), "Cancel", "" );
- ShowPlayerDialog( reciever, DIALOG_INCOMING_CALL, DIALOG_STYLE_MSGBOX, "Incoming call from:", PlayerName( caller ), "Accept", "Decline" );
- g_DialTimer[ caller ] = SetTimerEx( "DialTimer", ( 10 * 1000 ), false, "ii", caller, reciever );
- return true;
- }
- PhoneBookPath(playerid)
- {
- new
- path[ 42 ],
- pname[ 24 ];
- GetPlayerName( playerid, pname, sizeof( pname ));
- format( path, sizeof( path ), PHONE_BOOK_PATH, pname);
- return path;
- }
- PlayerName(playerid)
- {
- new
- name[ MAX_PLAYER_NAME ];
- GetPlayerName( playerid, name, sizeof( name ));
- return name;
- }
- PhoneNumberToPlayerid(number[])
- {
- foreach( Player, i )
- {
- if( !strcmp( g_PlayerPhone[ i ], number ))
- {
- return i;
- }
- }
- return INVALID_PLAYER_ID;
- }
- IsPhoneNumber(string[])
- {
- if( strfind( string, "-", true ) == 3 && strlen( string ) == 8 )
- {
- new i;
- while( i < PHONE_NUMBER_LENGTH )
- {
- if(( string[ i ] < '0' || string[ i ] > '9' ) && string[ i ] != EOS )
- {
- return false;
- }
- if( i == 2 ) //skip the '-'
- {
- i ++;
- }
- i ++;
- }
- return true;
- }
- return false;
- }
- valstr2(val)
- {
- new str[12];
- valstr(str, val);
- return str;
- }
- // This was made by LarzI aka zCourge - All rights reserved
Advertisement
Add Comment
Please, Sign In to add comment