Reorganize some utils, change dividing lines

This commit is contained in:
Vortrex
2021-03-16 00:34:45 -05:00
parent dc145f92b9
commit deaf0b34a5
98 changed files with 1765 additions and 1849 deletions

View File

@@ -2,32 +2,32 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: server.js
// DESC: Provides wrapped server natives for RAGEMP
// TYPE: Natives (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
// ===========================================================================
function getServerGame() {
return AG_GAME_GTA_V;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerPosition(client) {
return client.player.position;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerPosition(client, position) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s position to ${position.x}, ${position.y}, ${position.z}`);
client.position = position;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerHeading(client) {
if(getServerGame() == GAME_GTA_IV) {
@@ -39,14 +39,14 @@ function getPlayerHeading(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerHeading(client, heading) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s heading to ${heading}`);
sendPlayerSetHeading(client, heading);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerVehicle(client) {
if(getServerGame() == GAME_GTA_IV) {
@@ -59,13 +59,13 @@ function getPlayerVehicle(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerDimension(client) {
return client.player.dimension;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerInterior(client) {
if(getPlayerData(client)) {
@@ -75,14 +75,14 @@ function getPlayerInterior(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerDimension(client, dimension) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
client.player.dimension = dimension;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerInterior(client, interior) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
@@ -90,7 +90,7 @@ function setPlayerInterior(client, interior) {
getPlayerCurrentSubAccount(client).interior = interior;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerInAnyVehicle(client) {
if(getServerGame() == GAME_GTA_IV) {
@@ -100,7 +100,7 @@ function isPlayerInAnyVehicle(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerVehicleSeat(client) {
if(!isPlayerInAnyVehicle(client)) {
@@ -116,37 +116,37 @@ function getPlayerVehicleSeat(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerSpawned(client) {
return (client.player != null);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getVehiclePosition(vehicle) {
return vehicle.position;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getVehicleHeading(vehicle) {
return vehicle.heading;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getVehicleSyncer(vehicle) {
return getElementSyncer(vehicle);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getVehicleForNetworkEvent(vehicle) {
return vehicle;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteGameElement(element) {
logToConsole(LOG_DEBUG, `Destroying game element ${element.id} (Type: ${element.type})`);
@@ -157,13 +157,13 @@ function deleteGameElement(element) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerInFrontVehicleSeat(client) {
return (getPlayerVehicleSeat(client) == 0 || getPlayerVehicleSeat(client) == 1);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removePlayerFromVehicle(client) {
logToConsole(LOG_DEBUG, `Removing ${getPlayerDisplayForConsole(client)} from their vehicle`);
@@ -171,20 +171,20 @@ function removePlayerFromVehicle(client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerSkin(client, skin) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${skin} (${getSkinNameFromId(skin)})`);
client.player.modelIndex = skin;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerSkin(client) {
return client.player.modelIndex;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function disconnectPlayer(client) {
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
@@ -192,44 +192,44 @@ function disconnectPlayer(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getElementSyncer(element) {
return getClients()[element.syncer];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerWeaponAmmo(client) {
return client.player.weaponAmmunition;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerVelocity(client, velocity) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`);
client.player.velocity = velocity;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerVelocity(client, velocity) {
return client.player.velocity;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getElementDimension(element) {
return element.dimension;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setElementDimension(element, dimension) {
return element.dimension = dimension;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function givePlayerHealth(client, amount) {
if(getPlayerHealth(client)+amount > 100) {
@@ -241,7 +241,7 @@ function givePlayerHealth(client, amount) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function givePlayerArmour(client, amount) {
if(getPlayerArmour(client)+amount > 100) {
@@ -253,4 +253,4 @@ function givePlayerArmour(client, amount) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================