Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SurfTimer-telefinder #235

Merged
merged 5 commits into from
Sep 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions addons/sourcemod/scripting/ckSurf-telefinder.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "Elzi"
#define PLUGIN_VERSION "1.00"

#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <surftimer>

EngineVersion g_Game;

Handle g_hEntity;
int g_iEntIndex[MAXPLAYERS + 1];

public Plugin myinfo =
{
name = "[surftimer] Teleport Destination Finder",
author = PLUGIN_AUTHOR,
description = "Teleports clients using !cktele to info_teleport_destinations",
version = PLUGIN_VERSION,
url = ""
};

public void OnPluginStart()
{
g_Game = GetEngineVersion();
if(g_Game != Engine_CSGO && g_Game != Engine_CSS)
{
SetFailState("This plugin is for CSGO/CSS only.");
}

RegAdminCmd("sm_cktele", TeleToInfo, ADMFLAG_ROOT, "[surftimer] Teleport client to a teleport destination in the map");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps also RegAdminCmd("sm_cktele" ==> sm_telefinder ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the pr


}

public void OnMapStart()
{
for (int i = 0; i < MAXPLAYERS + 1; i++)
g_iEntIndex[i] = 0;

int iEnt;
g_hEntity = CreateArray(12);

while ((iEnt = FindEntityByClassname(iEnt, "info_teleport_destination")) != -1)
PushArrayCell(g_hEntity, iEnt);

}

public void OnMapEnd()
{
if (g_hEntity != null)
g_hEntity.Close();

g_hEntity = null;
}


public Action TeleToInfo(int client, int args)
{
if (g_hEntity == null)
{
ReplyToCommand(client, "[CK] g_hEntity was null!");
Bara marked this conversation as resolved.
Show resolved Hide resolved
return Plugin_Handled;
}

if (GetArraySize(g_hEntity) < 1)
{
ReplyToCommand(client, "[CK] No info_teleport_destinations found in map!");
return Plugin_Handled;
}

if (g_iEntIndex[client] == GetArraySize(g_hEntity))
{
ReplyToCommand(client, "[CK] All info_teleport_destinations were looped, back to index 0");
g_iEntIndex[client] = 0;
}

int iEnt = GetArrayCell(g_hEntity, g_iEntIndex[client]);

if (IsValidEntity(iEnt))
{
float position[3];
GetEntPropVector(iEnt, Prop_Send, "m_vecOrigin", position);

surftimer_SafeTeleport(client, position, NULL_VECTOR, NULL_VECTOR, true);

ReplyToCommand(client, "[CK] Teleporting to entity at %f, %f, %f", position[0], position[1], position[2]);
}
else

ReplyToCommand(client, "[CK] Entity was invalid!");


g_iEntIndex[client]++;
return Plugin_Handled;
}