Raised This Month: $ Target: $400
 0% 

Subplugin Submission [ZP] Extra-item: Silent Hill Radio


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 08-02-2009 , 01:01   Re: [ZP] Extra-item: Silent Hill Radio
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <zombieplague>

#define XPOS -1.0
#define YPOS -1.0
new mindistance[33]
new 
dist[33]
new 
is_radio_on[33] = 0
new player_has_radio[33]

new 
sound_noise[4][] =
{
    
"zombie_plague/shradio/18000.wav",
    
"zombie_plague/shradio/18001.wav",
    
"zombie_plague/shradio/18002.wav",
    
"zombie_plague/shradio/18003.wav"
}

public 
plugin_precache()
{
    for (new 
04i++)
        
precache_sound(sound_noise[i])
}

public 
plugin_init()
{
    
register_plugin("[ZP] Silent hill radio""1.0""HoRRoR")
    
register_clcmd("say /radio","radio_button")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
}

public 
client_connect(id)
{
    
player_has_radio[id] = 1
}

public 
radio_button(id)
{
    new 
text[100]
    if (
is_radio_on[id] != && player_has_radio[id] != 0)
    {
        if (
is_user_alive(id) && !zp_get_user_zombie(id) && !zp_get_user_nemesis(id))
        {
            
format(text,99,"^x04[ZP]^x01 Radio switched ^x03ON"
            
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
            
write_byte(id
            
write_string(text
            
message_end()
            
set_task(5.0,"check_radio",id,_,_,"b")
            
is_radio_on[id] = 1
        
}
    }
    else if (
is_radio_on[id] == && player_has_radio[id] != 0)
        {
            
format(text,99,"^x04[ZP]^x01 Radio switched ^x03OFF"
            
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
            
write_byte(id
            
write_string(text
            
message_end()
            
remove_task(id)
            
remove_task(id+100)
            
is_radio_on[id] = 0
        
}
    return 
PLUGIN_HANDLED;
}

public 
check_radio(id)
{
    
mindistance[id] = 8192
    dist
[id] = 8190

    
for (new 1<= get_maxplayers(); i++)
    {
        if (
zp_get_user_zombie(i) && is_valid_ent(i))
            
dist[id] = get_entity_distance(idi)
    
        if (
dist[id] < mindistance[id])
        {
            
mindistance[id] = dist[id]
        }
    }
    
//    client_print(id,print_chat,"[DEBUG] Distance is: %d", mindistance[id])
    
    
if (mindistance[id] < 300)
        
emit_sound(idCHAN_AUTOsound_noise[3], 1.0ATTN_NORM0PITCH_NORM)
    else if (
mindistance[id] >= 300 && mindistance[id] < 450)
        
emit_sound(idCHAN_AUTOsound_noise[2], 1.0ATTN_NORM0PITCH_NORM)
    else if (
mindistance[id] >= 450 && mindistance[id] < 600)
        
emit_sound(idCHAN_AUTOsound_noise[1], 1.0ATTN_NORM0PITCH_NORM)
    else if (
mindistance[id] >= 600)
        
emit_sound(idCHAN_AUTOsound_noise[0], 1.0ATTN_NORM0PITCH_NORM)
    
    
set_task(0.15,"hud_radio_wave1",id+100)
    
set_task(0.30,"hud_radio_wave2",id+100)
    
set_task(0.45,"hud_radio_wave3",id+100)
}


public 
hud_radio_wave1(taskid)
{
    new 
id
    id 
taskid 100;
    
set_hudmessage(200200200XPOSYPOS00.50.00.00.5, -1)
    
show_hudmessage(id"(            )")
}

public 
hud_radio_wave2(taskid)
{
    new 
id
    id 
taskid 100;
    
set_hudmessage(200200200XPOSYPOS00.50.00.00.5, -1)
    
show_hudmessage(id"(               )")
}

public 
hud_radio_wave3(taskid)
{
    new 
id
    id 
taskid 100;
    
set_hudmessage(200200200XPOSYPOS00.50.00.00.5, -1)
    
show_hudmessage(id"(                  )")
}

public 
zp_user_infected_post(id)
{
    if (
player_has_radio[id] != 0)
    {
        new 
text[100]
        
format(text,99,"^x04[ZP]^x01 Radio switched ^x03OFF"
        
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
        
write_byte(id
        
write_string(text
        
message_end()
        
remove_task(id)
        
remove_task(id+100)
        
is_radio_on[id] = 0
        player_has_radio
[id] = 0
    
}
}

public 
fw_PlayerKilled(id)
{    
    if (
player_has_radio[id] != 0)
    {
        new 
text[100]
        
format(text,99,"^x04[ZP]^x01 Radio switched ^x03OFF"
        
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
        
write_byte(id
        
write_string(text
        
message_end()
        
remove_task(id)
        
remove_task(id+100)
        
is_radio_on[id] = 0
        player_has_radio
[id] = 0
    
}

@spraypa1nt: Try this ..Not tested
__________________

Last edited by 5c0r-|3i0; 08-14-2009 at 05:54. Reason: >"<
5c0r-|3i0 is offline
Satoko
Senior Member
Join Date: Oct 2008
Location: Germany
Old 08-08-2009 , 12:24   Re: [ZP] Extra-item: Silent Hill Radio
Reply With Quote #2

5c0r-|3i0 don't work. it only works for one round it seems after that you can't activate it with /radio or deactivate it with it. don't hear sounds then.
__________________


Last edited by Satoko; 08-08-2009 at 12:28.
Satoko is offline
HoRRoR [CSM]
Member
Join Date: May 2009
Old 08-08-2009 , 13:22   Re: [ZP] Extra-item: Silent Hill Radio
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <zombieplague>

#define XPOS -1.0
#define YPOS -1.0
new mindistance[33]
new 
dist[33]
new 
is_radio_on[33] = 0

new sound_noise[4][] =
{
    
"zombie_plague/shradio/18000.wav",
    
"zombie_plague/shradio/18001.wav",
    
"zombie_plague/shradio/18002.wav",
    
"zombie_plague/shradio/18003.wav"
}

public 
plugin_precache()
{
    for (new 
04i++)
        
precache_sound(sound_noise[i])
}

public 
plugin_init()
{
    
register_plugin("[EXODUS] Silent hill radio (not extra-item)""1.1""HoRRoR")
    
register_clcmd("say /radio","radio_button")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
}

public 
radio_button(id)
{
    if (
is_radio_on[id] != 1)
    {
        if (
is_user_alive(id) && !zp_get_user_zombie(id) && !zp_get_user_nemesis(id))
        {
            
MsgChat(id,MSG_ONE,"^x04[EXODUS]^x01 Radio switched ^x03ON")
            
set_task(5.0,"check_radio",id,_,_,"b")
            
is_radio_on[id] = 1
        
}
    }
    else if (
is_radio_on[id] == 1)
        {
            
MsgChat(id,MSG_ONE,"^x04[EXODUS]^x01 Radio switched ^x03OFF")
            
remove_task(id)
            
remove_task(id+100)
            
is_radio_on[id] = 0
        
}
    return 
PLUGIN_HANDLED;
}

public 
check_radio(id)
{
    
mindistance[id] = 8192
    dist
[id] = 8190

    
for (new 1<= get_maxplayers(); i++)
    {
        if (
zp_get_user_zombie(i) && is_valid_ent(i))
            
dist[id] = get_entity_distance(idi)
    
        if (
dist[id] < mindistance[id])
        {
            
mindistance[id] = dist[id]
        }
    }
    
//    client_print(id,print_chat,"[DEBUG] Distance is: %d", mindistance[id])
    
    
if (mindistance[id] < 300)
        
emit_sound(idCHAN_AUTOsound_noise[3], 1.0ATTN_NORM0PITCH_NORM)
    else if (
mindistance[id] >= 300 && mindistance[id] < 450)
        
emit_sound(idCHAN_AUTOsound_noise[2], 1.0ATTN_NORM0PITCH_NORM)
    else if (
mindistance[id] >= 450 && mindistance[id] < 600)
        
emit_sound(idCHAN_AUTOsound_noise[1], 1.0ATTN_NORM0PITCH_NORM)
    else if (
mindistance[id] >= 600)
        
emit_sound(idCHAN_AUTOsound_noise[0], 1.0ATTN_NORM0PITCH_NORM)
    
    
set_task(0.15,"hud_radio_wave1",id+100)
    
set_task(0.30,"hud_radio_wave2",id+100)
    
set_task(0.45,"hud_radio_wave3",id+100)
}


public 
hud_radio_wave1(taskid)
{
    new 
id
    id 
taskid 100;
    
set_hudmessage(200200200XPOSYPOS00.50.00.00.5, -1)
    
show_hudmessage(id"(            )")
}

public 
hud_radio_wave2(taskid)
{
    new 
id
    id 
taskid 100;
    
set_hudmessage(200200200XPOSYPOS00.50.00.00.5, -1)
    
show_hudmessage(id"(               )")
}

public 
hud_radio_wave3(taskid)
{
    new 
id
    id 
taskid 100;
    
set_hudmessage(200200200XPOSYPOS00.50.00.00.5, -1)
    
show_hudmessage(id"(                  )")
}

public 
zp_user_infected_post(id)
{
    if (
is_radio_on[id] == 1)
    {
        
MsgChat(id,MSG_ONE,"^x04[EXODUS]^x01 Radio switched ^x03OFF")
        
remove_task(id)
        
remove_task(id+100)
        
is_radio_on[id] = 0
    
}
}

public 
fw_PlayerKilled(id)
{    
    if (
is_radio_on[id] == 1)
    {
        
MsgChat(id,MSG_ONE,"^x04[EXODUS]^x01 Radio switched ^x03OFF")
        
remove_task(id)
        
remove_task(id+100)
        
is_radio_on[id] = 0
    
}
}

stock MsgChat(idmsgtypetext[], any:...)
{
    
message_begin(msgtype,get_user_msgid("SayText"),{0,0,0},id
    
write_byte(id
    
write_string(text
    
message_end()

optimized code and it's work

Last edited by HoRRoR [CSM]; 08-08-2009 at 14:38.
HoRRoR [CSM] is offline
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 08-09-2009 , 01:50   Re: [ZP] Extra-item: Silent Hill Radio
Reply With Quote #4

@Satoko: Sorry . I remake it in 5 minutes ... NO time to test ...I just didn't enable when round start...Re-enable the radio again ....Sorry sorry .
5c0r-|3i0 is offline
hajani
Junior Member
Join Date: Jul 2009
Location: Hungary
Old 10-20-2009 , 13:36   Re: [ZP] Extra-item: Silent Hill Radio
Reply With Quote #5

Could you make it to "refresh" the radio faster?
Thank you in advance.

Last edited by hajani; 10-20-2009 at 13:57.
hajani is offline
tempito
Senior Member
Join Date: Feb 2009
Location: Peru
Old 10-20-2009 , 14:55   Re: [ZP] Extra-item: Silent Hill Radio
Reply With Quote #6

Yup, that is the big problem of this plugin.
__________________
My very first zp server movie.
http://www.youtube.com/watch?v=yvTmlFr_Y-4 <- now with translation in english

tempito is offline
hajani
Junior Member
Join Date: Jul 2009
Location: Hungary
Old 10-20-2009 , 15:57   Re: [ZP] Extra-item: Silent Hill Radio
Reply With Quote #7

I've edited the plugin so it refreshes the radio every 1 sec.
(Maybe this is not the best/not an acceptable way to do that, so if anyone could show me how to do this "nicely" i would be very happy )
Attached Files
File Type: sma Get Plugin or Get Source (zp_extraitem_silent_hill_radio.sma - 463 views - 6.9 KB)

Last edited by hajani; 10-20-2009 at 16:23.
hajani is offline
brirneyspier
New Member
Join Date: Jul 2012
Old 07-06-2012 , 00:11   Re: [ZP] Extra-item: Silent Hill Radio
Reply With Quote #8

Some one Help me!
brirneyspier 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 15:43.


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