Advertisement
RanAway

[ Pawn ] Story with ini

May 27th, 2022
1,565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.57 KB | None | 0 0
  1. /************* Includes *************/
  2. #include < amxmodx >
  3. #include < colorchat >
  4.  
  5. /************* Defines *************/
  6. #define Prefix          "AMXX"
  7.  
  8. #define StoryFile       "addons/amxmodx/configs/Story.ini"
  9.  
  10. /************* Story *************/
  11. enum _:Properties
  12. {
  13.     name[ 31 ]
  14. }
  15.  
  16. new Storys[ 120 ][ Properties ], StoryLoaded = 0, StoryID[ 33 ] = 0
  17.  
  18. public plugin_init()
  19. {
  20.     register_plugin( "Story", "v1.0", "RanAway`" )
  21.    
  22.     /************* command *************/
  23.     register_clcmd( "say /story", "Story" )
  24.    
  25.     /*********** Load story **************/
  26.     LoadStory()
  27. }
  28.  
  29. /************* Story *************/
  30. public Story( id )
  31. {
  32.     if( StoryLoaded == 0 )
  33.     {
  34.         ColorChat( id, NORMAL, "^3[^1 %s ^3]^1 There is not ^3storys^1 yet.", Prefix )
  35.         return 1
  36.     }
  37.    
  38.     if( StoryID[ id ] != sizeof StoryLoaded )
  39.         StoryID[ id ]++
  40.    
  41.     ColorChat( id, NORMAL, "^3[^1 %s ^3]^1 %s.", Prefix, Storys[ StoryID[ id ] ][ name ] )
  42.     return 1
  43. }
  44.  
  45. /*********** Load story **************/
  46. LoadStory()
  47. {
  48.     if( !file_exists( StoryFile ) )
  49.     {
  50.         write_file( StoryFile, "; Just add your story" )
  51.         write_file( StoryFile, "; Each line is Sentence^n" )
  52.         write_file( StoryFile, "; Each line must be in ^"^"" )
  53.         pause( "a" )
  54.         return 1
  55.     }
  56.    
  57.     new text[ 500 ]
  58.     if( file_exists( StoryFile ) )
  59.     {
  60.         new file = fopen( StoryFile, "rt" )
  61.        
  62.         while( !feof( file ) )
  63.         {
  64.             fgets( file, text, charsmax( text ) )
  65.             trim( text )
  66.            
  67.             if( text[ 0 ] == ';' || !text[ 0 ] )
  68.                 continue
  69.            
  70.             parse( text, Storys[ StoryLoaded ][ name ], 31 )
  71.            
  72.             StoryLoaded++
  73.         }
  74.         fclose( file )
  75.     }
  76.    
  77.     return 1
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement