AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help wid... half-life original sounds (https://forums.alliedmods.net/showthread.php?t=19391)

[ --<-@ ] Black Rose 10-15-2005 19:30

help wid... half-life original sounds
 
wich one of these is called first?
plugin_precache() or client_connect()
it sounds like it should be client_connect() but im not sure...

Brad 10-15-2005 19:41

plugin_precache is called long before client_connect. precache is called right about the time the plugin is initializing, in other words, at the start of a map. connect is called when a player connects to the server, in other words, after the map has started.

[ --<-@ ] Black Rose 10-15-2005 19:55

okey... this is the code...
Code:
#include <amxmodx> #define MAXSOUNDS 2 new soundlist[MAXSOUNDS][] = {"Prologue","Nightwish"} new i public precache() {     i = random_num(0,MAXSOUNDS-1)     if (i == 0) {         precache_sound("mp3/Prologue.mp3")     }     if (i == 1) {         precache_sound("mp3/Nightwish.mp3")     } } public client_connect(id) {     client_cmd(id,"mp3 play mp3/%s",soundlist[i])     return PLUGIN_CONTINUE } public plugin_init() {     register_plugin("ConnectSound","1.0","[ --<-@ ]") }
if i put this in plugin_precache()
Code:
i = random_num(0,MAXSOUNDS-1)
"i" would be assigned the same number in client_connect() that it had from plugin_precache() so it plays the same song as precached? right?


and there another way to make the plugin play the sounds when the user is dling stuff... so if i do like this...
Code:
#include <amxmodx> #define MAXSOUNDS 2 new soundlist[MAXSOUNDS][] = {"Prologue","Nightwish"} public precache() {     new i     i = random_num(0,MAXSOUNDS-1)     {         if (i == 0) {             precache_sound("mp3/Prologue.mp3")         }         if (i == 1) {             precache_sound("mp3/Nightwish.mp3")         }     }     client_cmd(id,"mp3 play mp3/%s",soundlist[i]) } public plugin_init() {     register_plugin("ConnectSound","1.0","[ --<-@ ]") }
would the user hear the sound when they are downloading? would that work?

XxAvalanchexX 10-15-2005 20:59

plugin_precache is called when the plugin has to load everything. It is different than the client's precaching, which I believe is what you are trying to catch. Try it on client_authorized.

[ --<-@ ] Black Rose 10-15-2005 21:09

okaaaay
i guess like this:
Code:
#include <amxmodx> #define MAXSOUNDS 2 new soundlist[MAXSOUNDS][] = {"Prologue","Nightwish"} new i public precache() {     i = random_num(0,MAXSOUNDS-1)     if (i == 0) {         precache_sound("mp3/Prologue.mp3")     }     if (i == 1) {         precache_sound("mp3/Nightwish.mp3")     } } public plugin_init() {     register_plugin("ConnectSound","1.0","[ --<-@ ]") } public client_authorized(id) {     client_cmd(id,"mp3 play mp3/%s",soundlist[i]) }

when exactly is that called... it says "when a player has authenticated with Steam" but i dont know what that is ;P

Brad 10-15-2005 21:17

Are you trying to have players hear music when they're connecting to your server? If so, why are you reinventing the wheel? This has already been done.

[ --<-@ ] Black Rose 10-15-2005 21:19

Quote:

Originally Posted by Brad
Are you trying to have players hear music when they're connecting to your server? If so, why are you reinventing the wheel? This has already been done.

I'm doing this to learn...
and where has this been done?
[offtopic] is it ur daughter on the pic? :)[/offtopic]

Zenith77 10-15-2005 22:10

It looks to me that this will not work for one major reason.

variable i is assigned to the function random_num() so every time ' i ' is called so is the function, which means that there is a 50% chance that it could play a song that is not precached.

[ --<-@ ] Black Rose 10-15-2005 22:16

aha... that was 1 of my questions b4 if the i has the same value as b4... well how should i fix this? :)

Zenith77 10-15-2005 22:17

Just precache both of them, then play a random song.


All times are GMT -4. The time now is 23:37.

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