Raised This Month: $51 Target: $400
 12% 

Precache in spawn function?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-08-2013 , 09:54   Precache in spawn function?
Reply With Quote #1

I'm trying to unprecache shoot sounds but I can't connect to the server, it said: Precache can only be done in spawn functions. Can I remove that? I know if shoot sounds are client.

Last edited by Randomize; 07-08-2013 at 09:57. Reason: Grammar
Randomize is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 07-08-2013 , 17:21   Re: Precache in spawn function?
Reply With Quote #2

Code?
__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-08-2013 , 19:17   Re: Precache in spawn function?
Reply With Quote #3

All precaching has to be done in plugin_precache().
__________________
fysiks is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-09-2013 , 01:02   Re: Precache in spawn function?
Reply With Quote #4

naven,
PHP Code:
if (equal(sound"weapons/ak47-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/ak47-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/aug-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/awp1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/deagle-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/deagle-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/elite_fire.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/famas-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/famas-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/fiveseven-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/g3sg1-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/galil-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/galil-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/m4a1_unsil-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/m4a1_unsil-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/m249-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/m249-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/mac10-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/mp5-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/mp5-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/p90-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/p228-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/scout_fire-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/sg550-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/sg552-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/sg552-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/tmp-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/tmp-2.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/ump45-1.wav")) return FMRES_SUPERCEDE
    
if (equal(sound"weapons/xm1014-1.wav")) return FMRES_SUPERCEDE
    
return FMRES_IGNORED
fysiks, even unprecache?
Randomize is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-09-2013 , 04:44   Re: Precache in spawn function?
Reply With Quote #5

Full code ? Also you may call forward_return(FMV_CELL, 0) before to return supercede
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-09-2013 , 09:32   Re: Precache in spawn function?
Reply With Quote #6

Connor, here is the full code
PHP Code:
public plugin_init()
{
    
register_plugin("No Radio""0.0.1""wbyokomo")
    
register_forward(FM_PrecacheSound"OnFwPrecacheSound")
}
public 
plugin_precache()
{
    
register_forward(FM_PrecacheSound"OnFwPrecacheSound")
}

public 
OnFwPrecacheSound(sound[])
{
    if (
equal(sound"weapons/ak47-1.wav"))
    {
        
forward_return(FMV_CELL0)
        return 
FMRES_SUPERCEDE
    
}
    if (
equal(sound"weapons/ak47-2.wav"))
    {
        
forward_return(FMV_CELL0)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED;


Last edited by Randomize; 07-10-2013 at 03:26. Reason: Oopss
Randomize is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-09-2013 , 10:18   Re: Precache in spawn function?
Reply With Quote #7

Dont unregister it, and use forward_return
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-10-2013 , 02:41   Re: Precache in spawn function?
Reply With Quote #8

Thank you for your advice, Connor.
EDIT: previous post, the code didn't work. Well, Arkshine's post said if forward_return(FMV_CELL, 0) doesn't work for shoot sounds.

Last edited by Randomize; 07-10-2013 at 03:37.
Randomize is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-10-2013 , 04:15   Re: Precache in spawn function?
Reply With Quote #9

If your aim is to block sounds from being played, it won't work because all is proceeded client side.
You need to block PlaybackEvent from being called.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-10-2013 , 04:29   Re: Precache in spawn function?
Reply With Quote #10

Oh, kayface thank you.
Randomize 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 20:47.


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