Untitled diff

Created Diff never expires
220 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
457 lines
124 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
363 lines
#include <sourcemod>
#include <sourcemod>
#include <sdktools>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>
#include <sdkhooks>
#include <cstrike>
#include <multicolors>
#include <multicolors>


#define PLUGIN_AUTHOR "Arkarr"
#pragma newdecls required
#define PLUGIN_VERSION "1.00 - Arkarr's version"
#define PLUGIN_TAG "[OITC]"
#define PLUGIN_CTAG "{green}[OITC]{default}"

#define SPAWN_FOLDER "configs/oitc_spawns"

#define POSITION_X "POSITION_X"
#define POSITION_Y "POSITION_Y"
#define POSITION_Z "POSITION_Z"

#define COLLISION_PUSH 17

#define NEXT_ROUND_TIMER 3.0

#define AMMO_ADD 0
#define AMMO_SET 1


#define PLUGIN_TAG "{blue}[OITC]{default}"
#define POSITION_X "POSITION_X"
#define POSITION_Y "POSITION_Y"
#define POSITION_Z "POSITION_Z"
#define COLLISION_PUSH 17
Handle ARRAY_Spawns;
Handle ARRAY_Spawns;
Handle CVAR_AmmunitionLogic;
Handle CVAR_MaxiumPoints;
Handle CVAR_RoudnsBeforeMapChange;

bool PluginEnabled;
bool PluginEnabled;
bool Immunised[MAXPLAYERS + 1];
bool Winning;


int NumberOfSpawns;
int NumberOfSpawns;
int Rounds;
int Points[MAXPLAYERS+1];

bool Immunised[MAXPLAYERS+1];
float Points[MAXPLAYERS + 1];


public Plugin myinfo =
public Plugin myinfo =
{
{
name = "[CSGO] One in the chamber",
name = "One in the chamber",
author = PLUGIN_AUTHOR,
author = "Noctember",
description = "Emulate CoD One In The Chamber game mode",
description = "",
version = PLUGIN_VERSION,
version = "0.1",
url = "http://www.sourcemode.net"
url = "https://steamcommunity.com/id/NCBRRR/"
};
};


public void OnPluginStart()
public void OnPluginStart()
{
{
EngineVersion Game = GetEngineVersion();
RegAdminCmd("sm_createspawn", Command_CreateSpawn, ADMFLAG_CONFIG, "Create a new spawn");
if (Game != Engine_CSGO && Game != Engine_CSS)
SetFailState("%s This plugin is for CSGO/CSS only.", PLUGIN_TAG);
HookEvent("round_end", Event_RoundEnd);
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("player_death", Event_OnPlayerDeath, EventHookMode_Post);
HookEvent("player_death", Event_OnPlayerDeath, EventHookMode_Post);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("switch_team", Event_JoinTeam);
CVAR_AmmunitionLogic = CreateConVar("sm_oitc_ammunition_logic", "1", "How does the ammunition reward work ? 1 = ALWAYS 1 ammo no matterr what | 0 = Each kill reward with +1 ammo", _, true, 0.0, true, 1.0);
HookEvent("player_team", Event_JoinTeam);
CVAR_MaxiumPoints = CreateConVar("sm_oitc_maximum_points", "30", "How much points needed to win for each round ?");
for (int i = 1; i <= MaxClients; i++)
CVAR_RoudnsBeforeMapChange = CreateConVar("sm_oitc_rounds_before_map_change", "3", "How much round each map ?");
RegAdminCmd("sm_createspawn", CMD_CreateSpawn, ADMFLAG_CHANGEMAP, "Create a new spawn location");
for (new i = 1; i <= MaxClients; i++)
{
{
if (IsClientInGame(i))
if (IsClientInGame(i))
{
{
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
SDKHook(i, SDKHook_PostThinkPost, OnPostThinkPost);
SDKHook(i, SDKHook_PostThinkPost, OnPostThinkPost);
SDKHook(i, SDKHook_WeaponDrop, Hook_WeaponDrop);
SDKHook(i, SDKHook_WeaponDrop, Hook_WeaponDrop);
}
}
}
}
ARRAY_Spawns = CreateArray();
ARRAY_Spawns = CreateArray();
}
}


