Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------- Includes --------------------//
- #include < amxmodx >
- //-------------------- Defines --------------------//
- #define Prefix "AMXX"
- #define StoryFile "addons/amxmodx/configs/Story.ini"
- //-------------------- Functions --------------------//
- new Storys[ 1000 ][ 512 ], StoryID[ 33 ], StoryLoaded = 0
- //-------------------- Plugin init --------------------//
- public plugin_init()
- {
- register_plugin( "Story", "v1.0", "RanAway`" )
- //-------------------- Commands --------------------//
- register_clcmd( "say /story", "Story" )
- }
- //-------------------- 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 --------------------//
- LoadStory()
- //-------------------- if the ini is empty --------------------//
- if( !StoryLoaded ) return ColorChat( id, "There is no ^3storys^1 yet." )
- //-------------------- make sure it will stop at maximum --------------------//
- if( StoryID[ id ] <= StoryLoaded ) StoryID[ id ]++
- //-------------------- Chat msg --------------------//
- return ColorChat( id, "%s.", Storys[ StoryID[ id ] ] )
- }
- //-------------------- Load --------------------//
- LoadStory()
- {
- //-------------------- clear the array for prevent bugs --------------------//
- arrayset( Storys[ StoryLoaded ], 0, StoryLoaded )
- StoryLoaded = 0
- //-------------------- instructions --------------------//
- if( !file_exists( StoryFile ) ) write_file( StoryFile, "; Just add your story^n; Each line is Sentence^n" )
- new Line[ 512 ], File = fopen( StoryFile, "rt" )
- //-------------------- open the file --------------------//
- while( !feof( File ) )
- {
- //-------------------- get the line --------------------//
- fgets( File, Line, charsmax( Line ) ); trim( Line )
- //-------------------- skip if there is empty line or start with ; --------------------//
- if( Line[ 0 ] == ';' || !Line[ 0 ] ) continue
- //-------------------- copy the line to array --------------------//
- copy( Storys[ StoryLoaded++ ], sizeof( Storys ), Line )
- }
- //-------------------- close the file --------------------//
- fclose( File )
- return 1
- }
- //-------------------- Stocks - ColorChat --------------------//
- stock ColorChat( id, const string[], any:... )
- {
- new msg[ 191 ], len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
- vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
- client_print_color( id, print_team_default, msg )
- return 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement