1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-08-05 07:31:48 +02:00

Untested update to the new plugin API.

Various other changes to the plugin as well.
This commit is contained in:
Sandu Liviu Catalin
2016-05-22 06:20:38 +03:00
parent ddb52677bd
commit f2361a27c3
167 changed files with 15520 additions and 60635 deletions

View File

@@ -1,17 +1,21 @@
// ------------------------------------------------------------------------------------------------
#include "Misc/Functions.hpp"
#include "Base/Shared.hpp"
#include "Base/Stack.hpp"
#include "Base/Color3.hpp"
#include "Base/Vector2.hpp"
#include "Base/Vector3.hpp"
#include "Library/Numeric.hpp"
// ------------------------------------------------------------------------------------------------
#include <cstring>
#include <algorithm>
#include "Entity/Player.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
static ServerSettings g_SvSettings;
static ServerSettings g_SvSettings;
static PluginInfo g_PluginInfo;
// ------------------------------------------------------------------------------------------------
static SQChar g_SvNameBuff[SQMOD_SVNAMELENGTH] = {0};
static SQChar g_PasswdBuff[SQMOD_PASSWDLENGTH] = {0};
static SQChar g_GmNameBuff[SQMOD_GMNAMELENGTH] = {0};
@@ -72,65 +76,166 @@ static String CS_Keycode_Names[] = {"", /* index 0 is not used */
};
// ------------------------------------------------------------------------------------------------
CCStr GetKeyCodeName(Uint8 keycode)
{ return CS_Keycode_Names[keycode].c_str(); }
void SetKeyCodeName(Uint8 keycode, CCStr name)
{ CS_Keycode_Names[keycode].assign(name); }
CSStr GetKeyCodeName(Uint8 keycode)
{
return CS_Keycode_Names[keycode].c_str();
}
// ------------------------------------------------------------------------------------------------
Uint32 GetPluginVersion()
{ return SQMOD_VERSION; }
CCStr GetPluginVersionStr()
{ return SQMOD_VERSION_STR; }
CCStr GetPluginName()
{ return SQMOD_NAME; }
CCStr GetPluginAuthor()
{ return SQMOD_AUTHOR; }
Int32 GetPluginID()
{ return _Info->nPluginId; }
Uint32 GetNumberOfPlugins()
{ return _Func->GetNumberOfPlugins(); }
Int32 FindPlugin(CCStr name)
{ return _Func->FindPlugin(const_cast< CStr >(name)); }
void SetKeyCodeName(Uint8 keycode, CSStr name)
{
CS_Keycode_Names[keycode].assign(name);
}
// ------------------------------------------------------------------------------------------------
Uint32 GetServerVersion()
{ return _Func->GetServerVersion(); }
{
return _Func->GetServerVersion();
}
// ------------------------------------------------------------------------------------------------
Table GetServerSettings()
{
// Update the server settings structure
_Func->GetServerSettings(&g_SvSettings);
// Allocate a script table
Table tbl;
// Add the structure members to the script table
tbl.SetValue(_SC("Name"), g_SvSettings.serverName);
tbl.SetValue(_SC("MaxPlayers"), g_SvSettings.maxPlayers);
tbl.SetValue(_SC("Port"), g_SvSettings.port);
tbl.SetValue(_SC("Flags"), g_SvSettings.flags);
// Return the resulted table
return tbl;
}
// ------------------------------------------------------------------------------------------------
Uint32 GetNumberOfPlugins()
{
return _Func->GetNumberOfPlugins();
}
// ------------------------------------------------------------------------------------------------
Table GetPluginInfo(Int32 plugin_id)
{
// Attempt to update the plug-in info structure
if (_Func->GetPluginInfo(plugin_id, &g_PluginInfo) == vcmpErrorNoSuchEntity)
{
STHROWF("Unknown plug-in identifier: %d", plugin_id);
}
// Allocate a script table
Table tbl;
// Add the structure members to the script table
tbl.SetValue(_SC("Id"), g_PluginInfo.pluginId);
tbl.SetValue(_SC("Name"), g_PluginInfo.name);
tbl.SetValue(_SC("Version"), g_PluginInfo.pluginVersion);
tbl.SetValue(_SC("MajorAPI"), g_PluginInfo.apiMajorVersion);
tbl.SetValue(_SC("MinorAPI"), g_PluginInfo.apiMinorVersion);
// Return the resulted table
return tbl;
}
// ------------------------------------------------------------------------------------------------
Int32 FindPlugin(CSStr name)
{
return _Func->FindPlugin(name);
}
// ------------------------------------------------------------------------------------------------
void SendPluginCommand(Uint32 identifier, CSStr payload)
{
_Func->SendPluginCommand(identifier, payload);
}
// ------------------------------------------------------------------------------------------------
const ULongInt & GetTime()
{
return GetULongInt(_Func->GetTime());
}
// ------------------------------------------------------------------------------------------------
SQInteger SendLogMessage(HSQUIRRELVM vm)
{
const Int32 top = sq_gettop(vm);
// Was the message value specified?
if (top <= 1)
{
return sq_throwerror(vm, "Missing message value");
}
// Attempt to generate the string value
StackStrF val(vm, 2);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
{
return val.mRes; // Propagate the error!
}
// Forward the resulted string value
else if (_Func->LogMessage("%s", val.mPtr) == vcmpErrorTooLargeInput)
{
STHROWF("Input is too big");
}
// This function does not return a value
return 0;
}
// ------------------------------------------------------------------------------------------------
Int32 GetLastError()
{
return _Func->GetLastError();
}
// ------------------------------------------------------------------------------------------------
Uint32 GetPluginVersion()
{
return SQMOD_VERSION;
}
// ------------------------------------------------------------------------------------------------
CSStr GetPluginVersionStr()
{
return SQMOD_VERSION_STR;
}
// ------------------------------------------------------------------------------------------------
CSStr GetPluginName()
{
return SQMOD_NAME;
}
// ------------------------------------------------------------------------------------------------
CSStr GetPluginAuthor()
{
return SQMOD_AUTHOR;
}
// ------------------------------------------------------------------------------------------------
Int32 GetPluginID()
{
return _Info->pluginId;
}
// ------------------------------------------------------------------------------------------------
Uint32 GetServerPort()
{
// Update the server settings structure
_Func->GetServerSettings(&g_SvSettings);
return g_SvSettings.uPort;
// Return the requested information
return g_SvSettings.port;
}
// ------------------------------------------------------------------------------------------------
Uint32 GetServerFlags()
{
// Update the server settings structure
_Func->GetServerSettings(&g_SvSettings);
return g_SvSettings.uFlags;
// Return the requested information
return g_SvSettings.flags;
}
// ------------------------------------------------------------------------------------------------
void SetServerName(CCStr name)
{ _Func->SetServerName(name); }
CCStr GetServerName()
Int32 GetMaxPlayers(void)
{
_Func->GetServerName(g_SvNameBuff, SQMOD_SVNAMELENGTH);
return g_SvNameBuff;
}
// ------------------------------------------------------------------------------------------------
ULongInt GetTime()
{
std::uint64_t time = 0;
_Func->GetTime(&time);
return ULongInt(time);
}
// ------------------------------------------------------------------------------------------------
void SendCustomCommand(Uint32 type, CCStr cmd)
{
_Func->SendCustomCommand(type, cmd);
return _Func->GetMaxPlayers();
}
// ------------------------------------------------------------------------------------------------
@@ -139,39 +244,534 @@ void SetMaxPlayers(Int32 max)
_Func->SetMaxPlayers(max);
}
Int32 GetMaxPlayers(void)
// ------------------------------------------------------------------------------------------------
CSStr GetServerName()
{
return _Func->GetMaxPlayers();
// Populate the buffer
if (_Func->GetServerName(g_SvNameBuff, SQMOD_SVNAMELENGTH) == vcmpErrorBufferTooSmall)
{
STHROWF("Server name was too big for the available buffer: %u", sizeof(g_SvNameBuff));
}
// Return the result
return g_SvNameBuff;
}
// ------------------------------------------------------------------------------------------------
void SetServerPassword(CCStr passwd)
{ _Func->SetServerPassword(const_cast< CStr >(passwd)); }
CCStr GetServerPassword()
void SetServerName(CSStr name)
{
_Func->GetServerPassword(g_PasswdBuff, SQMOD_PASSWDLENGTH);
_Func->SetServerName(name);
}
// ------------------------------------------------------------------------------------------------
CSStr GetServerPassword()
{
// Populate the buffer
if (_Func->GetServerPassword(g_PasswdBuff, SQMOD_PASSWDLENGTH) == vcmpErrorBufferTooSmall)
{
STHROWF("Server password was too big for the available buffer: %u", sizeof(g_PasswdBuff));
}
// Return the result
return g_PasswdBuff;
}
// ------------------------------------------------------------------------------------------------
void SetGameModeText(CCStr text)
{ _Func->SetGameModeText(text); }
CCStr GetGameModeText()
void SetServerPassword(CSStr passwd)
{
_Func->GetGameModeText(g_GmNameBuff, SQMOD_GMNAMELENGTH);
_Func->SetServerPassword(passwd);
}
// ------------------------------------------------------------------------------------------------
CSStr GetGameModeText()
{
// Populate the buffer
if (_Func->GetGameModeText(g_GmNameBuff, SQMOD_GMNAMELENGTH) == vcmpErrorBufferTooSmall)
{
STHROWF("Game-mode text was too big for the available buffer: %u", sizeof(g_GmNameBuff));
}
// Return the result
return g_GmNameBuff;
}
// ------------------------------------------------------------------------------------------------
Int32 PlaySound(Int32 world, Int32 sound, const Vector3 & pos)
{ return _Func->PlaySound(world, sound, pos.x, pos.y, pos.z); }
Int32 PlaySoundEx(Int32 world, Int32 sound, Float32 x, Float32 y, Float32 z)
{ return _Func->PlaySound(world, sound, x, y, z); }
void SetGameModeText(CSStr text)
{
_Func->SetGameModeText(text);
}
// ------------------------------------------------------------------------------------------------
Int32 AddRadioStream(Int32 id, CCStr name, CCStr url, bool listed)
{ return _Func->AddRadioStream(id, name, url, listed); }
Int32 RemoveRadioStream(Int32 id)
{ return _Func->RemoveRadioStream(id); }
void CreateRadioStream(CSStr name, CSStr url, bool listed)
{
if (_Func->AddRadioStream(-1, name, url, listed) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid radio stream identifier");
}
}
// ------------------------------------------------------------------------------------------------
void CreateRadioStreamEx(Int32 id, CSStr name, CSStr url, bool listed)
{
if (_Func->AddRadioStream(id, name, url, listed) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid radio stream identifier");
}
}
// ------------------------------------------------------------------------------------------------
void RemoveRadioStream(Int32 id)
{
if (_Func->RemoveRadioStream(id) == vcmpErrorNoSuchEntity)
{
STHROWF("No such radio stream exists");
}
}
// ------------------------------------------------------------------------------------------------
void ShutdownServer()
{
_Func->ShutdownServer();
}
// ------------------------------------------------------------------------------------------------
bool GetServerOption(Int32 option_id)
{
// Attempt to obtain the current value of the specified option
const bool value = _Func->GetServerOption(static_cast< vcmpServerOption >(option_id));
// Check for errors
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Unknown option identifier: %d", option_id);
}
// Return the obtained value
return value;
}
// ------------------------------------------------------------------------------------------------
void SetServerOption(Int32 option_id, bool toggle)
{
if (_Func->SetServerOption(static_cast< vcmpServerOption >(option_id),
toggle) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Unknown option identifier: %d", option_id);
}
else
{
Core::Get().EmitServerOption(option_id, toggle, 0, NullObject());
}
}
// ------------------------------------------------------------------------------------------------
void SetServerOptionEx(Int32 option_id, bool toggle, Int32 header, Object & payload)
{
if (_Func->SetServerOption(static_cast< vcmpServerOption >(option_id),
toggle) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Unknown option identifier: %d", option_id);
}
else
{
Core::Get().EmitServerOption(option_id, toggle, header, payload);
}
}
// ------------------------------------------------------------------------------------------------
Table GetWorldBounds()
{
Vector2 max, min;
// Retrieve the current world bounds
_Func->GetWorldBounds(&max.x, &min.x, &max.y, &min.y);
// Allocate a script table
Table tbl;
// Populate the table with the obtained values
tbl.SetValue(_SC("max"), max);
tbl.SetValue(_SC("min"), min);
// Return the result
return tbl;
}
// ------------------------------------------------------------------------------------------------
void SetWorldBounds(const Vector2 & max, const Vector2 & min)
{
_Func->SetWorldBounds(max.x, min.x, max.y, min.y);
}
// ------------------------------------------------------------------------------------------------
void SetWorldBoundsEx(Float32 max_x, Float32 max_y, Float32 min_x, Float32 min_y)
{
_Func->SetWorldBounds(max_x, min_x, max_y, min_y);
}
Table GetWastedSettings()
{
Uint32 fc, dt, ft, cfs, cft;
Float32 fis, fos;
Color3 c;
// Retrieve the current wasted settings bounds
_Func->GetWastedSettings(&dt, &ft, &fis, &fos, &fc, &cfs, &cft);
// Convert the packed color
c.SetRGB(fc);
// Allocate a script table
Table tbl;
// Populate the table with the obtained values
tbl.SetValue(_SC("DeathTimerOut"), dt);
tbl.SetValue(_SC("FadeTimer"), ft);
tbl.SetValue(_SC("FadeInSpeed"), fis);
tbl.SetValue(_SC("FadeOutSpeed"), fos);
tbl.SetValue(_SC("FadeColour"), c);
tbl.SetValue(_SC("CorpseFadeStart"), cfs);
tbl.SetValue(_SC("CorpseFadeTime"), cft);
// Return the result
return tbl;
}
// ------------------------------------------------------------------------------------------------
void SetWastedSettings(Uint32 dt, Uint32 ft, Float32 fis, Float32 fos,
const Color3 & fc, Uint32 cfs, Uint32 cft)
{
_Func->SetWastedSettings(dt, ft, fis, fos, fc.GetRGB(), cfs, cft);
}
// ------------------------------------------------------------------------------------------------
Uint32 GetTimeRate(void)
{
return _Func->GetTimeRate();
}
// ------------------------------------------------------------------------------------------------
void SetTimeRate(Uint32 rate)
{
_Func->SetTimeRate(rate);
}
// ------------------------------------------------------------------------------------------------
Int32 GetHour(void)
{
return _Func->GetHour();
}
// ------------------------------------------------------------------------------------------------
void SetHour(Int32 hour)
{
_Func->SetHour(hour);
}
// ------------------------------------------------------------------------------------------------
Int32 GetMinute(void)
{
return _Func->GetMinute();
}
// ------------------------------------------------------------------------------------------------
void SetMinute(Int32 minute)
{
_Func->SetMinute(minute);
}
// ------------------------------------------------------------------------------------------------
Int32 GetWeather(void)
{
return _Func->GetWeather();
}
// ------------------------------------------------------------------------------------------------
void SetWeather(Int32 weather)
{
_Func->SetWeather(weather);
}
// ------------------------------------------------------------------------------------------------
Float32 GetGravity(void)
{
return _Func->GetGravity();
}
// ------------------------------------------------------------------------------------------------
void SetGravity(Float32 gravity)
{
_Func->SetGravity(gravity);
}
// ------------------------------------------------------------------------------------------------
Float32 GetGameSpeed(void)
{
return _Func->GetGameSpeed();
}
// ------------------------------------------------------------------------------------------------
void SetGameSpeed(Float32 speed)
{
_Func->SetGameSpeed(speed);
}
// ------------------------------------------------------------------------------------------------
Float32 GetWaterLevel(void)
{
return _Func->GetWaterLevel();
}
// ------------------------------------------------------------------------------------------------
void SetWaterLevel(Float32 level)
{
_Func->SetWaterLevel(level);
}
// ------------------------------------------------------------------------------------------------
Float32 GetMaximumFlightAltitude(void)
{
return _Func->GetMaximumFlightAltitude();
}
// ------------------------------------------------------------------------------------------------
void SetMaximumFlightAltitude(Float32 height)
{
_Func->SetMaximumFlightAltitude(height);
}
// ------------------------------------------------------------------------------------------------
Int32 GetKillCommandDelay(void)
{
return _Func->GetKillCommandDelay();
}
// ------------------------------------------------------------------------------------------------
void SetKillCommandDelay(Int32 delay)
{
_Func->SetKillCommandDelay(delay);
}
// ------------------------------------------------------------------------------------------------
Float32 GetVehiclesForcedRespawnHeight(void)
{
return _Func->GetVehiclesForcedRespawnHeight();
}
// ------------------------------------------------------------------------------------------------
void SetVehiclesForcedRespawnHeight(Float32 height)
{
_Func->SetVehiclesForcedRespawnHeight(height);
}
// ------------------------------------------------------------------------------------------------
void CreateExplosion(Int32 world, Int32 type, const Vector3 & pos, CPlayer & source, bool grounded)
{
// Validate the specified player
source.Validate();
// Perform the requested operation
if (_Func->CreateExplosion(world, type, pos.x, pos.y, pos.z,
source.GetID(), grounded) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Argument value out of bounds");
}
}
// ------------------------------------------------------------------------------------------------
void CreateExplosionEx(Int32 world, Int32 type, Float32 x, Float32 y, Float32 z, CPlayer & source, bool grounded)
{
// Validate the specified player
source.Validate();
// Perform the requested operation
if (_Func->CreateExplosion(world, type, x, y, z,
source.GetID(), grounded) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Argument value out of bounds");
}
}
// ------------------------------------------------------------------------------------------------
void PlaySound(Int32 world, Int32 sound, const Vector3 & pos)
{
if (_Func->PlaySound(world, sound, pos.x, pos.y, pos.z) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Argument value out of bounds");
}
}
// ------------------------------------------------------------------------------------------------
void PlaySoundEx(Int32 world, Int32 sound, Float32 x, Float32 y, Float32 z)
{
if (_Func->PlaySound(world, sound, x, y, z) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Argument value out of bounds");
}
}
// ------------------------------------------------------------------------------------------------
void HideMapObject(Int32 model, const Vector3 & pos)
{
_Func->HideMapObject(model,
static_cast< Int16 >(std::floor(pos.x * 10.0f) + 0.5f),
static_cast< Int16 >(std::floor(pos.y * 10.0f) + 0.5f),
static_cast< Int16 >(std::floor(pos.z * 10.0f) + 0.5f)
);
}
// ------------------------------------------------------------------------------------------------
void HideMapObjectEx(Int32 model, Float32 x, Float32 y, Float32 z)
{
_Func->HideMapObject(model,
static_cast< Int16 >(std::floor(x * 10.0f) + 0.5f),
static_cast< Int16 >(std::floor(y * 10.0f) + 0.5f),
static_cast< Int16 >(std::floor(z * 10.0f) + 0.5f)
);
}
// ------------------------------------------------------------------------------------------------
void HideMapObjectRaw(Int32 model, Int16 x, Int16 y, Int16 z)
{
_Func->HideMapObject(model, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void ShowMapObject(Int32 model, const Vector3 & pos)
{
_Func->ShowMapObject(model,
static_cast< Int16 >(std::floor(pos.x * 10.0f) + 0.5f),
static_cast< Int16 >(std::floor(pos.y * 10.0f) + 0.5f),
static_cast< Int16 >(std::floor(pos.z * 10.0f) + 0.5f)
);
}
// ------------------------------------------------------------------------------------------------
void ShowMapObjectEx(Int32 model, Float32 x, Float32 y, Float32 z)
{
_Func->ShowMapObject(model,
static_cast< Int16 >(std::floor(x * 10.0f) + 0.5f),
static_cast< Int16 >(std::floor(y * 10.0f) + 0.5f),
static_cast< Int16 >(std::floor(z * 10.0f) + 0.5f)
);
}
// ------------------------------------------------------------------------------------------------
void ShowMapObjectRaw(Int32 model, Int16 x, Int16 y, Int16 z)
{
_Func->ShowMapObject(model, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void ShowAllMapObjects(void)
{
_Func->ShowAllMapObjects();
}
// ------------------------------------------------------------------------------------------------
SQFloat GetWeaponDataValue(Int32 weapon, Int32 field)
{
return ConvTo< SQFloat >::From(_Func->GetWeaponDataValue(weapon, field));
}
// ------------------------------------------------------------------------------------------------
bool SetWeaponDataValue(Int32 weapon, Int32 field, SQFloat value)
{
return (_Func->SetWeaponDataValue(weapon, field, value) != vcmpErrorArgumentOutOfBounds);
}
// ------------------------------------------------------------------------------------------------
bool ResetWeaponDataValue(Int32 weapon, Int32 field)
{
return (_Func->ResetWeaponDataValue(weapon, field) != vcmpErrorArgumentOutOfBounds);
}
// ------------------------------------------------------------------------------------------------
bool IsWeaponDataValueModified(Int32 weapon, Int32 field)
{
return _Func->IsWeaponDataValueModified(weapon, field);
}
// ------------------------------------------------------------------------------------------------
bool ResetWeaponData(Int32 weapon)
{
return (_Func->ResetWeaponData(weapon) != vcmpErrorArgumentOutOfBounds);
}
// ------------------------------------------------------------------------------------------------
void ResetAllWeaponData()
{
_Func->ResetAllWeaponData();
}
// ------------------------------------------------------------------------------------------------
Int32 AddPlayerClass(Int32 team, const Color3 & color, Int32 skin, const Vector3 & pos, Float32 angle,
Int32 wep1, Int32 ammo1, Int32 wep2, Int32 ammo2, Int32 wep3, Int32 ammo3)
{
return _Func->AddPlayerClass(team, color.GetRGB(), skin, pos.x, pos.y, pos.z, angle,
wep1, ammo1, wep2, ammo2, wep3, ammo3);
}
// ------------------------------------------------------------------------------------------------
void SetSpawnPlayerPosition(const Vector3 & pos)
{
_Func->SetSpawnPlayerPosition(pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
void SetSpawnCameraPosition(const Vector3 & pos)
{
_Func->SetSpawnCameraPosition(pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
void SetSpawnCameraLookAt(const Vector3 & pos)
{
_Func->SetSpawnCameraLookAt(pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
void SetSpawnPlayerPositionEx(Float32 x, Float32 y, Float32 z)
{
_Func->SetSpawnPlayerPosition(x, y, z);
}
// ------------------------------------------------------------------------------------------------
void SetSpawnCameraPositionEx(Float32 x, Float32 y, Float32 z)
{
_Func->SetSpawnCameraPosition(x, y, z);
}
// ------------------------------------------------------------------------------------------------
void SetSpawnCameraLookAtEx(Float32 x, Float32 y, Float32 z)
{
_Func->SetSpawnPlayerPosition(x, y, z);
}
// ------------------------------------------------------------------------------------------------
void BanIP(CSStr addr)
{
_Func->BanIP(const_cast< SStr >(addr));
}
// ------------------------------------------------------------------------------------------------
bool UnbanIP(CSStr addr)
{
return _Func->UnbanIP(const_cast< SStr >(addr));
}
// ------------------------------------------------------------------------------------------------
bool IsIPBanned(CSStr addr)
{
return _Func->IsIPBanned(const_cast< SStr >(addr));
}
// ------------------------------------------------------------------------------------------------
Int32 GetPlayerIdFromName(CSStr name)
{
return _Func->GetPlayerIdFromName(name);
}
// ------------------------------------------------------------------------------------------------
bool IsPlayerConnected(Int32 player_id)
{
return _Func->IsPlayerConnected(player_id);
}
// ------------------------------------------------------------------------------------------------
void ForceAllSelect()
{
_Func->ForceAllSelect();
}
// ------------------------------------------------------------------------------------------------
bool CheckEntityExists(Int32 type, Int32 index)
{
return _Func->CheckEntityExists(static_cast< vcmpEntityPool >(type), index);
}
} // Namespace:: SqMod

View File

@@ -7,55 +7,452 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CCStr GetKeyCodeName(Uint8 keycode);
void SetKeyCodeName(Uint8 keycode, CCStr name);
/* ------------------------------------------------------------------------------------------------
* Retrieve the name of a certain key-code.
*/
CSStr GetKeyCodeName(Uint8 keycode);
// ------------------------------------------------------------------------------------------------
Uint32 GetPluginVersion();
CCStr GetPluginVersionStr();
CCStr GetPluginName();
CCStr GetPluginAuthor();
Int32 GetPluginID();
Uint32 GetNumberOfPlugins();
Int32 FindPlugin(CCStr name);
/* ------------------------------------------------------------------------------------------------
* Modify the name of a certain key-code.
*/
void SetKeyCodeName(Uint8 keycode, CSStr name);
// ------------------------------------------------------------------------------------------------
/* ------------------------------------------------------------------------------------------------
* Retrieve the server version.
*/
Uint32 GetServerVersion();
// ------------------------------------------------------------------------------------------------
/* ------------------------------------------------------------------------------------------------
* Retrieve the server settings.
*/
Table GetServerSettings();
/* ------------------------------------------------------------------------------------------------
* Retrieve the number of loaded plug-ins.
*/
Uint32 GetNumberOfPlugins();
/* ------------------------------------------------------------------------------------------------
* Retrieve information about a certain plug-in.
*/
Table GetPluginInfo(Int32 plugin_id);
/* ------------------------------------------------------------------------------------------------
* Attempt to find a plug-in identifier by it's name.
*/
Int32 FindPlugin(CSStr name);
/* ------------------------------------------------------------------------------------------------
* Send a custom command to the loaded plug-ins.
*/
void SendPluginCommand(Uint32 identifier, CSStr payload);
/* ------------------------------------------------------------------------------------------------
* Retrieve the server time.
*/
const ULongInt & GetTime();
/* ------------------------------------------------------------------------------------------------
* Send a log message to the server.
*/
SQInteger SendLogMessage(HSQUIRRELVM vm);
/* ------------------------------------------------------------------------------------------------
* Retrieve the last error that occurred on the server.
*/
Int32 GetLastError();
/* ------------------------------------------------------------------------------------------------
* Retrieve the version of the host Squirrel plug-in as an integer.
*/
Uint32 GetPluginVersion();
/* ------------------------------------------------------------------------------------------------
* Retrieve the version of the host Squirrel plug-in as a string.
*/
CSStr GetPluginVersionStr();
/* ------------------------------------------------------------------------------------------------
* Retrieve the name of the host Squirrel plug-in.
*/
CSStr GetPluginName();
/* ------------------------------------------------------------------------------------------------
* Retrieve the author of the host Squirrel plug-in.
*/
CSStr GetPluginAuthor();
/* ------------------------------------------------------------------------------------------------
* Retrieve the id of the host Squirrel plug-in.
*/
Int32 GetPluginID();
/* ------------------------------------------------------------------------------------------------
* Retrieve the port onto which the server was binded.
*/
Uint32 GetServerPort();
/* ------------------------------------------------------------------------------------------------
* Retrieve the server flags.
*/
Uint32 GetServerFlags();
// ------------------------------------------------------------------------------------------------
void SetServerName(CCStr name);
CCStr GetServerName();
// ------------------------------------------------------------------------------------------------
ULongInt GetTime();
// ------------------------------------------------------------------------------------------------
void SendCustomCommand(Uint32 type, CCStr cmd);
// ------------------------------------------------------------------------------------------------
void SetMaxPlayers(Int32 max);
/* ------------------------------------------------------------------------------------------------
* Retrieve the maximum number of clients allowed on the server.
*/
Int32 GetMaxPlayers(void);
// ------------------------------------------------------------------------------------------------
void SetServerPassword(CCStr passwd);
CCStr GetServerPassword();
/* ------------------------------------------------------------------------------------------------
* Modify the maximum number of clients allowed on the server.
*/
void SetMaxPlayers(Int32 max);
// ------------------------------------------------------------------------------------------------
void SetGameModeText(CCStr text);
CCStr GetGameModeText();
/* ------------------------------------------------------------------------------------------------
* Retrieve the server name.
*/
CSStr GetServerName();
// ------------------------------------------------------------------------------------------------
Int32 PlaySound(Int32 world, Int32 sound, const Vector3 & pos);
Int32 PlaySoundEx(Int32 world, Int32 sound, Float32 x, Float32 y, Float32 z);
/* ------------------------------------------------------------------------------------------------
* Modify the server name.
*/
void SetServerName(CSStr name);
// ------------------------------------------------------------------------------------------------
Int32 AddRadioStream(Int32 id, CCStr name, CCStr url, bool listed);
Int32 RemoveRadioStream(Int32 id);
/* ------------------------------------------------------------------------------------------------
* Retrieve the server password.
*/
CSStr GetServerPassword();
/* ------------------------------------------------------------------------------------------------
* Modify the server password.
*/
void SetServerPassword(CSStr passwd);
/* ------------------------------------------------------------------------------------------------
* Retrieve the game-mode text.
*/
CSStr GetGameModeText();
/* ------------------------------------------------------------------------------------------------
* Modify the game-mode text.
*/
void SetGameModeText(CSStr text);
/* ------------------------------------------------------------------------------------------------
* Create a radio stream.
*/
void CreateRadioStream(CSStr name, CSStr url, bool listed);
/* ------------------------------------------------------------------------------------------------
* Create a radio stream.
*/
void CreateRadioStreamEx(Int32 id, CSStr name, CSStr url, bool listed);
/* ------------------------------------------------------------------------------------------------
* Remove a radio stream.
*/
void RemoveRadioStream(Int32 id);
/* ------------------------------------------------------------------------------------------------
* Shutdown the server.
*/
void ShutdownServer();
/* ------------------------------------------------------------------------------------------------
* Retrieve a server option.
*/
bool GetServerOption(Int32 option_id);
/* ------------------------------------------------------------------------------------------------
* Modify a server option.
*/
void SetServerOption(Int32 option_id, bool toggle);
/* ------------------------------------------------------------------------------------------------
* Modify a server option.
*/
void SetServerOptionEx(Int32 option_id, bool toggle, Int32 header, Object & payload);
/* ------------------------------------------------------------------------------------------------
* Retrieve the world bounds.
*/
Table GetWorldBounds();
/* ------------------------------------------------------------------------------------------------
* Modify the world bounds.
*/
void SetWorldBounds(const Vector2 & max, const Vector2 & min);
/* ------------------------------------------------------------------------------------------------
* Modify the world bounds.
*/
void SetWorldBoundsEx(Float32 max_x, Float32 max_y, Float32 min_x, Float32 min_y);
/* ------------------------------------------------------------------------------------------------
* Retrieve the wasted settings.
*/
Table GetWastedSettings();
/* ------------------------------------------------------------------------------------------------
* Modify the wasted settings.
*/
void SetWastedSettings(Uint32 dt, Uint32 ft, Float32 fis, Float32 fos,
const Color3 & fc, Uint32 cfs, Uint32 cft);
/* ------------------------------------------------------------------------------------------------
* Retrieve the current time-rate.
*/
Uint32 GetTimeRate(void);
/* ------------------------------------------------------------------------------------------------
* Modify the current time-rate.
*/
void SetTimeRate(Uint32 rate);
/* ------------------------------------------------------------------------------------------------
* Retrieve the game hour.
*/
Int32 GetHour(void);
/* ------------------------------------------------------------------------------------------------
* Modify the game hour.
*/
void SetHour(Int32 hour);
/* ------------------------------------------------------------------------------------------------
* Retrieve the game minute.
*/
Int32 GetMinute(void);
/* ------------------------------------------------------------------------------------------------
* Modify the game minute.
*/
void SetMinute(Int32 minute);
/* ------------------------------------------------------------------------------------------------
* Retrieve the weather effects.
*/
Int32 GetWeather(void);
/* ------------------------------------------------------------------------------------------------
* Modify the weather effects.
*/
void SetWeather(Int32 weather);
/* ------------------------------------------------------------------------------------------------
* Retrieve the game gravity.
*/
Float32 GetGravity(void);
/* ------------------------------------------------------------------------------------------------
* Modify the game gravity.
*/
void SetGravity(Float32 gravity);
/* ------------------------------------------------------------------------------------------------
* Retrieve the game speed.
*/
Float32 GetGameSpeed(void);
/* ------------------------------------------------------------------------------------------------
* Modify the game speed.
*/
void SetGameSpeed(Float32 speed);
/* ------------------------------------------------------------------------------------------------
* Retrieve the water level.
*/
Float32 GetWaterLevel(void);
/* ------------------------------------------------------------------------------------------------
* Modify the water level.
*/
void SetWaterLevel(Float32 level);
/* ------------------------------------------------------------------------------------------------
* Retrieve the maximum flight altitude.
*/
Float32 GetMaximumFlightAltitude(void);
/* ------------------------------------------------------------------------------------------------
* Modify the maximum flight altitude.
*/
void SetMaximumFlightAltitude(Float32 height);
/* ------------------------------------------------------------------------------------------------
* Retrieve the kill command delay.
*/
Int32 GetKillCommandDelay(void);
/* ------------------------------------------------------------------------------------------------
* Modify the kill command delay.
*/
void SetKillCommandDelay(Int32 delay);
/* ------------------------------------------------------------------------------------------------
* Retrieve the vehicles forced respawn height.
*/
Float32 GetVehiclesForcedRespawnHeight(void);
/* ------------------------------------------------------------------------------------------------
* Modify the vehicles forced respawn height.
*/
void SetVehiclesForcedRespawnHeight(Float32 height);
/* ------------------------------------------------------------------------------------------------
* Create a game explosion.
*/
void CreateExplosion(Int32 world, Int32 type, const Vector3 & pos, CPlayer & source, bool grounded);
/* ------------------------------------------------------------------------------------------------
* Create a game explosion.
*/
void CreateExplosionEx(Int32 world, Int32 type, Float32 x, Float32 y, Float32 z, CPlayer & source, bool grounded);
/* ------------------------------------------------------------------------------------------------
* Play a game sound.
*/
void PlaySound(Int32 world, Int32 sound, const Vector3 & pos);
/* ------------------------------------------------------------------------------------------------
* Play a game sound.
*/
void PlaySoundEx(Int32 world, Int32 sound, Float32 x, Float32 y, Float32 z);
/* ------------------------------------------------------------------------------------------------
* Make a map object invisible.
*/
void HideMapObject(Int32 model, const Vector3 & pos);
/* ------------------------------------------------------------------------------------------------
* Make a map object invisible.
*/
void HideMapObjectEx(Int32 model, Float32 x, Float32 y, Float32 z);
/* ------------------------------------------------------------------------------------------------
* Make a map object invisible.
*/
void HideMapObjectRaw(Int32 model, Int16 x, Int16 y, Int16 z);
/* ------------------------------------------------------------------------------------------------
* Make a map object visible again.
*/
void ShowMapObject(Int32 model, const Vector3 & pos);
/* ------------------------------------------------------------------------------------------------
* Make a map object visible again.
*/
void ShowMapObjectEx(Int32 model, Float32 x, Float32 y, Float32 z);
/* ------------------------------------------------------------------------------------------------
* Make a map object visible again.
*/
void ShowMapObjectRaw(Int32 model, Int16 x, Int16 y, Int16 z);
/* ------------------------------------------------------------------------------------------------
* Make all map objects visible again.
*/
void ShowAllMapObjects(void);
/* ------------------------------------------------------------------------------------------------
* Retrieve field data of a certain weapon.
*/
SQFloat GetWeaponDataValue(Int32 weapon, Int32 field);
/* ------------------------------------------------------------------------------------------------
* Modify field data of a certain weapon.
*/
bool SetWeaponDataValue(Int32 weapon, Int32 field, SQFloat value);
/* ------------------------------------------------------------------------------------------------
* Reset field data of a certain weapon.
*/
bool ResetWeaponDataValue(Int32 weapon, Int32 field);
/* ------------------------------------------------------------------------------------------------
* See whether field data of a certain weapon was modified.
*/
bool IsWeaponDataValueModified(Int32 weapon, Int32 field);
/* ------------------------------------------------------------------------------------------------
* Reset all fields data of a certain weapon.
*/
bool ResetWeaponData(Int32 weapon);
/* ------------------------------------------------------------------------------------------------
* Reset all fields data of a all weapons.
*/
void ResetAllWeaponData();
/* ------------------------------------------------------------------------------------------------
* Create a new player class.
*/
Int32 AddPlayerClass(Int32 team, const Color3 & color, Int32 skin, const Vector3 & pos, Float32 angle,
Int32 wep1, Int32 ammo1, Int32 wep2, Int32 ammo2, Int32 wep3, Int32 ammo3);
/* ------------------------------------------------------------------------------------------------
* Set the player position when spawning.
*/
void SetSpawnPlayerPosition(const Vector3 & pos);
/* ------------------------------------------------------------------------------------------------
* Set the camera position when spawning.
*/
void SetSpawnCameraPosition(const Vector3 & pos);
/* ------------------------------------------------------------------------------------------------
* Set the camera focus when spawning.
*/
void SetSpawnCameraLookAt(const Vector3 & pos);
/* ------------------------------------------------------------------------------------------------
* Set the player position when spawning.
*/
void SetSpawnPlayerPositionEx(Float32 x, Float32 y, Float32 z);
/* ------------------------------------------------------------------------------------------------
* Set the camera position when spawning.
*/
void SetSpawnCameraPositionEx(Float32 x, Float32 y, Float32 z);
/* ------------------------------------------------------------------------------------------------
* Set the camera focus when spawning.
*/
void SetSpawnCameraLookAtEx(Float32 x, Float32 y, Float32 z);
/* ------------------------------------------------------------------------------------------------
* Ban an IP address from the server.
*/
void BanIP(CSStr addr);
/* ------------------------------------------------------------------------------------------------
* Unban an IP address from the server.
*/
bool UnbanIP(CSStr addr);
/* ------------------------------------------------------------------------------------------------
* See if an IP address is banned from the server.
*/
bool IsIPBanned(CSStr addr);
/* ------------------------------------------------------------------------------------------------
* Retrieve the identifier of the player with the specified name.
*/
Int32 GetPlayerIdFromName(CSStr name);
/* ------------------------------------------------------------------------------------------------
* See if a player with the specified identifier is connected.
*/
bool IsPlayerConnected(Int32 player_id);
/* ------------------------------------------------------------------------------------------------
* Force all players on the server to select a class.
*/
void ForceAllSelect();
/* ------------------------------------------------------------------------------------------------
* See if an entity exists on the server.
*/
bool CheckEntityExists(Int32 type, Int32 index);
} // Namespace:: SqMod

View File

@@ -9,19 +9,16 @@
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CCStr GetModelName(Int32 id)
CSStr GetModelName(Int32 /*id*/)
{
// @TODO Implement...
SQMOD_UNUSED_VAR(id);
return _SC("");
}
// ------------------------------------------------------------------------------------------------
void SetModelName(Int32 id, CCStr name)
void SetModelName(Int32 /*id*/, CSStr /*name*/)
{
// @TODO Implement...
SQMOD_UNUSED_VAR(id);
SQMOD_UNUSED_VAR(name);
}
// ------------------------------------------------------------------------------------------------
@@ -71,6 +68,44 @@ bool IsModelWeapon(Int32 id)
}
// ------------------------------------------------------------------------------------------------
bool IsModelActuallyWeapon(Int32 id)
{
switch (id)
{
case 259:
case 260:
case 261:
case 262:
case 263:
case 264:
case 265:
case 266:
case 267:
case 268:
case 269:
case 270:
case 271:
case 272:
case 274:
case 275:
case 276:
case 277:
case 278:
case 279:
case 280:
case 281:
case 282:
case 283:
case 284:
case 285:
case 286:
case 287:
case 288:
case 289:
case 290:
case 291: return true;
default: return false;
}
}
} // Namespace:: SqMod

View File

@@ -7,12 +7,25 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CCStr GetModelName(Int32 id);
void SetModelName(Int32 id, CCStr name);
/* ------------------------------------------------------------------------------------------------
* Retrieve the name associated with a model identifier.
*/
CSStr GetModelName(Int32 id);
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a model identifier.
*/
void SetModelName(Int32 id, CSStr name);
/* ------------------------------------------------------------------------------------------------
* See whether the given model identifier is used a weapon model.
*/
bool IsModelWeapon(Int32 id);
/* ------------------------------------------------------------------------------------------------
* See whether the given model identifier is an actual weapon model.
*/
bool IsModelActuallyWeapon(Int32 id);
bool IsWeaponNatural(Int32 id);
} // Namespace:: SqMod

View File

@@ -47,42 +47,10 @@ static String CS_Skin_Names[] = {
""
};
// ------------------------------------------------------------------------------------------------
void SetUseClasses(bool toggle)
{ _Func->SetUseClasses(toggle); }
bool GetUseClasses(void)
{ return _Func->GetUseClasses(); }
// ------------------------------------------------------------------------------------------------
Int32 AddPlayerClass(Int32 team, const Color3 & color, Int32 skin, const Vector3 & pos, Float32 angle,
Int32 w1, Int32 a1, Int32 w2, Int32 a2, Int32 w3, Int32 a3)
{
return _Func->AddPlayerClass(team, color.GetRGB(), skin, pos.x, pos.y, pos.z, angle,
w1, a1, w2, a2, w3, a3);
}
// ------------------------------------------------------------------------------------------------
void SetSpawnPlayerPos(const Vector3 & pos)
{ _Func->SetSpawnPlayerPos(pos.x, pos.y, pos.z); }
void SetSpawnPlayerPosEx(Float32 x, Float32 y, Float32 z)
{ _Func->SetSpawnPlayerPos(x, y, z); }
// ------------------------------------------------------------------------------------------------
void SetSpawnCameraPos(const Vector3 & pos)
{ _Func->SetSpawnCameraPos(pos.x, pos.y, pos.z); }
void SetSpawnCameraPosEx(Float32 x, Float32 y, Float32 z)
{ _Func->SetSpawnCameraPos(x, y, z); }
// ------------------------------------------------------------------------------------------------
void SetSpawnCameraLookAt(const Vector3 & pos)
{ _Func->SetSpawnCameraLookAt(pos.x, pos.y, pos.z); }
void SetSpawnCameraLookAtEx(Float32 x, Float32 y, Float32 z)
{ _Func->SetSpawnCameraLookAt(x, y, z); }
// ------------------------------------------------------------------------------------------------
CCStr GetSkinName(Uint32 id)
{
return (id > 159) ? g_EmptyStr : CS_Skin_Names[id].c_str();
return (id > 159) ? _SC("") : CS_Skin_Names[id].c_str();
}
// ------------------------------------------------------------------------------------------------
@@ -721,29 +689,8 @@ Int32 GetSkinID(CCStr name)
// ------------------------------------------------------------------------------------------------
bool IsSkinValid(Int32 id)
{
return (strlen(GetSkinName(id)) > 0);
}
// ------------------------------------------------------------------------------------------------
Object & FindPlayer(Object & by)
{
switch (by.GetType())
{
case OT_INTEGER:
return _Core->GetPlayer(by.Cast< Int32 >()).mObj;
case OT_FLOAT:
return _Core->GetPlayer(round(by.Cast< Float32 >())).mObj;
case OT_STRING:
{
String str(by.Cast< String >());
Int32 id = _Func->GetPlayerIDFromName(&str[0]);
if (VALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
_Core->GetPlayer(id).mObj;
} break;
default:
STHROWF("Unsupported search identifier");
}
return NullObject();
CSStr name = GetSkinName(id);
return (name && *name != '\0');
}
} // Namespace:: SqMod

View File

@@ -7,34 +7,25 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
void SetUseClasses(bool toggle);
bool GetUseClasses(void);
// ------------------------------------------------------------------------------------------------
Int32 AddPlayerClass(Int32 team, const Color3 & color, Int32 skin, const Vector3 & pos, Float32 angle,
Int32 w1, Int32 a1, Int32 w2, Int32 a2, Int32 w3, Int32 a3);
// ------------------------------------------------------------------------------------------------
void SetSpawnPlayerPos(const Vector3 & pos);
void SetSpawnPlayerPosEx(Float32 x, Float32 y, Float32 z);
// ------------------------------------------------------------------------------------------------
void SetSpawnCameraPos(const Vector3 & pos);
void SetSpawnCameraPosEx(Float32 x, Float32 y, Float32 z);
// ------------------------------------------------------------------------------------------------
void SetSpawnCameraLookAt(const Vector3 & pos);
void SetSpawnCameraLookAtEx(Float32 x, Float32 y, Float32 z);
// ------------------------------------------------------------------------------------------------
/* ------------------------------------------------------------------------------------------------
* Retrieve the name associated with a skin model identifier.
*/
CCStr GetSkinName(Uint32 id);
void SetSkinName(Uint32 id, CCStr name);
Int32 GetSkinID(CCStr name);
bool IsSkinValid(Int32 id);
// ------------------------------------------------------------------------------------------------
Object & FindPlayer(Object & by);
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a skin model identifier.
*/
void SetSkinName(Uint32 id, CCStr name);
/* ------------------------------------------------------------------------------------------------
* Convert a vehicle model name to a skin model identifier.
*/
Int32 GetSkinID(CCStr name);
/* ------------------------------------------------------------------------------------------------
* See whether the specified skin model identifier is valid.
*/
bool IsSkinValid(Int32 id);
} // Namespace:: SqMod

View File

@@ -1,4 +1,6 @@
// ------------------------------------------------------------------------------------------------
#include "Core.hpp"
#include "Base/Shared.hpp"
#include "Base/Color3.hpp"
#include "Base/Vector2.hpp"
#include "Base/Vector3.hpp"
@@ -11,126 +13,148 @@
#include "Misc/Player.hpp"
#include "Misc/Vehicle.hpp"
#include "Misc/Weapon.hpp"
#include "Misc/World.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
static const Object & FindPlayer(Object & by)
{
switch (by.GetType())
{
case OT_INTEGER:
{
return Core::Get().GetPlayer(by.Cast< Int32 >()).mObj;
} break;
case OT_FLOAT:
{
return Core::Get().GetPlayer(std::round(by.Cast< Float32 >())).mObj;
} break;
case OT_STRING:
{
// Obtain the argument as a string
String str(by.Cast< String >());
// Attempt to locate the player with this name
Int32 id = _Func->GetPlayerIdFromName(&str[0]);
// Was there a player with this name?
if (VALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
{
Core::Get().GetPlayer(id).mObj;
}
} break;
default: STHROWF("Unsupported search identifier");
}
// Default to a null object
return NullObject();
}
// ================================================================================================
void Register_Misc(HSQUIRRELVM vm)
{
Table srvns(vm);
srvns.Func(_SC("SetTimeRate"), &SetTimeRate)
.Func(_SC("GetTimeRate"), &GetTimeRate)
.Func(_SC("SetHour"), &SetHour)
.Func(_SC("GetHour"), &GetHour)
.Func(_SC("SetMinute"), &SetMinute)
.Func(_SC("GetMinute"), &GetMinute)
.Func(_SC("SetWeather"), &SetWeather)
.Func(_SC("GetWeather"), &GetWeather)
.Func(_SC("SetGravity"), &SetGravity)
.Func(_SC("GetGravity"), &GetGravity)
.Func(_SC("SetGamespeed"), &SetGamespeed)
.Func(_SC("GetGamespeed"), &GetGamespeed)
.Func(_SC("SetWaterLevel"), &SetWaterLevel)
.Func(_SC("GetWaterLevel"), &GetWaterLevel)
.Func(_SC("SetMaxHeight"), &SetMaxHeight)
.Func(_SC("GetMaxHeight"), &GetMaxHeight)
.Func(_SC("SetKillCmdDelay"), &SetKillCmdDelay)
.Func(_SC("GetKillCmdDelay"), &GetKillCmdDelay)
.Func(_SC("SetVehiclesForcedRespawnHeight"), &SetVehiclesForcedRespawnHeight)
.Func(_SC("GetVehiclesForcedRespawnHeight"), &GetVehiclesForcedRespawnHeight)
.Func(_SC("ToggleSyncFrameLimiter"), &ToggleSyncFrameLimiter)
.Func(_SC("EnabledSyncFrameLimiter"), &EnabledSyncFrameLimiter)
.Func(_SC("ToggleFrameLimiter"), &ToggleFrameLimiter)
.Func(_SC("EnabledFrameLimiter"), &EnabledFrameLimiter)
.Func(_SC("ToggleTaxiBoostJump"), &ToggleTaxiBoostJump)
.Func(_SC("EnabledTaxiBoostJump"), &EnabledTaxiBoostJump)
.Func(_SC("ToggleDriveOnWater"), &ToggleDriveOnWater)
.Func(_SC("EnabledDriveOnWater"), &EnabledDriveOnWater)
.Func(_SC("ToggleFastSwitch"), &ToggleFastSwitch)
.Func(_SC("EnabledFastSwitch"), &EnabledFastSwitch)
.Func(_SC("ToggleFriendlyFire"), &ToggleFriendlyFire)
.Func(_SC("EnabledFriendlyFire"), &EnabledFriendlyFire)
.Func(_SC("ToggleDisableDriveby"), &ToggleDisableDriveby)
.Func(_SC("EnabledDisableDriveby"), &EnabledDisableDriveby)
.Func(_SC("TogglePerfectHandling"), &TogglePerfectHandling)
.Func(_SC("EnabledPerfectHandling"), &EnabledPerfectHandling)
.Func(_SC("ToggleFlyingCars"), &ToggleFlyingCars)
.Func(_SC("EnabledFlyingCars"), &EnabledFlyingCars)
.Func(_SC("ToggleJumpSwitch"), &ToggleJumpSwitch)
.Func(_SC("EnabledJumpSwitch"), &EnabledJumpSwitch)
.Func(_SC("ToggleShowMarkers"), &ToggleShowMarkers)
.Func(_SC("EnabledShowMarkers"), &EnabledShowMarkers)
.Func(_SC("ToggleStuntBike"), &ToggleStuntBike)
.Func(_SC("EnabledStuntBike"), &EnabledStuntBike)
.Func(_SC("ToggleShootInAir"), &ToggleShootInAir)
.Func(_SC("EnabledShootInAir"), &EnabledShootInAir)
.Func(_SC("ToggleShowNametags"), &ToggleShowNametags)
.Func(_SC("EnabledShowNametags"), &EnabledShowNametags)
.Func(_SC("ToggleJoinMessages"), &ToggleJoinMessages)
.Func(_SC("EnabledJoinMessages"), &EnabledJoinMessages)
.Func(_SC("ToggleDeathMessages"), &ToggleDeathMessages)
.Func(_SC("EnabledDeathMessages"), &EnabledDeathMessages)
.Func(_SC("ToggleChatTagsByDefaultEnabled"), &ToggleChatTagsByDefaultEnabled)
.Func(_SC("EnabledChatTagsByDefault"), &EnabledChatTagsByDefault)
.Func(_SC("CreateExplosion"), &CreateExplosion)
.Func(_SC("CreateExplosionEx"), &CreateExplosionEx)
.Func(_SC("HideMapObject"), &HideMapObject)
.Func(_SC("HideMapObjectEx"), &HideMapObjectEx)
.Func(_SC("HideMapObjectRaw"), &HideMapObjectRaw)
.Func(_SC("ShowMapObject"), &ShowMapObject)
.Func(_SC("ShowMapObjectEx"), &ShowMapObjectEx)
.Func(_SC("ShowAllMapObjects"), &ShowAllMapObjects)
.Func(_SC("SetWastedSettings"), &SetWastedSettings)
.Func(_SC("GetWastedSettings"), &GetWastedSettings)
.Func(_SC("SetWorldBounds"), &SetWorldBounds)
.Func(_SC("SetWorldBoundsEx"), &SetWorldBoundsEx)
.Func(_SC("GetWorldBounds"), &GetWorldBounds)
srvns.SquirrelFunc(_SC("SendLogMessage"), &SendLogMessage)
.Func(_SC("GetVersion"), &GetServerVersion)
.Func(_SC("GetSettings"), &GetServerSettings)
.Func(_SC("GetNumberOfPlugins"), &GetNumberOfPlugins)
.Func(_SC("GetPluginInfo"), &GetPluginInfo)
.Func(_SC("FindPlugin"), &FindPlugin)
.Func(_SC("SendPluginCommand"), &SendPluginCommand)
.Func(_SC("GetTime"), &GetTime)
.Func(_SC("GetLastError"), &GetLastError)
.Func(_SC("GetPluginVersion"), &GetPluginVersion)
.Func(_SC("GetPluginVersionStr"), &GetPluginVersionStr)
.Func(_SC("GetPluginName"), &GetPluginName)
.Func(_SC("GetPluginAuthor"), &GetPluginAuthor)
.Func(_SC("GetPluginID"), &GetPluginID)
.Func(_SC("GetNumberOfPlugins"), &GetNumberOfPlugins)
.Func(_SC("FindPlugin"), &FindPlugin)
.Func(_SC("GetVersion"), &GetServerVersion)
.Func(_SC("GetPort"), &GetServerPort)
.Func(_SC("GetFlags"), &GetServerFlags)
.Func(_SC("SetName"), &SetServerName)
.Func(_SC("GetName"), &GetServerName)
.Func(_SC("GetTime"), &GetTime)
.Func(_SC("SendCustomCommand"), &SendCustomCommand)
.Func(_SC("SetMaxPlayers"), &SetMaxPlayers)
.Func(_SC("GetServerPort"), &GetServerPort)
.Func(_SC("GetServerFlags"), &GetServerFlags)
.Func(_SC("GetMaxPlayers"), &GetMaxPlayers)
.Func(_SC("SetServerPassword"), &SetServerPassword)
.Func(_SC("GetServerPassword"), &GetServerPassword)
.Func(_SC("SetGameModeText"), &SetGameModeText)
.Func(_SC("SetMaxPlayers"), &SetMaxPlayers)
.Func(_SC("GetServerName"), &GetServerName)
.Func(_SC("SetServerName"), &SetServerName)
.Func(_SC("GetPassword"), &GetServerPassword)
.Func(_SC("SetPassword"), &SetServerPassword)
.Func(_SC("GetGameModeText"), &GetGameModeText)
.Func(_SC("AddRadioStream"), &AddRadioStream)
.Func(_SC("RemoveRadioStream"), &RemoveRadioStream);
.Func(_SC("SetGameModeText"), &SetGameModeText)
.Func(_SC("CreateRadioStream"), &CreateRadioStream)
.Func(_SC("CreateRadioStreamEx"), &CreateRadioStreamEx)
.Func(_SC("RemoveRadioStream"), &RemoveRadioStream)
.Func(_SC("Shutdown"), &ShutdownServer)
.Func(_SC("GetOption"), &GetServerOption)
.Func(_SC("SetOption"), &SetServerOption)
.Func(_SC("SetOptionEx"), &SetServerOptionEx)
.Func(_SC("GetWorldBounds"), &GetWorldBounds)
.Func(_SC("SetWorldBounds"), &SetWorldBounds)
.Func(_SC("SetWorldBoundsEx"), &SetWorldBoundsEx)
.Func(_SC("GetWastedSettings"), &GetWastedSettings)
.Func(_SC("SetWastedSettings"), &SetWastedSettings)
.Func(_SC("GetTimeRate"), &GetTimeRate)
.Func(_SC("SetTimeRate"), &SetTimeRate)
.Func(_SC("GetHour"), &GetHour)
.Func(_SC("SetHour"), &SetHour)
.Func(_SC("GetMinute"), &GetMinute)
.Func(_SC("SetMinute"), &SetMinute)
.Func(_SC("GetWeather"), &GetWeather)
.Func(_SC("SetWeather"), &SetWeather)
.Func(_SC("GetGravity"), &GetGravity)
.Func(_SC("SetGravity"), &SetGravity)
.Func(_SC("GetGameSpeed"), &GetGameSpeed)
.Func(_SC("SetGameSpeed"), &SetGameSpeed)
.Func(_SC("GetWaterLevel"), &GetWaterLevel)
.Func(_SC("SetWaterLevel"), &SetWaterLevel)
.Func(_SC("GetMaximumFlightAltitude"), &GetMaximumFlightAltitude)
.Func(_SC("SetMaximumFlightAltitude"), &SetMaximumFlightAltitude)
.Func(_SC("GetKillCommandDelay"), &GetKillCommandDelay)
.Func(_SC("SetKillCommandDelay"), &SetKillCommandDelay)
.Func(_SC("GetVehiclesForcedRespawnHeight"), &GetVehiclesForcedRespawnHeight)
.Func(_SC("SetVehiclesForcedRespawnHeight"), &SetVehiclesForcedRespawnHeight)
.Func(_SC("CreateExplosion"), &CreateExplosion)
.Func(_SC("CreateExplosionEx"), &CreateExplosionEx)
.Func(_SC("PlaySound"), &PlaySound)
.Func(_SC("PlaySoundEx"), &PlaySoundEx)
.Func(_SC("HideMapObject"), &HideMapObject)
.Func(_SC("HideMapObjectEx"), &SetKeyCodeName)
.Func(_SC("HideMapObjectRaw"), &HideMapObjectRaw)
.Func(_SC("ShowMapObject"), &ShowMapObject)
.Func(_SC("ShowMapObjectEx"), &ShowMapObjectEx)
.Func(_SC("ShowMapObjectRaw"), &ShowMapObjectRaw)
.Func(_SC("ShowAllMapObjects"), &ShowAllMapObjects)
.Func(_SC("GetWeaponDataValue"), &GetWeaponDataValue)
.Func(_SC("SetWeaponDataValue"), &SetWeaponDataValue)
.Func(_SC("ResetWeaponDataValue"), &ResetWeaponDataValue)
.Func(_SC("IsWeaponDataValueModified"), &IsWeaponDataValueModified)
.Func(_SC("ResetWeaponData"), &ResetWeaponData)
.Func(_SC("ResetAllWeaponData"), &ResetAllWeaponData)
.Func(_SC("AddPlayerClass"), &AddPlayerClass)
.Func(_SC("SetSpawnPlayerPosition"), &SetSpawnPlayerPosition)
.Func(_SC("SetSpawnCameraPosition"), &SetSpawnCameraPosition)
.Func(_SC("SetSpawnCameraLookAt"), &SetSpawnCameraLookAt)
.Func(_SC("SetSpawnPlayerPositionEx"), &SetSpawnPlayerPositionEx)
.Func(_SC("SetSpawnCameraPositionEx"), &SetSpawnCameraPositionEx)
.Func(_SC("SetSpawnCameraLookAtEx"), &SetSpawnCameraLookAtEx)
.Func(_SC("BanIP"), &BanIP)
.Func(_SC("UnbanIP"), &UnbanIP)
.Func(_SC("IsIPBanned"), &IsIPBanned)
.Func(_SC("GetPlayerIdFromName"), &GetPlayerIdFromName)
.Func(_SC("IsPlayerConnected"), &IsPlayerConnected)
.Func(_SC("ForceAllSelect"), &ForceAllSelect)
.Func(_SC("CheckEntityExists"), &SetKeyCodeName);
RootTable(vm).Bind(_SC("SqServer"), srvns);
RootTable(vm)
.Func(_SC("FindPlayer"), &FindPlayer)
.Func(_SC("GetKeyCodeName"), &GetKeyCodeName)
.Func(_SC("SetKeyCodeName"), &SetKeyCodeName)
.Func(_SC("GetModelName"), &GetModelName)
.Func(_SC("SetModelName"), &SetModelName)
.Func(_SC("IsModelWeapon"), &IsModelWeapon)
.Func(_SC("IsModelActuallyWeapon"), &IsModelActuallyWeapon)
.Func(_SC("IsWeaponNatural"), &IsWeaponNatural)
.Func(_SC("SetUseClasses"), &SetUseClasses)
.Func(_SC("GetUseClasses"), &GetUseClasses)
.Func(_SC("AddPlayerClass"), &AddPlayerClass)
.Func(_SC("SetSpawnPlayerPos"), &SetSpawnPlayerPos)
.Func(_SC("SetSpawnPlayerPosEx"), &SetSpawnPlayerPosEx)
.Func(_SC("SetSpawnCameraPos"), &SetSpawnCameraPos)
.Func(_SC("SetSpawnCameraPosEx"), &SetSpawnCameraPosEx)
.Func(_SC("GetSkinName"), &GetSkinName)
.Func(_SC("SetSkinName"), &SetSkinName)
.Func(_SC("GetSkinID"), &GetSkinID)
.Func(_SC("IsSkinValid"), &IsSkinValid)
.Func(_SC("FindPlayer"), &FindPlayer)
.Func(_SC("GetAutomobileName"), &GetAutomobileName)
.Func(_SC("SetAutomobileName"), &SetAutomobileName)
.Func(_SC("GetAutomobileID"), &GetAutomobileID)
@@ -140,8 +164,11 @@ void Register_Misc(HSQUIRRELVM vm)
.Func(_SC("GetWeaponID"), &GetWeaponID)
.Func(_SC("IsWeaponValid"), &IsWeaponValid)
.Func(_SC("WeaponToModel"), &WeaponToModel)
.Func(_SC("IsWeaponNatural"), &IsWeaponNatural)
.Func(_SC("PlaySound"), &PlaySound)
.Func(_SC("PlaySoundEx"), &PlaySoundEx);
.Func(_SC("PlaySoundEx"), &PlaySoundEx)
.Func(_SC("CreateExplosion"), &CreateExplosion)
.Func(_SC("CreateExplosionEx"), &CreateExplosionEx);
}
} // Namespace:: SqMod

View File

@@ -35,20 +35,22 @@ static String CS_Vehicle_Names[] = {
};
// ------------------------------------------------------------------------------------------------
CCStr GetAutomobileName(Uint32 id)
CSStr GetAutomobileName(Uint32 id)
{
return (id < 130 || id > 236) ? _SC("") : CS_Vehicle_Names[id-130].c_str();
}
// ------------------------------------------------------------------------------------------------
void SetAutomobileName(Uint32 id, CCStr name)
void SetAutomobileName(Uint32 id, CSStr name)
{
if (id >= 130 || id <= 236)
{
CS_Vehicle_Names[id-130].assign(name);
}
}
// ------------------------------------------------------------------------------------------------
Int32 GetAutomobileID(CCStr name)
Int32 GetAutomobileID(CSStr name)
{
// Clone the string into an editable version
String str(name);
@@ -58,7 +60,9 @@ Int32 GetAutomobileID(CCStr name)
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
// See if we still have a valid name after the cleanup
if(str.empty())
{
return SQMOD_UNKNOWN;
}
// Grab the actual length of the string
Uint32 len = static_cast< Uint32 >(str.length());
// Get the most significant characters used to identify a vehicle
@@ -70,7 +74,9 @@ Int32 GetAutomobileID(CCStr name)
b = str[1];
}
else if(str.length() >= 2)
{
b = str[1];
}
// Search for a pattern in the name
switch (a)
{
@@ -618,51 +624,8 @@ Int32 GetAutomobileID(CCStr name)
// ------------------------------------------------------------------------------------------------
bool IsAutomobileValid(Int32 id)
{
return (strlen(GetAutomobileName(id)) > 0);
CSStr name = GetAutomobileName(id);
return (name && *name != '\0');
}
// ------------------------------------------------------------------------------------------------
bool IsModelActuallyWeapon(Int32 id)
{
switch (id)
{
case 259:
case 260:
case 261:
case 262:
case 263:
case 264:
case 265:
case 266:
case 267:
case 268:
case 269:
case 270:
case 271:
case 272:
case 274:
case 275:
case 276:
case 277:
case 278:
case 279:
case 280:
case 281:
case 282:
case 283:
case 284:
case 285:
case 286:
case 287:
case 288:
case 289:
case 290:
case 291: return true;
default: return false;
}
}
// ------------------------------------------------------------------------------------------------
} // Namespace:: SqMod

View File

@@ -7,10 +7,24 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CCStr GetAutomobileName(Uint32 id);
void SetAutomobileName(Uint32 id, CCStr name);
Int32 GetAutomobileID(CCStr name);
/* ------------------------------------------------------------------------------------------------
* Retrieve the name associated with a vehicle model identifier.
*/
CSStr GetAutomobileName(Uint32 id);
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a vehicle model identifier.
*/
void SetAutomobileName(Uint32 id, CSStr name);
/* ------------------------------------------------------------------------------------------------
* Convert a vehicle model name to a vehicle model identifier.
*/
Int32 GetAutomobileID(CSStr name);
/* ------------------------------------------------------------------------------------------------
* See whether the specified vehicle model identifier is valid.
*/
bool IsAutomobileValid(Int32 id);
} // Namespace:: SqMod

View File

@@ -40,7 +40,9 @@ CCStr GetWeaponName(Uint32 id)
void SetWeaponName(Uint32 id, CCStr name)
{
if (id <= 70)
{
CS_Weapon_Names[id].assign(name);
}
}
// ------------------------------------------------------------------------------------------------
@@ -54,7 +56,9 @@ Int32 GetWeaponID(CCStr name)
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
// See if we still have a valid name after the cleanup
if(str.length() < 1)
{
return SQMOD_UNKNOWN;
}
// Grab the actual length of the string
Uint32 len = static_cast< Uint32 >(str.length());
// Get the most significant characters used to identify a weapon
@@ -66,7 +70,9 @@ Int32 GetWeaponID(CCStr name)
b = str[1];
}
else if(str.length() >= 2)
{
b = str[1];
}
// Search for a pattern in the name
switch(a)
{
@@ -242,22 +248,8 @@ Int32 GetWeaponID(CCStr name)
// ------------------------------------------------------------------------------------------------
bool IsWeaponValid(Int32 id)
{
return (strlen(GetWeaponName(id)) > 0);
}
// ------------------------------------------------------------------------------------------------
bool IsWeaponNatural(Int32 id)
{
switch (id)
{
case SQMOD_WEAPON_VEHICLE:
case SQMOD_WEAPON_DRIVEBY:
case SQMOD_WEAPON_DROWNED:
case SQMOD_WEAPON_FALL:
case SQMOD_WEAPON_EXPLOSION2:
case SQMOD_WEAPON_SUICIDE: return true;
default: return false;
}
CSStr name = GetWeaponName(id);
return (name && *name != '\0');
}
// ------------------------------------------------------------------------------------------------
@@ -299,21 +291,25 @@ Int32 WeaponToModel(Int32 id)
case SQMOD_WEAPON_FLAMETHROWER: return 288;
case SQMOD_WEAPON_M60: return 289;
case SQMOD_WEAPON_MINIGUN: return 290;
case SQMOD_WEAPON_BOMB: return SQMOD_UNKNOWN;
case SQMOD_WEAPON_HELICANNON: return 294;
case SQMOD_WEAPON_CAMERA: return 292;
case SQMOD_WEAPON_VEHICLE: return SQMOD_UNKNOWN;
case SQMOD_WEAPON_EXPLOSION1: return SQMOD_UNKNOWN;
case SQMOD_WEAPON_DRIVEBY: return SQMOD_UNKNOWN;
case SQMOD_WEAPON_DROWNED: return SQMOD_UNKNOWN;
case SQMOD_WEAPON_FALL: return SQMOD_UNKNOWN;
case SQMOD_WEAPON_EXPLOSION2: return SQMOD_UNKNOWN;
case SQMOD_WEAPON_SUICIDE: return SQMOD_UNKNOWN;
default: return SQMOD_UNKNOWN;
}
}
// ------------------------------------------------------------------------------------------------
bool IsWeaponNatural(Int32 id)
{
switch (id)
{
case SQMOD_WEAPON_VEHICLE:
case SQMOD_WEAPON_DRIVEBY:
case SQMOD_WEAPON_DROWNED:
case SQMOD_WEAPON_FALL:
case SQMOD_WEAPON_EXPLOSION2:
case SQMOD_WEAPON_SUICIDE: return true;
default: return false;
}
}
} // Namespace:: SqMod