public void OnMapStart()
public void OnMapStart()
{
{
char mapName[45];
char mapName[45];
GetCurrentMap(mapName, sizeof(mapName));
GetCurrentMap(mapName, sizeof(mapName));
PluginEnabled = LoadConfiguration(mapName);
PluginEnabled = LoadConfiguration(mapName);
if (!PluginEnabled)
if (!PluginEnabled)
{
{
PrintToServer("%s Plugin is DISABLED", PLUGIN_TAG);
SetFailState("%s No spawn defined for this map", PLUGIN_TAG)
ServerCommand("sm plugins unload Oneinthechamber");
}
}
else
else
{
{
ServerCommand("mp_freezetime 0");
ServerCommand("mp_freezetime 0");
ServerCommand("mp_warmuptime 0");
ServerCommand("mp_warmuptime 0");
ServerCommand("mp_roundtime_defuse 0");
ServerCommand("mp_roundtime_defuse 0");
ServerCommand("mp_do_warmup_period 0");
ServerCommand("mp_do_warmup_period 0");
ServerCommand("mp_roundtime_hostage 1");
ServerCommand("mp_roundtime_hostage 1");
ServerCommand("mp_teammates_are_enemies 1");
ServerCommand("mp_teammates_are_enemies 1");
ServerCommand("mp_ignore_round_win_conditions 1");
ServerCommand("mp_ignore_round_win_conditions 1");
ServerCommand("mp_maxrounds %i", GetConVarInt(CVAR_RoudnsBeforeMapChange));
}
}
}
}


Text moved with changes from lines 385-417 (99.1% similarity)
public void OnClientPutInServer(client)
stock bool LoadConfiguration(const char[] mapName)
{
char path[75];
BuildPath(Path_SM, path, sizeof(path), "configs/oitc/%s.cfg", mapName);
if (!DirExists("addons/sourcemod/configs/oitc"))
CreateDirectory("/addons/sourcemod/configs/oitc", 777);
Handle file = INVALID_HANDLE;
if (!FileExists(path))
file = OpenFile(path, "w");
else
file = OpenFile(path, "r");
char line[200];
ClearArray(ARRAY_Spawns);
while (!IsEndOfFile(file) && ReadFileLine(file, line, sizeof(line)))
{
char positions[3][15];
ExplodeString(line, ";", positions, sizeof positions, sizeof positions[]);
Handle trie = CreateTrie();
SetTrieValue(trie, POSITION_X, StringToFloat(positions[0]));
SetTrieValue(trie, POSITION_Y, StringToFloat(positions[1]));
SetTrieValue(trie, POSITION_Z, StringToFloat(positions[2]));
PushArrayCell(ARRAY_Spawns, trie);
}
CloseHandle(file);
NumberOfSpawns = GetArraySize(ARRAY_Spawns);
return true;
}

public void OnClientPutInServer(int client)
{
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
SDKHook(client, SDKHook_PostThinkPost, OnPostThinkPost);
SDKHook(client, SDKHook_PostThinkPost, OnPostThinkPost);
SDKHook(client, SDKHook_WeaponDrop, Hook_WeaponDrop);
SDKHook(client, SDKHook_WeaponDrop, Hook_WeaponDrop);
Points[client] = 0.0;
Points[client] = 0;

}
}


/**************
public Action Command_CreateSpawn(int client, int args)
COMMANDS
**************/

