PHP Code:
/*
Credits:
Vaggelis - Open Cells
*/
#include <sourcemod>
#include <sdktools>
// New's
new Float:min = 300.0
new Handle:g_doorlist
bool is_Simon[MAXPLAYERS+1] = false
int Is_Simon = -1
// Define's
#define CS_TEAM_CT 1
#define CS_TEAM_T 2
// Plugin Info
public Plugin myinfo =
{
name = "JailBreak Main ( Alpha )",
author = "Diversity",
description = "Pluginul de baza pentru JailBreak CS:GO",
version = "0.0.1",
url = "http://www.sourcemod.net/"
};
// Start
public void OnPluginStart()
{
g_doorlist = CreateArray()
RegConsoleCmd("sm_cells", CmdCells)
HookEvent("round_start", Event_RoundStart)
HookEvent("round_end", Event_RoundEnd)
HookEvent("player_death", Event_PlayerDeath)
HookEvent("player_spawn", Event_OnPlayerSpawn)
}
// Public's
public OnMapStart()
{
CacheDoors()
}
public OnMapEnd()
{
Reset_Simon()
ClearArray(g_doorlist)
}
// Event's
public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int victim_id = event.GetInt("userid")
//int attacker_id = event.GetInt("attacker")
int victim = GetClientOfUserId(victim_id)
//int attacker = GetClientOfUserId(attacker_id)
if(victim == Is_Simon) Reset_Simon()
}
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
Reset_Simon()
}
public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
Reset_Simon()
}
public Action Event_OnPlayerSpawn(Event event, const char[] name, bool bDontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(GetClientTeam(client) != CS_TEAM_CT)
return Plugin_Continue;
Reset_Simon()
return Plugin_Continue;
}
// Function's
CacheDoors()
{
new ent
new door
while((ent = FindEntityByClassname(ent, "info_player_terrorist")) != -1)
{
new Float:coor[3]
GetEntPropVector(ent, Prop_Data, "m_vecOrigin", coor)
while((door = FindEntityByClassname(door, "func_door")) != -1)
{
new Float:posi[3]
GetEntPropVector(door, Prop_Data, "m_vecOrigin", posi)
if(GetVectorDistance(posi, coor) < min)
{
min = GetVectorDistance(posi, coor)
}
}
}
ent = -1
door = -1
min += 80.0
while((ent = FindEntityByClassname(ent, "info_player_terrorist")) != -1)
{
new Float:coor[3]
GetEntPropVector(ent, Prop_Data, "m_vecOrigin", coor)
while((door = FindEntityByClassname(door, "func_door")) != -1)
{
new Float:posi[3]
GetEntPropVector(door, Prop_Data, "m_vecOrigin", posi)
if(GetVectorDistance(posi, coor) <= min)
{
PushArrayCell(g_doorlist, door)
}
}
}
}
OpnCell()
{
for(new i = 0; i < GetArraySize(g_doorlist); i++)
{
new temp = GetArrayCell(g_doorlist, i)
AcceptEntityInput(temp, "Use")
}
}
Reset_Simon()
{
/*
Is_Simon este "id-ul" playerului care are simon iar is_Simon este daca acel player este simon.
*/
if(Is_Simon > -1)
{
is_Simon[Is_Simon] = false
Is_Simon = -1
}
}
void Set_Simon(int client = -1)
{
new team = GetClientTeam(client);
if(team != CS_TEAM_CT) return PrintToChat(client, "Nu esti politist.")
if(client == -1) return PrintToChat(client, "#0001")
if(Is_Simon > -1) return PrintToChat(client, "Este deja un simon.")
Is_Simon = client
is_Simon[Is_Simon] = true
PrintToChat(client, "Acum esti Simon. Trebuie sa dai comenzi.");
for(new i = 1; i < MaxClients; i++) PrintToChat(i, "Noul simon este %s, ascultati-l!", Get_Name(Is_Simon))
// Menu_Simon(client)
return Plugin_Continue;
}
char Get_Name(int client)
{
char name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name));
return name;
}
// Command's
public Action:CmdCells(client, args)
{
if(is_Simon[Is_Simon] == true || GetUserFlagBits(client) & ADMFLAG_KICK)
{
OpnCell();
new String:name[32]
GetClientName(client, name, sizeof(name))
PrintToChatAll("%s opened cells.", name)
}
}
public Action OnClientCommand(int client, int args)
{
char cmd[16];
GetCmdArg(0, cmd, sizeof(cmd)); /* Get command name */
if (StrEqual(cmd, "simon"))
{
Set_Simon(client)
return Plugin_Handled
}
return Plugin_Continue;
}