AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with my song script (https://forums.alliedmods.net/showthread.php?t=11705)

DemonicFuzzball 03-26-2005 18:57

Need help with my song script
 
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

XxAvalanchexX 03-26-2005 23:30

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")  }

DemonicFuzzball 03-27-2005 11:58

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.


All times are GMT -4. The time now is 09:54.

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