public Action CMD_CreateSpawn(client, args)
{
{
if (!PluginEnabled)
if (!PluginEnabled)
return Plugin_Handled;
return Plugin_Handled;
if (client == 0)
if (client == 0)
{
{
PrintToServer("%s This command is restricted to in-game.", PLUGIN_TAG);
PrintToServer("%s Try using this command in game.", PLUGIN_TAG);
return Plugin_Handled;
return Plugin_Handled;
}
}
float newSpawn[3];
float newSpawn[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", newSpawn);
GetEntPropVector(client, Prop_Send, "m_vecOrigin", newSpawn);
Handle trie = CreateTrie();
Handle trie = CreateTrie();
SetTrieValue(trie, POSITION_X, newSpawn[0]);
SetTrieValue(trie, POSITION_X, newSpawn[0]);
SetTrieValue(trie, POSITION_Y, newSpawn[1]);
SetTrieValue(trie, POSITION_Y, newSpawn[1]);
SetTrieValue(trie, POSITION_Z, newSpawn[2]);
SetTrieValue(trie, POSITION_Z, newSpawn[2]);
PushArrayCell(ARRAY_Spawns, trie);
PushArrayCell(ARRAY_Spawns, trie);
CPrintToChat(client, "%s New spawn added !", PLUGIN_CTAG);
CPrintToChat(client, "%s New spawn added!", PLUGIN_TAG);
NumberOfSpawns++;
NumberOfSpawns++;
SaveConfiguration();
SaveConfiguration();
return Plugin_Handled;
return Plugin_Handled;
}
}

public void Event_JoinTeam(Event event, const char[] name, bool dontBroadcast)
/**************
{
EVENTS
int client = GetClientOfUserId(GetEventInt(event, "userid"));
**************/
CreateTimer(3.0, Timer_Respawn, client);
}


public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if (!PluginEnabled || !IsValidClient(client))
if (!PluginEnabled || !IsValidClient(client))
return;
return;
CreateTimer(0.5, CheckAmmo, client);
CreateTimer(0.5, CheckAmmo, client);
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 100, 255, 100, 200);
SetEntityRenderColor(client, 100, 255, 100, 200);
Immunised[client] = true;
Immunised[client] = true;
CreateTimer(5.0, TMR_SetMortality, client);
CreateTimer(5.0, Timer_SetMortality, client);
CPrintToChat(client, "%s You are in god mode for 5 seconds !", PLUGIN_CTAG);
CPrintToChat(client, "%s You are immunised for 5 seconds!", PLUGIN_TAG);
if(NumberOfSpawns == 0)
if(NumberOfSpawns == 0)
return;
return;
int spawnID = GetRandomInt(0, NumberOfSpawns - 1);
int spawnID = GetRandomInt(0, NumberOfSpawns - 1);
Handle positions = GetArrayCell(ARRAY_Spawns, spawnID);
Handle positions = GetArrayCell(ARRAY_Spawns, spawnID);
float newSpawn[3];
float newSpawn[3];
GetTrieValue(positions, POSITION_X, newSpawn[0]);
GetTrieValue(positions, POSITION_X, newSpawn[0]);
GetTrieValue(positions, POSITION_Y, newSpawn[1]);
GetTrieValue(positions, POSITION_Y, newSpawn[1]);
GetTrieValue(positions, POSITION_Z, newSpawn[2]);
GetTrieValue(positions, POSITION_Z, newSpawn[2]);
SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_PUSH);
SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_PUSH);
TeleportEntity(client, newSpawn, NULL_VECTOR, NULL_VECTOR);
TeleportEntity(client, newSpawn, NULL_VECTOR, NULL_VECTOR);
}
}


public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
public Action CheckAmmo(Handle timer, any client)
{
{
Text moved with changes from lines 321-346 (99.8% similarity)
for (new i = 1; i <= MaxClients; i++)
if ((!IsValidClient(client) || !IsPlayerAlive(client)) || (GetClientTeam(client) == CS_TEAM_SPECTATOR))
Points[i] = 0.0;
return;
Winning = false;
int c4 = GetPlayerWeaponSlot(client, CS_SLOT_C4);
if (c4 != -1)
char strRoundsLeft[45];
RemovePlayerItem(client, c4);
char lastRounds[45];
int roundsLeft = GetConVarInt(FindConVar("mp_maxrounds"))-Rounds;
int secondary = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY);
Format(strRoundsLeft, sizeof(strRoundsLeft), "%i rounds", roundsLeft);
if (secondary != -1)
Format(lastRounds, sizeof(lastRounds), "%s", (roundsLeft == 0) ? "LAST ROUND" : strRoundsLeft);
RemovePlayerItem(client, secondary);
CPrintToChatAll("%s %s until next map", PLUGIN_CTAG, lastRounds);
int primary = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY);
if (primary != -1)
RemovePlayerItem(client, primary);
int nadeslot = GetPlayerWeaponSlot(client, CS_SLOT_GRENADE);
if (nadeslot != -1)
RemovePlayerItem(client, nadeslot);
GivePlayerItem(client, "weapon_deagle");
SetEntProp(GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY), Prop_Data, "m_iClip1", 0);
SetEntProp(GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY), Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
SetEntProp(GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY), Prop_Send, "m_iSecondaryReserveAmmoCount", 0);
SetAmmo(GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY));
}
}


