Raised This Month: $ Target: $400
 0% 

FileLoad


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 09-05-2007 , 12:37   FileLoad
Reply With Quote #1

actully i didnt want to post becase i fellt stupid abut it
but can someone help?
Code:
 
public client_connect(id)
{
 new filepointer = fopen(filename,"r")
 if(filepointer)
 {
  new readdata[128]
  new parsedSound[32],parsedSound2[32],parsedSound3[32],parsedSound4[32],parsedSound5[32]
 
  while(fgets(filepointer,readdata,127))
  {   
   parse(readdata,parsedSound,31,parsedSound2,31,parsedSound3,31,parsedSound4,31,parsedSound5,31)      
 
   Sound[31] = parsedSound[31]
   Sound2[31] = parsedSound2[31]
   Sound3[31] = parsedSound3[31]
   Sound4[31] = parsedSound4[31]
   Sound5[31] = parsedSound5[31] 
   break
   //...
  }
  fclose(filepointer)
 }
}
__________________
If one of my plugins become broken, contact me by mail. [email protected]

Last edited by fxfighter; 09-05-2007 at 12:41.
fxfighter is offline
Send a message via MSN to fxfighter
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-05-2007 , 13:13   Re: FileLoad
Reply With Quote #2

What do you want to do exactly ?!

Provide more informations, please.
__________________
Arkshine is offline
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 09-05-2007 , 13:16   Re: FileLoad
Reply With Quote #3

load some info frome a doc at connect
strings
__________________
If one of my plugins become broken, contact me by mail. [email protected]
fxfighter is offline
Send a message via MSN to fxfighter
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-05-2007 , 13:20   Re: FileLoad
Reply With Quote #4

Ok.

How is formatted your file ?! (filename)

One sound per line ?
__________________
Arkshine is offline
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 09-05-2007 , 13:23   Re: FileLoad
Reply With Quote #5

5 on one line ,
actuly that might be the stupid part i did -.-
ini looks like this
Quote:

song1 song2 song3 song4 song5
but whit difrent names whitout numbers

dont think this under mather but why not -.-
Quote:
public plugin_init() {
register_plugin("", "", "")
get_configsdir(filename,255)
format(filename,255,"%s/music/music.txt",filename)
}
__________________
If one of my plugins become broken, contact me by mail. [email protected]

Last edited by fxfighter; 09-05-2007 at 13:26.
fxfighter is offline
Send a message via MSN to fxfighter
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-05-2007 , 13:44   Re: FileLoad
Reply With Quote #6

Well, I will make something like :

Code:
    #include <amxmodx>     #include <amxmisc>         #define MAX_SOUND         10     // Max Sounds     #define MAX_FILE_LENGTH   196    // Max length for files + path.             new const g_filename[] = "/music/music.txt";         new         g_SndList[ MAX_SOUND ][ MAX_FILE_LENGTH ],         g_iCnt;         #define _charsmax(%1)  sizeof( %1 ) - 1     #define _is_wav(%1)    equali( %1[strlen( %1 ) - 4], ".wav" )         public plugin_init()     {         // [...]             load_file();     }         load_file()     {             new         //  - - - - - - - - - - - - -                 sConfigsDir[128],                 sFilename[196],         //      |                 sBuffer[256],                 iCnt;         //  - - - - - - - - - - - - -                         get_configsdir( sConfigsDir, _charsmax( sConfigsDir ) );             formatex( sFilename, _charsmax( g_filename ), "%s/%s", sConfigsDir, g_filename );                         new fp = fopen( sFilename, "rt" );             while( !feof( fp ) )             {                 // -- get a line                 fgets( fp, sBuffer, _charsmax( sBuffer ) );                                 // -- skip blank line and comment ';'                 if( strlen( sBuffer ) <= 2 || sBuffer[0] == ';' )                     continue;                                 // -- remove spaces                 trim( sBuffer );                                 // -- save sounds in array                 copy( g_SndList[ g_iCnt++ ], _charsmax( g_SndList ), sBuffer );                                 // -- precache file                 precache_file( sbuffer );             }             fclose( fp );     }         // _sound for .wav / _generic for .mp3 .     precache_file( sound[] )     {         _is_wav( sound ) ?             precache_sound( sound[6] ) :             precache_generic( sound );     }

One sound per line, without quotes, like :

sound/myfolder/mysound1.mp3
sound/mysound2.wav
sound/mysound3.mp3
__________________

Last edited by Arkshine; 09-05-2007 at 14:17.
Arkshine is offline
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 09-05-2007 , 13:56   Re: FileLoad
Reply With Quote #7

this load 5 pices of text right so if i want to use them
something like this?
Quote:
g_SndList[ 1][127];
for first and 2 for second?
like
Quote:
client_print(id,print_chat," Playing %s",g_SndList[ 1][127])
?sry for nwb questions
__________________
If one of my plugins become broken, contact me by mail. [email protected]
fxfighter is offline
Send a message via MSN to fxfighter
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-05-2007 , 14:02   Re: FileLoad
Reply With Quote #8

Update.

Just added a precache function. ;)

You can use .mp3 / .wav format.


To use sound :

client_print (id, print_chat, "Playing %s", g_SndList[x] ); ( x = 0 to MAX_SOUNDS - 1 )
__________________

Last edited by Arkshine; 09-05-2007 at 14:04.
Arkshine is offline
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 09-05-2007 , 14:03   Re: FileLoad
Reply With Quote #9

Thx allot +karma for you =)
one thing i dont wanna take your time but
Quote:
client_print (id, print_chat, "Playing %s", g_SndList[x] ); ( x = 0 to MAX_SOUNDS - 1 )
dont get how it works sry but i have a litle experiance.
but x = 0 to MAX_SOUNDS - 1 gives right number if what?
if what? is the question.
like is thare something i shuld now when i use it?
sry just think i am stupid now-.-
__________________
If one of my plugins become broken, contact me by mail. [email protected]

Last edited by fxfighter; 09-05-2007 at 14:14.
fxfighter is offline
Send a message via MSN to fxfighter
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-05-2007 , 14:15   Re: FileLoad
Reply With Quote #10

Be careful if you planned to use .mp3 and .wav sounds.

for exemple, if you want to play a random sound, you can do like :

Code:
    play_sound()     {         new         //  - - - - - - - - - - - - - - - - -                 CurSnd[ MAX_FILE_LENGTH ],                 rand  = random( g_iCnt );         //  - - - - - - - - - - - - - - - - -             copy( CurSnd, MAX_FILE_LENGTH - 1, g_SndList[ rand ] );             _is_wav( CurSnd ) ?                 format( CurSnd, MAX_FILE_LENGTH - 1, "spk %s", CurSnd[6] ) :                 format( CurSnd, MAX_FILE_LENGTH - 1, "mp3 play %s", CurSnd );             client_cmd( 0, "%s", CurSnd );     }
__________________
Arkshine is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode