Raised This Month: $ Target: $400
 0% 

Need help with my song script


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DemonicFuzzball
Junior Member
Join Date: Jun 2004
Old 03-26-2005 , 18:57   Need help with my song script
Reply With Quote #1

Hey everyone, this is my first script, and my goal was ot have a song play everytime the round starts. So far, it works, but some people don't want it to play every round, so I was wondering how I could go about doing this without making 32 cvars, one for each player.
This is the script as of right now:
Quote:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

public plugin_init()
{
register_plugin("Theme Music Player", "0.1", "Demonic")
register_cvar("play_song","1")
register_logevent("play_theme_song",2,"0=Worl d triggered","1=Round_Start")
}

public play_theme_song()
{
if(get_cvar_num("play_song") == 0)
{
return PLUGIN_HANDLED
}
client_print(0,print_chat,"Welcome to *Team-@[CoDc] Clan Server. Got POONED?")
client_cmd(0,"spk misc/CDC2562.wav")
return PLUGIN_HANDLED
}
public plugin_precache()
{
precache_sound("misc/CDC2562.wav")
return PLUGIN_CONTINUE
}
Thanks A Lot!
- Demonic
DemonicFuzzball is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-26-2005 , 23:30  
Reply With Quote #2

Variables! Arrays in this case.

Code:
 #include <amxmodx>  #include <amxmisc>  #include <cstrike>  new song_on[33] = { 1, ... };  public plugin_init()  {     register_plugin("Theme Music Player", "0.1", "Demonic")     register_cvar("play_song","1")     register_logevent("play_theme_song",2,"0=World triggered","1=Round_Start")     register_clcmd("say /song","cmdSong")  }  public cmdSong(id)  {     if(song_on[id] == 0)     {         song_on[id] = 1         client_print(id,print_chat,"* You will now hear the song on round start")     }     else     {         song_on[id] = 0         client_print(id,print_chat,"* You will no longer hear the song on round start")     }     return PLUGIN_HANDLED  }  // reset variables when user leaves  public client_disconnect(id)  {     song_on[id] = 1;  }  public play_theme_song()  {     if(get_cvar_num("play_song") == 0)     {         return PLUGIN_HANDLED     }     new players[32], num, i     get_players(players,num)     for(i=0;i<num;i++)     {         new player = players[i]         if(song_on[player] == 1) {             client_cmd(id,"spk misc/CDC2562.wav")         }     }     client_print(0,print_chat,"Welcome to *Team-@[CoDc] Clan Server. Got POONED?")     return PLUGIN_HANDLED  }  public plugin_precache()  {     precache_sound("misc/CDC2562.wav")  }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
DemonicFuzzball
Junior Member
Join Date: Jun 2004
Old 03-27-2005 , 11:58  
Reply With Quote #3

Thanks Avalanche, that works great, but for some reason, the song_on resets every other round or so.
For example, the first round i type /song so next round i dont hear it, but the round AFTER that it plays again. I can't seem to find what does that tho. Perhaps its the client_disconnect method, but iono, i can't find nething that sets it to 1...

*EDIT: Nvm, it was an error on ym part, it works now.
DemonicFuzzball is offline
Reply


Thread Tools
Display Modes

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 09:54.


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