public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
stock void SetAmmo(int weapon)
{
{
Text moved with changes from lines 365-373 (94.5% similarity)
if(GameRules_GetProp("m_totalRoundsPlayed") == Rounds)
if (!IsValidEntity(weapon))
GameRules_SetProp("m_totalRoundsPlayed", ++Rounds);
return;
int client = GetEntPropEnt(weapon, Prop_Data, "m_hOwner");
if (client == -1)
return;
int ammo = GetEntProp(weapon, Prop_Data, "m_iClip1")+1;
SetEntProp(weapon, Prop_Data, "m_iClip1", ammo);
SetEntProp(weapon, Prop_Send, "m_iSecondaryReserveAmmoCount", 0);
}
}


public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason)
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
{
Rounds = GameRules_GetProp("m_totalRoundsPlayed");
for (int i = 1; i <= MaxClients; i++)
if(Rounds == GetConVarInt(FindConVar("mp_maxrounds")))
Points[i] = 0;
CreateTimer(NEXT_ROUND_TIMER, TMR_ChangeMap);
}
}


public Action TMR_ChangeMap(Handle tmr)
public Action Timer_SetMortality(Handle timer, any client)
{
char nextMap[45];
GetNextMap(nextMap, sizeof(nextMap));
ForceChangeLevel(nextMap, "[OITC] Map change.");
}
public Action TMR_SetMortality(Handle tmr, any client)
{
{
if(IsValidClient(client))
if(IsValidClient(client))
{
{
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client);
SetEntityRenderColor(client);
Immunised[client] = false;
Immunised[client] = false;
}
}
return Plugin_Continue;
return Plugin_Continue;
}
}


public Action OnTakeDamage(int victim, int&attacker, int&inflictor, float&damage, int&damagetype, int&weapon, float damageForce[3], float damagePosition[3])
public Action OnTakeDamage(int victim, int&attacker, int&inflictor, float&damage, int&damagetype, int&weapon, float damageForce[3], float damagePosition[3])
{
{
if (!PluginEnabled)
if (!PluginEnabled)
return Plugin_Continue;
return Plugin_Continue;
if (victim == attacker || attacker == 0)
if (victim == attacker || attacker == 0)
return Plugin_Continue;
return Plugin_Continue;
if (Immunised[victim])
if (Immunised[victim])
return Plugin_Handled;
return Plugin_Handled;
damage *= GetRandomFloat(100.0, 999.0);
damage *= GetRandomFloat(100.0, 999.0);
damageForce[0] *= GetRandomFloat(500.0, 800.0);
damageForce[0] *= GetRandomFloat(500.0, 800.0);
damageForce[1] *= GetRandomFloat(500.0, 800.0);
damageForce[1] *= GetRandomFloat(500.0, 800.0);
damageForce[2] *= GetRandomFloat(500.0, 800.0);
damageForce[2] *= GetRandomFloat(500.0, 800.0);
if(weapon != -1)
if(weapon != -1)
{
{
char sWeapon[32];
char sWeapon[32];
GetEntityClassname(weapon, sWeapon, sizeof(sWeapon));
GetEntityClassname(weapon, sWeapon, sizeof(sWeapon));
if(StrEqual(sWeapon, "weapon_knife"))
if(StrEqual(sWeapon, "weapon_knife"))
Points[attacker]+= 2;
Points[attacker]+= 2;
else
else
Points[attacker]+= 1;
Points[attacker]+= 1;
if(damagetype & CS_DMG_HEADSHOT)
CS_SetClientContributionScore(attacker, Points[attacker]);
Points[attacker]+= 0.5;
if(Points[attacker] >= GetConVarInt(CVAR_MaxiumPoints))
PlayerWon(attacker);
else
PrintHintText(attacker, "Points : %.2f/%.2f", Points[attacker], GetConVarFloat(CVAR_MaxiumPoints));
SetAmmo(GetPlayerWeaponSlot(attacker, CS_SLOT_SECONDARY));
SetAmmo(GetPlayerWeaponSlot(attacker, CS_SLOT_SECONDARY));
}
}
return Plugin_Changed;
return Plugin_Changed;
}
}


public Action Hook_WeaponDrop(client, weapon)
public Action Hook_WeaponDrop(int client, int weapon)
{
{
if(IsValidEdict(weapon))
if(IsValidEdict(weapon))
AcceptEntityInput( weapon, "Kill" );
AcceptEntityInput(weapon, "Kill");
return Plugin_Continue;
return Plugin_Continue;
}
}


public Action Event_OnPlayerDeath(Handle event, char[] name, bool dontBroadcast)
public Action Event_OnPlayerDeath(Handle event, char[] name, bool dontBroadcast)
{
{
if (!PluginEnabled)
if (!PluginEnabled)
return Plugin_Continue;
return Plugin_Continue;
int victim = GetClientOfUserId(GetEventInt(event, "userid"));
int victim = GetClientOfUserId(GetEventInt(event, "userid"));
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if(attacker == 0)
if(attacker == 0)
return Plugin_Continue;
return Plugin_Continue;
CreateTimer(0.1, TMR_Refill, attacker);
CreateTimer(5.0, Timer_Respawn, victim);
CreateTimer(3.0, TMR_Respawn, victim);
return Plugin_Continue;
return Plugin_Continue;
}
}


public Action TMR_Refill(Handle tmr, any client)
public Action Timer_Refill(Handle timer, any client)
{
{
int weapon = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY);
int weapon = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY);
if(weapon != -1)
if(weapon != -1)
SetAmmo(weapon);
SetAmmo(weapon);
return Plugin_Continue;
return Plugin_Continue;
}
}


public Action TMR_Respawn(Handle tmr, any client)
public Action Timer_Respawn(Handle timer, any client)
{
{
if(IsValidClient(client))
if(IsValidClient(client))
CS_RespawnPlayer(client);
CS_RespawnPlayer(client);
return Plugin_Continue;
return Plugin_Continue;
}
}


public Action OnPostThinkPost(entity)
public Action OnPostThinkPost(int entity)
{
{
if (!PluginEnabled)
if (!PluginEnabled)
return Plugin_Continue;
return Plugin_Continue;
SetEntProp(entity, Prop_Send, "m_bInBuyZone", 0);
SetEntProp(entity, Prop_Send, "m_bInBuyZone", 0);
return Plugin_Continue;
return Plugin_Continue;
}
}


public Action CheckAmmo(Handle timer, any client)
{
Text moved with changes to lines 190-215 (99.8% similarity)
if ((!IsValidClient(client) || !IsPlayerAlive(client)) || (GetClientTeam(client) == CS_TEAM_SPECTATOR))
return;
int c4 = GetPlayerWeaponSlot(client, CS_SLOT_C4);
if (c4 != -1)
RemovePlayerItem(client, c4);
int secondary = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY);
if (secondary != -1)
RemovePlayerItem(client, secondary);
int primary = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY);
if (primary != -1)
RemovePlayerItem(client, primary);
int nadeslot = GetPlayerWeaponSlot(client, CS_SLOT_GRENADE);
if (nadeslot != -1)
RemovePlayerItem(client, nadeslot);
GivePlayerItem(client, "weapon_deagle");
SetEntProp(GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY), Prop_Data, "m_iClip1", 0);
SetEntProp(GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY), Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
SetEntProp(GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY), Prop_Send, "m_iSecondaryReserveAmmoCount", 0);
SetAmmo(GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY));
}

/**************
STOCKS
**************/

stock void PlayerWon(int client)
{
if(!Winning)
{
PrintHintTextToAll("%N won with %.2f points !", client, Points[client]);
Winning = true;
CS_TerminateRound(NEXT_ROUND_TIMER, CSRoundEnd_GameStart);
}
}