View File

@@ -7,13 +7,36 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CCStr GetWeaponName(Uint32 id);
void SetWeaponName(Uint32 id, CCStr name);
Int32 GetWeaponID(CCStr name);
/* ------------------------------------------------------------------------------------------------
* Retrieve the name associated with a weapon identifier.
*/
CSStr GetWeaponName(Uint32 id);
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a weapon identifier.
*/
void SetWeaponName(Uint32 id, CSStr name);
/* ------------------------------------------------------------------------------------------------
* Convert a weapon name to a weapon identifier.
*/
Int32 GetWeaponID(CSStr name);
/* ------------------------------------------------------------------------------------------------
* See whether the specified weapon identifier is valid.
*/
bool IsWeaponValid(Int32 id);
/* ------------------------------------------------------------------------------------------------
* Convert the given weapon identifier to it's associated model identifier.
*/
Int32 WeaponToModel(Int32 id);
/* ------------------------------------------------------------------------------------------------
* See whether the given weapon identifier cannot be used by another player to inflict damage.
*/
bool IsWeaponNatural(Int32 id);
} // Namespace:: SqMod
#endif // _MISC_WEAPON_HPP_

View File

@@ -1,254 +0,0 @@
// ------------------------------------------------------------------------------------------------
#include "Misc/World.hpp"
#include "Base/Color3.hpp"
#include "Base/Vector2.hpp"
#include "Base/Vector3.hpp"
#include "Entity/Player.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
void SetTimeRate(Uint32 rate) { _Func->SetTimeRate(rate); }
Uint32 GetTimeRate(void) { return _Func->GetTimeRate(); }
// ------------------------------------------------------------------------------------------------
void SetHour(Int32 hour) { _Func->SetHour(hour); }
Int32 GetHour(void) { return _Func->GetHour(); }
// ------------------------------------------------------------------------------------------------
void SetMinute(Int32 minute) { _Func->SetMinute(minute); }
Int32 GetMinute(void) { return _Func->GetMinute(); }
// ------------------------------------------------------------------------------------------------
void SetWeather(Int32 weather) { _Func->SetWeather(weather); }
Int32 GetWeather(void) { return _Func->GetWeather(); }
// ------------------------------------------------------------------------------------------------
void SetGravity(Float32 gravity) { _Func->SetGamespeed(gravity); }
Float32 GetGravity(void) { return _Func->GetGamespeed(); }
// ------------------------------------------------------------------------------------------------
void SetGamespeed(Float32 speed) { _Func->SetGamespeed(speed); }
Float32 GetGamespeed(void) { return _Func->GetGamespeed(); }
// ------------------------------------------------------------------------------------------------
void SetWaterLevel(Float32 level) { _Func->SetWaterLevel(level); }
Float32 GetWaterLevel(void) { return _Func->GetWaterLevel(); }
// ------------------------------------------------------------------------------------------------
void SetMaxHeight(Float32 height) { _Func->SetMaxHeight(height); }
Float32 GetMaxHeight(void) { return _Func->GetMaxHeight(); }
// ------------------------------------------------------------------------------------------------
void SetKillCmdDelay(Int32 delay) { _Func->SetKillCmdDelay(delay); }
Int32 GetKillCmdDelay(void) { return _Func->GetKillCmdDelay(); }
// ------------------------------------------------------------------------------------------------
void SetVehiclesForcedRespawnHeight(Float32 height)
{ _Func->SetVehiclesForcedRespawnHeight(height); }
Float32 GetVehiclesForcedRespawnHeight(void)
{ return _Func->GetVehiclesForcedRespawnHeight(); }
// ------------------------------------------------------------------------------------------------
void ToggleSyncFrameLimiter(bool toggle)
{ _Func->ToggleSyncFrameLimiter(toggle); }
bool EnabledSyncFrameLimiter(void)
{ return _Func->EnabledSyncFrameLimiter(); }
// ------------------------------------------------------------------------------------------------
void ToggleFrameLimiter(bool toggle)
{ _Func->ToggleFrameLimiter(toggle); }
bool EnabledFrameLimiter(void)
{ return _Func->EnabledFrameLimiter(); }
// ------------------------------------------------------------------------------------------------
void ToggleTaxiBoostJump(bool toggle)
{ _Func->ToggleTaxiBoostJump(toggle); }
bool EnabledTaxiBoostJump(void)
{ return _Func->EnabledTaxiBoostJump(); }
// ------------------------------------------------------------------------------------------------
void ToggleDriveOnWater(bool toggle)
{ _Func->ToggleDriveOnWater(toggle); }
bool EnabledDriveOnWater(void)
{ return _Func->EnabledDriveOnWater(); }
// ------------------------------------------------------------------------------------------------
void ToggleFastSwitch(bool toggle)
{ _Func->ToggleFastSwitch(toggle); }
bool EnabledFastSwitch(void)
{ return _Func->EnabledFastSwitch(); }
// ------------------------------------------------------------------------------------------------
void ToggleFriendlyFire(bool toggle)
{ _Func->ToggleFriendlyFire(toggle); }
bool EnabledFriendlyFire(void)
{ return _Func->EnabledFriendlyFire(); }
// ------------------------------------------------------------------------------------------------
void ToggleDisableDriveby(bool toggle)
{ _Func->ToggleDisableDriveby(toggle); }
bool EnabledDisableDriveby(void)
{ return _Func->EnabledDisableDriveby(); }
// ------------------------------------------------------------------------------------------------
void TogglePerfectHandling(bool toggle)
{ _Func->TogglePerfectHandling(toggle); }
bool EnabledPerfectHandling(void)
{ return _Func->EnabledPerfectHandling(); }
// ------------------------------------------------------------------------------------------------
void ToggleFlyingCars(bool toggle)
{ _Func->ToggleFlyingCars(toggle); }
bool EnabledFlyingCars(void)
{ return _Func->EnabledFlyingCars(); }
// ------------------------------------------------------------------------------------------------
void ToggleJumpSwitch(bool toggle)
{ _Func->ToggleJumpSwitch(toggle); }
bool EnabledJumpSwitch(void)
{ return _Func->EnabledJumpSwitch(); }
// ------------------------------------------------------------------------------------------------
void ToggleShowMarkers(bool toggle)
{ _Func->ToggleShowMarkers(toggle); }
bool EnabledShowMarkers(void)
{ return _Func->EnabledShowMarkers(); }
// ------------------------------------------------------------------------------------------------
void ToggleStuntBike(bool toggle)
{ _Func->ToggleStuntBike(toggle); }
bool EnabledStuntBike(void)
{ return _Func->EnabledStuntBike(); }
// ------------------------------------------------------------------------------------------------
void ToggleShootInAir(bool toggle)
{ _Func->ToggleShootInAir(toggle); }
bool EnabledShootInAir(void)
{ return _Func->EnabledShootInAir(); }
// ------------------------------------------------------------------------------------------------
void ToggleShowNametags(bool toggle)
{ _Func->ToggleShowNametags(toggle); }
bool EnabledShowNametags(void)
{ return _Func->EnabledShowNametags(); }
// ------------------------------------------------------------------------------------------------
void ToggleJoinMessages(bool toggle)
{ _Func->ToggleJoinMessages(toggle); }
bool EnabledJoinMessages(void)
{ return _Func->EnabledJoinMessages(); }
// ------------------------------------------------------------------------------------------------
void ToggleDeathMessages(bool toggle)
{ _Func->ToggleDeathMessages(toggle); }
bool EnabledDeathMessages(void)
{ return _Func->EnabledDeathMessages(); }
// ------------------------------------------------------------------------------------------------
void ToggleChatTagsByDefaultEnabled(bool toggle)
{ _Func->ToggleChatTagsByDefaultEnabled(toggle); }
bool EnabledChatTagsByDefault(void)
{ return _Func->EnabledChatTagsByDefault(); }
// ------------------------------------------------------------------------------------------------
void CreateExplosion(Int32 world, Int32 type, const Vector3 & pos, CPlayer & source, Uint32 level)
{
// Validate the specified player
source.Validate();
// Perform the requested operation
_Func->CreateExplosion(world, type, pos.x, pos.y, pos.z, source.GetID(), level);
}
void CreateExplosionEx(Int32 world, Int32 type, Float32 x, Float32 y, Float32 z, CPlayer & source, Uint32 level)
{
// Validate the specified player
source.Validate();
// Perform the requested operation
_Func->CreateExplosion(world, type, x, y, z, source.GetID(), level);
}
// ------------------------------------------------------------------------------------------------
void HideMapObject(Int32 model, const Vector3 & pos)
{
_Func->HideMapObject(model,
static_cast< Int32 >(std::floor(pos.x * 10.0f) + 0.5f),
static_cast< Int32 >(std::floor(pos.y * 10.0f) + 0.5f),
static_cast< Int32 >(std::floor(pos.z * 10.0f) + 0.5f)
);
}
// ------------------------------------------------------------------------------------------------
void HideMapObjectEx(Int32 model, Float32 x, Float32 y, Float32 z)
{
_Func->HideMapObject(model,
static_cast< Int32 >(std::floor(x * 10.0f) + 0.5f),
static_cast< Int32 >(std::floor(y * 10.0f) + 0.5f),
static_cast< Int32 >(std::floor(z * 10.0f) + 0.5f)
);
}
// ------------------------------------------------------------------------------------------------
void HideMapObjectRaw(Int32 model, Int32 x, Int32 y, Int32 z)
{
_Func->HideMapObject(model, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void ShowMapObject(Int32 model, const Vector3 & pos)
{ _Func->ShowMapObject(model, pos.x, pos.y, pos.z); }
void ShowMapObjectEx(Int32 model, Float32 x, Float32 y, Float32 z)
{ _Func->ShowMapObject(model, x, y, z); }
// ------------------------------------------------------------------------------------------------
void ShowAllMapObjects(void)
{ _Func->ShowAllMapObjects(); }
// ------------------------------------------------------------------------------------------------
void SetWastedSettings(Uint32 dt, Uint32 ft, Float32 fis, Float32 fos,
const Color3 & fc, Uint32 cfs, Uint32 cft)
{
_Func->SetWastedSettings(dt, ft, fis, fos, fc.GetRGB(), cfs, cft);
}
Table GetWastedSettings()
{
Uint32 fc, dt, ft, cfs, cft;
Float32 fis, fos;
Color3 c;
_Func->GetWastedSettings(&dt, &ft, &fis, &fos, &fc, &cfs, &cft);
c.SetRGB(fc);
Table t(DefaultVM::Get());
t.SetValue(_SC("dt"), dt);
t.SetValue(_SC("ft"), ft);
t.SetValue(_SC("fis"), fis);
t.SetValue(_SC("fos"), fos);
t.SetValue(_SC("fc"), c);
t.SetValue(_SC("cfs"), cfs);
t.SetValue(_SC("cft"), cft);
return t;
}
// ------------------------------------------------------------------------------------------------
void SetWorldBounds(const Vector2 & max, const Vector2 & min)
{
_Func->SetWorldBounds(max.x, min.x, max.y, min.y);
}
void SetWorldBoundsEx(Float32 max_x, Float32 max_y, Float32 min_x, Float32 min_y)
{
_Func->SetWorldBounds(max_x, min_x, max_y, min_y);
}
Table GetWorldBounds()
{
Vector2 max, min;
_Func->GetWorldBounds(&max.x, &min.x, &max.y, &min.y);
Table t(DefaultVM::Get());
t.SetValue(_SC("max"),max);
t.SetValue(_SC("min"), min);
return t;
}
} // Namespace:: SqMod

View File

@@ -1,114 +0,0 @@
#ifndef _MISC_WORLD_HPP_
#define _MISC_WORLD_HPP_
// ------------------------------------------------------------------------------------------------
#include "SqBase.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
void SetTimeRate(Uint32 rate);
Uint32 GetTimeRate(void);
// ------------------------------------------------------------------------------------------------
void SetHour(Int32 hour);
Int32 GetHour(void);
// ------------------------------------------------------------------------------------------------
void SetMinute(Int32 minute);
Int32 GetMinute(void);
// ------------------------------------------------------------------------------------------------
void SetWeather(Int32 weather);
Int32 GetWeather(void);
// ------------------------------------------------------------------------------------------------
void SetGravity(Float32 gravity);
Float32 GetGravity(void);
// ------------------------------------------------------------------------------------------------
void SetGamespeed(Float32 speed);
Float32 GetGamespeed(void);
// ------------------------------------------------------------------------------------------------
void SetWaterLevel(Float32 level);
Float32 GetWaterLevel(void);
// ------------------------------------------------------------------------------------------------
void SetMaxHeight(Float32 height);
Float32 GetMaxHeight(void);
// ------------------------------------------------------------------------------------------------
void SetKillCmdDelay(Int32 delay);
Int32 GetKillCmdDelay(void);
// ------------------------------------------------------------------------------------------------
void SetVehiclesForcedRespawnHeight(Float32 height);
Float32 GetVehiclesForcedRespawnHeight(void);
// ------------------------------------------------------------------------------------------------
void ToggleSyncFrameLimiter(bool toggle);
bool EnabledSyncFrameLimiter(void);
void ToggleFrameLimiter(bool toggle);
bool EnabledFrameLimiter(void);
void ToggleTaxiBoostJump(bool toggle);
bool EnabledTaxiBoostJump(void);
void ToggleDriveOnWater(bool toggle);
bool EnabledDriveOnWater(void);
void ToggleFastSwitch(bool toggle);
bool EnabledFastSwitch(void);
void ToggleFriendlyFire(bool toggle);
bool EnabledFriendlyFire(void);
void ToggleDisableDriveby(bool toggle);
bool EnabledDisableDriveby(void);
void TogglePerfectHandling(bool toggle);
bool EnabledPerfectHandling(void);
void ToggleFlyingCars(bool toggle);
bool EnabledFlyingCars(void);
void ToggleJumpSwitch(bool toggle);
bool EnabledJumpSwitch(void);
void ToggleShowMarkers(bool toggle);
bool EnabledShowMarkers(void);
void ToggleStuntBike(bool toggle);
bool EnabledStuntBike(void);
void ToggleShootInAir(bool toggle);
bool EnabledShootInAir(void);
void ToggleShowNametags(bool toggle);
bool EnabledShowNametags(void);
void ToggleJoinMessages(bool toggle);
bool EnabledJoinMessages(void);
void ToggleDeathMessages(bool toggle);
bool EnabledDeathMessages(void);
void ToggleChatTagsByDefaultEnabled(bool toggle);
bool EnabledChatTagsByDefault(void);
// ------------------------------------------------------------------------------------------------
void CreateExplosion(Int32 world, Int32 type, const Vector3 & pos, CPlayer & source, Uint32 level);
void CreateExplosionEx(Int32 world, Int32 type, Float32 x, Float32 y, Float32 z, CPlayer & source, Uint32 level);
// ------------------------------------------------------------------------------------------------
void HideMapObject(Int32 model, const Vector3 & pos);
void HideMapObjectEx(Int32 model, Float32 x, Float32 y, Float32 z);
void HideMapObjectRaw(Int32 model, Int32 x, Int32 y, Int32 z);
// ------------------------------------------------------------------------------------------------
void ShowMapObject(Int32 model, const Vector3 & pos);
void ShowMapObjectEx(Int32 model, Float32 x, Float32 y, Float32 z);
// ------------------------------------------------------------------------------------------------
void ShowAllMapObjects(void);
// ------------------------------------------------------------------------------------------------
void SetWastedSettings(Uint32 dt, Uint32 ft, Float32 fis, Float32 fos,
const Color3 & fc, Uint32 cfs, Uint32 cft);
Table GetWastedSettings();
// ------------------------------------------------------------------------------------------------
void SetWorldBounds(const Vector2 & max, const Vector2 & min);
void SetWorldBoundsEx(Float32 max_x, Float32 max_y, Float32 min_x, Float32 min_y);
Table GetWorldBounds();
} // Namespace:: SqMod
#endif // _MISC_WORLD_HPP_