-
-
Save JoinedSenses/f9b9f322c23c0210578ed73eff0dcca6 to your computer and use it in GitHub Desktop.
disc.Fork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sourcemod> | |
#include <sdktools> | |
#define PLUGIN_VERSION "1.5" | |
public Plugin:myinfo = | |
{ | |
name = "DISCO!!!", | |
author = "MitchDizzle_ (Fork by Alex Dragokas)", | |
description = "Mitch's Disco Mod!", | |
version = PLUGIN_VERSION, | |
url = "https://forums.alliedmods.net/showthread.php?t=180520" | |
} | |
/* ChangeLog | |
v1.1 | |
- Removed music looping | |
- Added alias !disco for !discomenu | |
- Added alias !music for !discomenu | |
v1.3 | |
- Added 'Play music for self' menu | |
* commands: | |
!discomenu - show disco menu (admin only) | |
!disco_reloadconfig - reloading configuration (admin only) | |
!stopmusic - will stop the music for client who typed this command | |
*/ | |
#define MAX_SONGS 512 | |
new String:song_name[MAX_SONGS][128]; | |
new String:song_path[MAX_SONGS][128]; | |
//new song_type[MAX_SONGS]; | |
new DiscoBall = -1; | |
new DiscoColor = 0; | |
new Handle:DiscoTimer = INVALID_HANDLE; | |
new Handle:SchemeTimer = INVALID_HANDLE; | |
//Cvars | |
new Handle:cCustomModel = INVALID_HANDLE; | |
new String:sCustomModel[128]; | |
new Handle:cZOffset = INVALID_HANDLE; | |
new Float:fZOffset = 0.0; | |
new Handle:cRotation = INVALID_HANDLE; | |
new Float:fRotation[3] = {11.25,...}; | |
new bool:bMusicPlaying[MAXPLAYERS]; | |
new bool:bTaceRayInProgress = false; | |
new bool:bDoStartBall = false; | |
new bool:bDoPlaySelf = false; | |
int BEAM_ALPHA = 10; | |
float BEAM_CREATION_SPEED = 0.2; | |
float BEAM_LIFETIME = 5.0; | |
float BEAM_WIDTH_START = 10.0; | |
float BEAM_WIDTH_END = 20.0; | |
float SCHEME_TIMER_SPEED = 2.0; | |
const COLOR_NUMBER = 12 ; | |
new const g_DefaultColors_c[COLOR_NUMBER][3] = { | |
{255,0,0}, // red | |
{128,0,0}, // maroon | |
{0,128,0}, // green | |
{0,255,0}, // lime | |
{0,0,255}, // blue | |
{255,255,0}, // yellow | |
{0,255,255}, // cyan | |
{255,0,255}, // fuchsia | |
{128,0,128}, // purple | |
{255,0,143}, // magenta | |
{146,0,10}, // sanguine | |
{255,128,0} // orange | |
}; | |
new const String:g_DefaultColors_p[COLOR_NUMBER][] = { | |
"materials/sprites/redglow1.vmt", | |
"materials/sprites/redglow1.vmt", | |
"materials/sprites/greenglow1.vmt", | |
"materials/sprites/blueglow1.vmt", | |
"materials/sprites/blueglow1.vmt", | |
"materials/sprites/yellowglow1.vmt", | |
"materials/sprites/glow1.vmt", | |
"materials/sprites/purpleglow1.vmt", | |
"materials/sprites/purpleglow1.vmt", | |
"materials/sprites/purpleglow1.vmt", | |
"materials/sprites/purpleglow1.vmt", | |
"materials/sprites/purpleglow1.vmt" | |
}; | |
new g_DefaultColors_s[COLOR_NUMBER]; | |
new g_sprite; | |
new count; | |
public OnPluginStart() | |
{ | |
CreateConVar("sm_disco_version", PLUGIN_VERSION, "Disco Mod Version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); | |
cCustomModel = CreateConVar("sm_disco_custommodel", "models/name_of_your_model.mdl", "Path to the Disco ball model."); | |
cZOffset = CreateConVar("sm_disco_zoffset", "0.0", "Offset on the Z global vector for the lights."); | |
cRotation = CreateConVar("sm_disco_rotation", "11.25 0.0 11.25", "Offset on the Z global vector for the lights."); | |
GetCvars(); | |
for (int i = 1; i < MAXPLAYERS; i++) | |
bMusicPlaying[i] = false; | |
//HookConVarChange(g_hcvarCustomModel, ConVarChanged_MDL); | |
AutoExecConfig(); | |
RegAdminCmd("sm_discomenu", Command_Disco, ADMFLAG_CUSTOM2); | |
RegAdminCmd("sm_disco", Command_Disco, ADMFLAG_CUSTOM2); | |
RegAdminCmd("sm_music", Command_Disco, ADMFLAG_CUSTOM2); | |
RegAdminCmd("sm_disco_reloadconfig", Command_ReloadDisco, ADMFLAG_ROOT); | |
RegConsoleCmd("say", Command_StopMusic); | |
RegConsoleCmd("say_team", Command_StopMusic); | |
LoadMusicconfig(); | |
HookEvent("round_end", RoundEnd); | |
} | |
GetCvars() | |
{ | |
GetConVarString(cCustomModel, sCustomModel, sizeof(sCustomModel)); | |
// if (!IsModelPrecached(sCustomModel)) | |
PrecacheModel(sCustomModel); | |
fZOffset = GetConVarFloat(cZOffset); | |
new String:BuffStr[24]; | |
GetConVarString(cRotation, BuffStr, sizeof(BuffStr)); | |
new String:items[3][8]; | |
ExplodeString(BuffStr, " ", items, 3, 8); | |
fRotation[0] = StringToFloat(items[0]); | |
fRotation[1] = StringToFloat(items[1]); | |
fRotation[2] = StringToFloat(items[2]); | |
} | |
public RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) | |
{ | |
StopTraceRay(); | |
} | |
public OnMapStart() | |
{ | |
GetCvars(); | |
// if (!IsModelPrecached("materials/sprites/laser.vmt")) | |
g_sprite = PrecacheModel("materials/sprites/laser.vmt", true); | |
PrecacheModel(sCustomModel, true); | |
for(new i = 0; i < COLOR_NUMBER; i++) | |
{ | |
// if (!IsModelPrecached(g_DefaultColors_p[i])) | |
g_DefaultColors_s[i] = PrecacheModel(g_DefaultColors_p[i], true); | |
} | |
StopTraceRay(); | |
} | |
public OnPluginEnd() | |
{ | |
DiscoTimer = INVALID_HANDLE; | |
SchemeTimer = INVALID_HANDLE; | |
if(IsDiscoBall(DiscoBall)) | |
{ | |
AcceptEntityInput( DiscoBall , "Kill" ); | |
DiscoBall = -1; | |
} | |
} | |
public OnMapEnd() | |
{ | |
DiscoTimer = INVALID_HANDLE; | |
SchemeTimer = INVALID_HANDLE; | |
} | |
public Action:Command_StopMusic(client, args) | |
{ | |
PrintToServer("Someone say in comsole, client: %i", client); | |
if (client <= 0 || client > MaxClients || !IsClientInGame(client)) | |
return (Plugin_Continue); | |
decl String:strMessage[128]; | |
GetCmdArgString(strMessage, sizeof(strMessage)); | |
PrintToServer("Message is %s", strMessage); | |
if(StrContains(strMessage, "stopmusic", false) != -1) | |
{ | |
DoUrl(client, "about:blank"); | |
bMusicPlaying[client] = false; | |
return (Plugin_Continue); | |
} else { | |
return (Plugin_Continue); | |
} | |
} | |
stock LoadMusicconfig() | |
{ | |
count = 0; | |
new Handle:kvs = CreateKeyValues("MusicConfig"); | |
decl String:sPaths[PLATFORM_MAX_PATH]; | |
BuildPath(Path_SM, sPaths, sizeof(sPaths),"configs/musicconfig.cfg"); | |
if(!FileToKeyValues(kvs, sPaths)) | |
{ | |
CloseHandle(kvs); | |
return; | |
} | |
if (!KvGotoFirstSubKey(kvs)) | |
{ | |
CloseHandle(kvs); | |
return; | |
} | |
count = 1; | |
do | |
{ | |
KvGetSectionName(kvs, song_name[count], 128); | |
KvGetString(kvs, "path", song_path[count], 128); | |
count++; | |
} while (KvGotoNextKey(kvs)); | |
count--; | |
CloseHandle(kvs); | |
return; | |
} | |
public Action:Command_Disco ( client , args ) | |
{ | |
Void_Menu_Disco(client); | |
return Plugin_Handled; | |
} | |
public Action:Command_ReloadDisco ( client , args ) | |
{ | |
LoadMusicconfig(); | |
GetCvars(); | |
PrintToChat(client, "\x03[\x04Disco\x03]\x01 конфиг. перезагружен!"); | |
return Plugin_Handled; | |
} | |
stock bool:IsDiscoBall(Ent=-1) | |
{ | |
if(Ent != -1) | |
{ | |
if(IsValidEdict(Ent) && IsValidEntity(Ent) && IsEntNetworkable(Ent)) | |
{ | |
decl String:ClassName[255]; | |
GetEdictClassname(Ent, ClassName, 255); | |
if(StrEqual(ClassName, "disco_ball")) | |
{ | |
return (true); | |
} | |
} | |
} | |
return (false); | |
} | |
StopBall(client) | |
{ | |
if(IsDiscoBall(DiscoBall)) | |
{ | |
AcceptEntityInput( DiscoBall , "Kill" ); | |
DiscoBall = -1; | |
DiscoTimer = INVALID_HANDLE; | |
SchemeTimer = INVALID_HANDLE; | |
} | |
} | |
StartBall(client, Float:Pos[3]) | |
{ | |
if(!IsDiscoBall(DiscoBall)) | |
{ | |
DiscoBall = CreateEntityByName("prop_dynamic_override"); | |
DispatchKeyValue(DiscoBall, "classname", "disco_ball"); | |
DispatchKeyValue(DiscoBall, "model", sCustomModel ); | |
DispatchKeyValue(DiscoBall, "solid", "0"); | |
DispatchSpawn( DiscoBall ); | |
TeleportEntity( DiscoBall, Pos, NULL_VECTOR, NULL_VECTOR ); | |
PrintToChatAll("\x03[\x04Disco\x03]\x05 %N\x01 начал дискотеку!!", client); | |
DiscoColor = 0; | |
SchemeTimer = CreateTimer(SCHEME_TIMER_SPEED, Timer_SchemeUpdate, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); | |
DiscoTimer = CreateTimer(BEAM_CREATION_SPEED, Timer_DiscoUpdate, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); | |
} | |
} | |
StopMusic(int client, bool Self = false) | |
{ | |
if (Self) { | |
DoUrl(client, "about:blank"); | |
} else { | |
if(count != 0) | |
{ | |
for(new x = 1; x <= MaxClients; x++) | |
{ | |
if(IsClientInGame(x)) | |
{ | |
DoUrl(x, "about:blank"); | |
} | |
bMusicPlaying[x] = false; | |
} | |
} | |
PrintToChatAll("\x03[\x04Disco\x03]\x05 %N\x01 выгнал Диджея!", client); | |
} | |
} | |
StartMusic(int client, int songindex = 0, bool bPlaySelf = false) | |
{ | |
{ | |
if(songindex!=0) | |
{ | |
if (bPlaySelf) | |
{ | |
DoUrl(client, "about:blank"); | |
DoUrl(client, song_path[songindex]); | |
bMusicPlaying[client] = true; | |
PrintToChat(client, "\x03[\x04Disco\x03]\x01 Песня: \x05%s\x01.", song_name[songindex]); | |
PrintToChat(client, "\x03[\x04Disco\x03]\x01 чтобы отключить музыку, введите \x05stopmusic\x01 в чате."); | |
} | |
else | |
{ | |
for(new x = 1; x <= MaxClients; x++) | |
{ | |
if(IsClientInGame(x)) | |
{ | |
DoUrl(x, song_path[songindex]); | |
bMusicPlaying[x] = true; | |
} | |
} | |
PrintToChatAll("\x03[\x04Disco\x03]\x01 Песня: \x05%s\x01.", song_name[songindex]); | |
PrintToChatAll("\x03[\x04Disco\x03]\x01 чтобы отключить музыку, введите \x05stopmusic\x01 в чате."); | |
} | |
} | |
} | |
} | |
StartDisco( client, Float:Pos[3] , songindex = 0 ) | |
{ | |
StartBall(client, Pos); | |
StartMusic(client, songindex, false); | |
} | |
StopDisco( client) | |
{ | |
StopBall(client); | |
StopMusic(client); | |
} | |
static Action:Timer_SchemeUpdate(Handle:timer) | |
{ | |
const float BeamCreationSpeed_Min = 0.2; | |
const float BeamCreationSpeed_Max = 1.0; | |
// direction: from Max to Min | |
const float BeamLifeTime_Mix = 1.0; | |
const float BeamLifeTime_Max = 5.0; | |
const float BeamWidthStart_Min = 1.0; | |
const float BeamWidthStart_Max = 10.0; | |
const float BeamWidthEnd_Min = 3.0; | |
const float BeamWidthEnd_Max = 20.0; | |
static int tsd; // beam alpha direction | |
if (tsd == 0) | |
tsd = 1; | |
if ((BEAM_ALPHA + tsd) > 255) { | |
BEAM_ALPHA = 255 | |
} else if ((BEAM_ALPHA + tsd) < 10) { | |
BEAM_ALPHA = 10; | |
} else { | |
BEAM_ALPHA += tsd; | |
} | |
BEAM_CREATION_SPEED = RoundToDig( (BeamCreationSpeed_Max - BeamCreationSpeed_Min) * BEAM_ALPHA / 255 ,1) + BeamCreationSpeed_Min; | |
// vice versa movement | |
BEAM_LIFETIME = BeamLifeTime_Max - RoundToDig( (BeamLifeTime_Max - BeamLifeTime_Mix) * BEAM_ALPHA / 255 ,1); | |
BEAM_WIDTH_START = BeamWidthStart_Max - RoundToDig( (BeamWidthStart_Max - BeamWidthStart_Min) * BEAM_ALPHA / 255 ,1); | |
BEAM_WIDTH_END = BeamWidthEnd_Max - RoundToDig( (BeamWidthEnd_Max - BeamWidthEnd_Min) * BEAM_ALPHA / 255 ,1); | |
/* | |
Timer speed algorithm: | |
0 < ALPHA < 50 (dir == +1), dir = -2 | |
at 0, dir = +4 | |
at 100, dir =-2 | |
at 50, dir =+8 | |
at 255, dir =-8 | |
at 0, dir =+1 | |
*/ | |
if (BEAM_ALPHA >= 50 && tsd == 1) | |
{ | |
tsd = -2; | |
} else if (BEAM_ALPHA == 10 && tsd == -2) { | |
tsd = 4; | |
} else if (BEAM_ALPHA >= 100 && tsd == 4) { | |
tsd = -2; | |
} else if (BEAM_ALPHA > 52 && BEAM_ALPHA <= 56 && tsd == -2) { | |
tsd = 6; | |
} else if (BEAM_ALPHA == 255) { | |
tsd = -6; | |
} else if (BEAM_ALPHA == 10) { | |
tsd = 1; | |
} | |
} | |
float RoundToDig(float Num, int DigAfterZero) | |
{ | |
for (int i = 0; i < DigAfterZero; i++) Num *= 10; | |
Num = RoundFloat(Num); | |
for (int i = 0; i < DigAfterZero; i++) Num /= 10; | |
return (Num); | |
} | |
static Action:Timer_DiscoUpdate(Handle:timer) | |
{ | |
// if(IsDiscoBall(DiscoBall)) | |
if(DiscoBall != -1) | |
{ | |
SetEntityRenderColor(DiscoBall, g_DefaultColors_c[DiscoColor][0], g_DefaultColors_c[DiscoColor][1], g_DefaultColors_c[DiscoColor][2], 255); | |
new Float:propangle[3]; | |
GetEntPropVector(DiscoBall, Prop_Data, "m_angRotation", propangle); | |
propangle[0] += fRotation[0]; | |
propangle[1] += fRotation[1]; | |
propangle[2] += fRotation[2]; | |
TeleportEntity(DiscoBall, NULL_VECTOR, propangle, NULL_VECTOR); | |
new Float:POS[3]; | |
new Float:END[3]; | |
GetEntPropVector(DiscoBall, Prop_Send, "m_vecOrigin", POS); | |
if(fZOffset != 0) POS[2] -= fZOffset; | |
/* | |
@pos - Position of the sprite. | |
@Model - Precached model index. | |
@Life - Time duration of the sprite. | |
@Size - Sprite size. | |
@Brightness - Sprite brightness. | |
*/ | |
// TE_SetupGlowSprite(POS, g_DefaultColors_s[DiscoColor], 0.1, 2.0, 30); | |
TE_SetupGlowSprite(POS, g_DefaultColors_s[DiscoColor], 10.0, 2.0, 255); | |
TE_SendToAll(); | |
new Color[4]; | |
Color[3] = BEAM_ALPHA; // Alpha-channel | |
new Float:vAngles[3] | |
new Handle:trace = INVALID_HANDLE; | |
for(new i = 0; i < COLOR_NUMBER; i++) | |
{ | |
vAngles[0] = GetRandomFloat( 0.0, 90.0 ); // vector around horizontal axis (angle begins from horizontal plane) | |
vAngles[1] = GetRandomFloat(-180.0, 180.0); // vector around vertical axis | |
vAngles[2] = 0.0 | |
trace = TR_TraceRayFilterEx(POS, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer); | |
if(TR_DidHit(trace)) | |
{ | |
TR_GetEndPosition(END, trace); | |
Color[0] = g_DefaultColors_c[i][0]; | |
Color[1] = g_DefaultColors_c[i][1]; | |
Color[2] = g_DefaultColors_c[i][2]; | |
RandomizeRGB (Color); | |
LaserP(POS, END, Color); | |
} | |
CloseHandle(trace); | |
} | |
DiscoColor++; | |
if(DiscoColor >= COLOR_NUMBER) DiscoColor = 0; | |
return Plugin_Continue; | |
} | |
DiscoTimer = INVALID_HANDLE; | |
SchemeTimer = INVALID_HANDLE; | |
return Plugin_Stop; | |
} | |
/* | |
GLOW_SIZE | |
GLOW_BRIGHTNESS | |
GLOW_LIFETIME | |
BEAM_ALPHA | |
BEAM_CREATION_SPEED | |
BEAM_LIFETIME | |
BEAM_FADE_LIFETIME | |
BEAM_WIDTH_START | |
BEAM_WIDTH_END | |
BEAMS_AT_ONCE | |
*/ | |
public bool:TraceEntityFilterPlayer(entity, contentsMask) | |
{ | |
return (entity > MaxClients || !entity); | |
} | |
stock LaserP(const Float:start[3], const Float:end[3], const color[4]) | |
{ | |
/* | |
@start - Start position of the beam. | |
@end - End position of the beam. | |
@ModelIndex - Precached model index. | |
@HaloIndex - Precached model index. | |
@StartFrame - Initial frame to render. | |
@FrameRate - Beam frame rate. | |
@Life - Time duration of the beam. | |
@Width - Initial beam width. | |
@EndWidth - Final beam width. | |
@FadeLength - Beam fade time duration. | |
@Amplitude - Beam amplitude. | |
@Color - Color array (r, g, b, a). | |
@Speed - Speed of the beam. | |
*/ | |
// TE_SetupBeamPoints(start, end, g_sprite, 0, 0, 0, 0.1, 3.0, 3.0, 7, 0.0, color, 0); | |
TE_SetupBeamPoints(start, end, g_sprite, 0, 0, 0, BEAM_LIFETIME, BEAM_WIDTH_START, BEAM_WIDTH_END, 7, 0.0, color, 0); | |
TE_SendToAll(); | |
} | |
void RandomizeRGB(int[] color) | |
{ | |
for (int i = 0; i < 3; i++) | |
color[i] = GetRandomColor(color[i]); | |
} | |
int GetRandomColor(int level) | |
{ | |
const int MinRange = 25; // for 0 level | |
const int MaxRange = 100; // for other levels | |
int LBound, UBound; | |
int Range = ((level == 0) ? MinRange : MaxRange ); | |
LBound = level - (Range / 2); | |
UBound = level + (Range / 2); | |
if (LBound < 0) { | |
UBound -= LBound; | |
LBound = 0; | |
} | |
if (UBound > 255) { | |
LBound -= (UBound - 255); | |
UBound = 255; | |
} | |
return (GetRandomInt(LBound, UBound)); | |
} | |
DoUrl(client, String:url[128]) | |
{ | |
new Handle:setup = CreateKeyValues("data"); | |
KvSetString(setup, "title", "DISCO"); | |
KvSetNum(setup, "type", MOTDPANEL_TYPE_URL); | |
KvSetString(setup, "msg", url); | |
ShowVGUIPanel(client, "info", setup, false); | |
CloseHandle(setup); | |
} | |
//MENUS | |
Void_Menu_Disco(client, index=0) | |
{ | |
new Handle:menu = CreateMenu(Menu_Disco, MENU_ACTIONS_DEFAULT); | |
SetMenuTitle(menu, "- Disco -"); | |
if(!IsDiscoBall(DiscoBall) | !bMusicPlaying[client]) | |
AddMenuItem(menu, "StartDisco", "Начать дискарик", ITEMDRAW_DEFAULT); | |
else | |
AddMenuItem(menu, "StopDisco", "Выгнать диджея", ITEMDRAW_DEFAULT); | |
if(!IsDiscoBall(DiscoBall)) | |
AddMenuItem(menu, "StartBall", "Запустить шар", ITEMDRAW_DEFAULT); | |
else | |
AddMenuItem(menu, "StopBall", "Убрать шар", ITEMDRAW_DEFAULT); | |
AddMenuItem(menu, "StartMusic", "Играть музон", ITEMDRAW_DEFAULT); | |
AddMenuItem(menu, "StopMusic", "Остановить музон", ITEMDRAW_DEFAULT); | |
if(!bMusicPlaying[client]) | |
AddMenuItem(menu, "StartMusicSelf", "Играть музон (только себе)", ITEMDRAW_DEFAULT); | |
else | |
AddMenuItem(menu, "StopMusicSelf", "Остановить музон (у себя)", ITEMDRAW_DEFAULT); | |
DisplayMenuAtItem(menu, client, index, MENU_TIME_FOREVER); | |
} | |
Void_Menu_DiscoSongList(client, index, bool bStartBall, bool bPlaySelf) | |
{ | |
bDoStartBall = bStartBall; | |
bDoPlaySelf = bPlaySelf; | |
if (count == 0) | |
return; | |
new Handle:menu = CreateMenu(Menu_DiscoSL, MENU_ACTIONS_DEFAULT); | |
SetMenuTitle(menu, "- Disco Song: -"); | |
decl String:g_sDisplay[128]; | |
decl String:g_sChoice[128]; | |
AddMenuItem(menu, "0", "No Song", ITEMDRAW_DEFAULT); | |
for(new X = 1; X <= count; X++) | |
{ | |
Format(g_sDisplay, sizeof(g_sDisplay), "%s", song_name[X]); | |
Format(g_sChoice, sizeof(g_sChoice), "%i", X); | |
AddMenuItem(menu, g_sChoice, g_sDisplay, ITEMDRAW_DEFAULT); | |
} | |
SetMenuExitBackButton(menu, true); | |
DisplayMenuAtItem(menu, client, index, MENU_TIME_FOREVER); | |
} | |
float[] StartTraceRay(int client) | |
{ | |
new Float:Pos[3]; | |
new Float:END[3]; | |
if (bTaceRayInProgress) | |
return (Pos); | |
bTaceRayInProgress = true; | |
GetEntPropVector(client, Prop_Send, "m_vecOrigin", Pos); | |
new Float:vAngles[3]; | |
vAngles[0] = -90.0; | |
vAngles[1] = 0.0; | |
vAngles[2] = 0.0; | |
new Handle:trace = TR_TraceRayFilterEx(Pos, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer); | |
if(TR_DidHit(trace)) | |
{ | |
TR_GetEndPosition(END, trace); | |
} | |
CloseHandle(trace); | |
if(GetVectorDistance(Pos, END) > 2048.00) | |
{ | |
Pos[2] += 312.0; | |
} | |
else | |
{ | |
Pos[0] = END[0]; | |
Pos[1] = END[1]; | |
Pos[2] = END[2]; | |
} | |
return (Pos); | |
} | |
StopTraceRay() | |
{ | |
if (!bTaceRayInProgress) | |
return; | |
bTaceRayInProgress = false; | |
if ( DiscoTimer != INVALID_HANDLE ) | |
{ | |
KillTimer( DiscoTimer ); | |
DiscoTimer = INVALID_HANDLE; | |
} | |
if ( SchemeTimer != INVALID_HANDLE ) | |
{ | |
KillTimer( SchemeTimer ); | |
SchemeTimer = INVALID_HANDLE; | |
} | |
if(IsDiscoBall(DiscoBall)) | |
{ | |
AcceptEntityInput( DiscoBall , "Kill" ); | |
DiscoBall = -1; | |
} | |
} | |
public Menu_Disco(Handle:menu, MenuAction:action, param1, param2) | |
{ | |
switch (action) | |
{ | |
case MenuAction_End: | |
CloseHandle(menu); | |
case MenuAction_Select: | |
{ | |
new client = param1; | |
new ItemIndex = param2; | |
new String:info[130]; | |
GetMenuItem(menu, ItemIndex, info, sizeof(info)); | |
if(StrEqual("StartDisco", info, false)) | |
{ | |
// no song list | |
if(count == 0) | |
{ | |
// just start the ball | |
StartDisco(client, StartTraceRay(client), 0); | |
Void_Menu_Disco(client); | |
} | |
else | |
{ | |
Void_Menu_DiscoSongList(client, 0, true, false); // Startball = true, PlaySelf = false | |
} | |
} | |
if(StrEqual("StopDisco", info, false)) | |
{ | |
StopTraceRay(); | |
StopDisco(client); | |
Void_Menu_Disco(client); | |
} | |
if(StrEqual("StartBall", info, false)) | |
{ | |
StartBall(client, StartTraceRay(client)); | |
Void_Menu_Disco(client); | |
} | |
if(StrEqual("StopBall", info, false)) | |
{ | |
StopTraceRay(); | |
StopBall(client); | |
Void_Menu_Disco(client); | |
} | |
if(StrEqual("StartMusic", info, false)) | |
{ | |
Void_Menu_DiscoSongList(client, 0, false, false); // Startball = false, PlaySelf = false | |
} | |
if(StrEqual("StartMusicSelf", info, false)) | |
{ | |
Void_Menu_DiscoSongList(client, 0, false, true); // Startball = false, PlaySelf = true | |
} | |
if(StrEqual("StopMusicSelf", info, false)) | |
{ | |
StopMusic (client, true); // true - Self | |
Void_Menu_Disco(client); | |
} | |
if(StrEqual("StopMusic", info, false)) | |
{ | |
StopMusic (client); | |
Void_Menu_Disco(client); | |
} | |
} | |
} | |
return; | |
} | |
// List of songs | |
public Menu_DiscoSL(Handle:menu, MenuAction:action, param1, param2) | |
{ | |
switch (action) | |
{ | |
case MenuAction_End: | |
CloseHandle(menu); | |
case MenuAction_Cancel: | |
Void_Menu_Disco(param1); | |
case MenuAction_Select: | |
{ | |
new client = param1; | |
new ItemIndex = param2; | |
new String:info[130]; | |
GetMenuItem(menu, ItemIndex, info, sizeof(info)); | |
if (bDoStartBall) | |
{ | |
StartDisco(client, StartTraceRay(client), StringToInt(info)); // song index | |
} | |
else | |
{ | |
if (bDoPlaySelf) | |
{ | |
StartMusic (client, StringToInt(info), true); // bDoPlaySelf = true | |
} | |
else | |
{ | |
StartMusic (client, StringToInt(info), false); // bDoPlaySelf = false | |
} | |
} | |
if (bDoPlaySelf) | |
Void_Menu_DiscoSongList(client, 0, false, true); // Startball = false, PlaySelf = true | |
} | |
} | |
return; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment