AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Precache in spawn function? (https://forums.alliedmods.net/showthread.php?t=220210)

Randomize 07-08-2013 09:54

Precache in spawn function?
 
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? :D I know if shoot sounds are client.

naven 07-08-2013 17:21

Re: Precache in spawn function?
 
Code?

fysiks 07-08-2013 19:17

Re: Precache in spawn function?
 
All precaching has to be done in plugin_precache().

Randomize 07-09-2013 01:02

Re: Precache in spawn function?
 
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?

ConnorMcLeod 07-09-2013 04:44

Re: Precache in spawn function?
 
Full code ? Also you may call forward_return(FMV_CELL, 0) before to return supercede

Randomize 07-09-2013 09:32

Re: Precache in spawn function?
 
Connor, here is the full code :D
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;



ConnorMcLeod 07-09-2013 10:18

Re: Precache in spawn function?
 
Dont unregister it, and use forward_return

Randomize 07-10-2013 02:41

Re: Precache in spawn function?
 
Thank you for your advice, Connor. :D
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.

ConnorMcLeod 07-10-2013 04:15

Re: Precache in spawn function?
 
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.

Randomize 07-10-2013 04:29

Re: Precache in spawn function?
 
Oh, :okayface thank you.


All times are GMT -4. The time now is 06:29.

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