AlliedModders

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

rrduna 11-26-2010 21:17

ThunderClap
 
Want to know how a public event to random sounds of thunder,
event like the thunderclap of the Zombie Plague Mod
If unable to understand perfectly, I want a plugin that performs random sounds of thunder during the game.

I tried writing it did not get more, it is very difficult.
Look, what I did was more or less this:



PHP Code:

public thunderclap(){
    
ArrayGetString(sound_thunderrandom_num(0ArraySize(sound_thunder) - 1), soundcharsmax(sound))
    
PlaySound(sound)



r4ndomz 11-26-2010 22:34

Re: ThunderClap
 
PHP Code:

public Thunderclap(id)
{
    
ArrayGetString(sound_thunderrandom_num(0ArraySize(sound_thunder) - 1), soundcharsmax(sound))
    
PlaySound(sound);

    
set_taskrandom_float30.0,  90.0 ), "Thunderclap");


That might work. The fact that set_task is in the function kinda scares me, but you said public event, not sure if you wanted it to be one function.

rrduna 11-27-2010 07:36

Re: ThunderClap
 
It did not work. Now what do I do?

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Plugin Name"
#define VERSION "1.0"
#define AUTHOR "AMXX-Studio"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
Thunderclap(id){
    
ArrayGetString(sound_thunderrandom_num(0ArraySize(sound_thunder) - 1), soundcharsmax(sound))
    
PlaySound(sound);
    
    
set_taskrandom_float30.0,  90.0 ), "Thunderclap");



abdul-rehman 11-27-2010 08:55

Re: ThunderClap
 
Quote:

Originally Posted by rrduna (Post 1357715)
It did not work. Now what do I do?

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Plugin Name"
#define VERSION "1.0"
#define AUTHOR "AMXX-Studio"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
Thunderclap(id){
    
ArrayGetString(sound_thunderrandom_num(0ArraySize(sound_thunder) - 1), soundcharsmax(sound))
    
PlaySound(sound);
    
    
set_taskrandom_float30.0,  90.0 ), "Thunderclap");



:arrow:
Code:
#include <amxmodx> new const sound_thunder[] = "the_thunder_clap_sound.wav" public plugin_init() register_plugin("What", "0.0000.0.1", "No oNe :P")     set_task( random_float( 30.0,  60.0 ), "Thunderclap") public plugin_precache() precache_sound( sound_thunder ) public Thunderclap() client_cmd(0, "spk ^"%s^"", sound_thunder)     set_task( random_float( 30.0,  60.0 ), "Thunderclap")

rrduna 11-27-2010 09:37

Re: ThunderClap
 
thanks! :D

how do I add a cvar to set the run time of sound?

r4ndomz 11-27-2010 10:40

Re: ThunderClap
 
Quote:

Originally Posted by rrduna (Post 1357815)
thanks! :D

how do I add a cvar to set the run time of sound?

PHP Code:

#include <amxmodx>

new pcvar_thundertime1
new pcvar_thungertime2
new const sound_thunder[] = "the_thunder_clap_sound.wav"

public plugin_init()
{
    
register_plugin("What""0.0000.0.1""No oNe :P")
    
set_taskrandom_float30.0,  60.0 ), "Thunderclap")
    
pcvar_thundertime1 register_cvar("amx_thundertime1""30.0")
    
pcvar_thundertime2 register_cvar("amx_thundertime2""60.0")
}

public 
plugin_precache()
{
    
precache_soundsound_thunder )
}

public 
Thunderclap() client_cmd(0"spk ^"%s^""sound_thunder)
{
    
set_taskrandom_floatget_pcvar_num(pcvar_thundertime1), get_pcvar_num(pcvar_thundertime2), "Thunderclap")



EDIT: Fixed a mistake in code that i just noticed

rrduna 11-27-2010 11:35

Re: ThunderClap
 
because two cvars?

nikhilgupta345 11-27-2010 12:32

Re: ThunderClap
 
Because if you look at ThunderClap(), the set task is called with a random float between the two cvars, so it actually seems random. You can change them to be the same if you want, which will force it to happen at exact intervals.

rrduna 11-27-2010 12:37

Re: ThunderClap
 
thanks! :D

rrduna 11-27-2010 13:24

Re: ThunderClap
 
how can I add the sky "space" in scripting?
is there any way to increase the time of light?
the time of light emitted is minimal, very little, one second I think.

help me please!


PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new const PLUGIN   [] = "Thunderclap"
new const VERSION  [] = "1.0"
new const AUTHOR   [] = "Duna"

#define TASKID1 1324687358 

new thunder_sounds[][] = 
{
    
"thunderclap/thunder_clap1",
    
"thunderclap/thunder_clap2"
}

public 
plugin_init() {
    
register_plugin(PLUGIN,VERSION,AUTHOR)
    
set_taskrandom_float30.0,  60.0 ), "thunderclap")
    return 
PLUGIN_CONTINUE;
}

public 
client_putinserver(id){ 
    if(
is_user_bot(id)) 
    return
    
    if(!
task_exists(TASKID1))
    { 
    
Restore_LightStyle() 

}

public 
thunderclap() { 
    
client_cmd(0,"spk %s",thunder_sounds[random(sizeof thunder_sounds)]);
    
set_taskrandom_float30.0,  60.0 ), "thunderclap")
    
    
engfunc(EngFunc_LightStyle0"z")
    if(
task_exists(TASKID1))
    {
    
remove_task(TASKID1
    }
    
set_task(0.4"Restore_LightStyle"TASKID1
    return 
FMRES_HANDLED
}

public 
Restore_LightStyle() {
    
engfunc(EngFunc_LightStyle0"m")
}

public 
plugin_precache() {
    
precache_sound("thunderclap/thunder_clap1.wav");
    
precache_sound("thunderclap/thunder_clap2.wav");




All times are GMT -4. The time now is 11:18.

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