When this plugin is 1v1, it is teleport the players. The code should have errors, but I can't find the error and can't understand it. Sometimes it teleport to the wrong location. Sometimes not teleport to the noscope zone. Can you help me fix it?
PHP Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "Ak0"
#define PLUGIN_VERSION "1.0"
#include <sourcemod>
#include <sdktools>
#include <cstrike>
//#include <sdkhooks>
int RandomRoom;
ConVar teleport61;
public Plugin myinfo =
{
name = "[AWP] 1v1 Teleport",
author = PLUGIN_AUTHOR,
description = "",
version = PLUGIN_VERSION,
url = ""
};
public OnPluginStart()
{
teleport61 = CreateConVar("sm_awp_teleport", "1");
HookEvent("player_death", Player_Death61, EventHookMode_Pre);
HookEvent("round_start", Round_Start61);
}
public Action Round_Start61(Handle event, const char[] name, bool dontBroadcast)
{
int random61 = GetRandomInt(1, 4);
RandomRoom = random61;
ServerCommand("sm plugins load Awp/deagle_qq");
ServerCommand("sm plugins unload Awp/noscope");
ServerCommand("sm plugins unload abner_bhop");
}
public Action Player_Death61(Handle event, char[] name, bool dontBroadcast)
{
if(GetConVarInt(teleport61) == 1)
{
if (LivePlayer(2) == 1 && LivePlayer(3) == 1)
{
ServerCommand("sm plugins unload Awp/deagle_qq");
if (RandomRoom == 1)
{
ServerCommand("sm plugins load abner_bhop");
}
else if (RandomRoom == 2)
{
ServerCommand("sm plugins load Awp/noscope");
}
else if (RandomRoom == 3)
{
ServerCommand("sm plugins load abner_bhop");
}
else if (RandomRoom == 4)
{
ServerCommand("sm plugins load abner_bhop");
}
}
// Bunny Hop Room
float bunnyhopT[3];
float bunnyhopCT[3];
bunnyhopT[0] = 3023.0;
bunnyhopT[1] = -866.0;
bunnyhopT[2] = 12.0;
bunnyhopCT[0] = 3023.0;
bunnyhopCT[1] = 992.0;
bunnyhopCT[2] = 12.0;
// NoScope Room
float noscopeT[3];
float noscopeCT[3];
noscopeT[0] = 2626.0;
noscopeT[1] = 568.0;
noscopeT[2] = -78.0;
noscopeCT[0] = 2613.0;
noscopeCT[1] = -277.0;
noscopeCT[2] = -80.0;
// labyrinth Room
float labyrinthT[3];
float labyrinthCT[3];
labyrinthT[0] = 1285.0;
labyrinthT[1] = -487.0;
labyrinthT[2] = -24.0;
labyrinthCT[0] = 1285.0;
labyrinthCT[1] = -435.0;
labyrinthCT[2] = -24.0;
// KZ Room
float kzT[3];
float kzCT[3];
kzT[0] = 4073.0;
kzT[1] = -423.0;
kzT[2] = -201.0;
kzCT[0] = 3966.0;
kzCT[1] = -423.0;
kzCT[2] = -201.0;
for (int i = 1; i <= MaxClients; i++)
{
if (i && IsClientInGame(i) && IsClientConnected(i) && !IsFakeClient(i) && IsPlayerAlive(i))
{
if (LivePlayer(2) == 1 && LivePlayer(3) == 1)
{
WeaponRemove61(i);
SetEntityHealth(i, 100);
switch (RandomRoom)
{
case 1:
{
if (GetClientTeam(i) == 2)
{
TeleportEntity(i, bunnyhopT, NULL_VECTOR, NULL_VECTOR);
GivePlayerItem(i, "weapon_knife");
}
else if (GetClientTeam(i) == 3)
{
TeleportEntity(i, bunnyhopCT, NULL_VECTOR, NULL_VECTOR);
GivePlayerItem(i, "weapon_knife");
}
}
case 2:
{
if (GetClientTeam(i) == 2)
{
TeleportEntity(i, noscopeT, NULL_VECTOR, NULL_VECTOR);
GivePlayerItem(i, "weapon_knife");
}
else if (GetClientTeam(i) == 3)
{
TeleportEntity(i, noscopeCT, NULL_VECTOR, NULL_VECTOR);
GivePlayerItem(i, "weapon_knife");
}
}
case 3:
{
if (GetClientTeam(i) == 2)
{
TeleportEntity(i, labyrinthT, NULL_VECTOR, NULL_VECTOR);
}
else if (GetClientTeam(i) == 3)
{
TeleportEntity(i, labyrinthCT, NULL_VECTOR, NULL_VECTOR);
}
}
case 4:
{
if (GetClientTeam(i) == 2)
{
TeleportEntity(i, kzT, NULL_VECTOR, NULL_VECTOR);
GivePlayerItem(i, "weapon_knife");
}
else if (GetClientTeam(i) == 3)
{
TeleportEntity(i, kzCT, NULL_VECTOR, NULL_VECTOR);
GivePlayerItem(i, "weapon_knife");
}
}
}
}
}
}
}
}
LivePlayer(iTeam)
{
int iCount, i;
iCount = 0;
for (i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == iTeam)
{
iCount++;
}
}
return iCount;
}
stock void WeaponRemove61(int client)
{
int iEnt;
for (int i = 0; i <= 4; ++i)
{
while ((iEnt = GetPlayerWeaponSlot(client, i)) != -1)
{
RemovePlayerItem(client, iEnt);
AcceptEntityInput(iEnt, "Kill");
}
}
}
/// void SetCvar(const char[] name, const char[] value)
/// {
/// ConVar cvar = FindConVar(name);
/// if (cvar)
/// {
/// cvar.Flags &= ~FCVAR_NOTIFY;
/// cvar.SetString(value);
/// cvar.Flags |= FCVAR_NOTIFY;
/// }
/// }
__________________