AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   FileLoad (https://forums.alliedmods.net/showthread.php?t=60508)

fxfighter 09-05-2007 12:37

FileLoad
 
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)
 }
}


Arkshine 09-05-2007 13:13

Re: FileLoad
 
What do you want to do exactly ?!

Provide more informations, please.

fxfighter 09-05-2007 13:16

Re: FileLoad
 
load some info frome a doc at connect
strings

Arkshine 09-05-2007 13:20

Re: FileLoad
 
Ok.

How is formatted your file ?! (filename)

One sound per line ?

fxfighter 09-05-2007 13:23

Re: FileLoad
 
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)
}

Arkshine 09-05-2007 13:44

Re: FileLoad
 
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

fxfighter 09-05-2007 13:56

Re: FileLoad
 
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

Arkshine 09-05-2007 14:02

Re: FileLoad
 
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 )

fxfighter 09-05-2007 14:03

Re: FileLoad
 
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-.-

Arkshine 09-05-2007 14:15

Re: FileLoad
 
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 );     }


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

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