stock void SetAmmo(weapon)
{
Text moved with changes to lines 220-228 (94.5% similarity)
if (!IsValidEntity(weapon))
return;
int client = GetEntPropEnt(weapon, Prop_Data, "m_hOwner");
if (client == -1)
return;
int primammotype = GetEntProp(weapon, Prop_Data, "m_iPrimaryAmmoType");
if (primammotype != -1)
{
if(GetConVarInt(CVAR_AmmunitionLogic) == AMMO_ADD)
SetEntProp(weapon, Prop_Data, "m_iClip1", GetEntProp(weapon, Prop_Data, "m_iClip1")+1);
else if(GetConVarInt(CVAR_AmmunitionLogic) == AMMO_SET)
SetEntProp(weapon, Prop_Data, "m_iClip1", 1);
SetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
SetEntProp(weapon, Prop_Send, "m_iSecondaryReserveAmmoCount", 0);
}
}

Text moved with changes to lines 74-106 (99.1% similarity)
stock bool LoadConfiguration(const char[] mapName)
{
char path[75];
BuildPath(Path_SM, path, sizeof(path), "%s/%s.cfg", SPAWN_FOLDER, mapName);
if (!DirExists("addons/sourcemod/configs/oitc_spawns"))
CreateDirectory("/addons/sourcemod/configs/oitc_spawns", 777);
Handle file = INVALID_HANDLE;
if (!FileExists(path))
file = OpenFile(path, "w");
else
file = OpenFile(path, "r");
char line[200];
ClearArray(ARRAY_Spawns);
while (!IsEndOfFile(file) && ReadFileLine(file, line, sizeof(line)))
{
char positions[3][15];
ExplodeString(line, ";", positions, sizeof positions, sizeof positions[]);
Handle trie = CreateTrie();
SetTrieValue(trie, POSITION_X, StringToFloat(positions[0]));
SetTrieValue(trie, POSITION_Y, StringToFloat(positions[1]));
SetTrieValue(trie, POSITION_Z, StringToFloat(positions[2]));
PushArrayCell(ARRAY_Spawns, trie);
}
CloseHandle(file);
NumberOfSpawns = GetArraySize(ARRAY_Spawns);
if (NumberOfSpawns < 1)
PrintToServer("%s ZERO SPAWNS FOUND !", PLUGIN_TAG);
else
PrintToServer("%s LOADED %i CUSTOM SPAWNS !", PLUGIN_TAG, NumberOfSpawns);
return true;
}

stock void SaveConfiguration()
stock void SaveConfiguration()
{
{
char path[75], mapName[45];
char path[75], mapName[45];
GetCurrentMap(mapName, sizeof(mapName));
GetCurrentMap(mapName, sizeof(mapName));
BuildPath(Path_SM, path, sizeof(path), "%s/%s.cfg", SPAWN_FOLDER, mapName);
BuildPath(Path_SM, path, sizeof(path), "configs/oitc/%s.cfg", mapName);
PrintToServer("%s Target file : %s", PLUGIN_TAG, path);
Handle file = OpenFile(path, "w");
Handle file = OpenFile(path, "w");
for (int i = 0; i < GetArraySize(ARRAY_Spawns); i++)
for (int i = 0; i < GetArraySize(ARRAY_Spawns); i++)
{
{
Handle trie = GetArrayCell(ARRAY_Spawns, i);
Handle trie = GetArrayCell(ARRAY_Spawns, i);
float Px = 0.0;
float Px = 0.0;
float Py = 0.0;
float Py = 0.0;
float Pz = 0.0;
float Pz = 0.0;
GetTrieValue(trie, POSITION_X, Px);
GetTrieValue(trie, POSITION_X, Px);
GetTrieValue(trie, POSITION_Y, Py);
GetTrieValue(trie, POSITION_Y, Py);
GetTrieValue(trie, POSITION_Z, Pz);
GetTrieValue(trie, POSITION_Z, Pz);
WriteFileLine(file, "%f;%f;%f", Px, Py, Pz);
WriteFileLine(file, "%f;%f;%f", Px, Py, Pz);
PrintToServer("%s New spawn saved : X: %f Y: %f Z: %f", PLUGIN_TAG, Px, Py, Pz);
}
}
CloseHandle(file);
CloseHandle(file);
}
}


stock bool IsValidClient(int client)
stock bool IsValidClient(int client)
{
{
if (client <= 0)return false;
if (client <= 0)return false;
if (client > MaxClients)return false;
if (client > MaxClients)return false;
if (!IsClientConnected(client))return false;
if (!IsClientConnected(client))return false;
return IsClientInGame(client);
return IsClientInGame(client);
}
}