PauliusZZ Administratorius
Pranešimų skaičius : 70 Reputacija : 2 Join date : 2010-08-29
| Temos pavadinimas: [PAMOKA] Muzika serveryje. Rugsėjis 5th 2010, 17:30 | |
| Ši pamoka išmokis jus sukurti ir redaguoti muzikos pluginą.
Jai tyngit lipdyt pluginą tai siūskitės iš Čia
Viską padare dainas dedam pagal pavizdį - Citata :
- sound/Pavizdys/Daina1.mp3
O jai netyngit pradedam!
Moduliai:
- Kodas:
-
#include <amxmodx> #include <amxmisc> Defainai:
- Kodas:
-
#define PLUGIN "Muzika" #define VERSION "1.0" #define AUTHOR "Autorius" Variablai:
- Kodas:
-
new listening[33] new g_Maxplayers Constai:
- Kodas:
-
new const music[][] = { "sound/Pavizdys/Daina1.mp3", "sound/Pavizdys/Daina2.mp3", "sound/Pavizdys/Daina3.mp3", "sound/Pavizdys/Daina4.mp3" }
new const Float:music_lenght[] = { 226.0, 206.0, 169.0, 226.0 }
Init:
- Kodas:
-
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_logevent("logevent_round_start", 2, "1=Round_Start") register_logevent("logevent_round_end", 2, "1=Round_End"); g_Maxplayers = get_maxplayers( );
register_clcmd("say /sustabdyti","stop") register_clcmd("say_team /sustabdyti","stop") register_clcmd("say /groti","play") register_clcmd("say_team /groti","play") }
Groti/stabdyti
- Kodas:
-
public stop(Client) { client_cmd(Client, "mp3 stop"); if (task_exists(Client)) remove_task(Client); listening[Client] = 0; }
public play(id) { if(!listening[id]) { new abc = random_num(0,sizeof music - 1) client_cmd(id, "mp3 play %s", music[abc]) listening[id] = 1 set_task(music_lenght[abc],"stop",id) } else { client_print(id,print_chat,"Tu jau klausai!") } }
Precache:
- Kodas:
-
public plugin_precache() { for(new i = 0; i < sizeof music; i++) precache_generic(music[i]) }
Pridedam dar šitą:
- Kodas:
-
public logevent_round_start() { client_cmd(0, "mp3 play %s", music[random_num(0,sizeof music - 1)]) }
public logevent_round_end() { for (new id = 1; id < g_Maxplayers; id++) { if (is_user_connected(id)) { client_cmd(id, "mp3 stop"); listening[id] = 0;
if (task_exists(id)) remove_task(id); } } }
public client_disconnect(id) { listening[id] = 0 if(task_exists(id)) remove_task(id) }
| |
|