2009-04-29 01:58:41 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-07-05 08:49:23 +02:00
|
|
|
* Zombie:Reloaded
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
2009-06-12 05:51:26 +02:00
|
|
|
* File: tools_functions.inc
|
|
|
|
* Type: Core
|
|
|
|
* Description: API for offsets/signatures exposed in tools.inc
|
|
|
|
*
|
2013-01-12 08:47:36 +01:00
|
|
|
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
2009-06-12 05:51:26 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get or set a client's velocity.
|
|
|
|
* @param client The client index.
|
|
|
|
* @param vecVelocity Array to store vector in, or velocity to set on client.
|
|
|
|
* @param retrieve True to get client's velocity, false to set it.
|
|
|
|
* @param stack If modifying velocity, then true will stack new velocity onto the client's
|
|
|
|
* current velocity, false will reset it.
|
|
|
|
*/
|
2009-06-27 03:33:09 +02:00
|
|
|
stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:stack = true)
|
2009-04-29 01:58:41 +02:00
|
|
|
{
|
|
|
|
// If retrieve if true, then get client's velocity.
|
|
|
|
if (!apply)
|
|
|
|
{
|
|
|
|
// x = vector component.
|
|
|
|
for (new x = 0; x < 3; x++)
|
|
|
|
{
|
|
|
|
vecVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If stack is true, then add client's velocity.
|
|
|
|
if (stack)
|
|
|
|
{
|
|
|
|
// Get client's velocity.
|
|
|
|
new Float:vecClientVelocity[3];
|
|
|
|
|
|
|
|
// x = vector component.
|
|
|
|
for (new x = 0; x < 3; x++)
|
|
|
|
{
|
|
|
|
vecClientVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
|
|
|
|
}
|
|
|
|
|
|
|
|
AddVectors(vecClientVelocity, vecVelocity, vecVelocity);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply velocity on client.
|
|
|
|
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vecVelocity);
|
|
|
|
}
|
|
|
|
|
2012-09-20 11:32:00 +02:00
|
|
|
/**
|
|
|
|
* Gets client's velocity.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @param vecVelocity Array to store vector in.
|
|
|
|
*/
|
|
|
|
stock ToolsGetClientVelocity(client, Float:vecVelocity[3])
|
|
|
|
{
|
|
|
|
// x = vector component.
|
|
|
|
for (new x = 0; x < 3; x++)
|
|
|
|
{
|
|
|
|
vecVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
/**
|
|
|
|
* Set a client's lagged movement value.
|
|
|
|
* @param client The client index.
|
2010-07-04 17:58:27 +02:00
|
|
|
* @param value LMV value. (300.0 = default, 600.0 = double)
|
2009-04-29 01:58:41 +02:00
|
|
|
*/
|
2009-06-27 03:33:09 +02:00
|
|
|
stock ToolsSetClientLMV(client, Float:fLMV)
|
2009-04-29 01:58:41 +02:00
|
|
|
{
|
|
|
|
// Set lagged movement value of client.
|
|
|
|
SetEntDataFloat(client, g_iToolsLMV, fLMV / 300.0, true);
|
|
|
|
}
|
|
|
|
|
2009-07-07 06:32:34 +02:00
|
|
|
/**
|
|
|
|
* Get nightvision values on a client.
|
|
|
|
* @param client The client index.
|
|
|
|
* @param ownership If true, function will return the value of the client's ownership of nightvision.
|
|
|
|
* If false, function will return the value of the client's on/off state of the nightvision.
|
|
|
|
* @return True if aspect of nightvision is enabled on the client, false if not.
|
|
|
|
*/
|
|
|
|
stock bool:ToolsGetClientNightVision(client, bool:ownership = true)
|
|
|
|
{
|
|
|
|
// If ownership is true, then toggle the ownership of nightvision on client.
|
|
|
|
if (ownership)
|
|
|
|
{
|
|
|
|
return bool:GetEntData(client, g_iToolsHasNightVision, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bool:GetEntData(client, g_iToolsNightVisionOn, 1);
|
|
|
|
}
|
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
/**
|
|
|
|
* Control nightvision values on a client.
|
|
|
|
* @param client The client index.
|
|
|
|
* @param enable Enable or disable an aspect of nightvision. (see ownership parameter)
|
|
|
|
* @param ownership If true, enable will toggle the client's ownership of nightvision.
|
|
|
|
* If false, enable will toggle the client's on/off state of the nightvision.
|
|
|
|
*/
|
2009-07-07 06:32:34 +02:00
|
|
|
stock ToolsSetClientNightVision(client, bool:enable, bool:ownership = true)
|
2009-04-29 01:58:41 +02:00
|
|
|
{
|
|
|
|
// If ownership is true, then toggle the ownership of nightvision on client.
|
|
|
|
if (ownership)
|
|
|
|
{
|
|
|
|
SetEntData(client, g_iToolsHasNightVision, enable, 1, true);
|
|
|
|
|
|
|
|
// Stop here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetEntData(client, g_iToolsNightVisionOn, enable, 1, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a client's default field of vision.
|
|
|
|
* @param client The client index.
|
|
|
|
* @param FOV The field of vision of the client.
|
|
|
|
*/
|
2009-06-27 03:33:09 +02:00
|
|
|
stock ToolsSetClientDefaultFOV(client, FOV)
|
2009-04-29 01:58:41 +02:00
|
|
|
{
|
2009-12-11 15:16:28 +01:00
|
|
|
SetEntData(client, g_iToolsFOV, FOV, 1, true);
|
2009-04-29 01:58:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get or set a client's score or deaths.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @param score True to look at score, false to look at deaths.
|
|
|
|
* @param apply True to set scores or death, false to get.
|
|
|
|
* @param value The value of the client's score or deaths.
|
|
|
|
* @return The score or death count of the client, -1 if setting.
|
|
|
|
*/
|
2009-06-27 03:33:09 +02:00
|
|
|
stock ToolsClientScore(client, bool:score = true, bool:apply = true, value = 0)
|
2009-04-29 01:58:41 +02:00
|
|
|
{
|
|
|
|
if (!apply)
|
|
|
|
{
|
|
|
|
if (score)
|
|
|
|
{
|
|
|
|
// If score is true, then return client's score.
|
|
|
|
return GetEntProp(client, Prop_Data, "m_iFrags");
|
|
|
|
}
|
|
|
|
// Return client's deaths.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return GetEntProp(client, Prop_Data, "m_iDeaths");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If score is true, then set client's score.
|
|
|
|
if (score)
|
|
|
|
{
|
|
|
|
SetEntProp(client, Prop_Data, "m_iFrags", value);
|
|
|
|
}
|
|
|
|
// Set client's deaths.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetEntProp(client, Prop_Data, "m_iDeaths", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We set the client's score or deaths.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a client's alpha value.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @param alpha The alpha value to set client's alpha to. (0-255)
|
2009-05-08 07:37:07 +02:00
|
|
|
* @param weapons Apply alpha to all client's weapons.
|
2009-04-29 01:58:41 +02:00
|
|
|
*/
|
2009-06-27 03:33:09 +02:00
|
|
|
stock ToolsSetClientAlpha(client, alpha)
|
2009-04-29 01:58:41 +02:00
|
|
|
{
|
|
|
|
// Turn rendermode on, on the client.
|
2009-05-08 07:37:07 +02:00
|
|
|
SetEntityRenderMode(client, RENDER_TRANSALPHA);
|
2009-04-29 01:58:41 +02:00
|
|
|
|
|
|
|
// Set alpha value on the client.
|
2009-05-08 07:37:07 +02:00
|
|
|
SetEntityRenderColor(client, _, _, _, alpha);
|
|
|
|
|
2009-05-12 03:12:05 +02:00
|
|
|
// Forward event to modules.
|
|
|
|
WeaponAlphaOnClientAlphaChanged(client, alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets an entity's color. (This is the "get" version of SetEntityRenderColor)
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @return The alpha value of the client. (0-255)
|
|
|
|
*/
|
2009-06-27 03:33:09 +02:00
|
|
|
stock ToolsGetEntityAlpha(entity)
|
2009-05-12 03:12:05 +02:00
|
|
|
{
|
|
|
|
static bool:gotconfig = false;
|
|
|
|
static String:prop[32];
|
|
|
|
|
|
|
|
if (!gotconfig)
|
|
|
|
{
|
|
|
|
new Handle:gc = LoadGameConfigFile("core.games");
|
|
|
|
new bool:exists = GameConfGetKeyValue(gc, "m_clrRender", prop, sizeof(prop));
|
|
|
|
CloseHandle(gc);
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
{
|
|
|
|
strcopy(prop, sizeof(prop), "m_clrRender");
|
|
|
|
}
|
|
|
|
|
|
|
|
gotconfig = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
new offset = GetEntSendPropOffs(entity, prop);
|
|
|
|
|
|
|
|
return GetEntData(entity, offset + 3, 1);
|
2009-05-01 11:22:45 +02:00
|
|
|
}
|