Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------- Includes --------------------//
- #include < amxmodx >
- //-------------------- Defines --------------------//
- #define Prefix "AMXX"
- #define MAX_STORYS 120
- #define StoryFile "addons/amxmodx/configs/Story.ini"
- //-------------------- Functions --------------------//
- new Storys[ MAX_STORYS ][ 200 ], StoryID[ 33 ], StoryLoaded = 0
- //-------------------- Plugin init --------------------//
- public plugin_init()
- {
- register_plugin( "Story", "v1.0", "RanAway`" )
- //-------------------- Commands --------------------//
- register_clcmd( "say /story", "Story" )
- //-------------------- Load --------------------//
- LoadStory()
- }
- //-------------------- make sure it will start from the first line --------------------//
- public client_authorized( id ) if( StoryID[ id ] == 0 ) StoryID[ id ] = -1
- //-------------------- Story --------------------//
- public Story( id )
- {
- //-------------------- reload in real time --------------------//
- StoryLoaded = 0
- LoadStory()
- //-------------------- if the ini is empty --------------------//
- if( StoryLoaded == 0 ) return ColorChat( id, "There is not ^3storys^1 yet." )
- //-------------------- make sure it will stop at maximum --------------------//
- if( StoryID[ id ] < StoryLoaded - 1 ) StoryID[ id ]++
- //-------------------- Chat msg --------------------//
- return ColorChat( id, "%s.", Storys[ StoryID[ id ] ] )
- }
- //-------------------- Load --------------------//
- LoadStory()
- {
- //-------------------- instructions --------------------//
- if( !file_exists( StoryFile ) ) write_file( StoryFile, "; Just add your story^n; Each line is Sentence^n" )
- new text[ 500 ], File = fopen( StoryFile, "rt" )
- //-------------------- open the file --------------------//
- while( !feof( File ) )
- {
- //-------------------- get the line --------------------//
- fgets( File, text, charsmax( text ) )
- //-------------------- removes whitespace characters from the beginning and end of a string --------------------//
- trim( text )
- //-------------------- skip if there is empty line or start with ; --------------------//
- if( text[ 0 ] == ';' || !text[ 0 ] ) continue
- //-------------------- copy the line to array --------------------//
- copy( Storys[ StoryLoaded ], sizeof( Storys ), text )
- //-------------------- count the lines --------------------//
- StoryLoaded++
- }
- //-------------------- close the file --------------------//
- fclose( File )
- return 1
- }
- //-------------------- Stocks - ColorChat --------------------//
- stock ColorChat( id, const string[], any:... )
- {
- new msg[ 191 ], players[ 32 ], count = 1
- new len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
- vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
- if( id )
- players[ 0 ] = id
- else
- get_players( players, count, "ch" )
- for( new i = 0; i < count; i++ )
- {
- if( is_user_connected( players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
- write_byte( players[ i ] )
- write_string( msg )
- message_end()
- }
- }
- return 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement