Raised This Month: $ Target: $400
 0% 

Problem precaching + reading file.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 01-14-2007 , 22:55   Problem precaching + reading file.
Reply With Quote #1

Hi, I am trying to have my plugin read a sound filename from a file, then precache that sound.

Here is the code:
Code:
new saveFile[128]; new configsDir[128]; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     get_configsdir(configsDir, 127);     format(saveFile, 127, "%s/mpn.ini", configsDir); } public plugin_precache() {     new file = fopen(saveFile, "r");     new data[256];         if(file) {         while(!feof(file)) {             fgets(file, data, 255); // Get the current line                         // Break the line into 2 parts, get the 2nd part and rem quotes             new left[128], right[128];             strbreak(data, left, 127, right, 127);             remove_quotes(right);                         new output[128];             if(containi(right, ".wav") > -1) {                 // Precache wav file                 format(output, 127, "themes/%s", right);                 precache_sound(output);             } else if(containi(right, ".mp3") > -1) {                 // Precache mp3 file                 format(output, 127, "sound/themes/%s", right);                 precache_generic(output);             }         }     }     fclose(file); }

Here is the file it's reading from (note the steam ids are for other parts of the plugin):
Quote:
"STEAM_xxxxxxx" "testwav.wav"
"STEAM_xxxxx" "testmp3.mp3"
hlstriker is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-14-2007 , 23:51   Re: Problem precaching + reading file.
Reply With Quote #2

Move this to the first line of plugin_precache.

Code:
    get_configsdir(configsDir, 127);     format(saveFile, 127, "%s/mpn.ini", configsDir);


The reason why is because plugin_precache is called before plugin_init.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 01-14-2007 , 23:57   Re: Problem precaching + reading file.
Reply With Quote #3

Thanks, can you also tell me if there is something wrong with this code below? I think it is crashing my server...

Code:
public client_connect(id) {     // Check to see the clients connection status     new connectCheckNum = 0;     while(connectCheckNum == 0) {         if(is_user_connecting(id) == 1) {             // Do nothing         } else if(is_user_connected(id) == 1) {             connectCheckNum = 1;         } else {             return PLUGIN_HANDLED;         }     }         client_print(0, print_chat, "A player just connected fully...");     // Do more below... }
hlstriker is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-15-2007 , 00:02   Re: Problem precaching + reading file.
Reply With Quote #4

Inifinite loop.


Code:
new connectCheckNum = 0;     while(connectCheckNum == 0) {

connectCheckNum will always = 0. So it will always execute.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 01-15-2007 , 00:03   Re: Problem precaching + reading file.
Reply With Quote #5

Once the player connects fully though it sets to 1 though, right?

Code:
        } else if(is_user_connected(id) == 1) {             connectCheckNum = 1;

How can I fix this?
hlstriker is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-15-2007 , 00:06   Re: Problem precaching + reading file.
Reply With Quote #6

You should use client_putinserver. It the same as what you are doing.

edit:

Also i'm not sure why you are trying to detect when they are fully joined the server but client_putinserver forward is what you need if you are trying to do that. When client_putinserver is execute they are about to initializing screen I believe.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 01-15-2007 , 00:10   Re: Problem precaching + reading file.
Reply With Quote #7

EDIT:
Alright it's all fixed except now even if the user has the file being precached it will try and make them download it anyway. Then it doesn't get past downloading and verifying resources when connecting to the server.

Can anyone help with this?

Last edited by hlstriker; 01-15-2007 at 00:53.
hlstriker is offline
Reply


Thread Tools
Display Modes

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 22:29.


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