2 Commits

Author SHA1 Message Date
Vortrex
133d60ffdd Merge branch 'nightly' into non-server-elements 2022-06-14 05:57:21 -05:00
Vortrex
ee014b2578 Start using IDs instead of element objects 2022-05-31 08:35:40 -05:00
137 changed files with 8154 additions and 12270 deletions

View File

@@ -14,8 +14,7 @@
### Interactive peds with each one having a background story, characteristics, certain people or groups they like/dislike. ### Interactive peds with each one having a background story, characteristics, certain people or groups they like/dislike.
* Procedurally generated? * Procedurally generated?
--- ---
### Bouncers * Nightclubs, bars, etc can employ "bouncer" peds that either prevent entry to certain people, or kick people out.
* Nightclubs, bars, etc can employ "bouncer" peds that either prevent entry to certain people, or kick people out.
--- ---
### Background ambience. ### Background ambience.
* Anonymous city traffic and pedestrians * Anonymous city traffic and pedestrians
@@ -52,9 +51,9 @@
### Vehicle Towing ### Vehicle Towing
* Use a Yankee or something to store the vehicle "inside" (just make the car disappear) until better sync options are built. * Use a Yankee or something to store the vehicle "inside" (just make the car disappear) until better sync options are built.
* Universal command to tow/release a vehicle ( /tow ). * Universal command to tow/release a vehicle ( /tow ).
* Try attach to nearest vehicle. * Attach to nearest vehicle.
--- ---
### Item System (FINISHED) ### Item System
* Several item types, including armour, skins, weapons, drugs, materials, and more. * Several item types, including armour, skins, weapons, drugs, materials, and more.
* Items can be dropped and picked up. * Items can be dropped and picked up.
* Items can be stored in a vehicle trunk or dash compartment. * Items can be stored in a vehicle trunk or dash compartment.
@@ -69,21 +68,21 @@
* If all are full, have a waiting list. * If all are full, have a waiting list.
* Allow people to go in and lay on a bed to heal (or use a check-in system) * Allow people to go in and lay on a bed to heal (or use a check-in system)
--- ---
### Several NPC's (NEEDS SPAWNED) ### Several NPC's
* Paramedics/Doctors at hospitals, * Paramedics/Doctors at hospitals,
* LC/VC/LS/SF/LV police dept desk clerk and dispatcher. * LC/VC/LS/SF/LV police dept desk clerk and dispatcher.
* Jail guard * Jail guard
* Interactive. Go up and talk to them for responses etc * Interactive. Go up and talk to them for responses etc
--- ---
### Use permissions/flag system for everything (FINISHED) ### Use permissions/flag system for everything.
* Admin abilities * Admin abilities
* Moderation (muted/frozen/etc) * Moderation (muted/frozen/etc)
* LEO abilities (skipped for now) * LEO abilities
* Clan abilities * Clan abilities
* Account Settings * Account Settings
* etc * etc
--- ---
### Interiors (FINISHED) ### Interiors
* For games with interiors, properties inside of properties (possibly make it a sub-property, but using a "type" to define it. May not be necessary) AKA a business inside a business (illegal back room gambling, anyone?) * For games with interiors, properties inside of properties (possibly make it a sub-property, but using a "type" to define it. May not be necessary) AKA a business inside a business (illegal back room gambling, anyone?)
--- ---
### Stealable skins. ### Stealable skins.
@@ -175,6 +174,8 @@
* Concealable smaller weapon. * Concealable smaller weapon.
* Officers usually have a utility belt. Allow it to hold equipment as well. * Officers usually have a utility belt. Allow it to hold equipment as well.
--- ---
###
---
### Vehicle Trunks ### Vehicle Trunks
* Can hold tied up players/peds * Can hold tied up players/peds
* Can hold items * Can hold items
@@ -229,10 +230,10 @@
* Tweakers * Tweakers
* Bouncers * Bouncers
--- ---
### Accents (FINISHED) ### Accents
* Shown before message ... "[Japanese] John Smith says: hello" * Shown before message ... "[Japanese] John Smith says: hello"
* Pre-set accent choices * Pre-set accent choices
* Custom accent (skipped for now) * Custom accent
--- ---
### Speakerphone ### Speakerphone
* While on a phone call, using /speakerphone or something can allow others near the person on the phone to hear and be heard over the call. * While on a phone call, using /speakerphone or something can allow others near the person on the phone to hear and be heard over the call.
@@ -332,8 +333,7 @@
--- ---
### Pointing ### Pointing
* Key to point sort of like FiveM has. * Key to point sort of like FiveM has.
* Use a 3D primitive on the spot thats pointed to. * Use a 3D primitive on the spot thats pointed to, if no anim available.
* Use pointing (finger?) animation if available
--- ---
### Multi-command one-liners ### Multi-command one-liners
Obviously this would still be using slashes for commands still. The way this works is simple: Every command returns a value `{RETURN}`, and provides indexed numerical references to it's args that can be *piped* to another command `{1}`, `{2}`, etc. For example, the /tempveh command adds a vehicle and provides both a reference to the vehicle itself (`{RETURN}`) and a reference to it's only argument (`{1}`). Some commands already implement a final, optional command to override the default chosen entity to act on (for example, `/bizname Some Business 3` will set business ID 3's name instead of the closest business to the player. Only works for staff with the manageBusinesses permission or if the player using it owns or is in the clan that owns business ID 3 and has the ability to set it's name. So this: `/tempveh infernus | /vehrgb 0 0 0 0 {RETURN} | /vehrgb 1 {2} {3} {4} {RETURN}` Would spawn a temporary infernus and immediately set both colours as completely black RGB values. Obviously this would still be using slashes for commands still. The way this works is simple: Every command returns a value `{RETURN}`, and provides indexed numerical references to it's args that can be *piped* to another command `{1}`, `{2}`, etc. For example, the /tempveh command adds a vehicle and provides both a reference to the vehicle itself (`{RETURN}`) and a reference to it's only argument (`{1}`). Some commands already implement a final, optional command to override the default chosen entity to act on (for example, `/bizname Some Business 3` will set business ID 3's name instead of the closest business to the player. Only works for staff with the manageBusinesses permission or if the player using it owns or is in the clan that owns business ID 3 and has the ability to set it's name. So this: `/tempveh infernus | /vehrgb 0 0 0 0 {RETURN} | /vehrgb 1 {2} {3} {4} {RETURN}` Would spawn a temporary infernus and immediately set both colours as completely black RGB values.
@@ -350,20 +350,20 @@ Obviously this would still be using slashes for commands still. The way this wor
* Ice cream cone * Ice cream cone
* Cotton Candy * Cotton Candy
* Snow cone * Snow cone
* Misc * Misc
* Gas Can * Gas Can
--- ---
### Quick Reply (FINISHED) ### Quick Reply
* When somebody sends a private message, use /reply to quickly reply without having to find their ID to use the private message command * When somebody sends a private message, use /reply to quickly reply without having to find their ID to use the private message command
--- ---
### Item management commands (ALMOST FINISHED) ### Item management commands
* Item Types * Item Types
* Create * Create
* Set base price * Set base price
* Set model * Set model
* Set drop position offset * Set drop position offset
* Set drop rotation offset * Set drop rotation offset
* Set forward
--- ---
### Tutorial ### Tutorial
* Pick up item (grab bottle of beer off ground) * Pick up item (grab bottle of beer off ground)
@@ -379,21 +379,3 @@ Obviously this would still be using slashes for commands still. The way this wor
So with new Steam Deck being available now, and all the other attempts to use mobile devices that either emulate or stream the older GTA PC games, I figure we'd need a way for players to interact with each other using them. Roleplay is usually a very chat-oriented gamemode, but I can probably make things easier with simple controls. Also customizable messages, animations, and actions for each menu/wheel slot So with new Steam Deck being available now, and all the other attempts to use mobile devices that either emulate or stream the older GTA PC games, I figure we'd need a way for players to interact with each other using them. Roleplay is usually a very chat-oriented gamemode, but I can probably make things easier with simple controls. Also customizable messages, animations, and actions for each menu/wheel slot
The inventory system is already planned to use a hotbar/wheel but I don't have all the images for it yet The inventory system is already planned to use a hotbar/wheel but I don't have all the images for it yet
--- ---
### Fishing
* Fishing works near water or on a boat (I have a way to detect both)
* Use the bat swing anim for casting line, and the crouch anim for applying bait.
* Bait is used same as ammo item for a weapon. Hold the fishing rod, make sure bait is in inventory, and press use (default U) to apply bait.
* Use a "press and hold" key to cast a line to a custom distance. Show progress bar to indicate how far the line will be cast.
* Place a single-use particle effect on the water (distance to front of player) to show where the casted line hits.
* Use particle effects (water spray or splash effect) to display a fish being hooked.
* Slowly move the particle effect to the player to show it being reeled in as the player holds the reel key.
* Random selection of predefined catch items, both junk and fish.
* Player would be wise to bring a bucket or crate to keep the fish in, using existing /take and /put system like any other item.
**This will need extra stuff added to keybinds system for duration key holding**
---
### GPS indicator like the 3D Fallout games
An indicator at the bottom, showing compass direction and a dot or something in the direction of the GPS location. Like an object marker.
In-world indicator too, when player gets close and is in line of sight
---
### Item/Object pickup and move like the 3D Fallout games
Fallout 3 and New Vegas have a neat feature where you can "grab" an object and fling it around while the key is pressed. Could be implemented for items in GTACRP servers

View File

@@ -21,6 +21,3 @@
--- ---
== Bug Fixes == Bug Fixes
* Check natives for if player is console (getPlayerPosition, etc) * Check natives for if player is console (getPlayerPosition, etc)
* Add command to copy account keybinds to other server(s)
* Add command to reset all account keybinds to default

104
meta.xml
View File

@@ -15,6 +15,7 @@
<script src="scripts/client/native/connected.js" type="client" language="javascript" /> <script src="scripts/client/native/connected.js" type="client" language="javascript" />
<!-- Server Scripts --> <!-- Server Scripts -->
<script src="scripts/server/class.js" type="server" language="javascript" />
<script src="scripts/server/accent.js" type="server" language="javascript" /> <script src="scripts/server/accent.js" type="server" language="javascript" />
<script src="scripts/server/account.js" type="server" language="javascript" /> <script src="scripts/server/account.js" type="server" language="javascript" />
<script src="scripts/server/animation.js" type="server" language="javascript" /> <script src="scripts/server/animation.js" type="server" language="javascript" />
@@ -22,11 +23,10 @@
<script src="scripts/server/ban.js" type="server" language="javascript" /> <script src="scripts/server/ban.js" type="server" language="javascript" />
<script src="scripts/server/bitflag.js" type="server" language="javascript" /> <script src="scripts/server/bitflag.js" type="server" language="javascript" />
<script src="scripts/server/business.js" type="server" language="javascript" /> <script src="scripts/server/business.js" type="server" language="javascript" />
<script src="scripts/server/casino.js" type="server" language="javascript" />
<script src="scripts/server/chat.js" type="server" language="javascript" /> <script src="scripts/server/chat.js" type="server" language="javascript" />
<script src="scripts/server/clan.js" type="server" language="javascript" /> <script src="scripts/server/clan.js" type="server" language="javascript" />
<script src="scripts/server/client.js" type="server" language="javascript" /> <script src="scripts/server/client.js" type="server" language="javascript" />
<script src="scripts/server/crime.js" type="server" language="javascript" /> <script src="scripts/server/const.js" type="server" language="javascript" />
<script src="scripts/server/database.js" type="server" language="javascript" /> <script src="scripts/server/database.js" type="server" language="javascript" />
<script src="scripts/server/developer.js" type="server" language="javascript" /> <script src="scripts/server/developer.js" type="server" language="javascript" />
<script src="scripts/server/discord.js" type="server" language="javascript" /> <script src="scripts/server/discord.js" type="server" language="javascript" />
@@ -34,13 +34,10 @@
<script src="scripts/server/email.js" type="server" language="javascript" /> <script src="scripts/server/email.js" type="server" language="javascript" />
<script src="scripts/server/event.js" type="server" language="javascript" /> <script src="scripts/server/event.js" type="server" language="javascript" />
<script src="scripts/server/fishing.js" type="server" language="javascript" /> <script src="scripts/server/fishing.js" type="server" language="javascript" />
<script src="scripts/server/forensics.js" type="server" language="javascript" />
<script src="scripts/server/gate.js" type="server" language="javascript" /> <script src="scripts/server/gate.js" type="server" language="javascript" />
<script src="scripts/server/gps.js" type="server" language="javascript" />
<script src="scripts/server/gui.js" type="server" language="javascript" /> <script src="scripts/server/gui.js" type="server" language="javascript" />
<script src="scripts/server/help.js" type="server" language="javascript" /> <script src="scripts/server/help.js" type="server" language="javascript" />
<script src="scripts/server/house.js" type="server" language="javascript" /> <script src="scripts/server/house.js" type="server" language="javascript" />
<script src="scripts/server/insurance.js" type="server" language="javascript" />
<script src="scripts/server/item.js" type="server" language="javascript" /> <script src="scripts/server/item.js" type="server" language="javascript" />
<script src="scripts/server/job.js" type="server" language="javascript" /> <script src="scripts/server/job.js" type="server" language="javascript" />
<script src="scripts/server/keybind.js" type="server" language="javascript" /> <script src="scripts/server/keybind.js" type="server" language="javascript" />
@@ -48,10 +45,9 @@
<script src="scripts/server/messaging.js" type="server" language="javascript" /> <script src="scripts/server/messaging.js" type="server" language="javascript" />
<script src="scripts/server/misc.js" type="server" language="javascript" /> <script src="scripts/server/misc.js" type="server" language="javascript" />
<script src="scripts/server/npc.js" type="server" language="javascript" /> <script src="scripts/server/npc.js" type="server" language="javascript" />
<script src="scripts/server/netevents.js" type="server" language="javascript" />
<script src="scripts/server/paintball.js" type="server" language="javascript" />
<script src="scripts/server/race.js" type="server" language="javascript" /> <script src="scripts/server/race.js" type="server" language="javascript" />
<script src="scripts/server/radio.js" type="server" language="javascript" /> <script src="scripts/server/radio.js" type="server" language="javascript" />
<script src="scripts/server/radio.js" type="server" language="javascript" />
<script src="scripts/server/security.js" type="server" language="javascript" /> <script src="scripts/server/security.js" type="server" language="javascript" />
<script src="scripts/server/staff.js" type="server" language="javascript" /> <script src="scripts/server/staff.js" type="server" language="javascript" />
<script src="scripts/server/subaccount.js" type="server" language="javascript" /> <script src="scripts/server/subaccount.js" type="server" language="javascript" />
@@ -86,55 +82,10 @@
<file type="client" src="files/fonts/roboto-regular.ttf" /> <file type="client" src="files/fonts/roboto-regular.ttf" />
<file type="client" src="files/fonts/pricedown.ttf" /> <file type="client" src="files/fonts/pricedown.ttf" />
<file type="client" src="files/images/skins/none.png" /> <file type="client" src="files/images/skins/none.png" />
<!--<file type="client" src="files/images/server-logo.png" />--> <file type="client" src="files/images/mafiac-logo.png" />
<file type="client" src="files/images/gtac-logo.png" />
<file type="client" src="files/images/asshat-logo.png" /> <file type="client" src="files/images/asshat-logo.png" />
<!-- GUI -->
<script src="scripts/client/gui/2fa.js" type="client" language="javascript" />
<script src="scripts/client/gui/bizmgr.js" type="client" language="javascript" />
<script src="scripts/client/gui/changepass.js" type="client" language="javascript" />
<script src="scripts/client/gui/charselect.js" type="client" language="javascript" />
<script src="scripts/client/gui/clanmgr.js" type="client" language="javascript" />
<script src="scripts/client/gui/error.js" type="client" language="javascript" />
<script src="scripts/client/gui/housemgr.js" type="client" language="javascript" />
<script src="scripts/client/gui/info.js" type="client" language="javascript" />
<script src="scripts/client/gui/login.js" type="client" language="javascript" />
<script src="scripts/client/gui/list.js" type="client" language="javascript" />
<script src="scripts/client/gui/newchar.js" type="client" language="javascript" />
<script src="scripts/client/gui/register.js" type="client" language="javascript" />
<script src="scripts/client/gui/resetpass.js" type="client" language="javascript" />
<script src="scripts/client/gui/yesno.js" type="client" language="javascript" />
<script src="scripts/client/gui/localechooser.js" type="client" language="javascript" />
<!-- Client Scripts -->
<script src="scripts/client/afk.js" type="client" language="javascript" />
<script src="scripts/client/animation.js" type="client" language="javascript" />
<script src="scripts/client/business.js" type="client" language="javascript" />
<script src="scripts/client/chat.js" type="client" language="javascript" />
<script src="scripts/client/event.js" type="client" language="javascript" />
<script src="scripts/client/gui.js" type="client" language="javascript" />
<script src="scripts/client/gps.js" type="client" language="javascript" />
<script src="scripts/client/house.js" type="client" language="javascript" />
<script src="scripts/client/item.js" type="client" language="javascript" />
<script src="scripts/client/job.js" type="client" language="javascript" />
<script src="scripts/client/keybind.js" type="client" language="javascript" />
<script src="scripts/client/label.js" type="client" language="javascript" />
<script src="scripts/client/locale.js" type="client" language="javascript" />
<script src="scripts/client/logo.js" type="client" language="javascript" />
<script src="scripts/client/main.js" type="client" language="javascript" />
<script src="scripts/client/messaging.js" type="client" language="javascript" />
<script src="scripts/client/mousecam.js" type="client" language="javascript" />
<script src="scripts/client/nametag.js" type="client" language="javascript" />
<script src="scripts/client/npc.js" type="client" language="javascript" />
<script src="scripts/client/radio.js" type="client" language="javascript" />
<script src="scripts/client/scoreboard.js" type="client" language="javascript" />
<script src="scripts/client/netevents.js" type="client" language="javascript" />
<script src="scripts/client/skin-select.js" type="client" language="javascript" />
<script src="scripts/client/sync.js" type="client" language="javascript" />
<script src="scripts/client/time.nut" type="client" language="squirrel" />
<script src="scripts/client/utilities.js" type="client" language="javascript" />
<script src="scripts/client/vehicle.js" type="client" language="javascript" />
<!-- Locale Files --> <!-- Locale Files -->
<file type="client" src="config/client/locale.json" /> <file type="client" src="config/client/locale.json" />
<file type="client" src="locale/english.json" /> <file type="client" src="locale/english.json" />
@@ -162,6 +113,51 @@
<file type="client" src="files/images/flags/fi.png" /> <file type="client" src="files/images/flags/fi.png" />
<file type="client" src="files/images/flags/ru.png" /> <file type="client" src="files/images/flags/ru.png" />
<!-- GUI -->
<script src="scripts/client/gui/login.js" type="client" language="javascript" />
<script src="scripts/client/gui/newchar.js" type="client" language="javascript" />
<script src="scripts/client/gui/charselect.js" type="client" language="javascript" />
<script src="scripts/client/gui/error.js" type="client" language="javascript" />
<script src="scripts/client/gui/info.js" type="client" language="javascript" />
<script src="scripts/client/gui/yesno.js" type="client" language="javascript" />
<script src="scripts/client/gui/register.js" type="client" language="javascript" />
<script src="scripts/client/gui/resetpass.js" type="client" language="javascript" />
<script src="scripts/client/gui/changepass.js" type="client" language="javascript" />
<script src="scripts/client/gui/clanmgr.js" type="client" language="javascript" />
<script src="scripts/client/gui/housemgr.js" type="client" language="javascript" />
<script src="scripts/client/gui/bizmgr.js" type="client" language="javascript" />
<script src="scripts/client/gui/2fa.js" type="client" language="javascript" />
<script src="scripts/client/gui/list.js" type="client" language="javascript" />
<script src="scripts/client/gui/localechooser.js" type="client" language="javascript" />
<!-- Client Scripts -->
<script src="scripts/client/afk.js" type="client" language="javascript" />
<script src="scripts/client/animation.js" type="client" language="javascript" />
<script src="scripts/client/business.js" type="client" language="javascript" />
<script src="scripts/client/chatbox.js" type="client" language="javascript" />
<script src="scripts/client/event.js" type="client" language="javascript" />
<script src="scripts/client/gui.js" type="client" language="javascript" />
<script src="scripts/client/gps.js" type="client" language="javascript" />
<script src="scripts/client/house.js" type="client" language="javascript" />
<script src="scripts/client/item.js" type="client" language="javascript" />
<script src="scripts/client/job.js" type="client" language="javascript" />
<script src="scripts/client/keybind.js" type="client" language="javascript" />
<script src="scripts/client/label.js" type="client" language="javascript" />
<script src="scripts/client/locale.js" type="client" language="javascript" />
<script src="scripts/client/logo.js" type="client" language="javascript" />
<script src="scripts/client/main.js" type="client" language="javascript" />
<script src="scripts/client/messaging.js" type="client" language="javascript" />
<script src="scripts/client/mousecam.js" type="client" language="javascript" />
<script src="scripts/client/nametag.js" type="client" language="javascript" />
<script src="scripts/client/npc.js" type="client" language="javascript" />
<script src="scripts/client/radio.js" type="client" language="javascript" />
<script src="scripts/client/scoreboard.js" type="client" language="javascript" />
<script src="scripts/client/server.js" type="client" language="javascript" />
<script src="scripts/client/skin-select.js" type="client" language="javascript" />
<script src="scripts/client/sync.js" type="client" language="javascript" />
<script src="scripts/client/utilities.js" type="client" language="javascript" />
<script src="scripts/client/vehicle.js" type="client" language="javascript" />
<!-- MexUI --> <!-- MexUI -->
<file type="client" src="third-party/mexui/Images/down-arrow.png" /> <file type="client" src="third-party/mexui/Images/down-arrow.png" />
<script language="javascript" type="client" src="third-party/mexui/mexui.js" /> <script language="javascript" type="client" src="third-party/mexui/mexui.js" />

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: afk.js // FILE: afk.js
// DESC: Provides AFK detection // DESC: Provides AFK detection

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: animation.js // FILE: animation.js
// DESC: Provides animation functions and usage // DESC: Provides animation functions and usage
@@ -11,7 +10,7 @@
function makePedPlayAnimation(pedId, animationSlot, positionOffset) { function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
let ped = getElementFromId(pedId); let ped = getElementFromId(pedId);
if (ped == null) { if(ped == null) {
return false; return false;
} }
@@ -19,37 +18,37 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animationData[0]} for ped ${pedId}`); logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animationData[0]} for ped ${pedId}`);
let freezePlayer = false; let freezePlayer = false;
switch (animationData.moveType) { switch(animationData.moveType) {
case AGRP_ANIMMOVE_FORWARD: { case VRR_ANIMMOVE_FORWARD: {
setElementCollisionsEnabled(ped, false); setElementCollisionsEnabled(ped, false);
if (ped.isSyncer) { if(ped.isSyncer) {
setElementPosition(ped, getPosInFrontOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset)); setElementPosition(ped, getPosInFrontOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
} }
freezePlayer = true; freezePlayer = true;
break; break;
} }
case AGRP_ANIMMOVE_BACK: { case VRR_ANIMMOVE_BACK: {
setElementCollisionsEnabled(pedId, false); setElementCollisionsEnabled(pedId, false);
if (ped.isSyncer) { if(ped.isSyncer) {
setElementPosition(pedId, getPosBehindPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset)); setElementPosition(pedId, getPosBehindPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
} }
freezePlayer = true; freezePlayer = true;
break; break;
} }
case AGRP_ANIMMOVE_LEFT: { case VRR_ANIMMOVE_LEFT: {
setElementCollisionsEnabled(pedId, false); setElementCollisionsEnabled(pedId, false);
if (ped.isSyncer) { if(ped.isSyncer) {
setElementPosition(pedId, getPosToLeftOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset)); setElementPosition(pedId, getPosToLeftOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
} }
freezePlayer = true; freezePlayer = true;
break; break;
} }
case AGRP_ANIMMOVE_RIGHT: { case VRR_ANIMMOVE_RIGHT: {
setElementCollisionsEnabled(pedId, false); setElementCollisionsEnabled(pedId, false);
if (ped.isSyncer) { if(ped.isSyncer) {
setElementPosition(pedId, getPosToRightOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset)); setElementPosition(pedId, getPosToRightOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
} }
freezePlayer = true; freezePlayer = true;
@@ -61,21 +60,21 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
} }
} }
if (getGame() < AGRP_GAME_GTA_IV) { if(getGame() < VRR_GAME_GTA_IV) {
if (animationData.animType == AGRP_ANIMTYPE_NORMAL || animationData.animType == AGRP_ANIMTYPE_SURRENDER) { if(animationData.animType == VRR_ANIMTYPE_NORMAL || animationData.animType == VRR_ANIMTYPE_SURRENDER) {
if (getGame() == AGRP_GAME_GTA_VC || getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
ped.clearAnimations(); ped.clearAnimations();
} else { } else {
ped.clearObjective(); ped.clearObjective();
} }
ped.addAnimation(animationData.groupId, animationData.animId); ped.addAnimation(animationData.groupId, animationData.animId);
if (ped == localPlayer && freezePlayer == true) { if(ped == localPlayer && freezePlayer == true) {
inAnimation = true; inAnimation = true;
setLocalPlayerControlState(false, false); setLocalPlayerControlState(false, false);
localPlayer.collisionsEnabled = false; localPlayer.collisionsEnabled = false;
} }
} else if (animationData.animType == AGRP_ANIMTYPE_BLEND) { } else if(animationData.animType == VRR_ANIMTYPE_BLEND) {
ped.position = ped.position; ped.position = ped.position;
ped.blendAnimation(animationData.groupId, animationData.animId, animationData.animSpeed); ped.blendAnimation(animationData.groupId, animationData.animId, animationData.animSpeed);
} }
@@ -90,17 +89,17 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
function forcePedAnimation(pedId, animSlot) { function forcePedAnimation(pedId, animSlot) {
let ped = getElementFromId(pedId); let ped = getElementFromId(pedId);
if (ped == null) { if(ped == null) {
return false; return false;
} }
let animationData = getAnimationData(animSlot); let animationData = getAnimationData(animSlot);
if (getGame() < AGRP_GAME_GTA_IV) { if(getGame() < VRR_GAME_GTA_IV) {
ped.position = ped.position; ped.position = ped.position;
ped.addAnimation(animationData.groupId, animationData.animId); ped.addAnimation(animationData.groupId, animationData.animId);
if (ped == localPlayer) { if(ped == localPlayer) {
inAnimation = true; inAnimation = true;
setLocalPlayerControlState(false, false); setLocalPlayerControlState(false, false);
localPlayer.collisionsEnabled = false; localPlayer.collisionsEnabled = false;
@@ -116,20 +115,20 @@ function forcePedAnimation(pedId, animSlot) {
function makePedStopAnimation(pedId) { function makePedStopAnimation(pedId) {
let ped = getElementFromId(pedId); let ped = getElementFromId(pedId);
if (ped == null) { if(ped == null) {
return false; return false;
} }
if (getGame() != AGRP_GAME_GTA_IV) { if(getGame() != VRR_GAME_GTA_IV) {
if (getGame() == AGRP_GAME_GTA_VC || getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
ped.clearAnimations(); ped.clearAnimations();
} else { } else {
ped.clearObjective(); ped.clearObjective();
} }
} }
if (ped == localPlayer) { if(ped == localPlayer) {
if (getGame() != AGRP_GAME_GTA_IV) { if(getGame() != VRR_GAME_GTA_IV) {
localPlayer.collisionsEnabled = true; localPlayer.collisionsEnabled = true;
} }
setLocalPlayerControlState(true, false); setLocalPlayerControlState(true, false);
@@ -137,3 +136,13 @@ function makePedStopAnimation(pedId) {
} }
// =========================================================================== // ===========================================================================
/**
* @param {number} animationSlot - The slot index of the animation
* @return {AnimationData} The animation's data (array)
*/
function getAnimationData(animationSlot, gameId = getGame()) {
return getGameConfig().animations[gameId][animationSlot];
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: business.js // FILE: business.js
// DESC: Provides business functions and usage // DESC: Provides business functions and usage
@@ -28,8 +27,8 @@ class BusinessData {
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) { function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
logToConsole(LOG_DEBUG, `[VRR.Business] Received business ${businessId} (${name}) from server`); logToConsole(LOG_DEBUG, `[VRR.Business] Received business ${businessId} (${name}) from server`);
if (!areServerElementsSupported()) { if(!areServerElementsSupported()) {
if (getBusinessData(businessId) != false) { if(getBusinessData(businessId) != false) {
let businessData = getBusinessData(businessId); let businessData = getBusinessData(businessId);
businessData.name = name; businessData.name = name;
businessData.entrancePosition = entrancePosition; businessData.entrancePosition = entrancePosition;
@@ -39,10 +38,10 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
businessData.hasItems = hasItems; businessData.hasItems = hasItems;
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} already exists. Checking blip ...`); logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} already exists. Checking blip ...`);
if (blipModel == -1) { if(blipModel == -1) {
if (businessData.blipId != -1) { if(businessData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been removed by the server`); logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been removed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId); natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
} else { } else {
destroyElement(getElementFromId(blipId)); destroyElement(getElementFromId(blipId));
@@ -54,18 +53,18 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip is unchanged`); logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip is unchanged`);
} }
} else { } else {
if (businessData.blipId != -1) { if(businessData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been changed by the server`); logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been changed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
natives.setBlipCoordinates(businessData.blipId, businessData.entrancePosition); natives.setBlipCoordinates(businessData.blipId, businessData.entrancePosition);
natives.changeBlipSprite(businessData.blipId, businessData.blipModel); natives.changeBlipSprite(businessData.blipId, businessData.blipModel);
natives.setBlipMarkerLongDistance(businessData.blipId, false); natives.setBlipMarkerLongDistance(businessData.blipId, false);
natives.setBlipAsShortRange(tempBusinessData.blipId, true); natives.setBlipAsShortRange(tempBusinessData.blipId, true);
natives.changeBlipNameFromAscii(businessData.blipId, `${businessData.name.substr(0, 24)}${(businessData.name.length > 24) ? " ..." : ""}`); natives.changeBlipNameFromAscii(businessData.blipId, `${businessData.name.substr(0, 24)}${(businessData.name.length > 24) ? " ...": ""}`);
} }
} else { } else {
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name); let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
if (blipId != -1) { if(blipId != -1) {
tempBusinessData.blipId = blipId; tempBusinessData.blipId = blipId;
} }
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`); logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
@@ -74,9 +73,9 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
} else { } else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} doesn't exist. Adding ...`); logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} doesn't exist. Adding ...`);
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems); let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
if (blipModel != -1) { if(blipModel != -1) {
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name); let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
if (blipId != -1) { if(blipId != -1) {
tempBusinessData.blipId = blipId; tempBusinessData.blipId = blipId;
} }
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`); logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
@@ -101,8 +100,8 @@ function getBusinessData(businessId) {
let businesses = getServerData().businesses; let businesses = getServerData().businesses;
for (let i in businesses) { for(let i in businesses) {
if (businesses[i].businessId == businessId) { if(businesses[i].businessId == businessId) {
return businesses[i]; return businesses[i];
} }
} }
@@ -113,7 +112,7 @@ function getBusinessData(businessId) {
// =========================================================================== // ===========================================================================
function setAllBusinessDataIndexes() { function setAllBusinessDataIndexes() {
for (let i in getServerData().businesses) { for(let i in getServerData().businesses) {
getServerData().businesses[i].index = i; getServerData().businesses[i].index = i;
} }
} }

View File

@@ -1,235 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: chatbox.js
// DESC: Provides extra chatbox features
// TYPE: Client (JavaScript)
// ===========================================================================
// ===========================================================================
let chatTimeStampsEnabled = false;
let chatEmojiEnabled = false;
let chatBoxHistory = [];
let bottomMessageIndex = 0;
let maxChatBoxHistory = 500;
let scrollAmount = 1;
let maxChatBoxLines = 6;
let chatAutoHideDelay = 0;
let chatLastUse = 0;
let scrollUpKey = false;
let scrollDownKey = false;
// ===========================================================================
function initChatBoxScript() {
logToConsole(LOG_DEBUG, "[VRR.Chat]: Initializing chat script ...");
scrollUpKey = getKeyIdFromParams("pageup");
scrollDownKey = getKeyIdFromParams("pagedown");
bindChatBoxKeys();
logToConsole(LOG_DEBUG, "[VRR.Chat]: Chat script initialized!");
}
// ===========================================================================
function bindChatBoxKeys() {
bindKey(toInteger(scrollUpKey), KEYSTATE_DOWN, chatBoxScrollUp);
bindKey(toInteger(scrollDownKey), KEYSTATE_DOWN, chatBoxScrollDown);
}
// ===========================================================================
function unBindChatBoxKeys() {
unbindKey(toInteger(scrollUpKey));
unbindKey(toInteger(scrollDownKey));
}
// ===========================================================================
function receiveChatBoxMessageFromServer(messageString, colour, hour, minute, second) {
logToConsole(LOG_DEBUG, `[VRR.Chat]: Received chatbox message from server: ${messageString}`);
// Just in case it's hidden by auto hide
//setChatWindowEnabled(true);
//let timeStamp = findResourceByName("agrp_time").exports.getCurrentUnixTimeStampSquirrel();
hour = fillLeadingZeros(hour, 2);
minute = fillLeadingZeros(minute, 2);
second = fillLeadingZeros(second, 2);
addToChatBoxHistory(messageString, colour, hour, minute, second);
//let unixTimeStampMS = new Date().getTime();
//let timeStampDate = new Date(unixTimeStampMS);
//let timeStampDate = new Date(timeStamp);
//let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`;
let outputString = messageString;
if (chatTimeStampsEnabled == true) {
//timeStampString = `{TIMESTAMPCOLOUR}[${findResourceByName("agrp_time").exports.getTimeStampOutput(timeStamp)}]{MAINCOLOUR}`;
let timeStampString = `{TIMESTAMPCOLOUR}[${hour}:${minute}:${second}] `;
outputString = `${timeStampString}${messageString}`;
}
logToConsole(LOG_DEBUG, `[VRR.Chat]: Changed colours in string: ${outputString}`);
outputString = replaceColoursInMessage(`${outputString}`);
if (chatEmojiEnabled == true) {
logToConsole(LOG_DEBUG, `[VRR.Chat]: Enabled emoji in string: ${outputString}`);
outputString = replaceEmojiInMessage(outputString);
}
if (profanityFilterEnabled == true) {
logToConsole(LOG_DEBUG, `[VRR.Chat]: Removed profanity in string: ${outputString}`);
outputString = replaceProfanityInMessage(outputString);
}
message(outputString, colour);
bottomMessageIndex = chatBoxHistory.length - 1;
chatLastUse = getCurrentUnixTimestamp();
}
// ===========================================================================
function setChatScrollLines(amount) {
scrollAmount = amount;
}
// ===========================================================================
function setChatTimeStampsState(state) {
chatTimeStampsEnabled = state;
updateChatBox();
}
// ===========================================================================
function setChatEmojiState(state) {
chatEmojiEnabled = state;
updateChatBox();
}
// ===========================================================================
function setChatAutoHideDelay(delay) {
chatAutoHideDelay = delay * 1000;
}
// ===========================================================================
function addToChatBoxHistory(messageString, colour, hour, minute, second) {
chatBoxHistory.push([messageString, colour, hour, minute, second]);
}
// ===========================================================================
function chatBoxScrollUp() {
if (bottomMessageIndex > maxChatBoxLines) {
bottomMessageIndex = bottomMessageIndex - scrollAmount;
updateChatBox();
}
}
// ===========================================================================
function chatBoxScrollDown() {
if (bottomMessageIndex < chatBoxHistory.length - 1) {
bottomMessageIndex = bottomMessageIndex + scrollAmount;
updateChatBox();
}
}
// ===========================================================================
function clearChatBox() {
for (let i = 0; i <= maxChatBoxLines; i++) {
message("", COLOUR_WHITE);
}
}
// ===========================================================================
function updateChatBox() {
clearChatBox();
for (let i = bottomMessageIndex - maxChatBoxLines; i <= bottomMessageIndex; i++) {
if (typeof chatBoxHistory[i] != "undefined") {
let outputString = chatBoxHistory[i][0];
if (chatTimeStampsEnabled == true) {
//let timeStampDate = new Date(chatBoxHistory[i][2]);
//let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`;
//let timeStampText = findResourceByName("agrp_time").exports.getTimeStampOutput(chatBoxHistory[i][2]);
let timeStampText = `${chatBoxHistory[i][2]}:${chatBoxHistory[i][3]}:${chatBoxHistory[i][4]}`;
outputString = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${chatBoxHistory[i][0]}`;
}
outputString = replaceColoursInMessage(outputString);
if (chatEmojiEnabled == true) {
outputString = replaceEmojiInMessage(outputString);
}
if (profanityFilterEnabled == true) {
outputString = replaceProfanityInMessage(outputString);
}
message(outputString, chatBoxHistory[i][1]);
} else {
message("", COLOUR_WHITE);
}
}
chatLastUse = getCurrentUnixTimestamp();
}
// ===========================================================================
function processMouseWheelForChatBox(mouseId, deltaCoordinates, flipped) {
// There isn't a way to detect whether chat input is active, but mouse cursor is forced shown when typing so ¯\_(ツ)_/¯
if (!gui.cursorEnabled) {
return false;
}
if (!flipped) {
if (deltaCoordinates.y > 0) {
chatBoxScrollUp();
} else {
chatBoxScrollDown();
}
} else {
if (deltaCoordinates.y > 0) {
chatBoxScrollDown();
} else {
chatBoxScrollUp();
}
}
}
// ===========================================================================
function checkChatAutoHide() {
return false;
// Make sure chat input isn't active
if (gui.cursorEnabled) {
return false;
}
// Don't process auto-hide if it's disabled
if (chatAutoHideDelay == 0) {
return false;
}
if (getCurrentUnixTimestamp() - chatLastUse >= chatAutoHideDelay) {
setChatWindowEnabled(false);
}
}
// ===========================================================================

171
scripts/client/chatbox.js Normal file
View File

@@ -0,0 +1,171 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: chatbox.js
// DESC: Provides extra chatbox features
// TYPE: Client (JavaScript)
// ===========================================================================
// ===========================================================================
let chatBoxHistory = [];
let bottomMessageIndex = 0;
let maxChatBoxHistory = 500;
let scrollAmount = 1;
let maxChatBoxLines = 6;
let chatAutoHideDelay = 0;
let chatLastUse = 0;
let scrollUpKey = false;
let scrollDownKey = false;
// ===========================================================================
function initChatBoxScript() {
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Initializing chatbox script ...");
scrollUpKey = getKeyIdFromParams("pageup");
scrollDownKey = getKeyIdFromParams("pagedown");
bindChatBoxKeys();
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Chatbox script initialized!");
}
// ===========================================================================
function bindChatBoxKeys() {
bindKey(toInteger(scrollUpKey), KEYSTATE_DOWN, chatBoxScrollUp);
bindKey(toInteger(scrollDownKey), KEYSTATE_DOWN, chatBoxScrollDown);
}
// ===========================================================================
function unBindChatBoxKeys() {
unbindKey(toInteger(scrollUpKey));
unbindKey(toInteger(scrollDownKey));
}
// ===========================================================================
function receiveChatBoxMessageFromServer(messageString, colour) {
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Received chatbox message from server: ${messageString}`);
// Just in case it's hidden by auto hide
//setChatWindowEnabled(true);
let colouredString = replaceColoursInMessage(messageString);
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Changed colours in string: ${colouredString}`);
addToChatBoxHistory(colouredString, colour);
//if(bottomMessageIndex >= chatBoxHistory.length-1) {
message(colouredString, colour);
bottomMessageIndex = chatBoxHistory.length-1;
//}
chatLastUse = getCurrentUnixTimestamp();
}
// ===========================================================================
function setChatScrollLines(amount) {
scrollAmount = amount;
}
// ===========================================================================
function setChatAutoHideDelay(delay) {
chatAutoHideDelay = delay*1000;
}
// ===========================================================================
function addToChatBoxHistory(messageString, colour) {
chatBoxHistory.push([messageString, colour]);
}
// ===========================================================================
function chatBoxScrollUp() {
if(bottomMessageIndex > maxChatBoxLines) {
bottomMessageIndex = bottomMessageIndex-scrollAmount;
updateChatBox();
}
}
// ===========================================================================
function chatBoxScrollDown() {
if(bottomMessageIndex < chatBoxHistory.length-1) {
bottomMessageIndex = bottomMessageIndex+scrollAmount;
updateChatBox();
}
}
// ===========================================================================
function clearChatBox() {
for(let i = 0 ; i <= maxChatBoxLines ; i++) {
message("", COLOUR_WHITE);
}
}
// ===========================================================================
function updateChatBox() {
clearChatBox();
for(let i = bottomMessageIndex-maxChatBoxLines ; i <= bottomMessageIndex ; i++) {
if(typeof chatBoxHistory[i] != "undefined") {
message(chatBoxHistory[i][0], chatBoxHistory[i][1]);
} else {
message("", COLOUR_WHITE);
}
}
chatLastUse = getCurrentUnixTimestamp();
}
// ===========================================================================
function processMouseWheelForChatBox(mouseId, deltaCoordinates, flipped) {
// There isn't a way to detect whether chat input is active, but mouse cursor is forced shown when typing so ¯\_(ツ)_/¯
if(!gui.cursorEnabled) {
return false;
}
if(!flipped) {
if(deltaCoordinates.y > 0) {
chatBoxScrollUp();
} else {
chatBoxScrollDown();
}
} else {
if(deltaCoordinates.y > 0) {
chatBoxScrollDown();
} else {
chatBoxScrollUp();
}
}
}
// ===========================================================================
function checkChatAutoHide() {
return false;
// Make sure chat input isn't active
if(gui.cursorEnabled) {
return false;
}
// Don't process auto-hide if it's disabled
if(chatAutoHideDelay == 0) {
return false;
}
if(getCurrentUnixTimestamp()-chatLastUse >= chatAutoHideDelay) {
setChatWindowEnabled(false);
}
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: content.js // FILE: content.js
// DESC: Provides connection to extra content resources // DESC: Provides connection to extra content resources
@@ -10,10 +9,10 @@
function getCustomImage(imageName) { function getCustomImage(imageName) {
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]); let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if (contentResource != null) { if(contentResource != null) {
if (contentResource.isStarted) { if(contentResource.isStarted) {
let image = contentResource.exports.getCustomImage(imageName); let image = contentResource.exports.getCustomImage(imageName);
if (image != null) { if(image != null) {
return image; return image;
} }
} }
@@ -25,10 +24,10 @@ function getCustomImage(imageName) {
function getCustomFont(fontName) { function getCustomFont(fontName) {
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]); let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if (contentResource != null) { if(contentResource != null) {
if (contentResource.isStarted) { if(contentResource.isStarted) {
let font = contentResource.exports.getCustomFont(fontName); let font = contentResource.exports.getCustomFont(fontName);
if (font != null) { if(font != null) {
return font; return font;
} }
} }
@@ -40,10 +39,10 @@ function getCustomFont(fontName) {
function getCustomAudio(audioName) { function getCustomAudio(audioName) {
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]); let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if (contentResource != null) { if(contentResource != null) {
if (contentResource.isStarted) { if(contentResource.isStarted) {
let audioFile = contentResource.exports.getCustomAudio(audioName); let audioFile = contentResource.exports.getCustomAudio(audioName);
if (audioFile != null) { if(audioFile != null) {
return audioFile; return audioFile;
} }
} }
@@ -55,8 +54,8 @@ function getCustomAudio(audioName) {
function playCustomAudio(audioName, volume = 0.5, loop = false) { function playCustomAudio(audioName, volume = 0.5, loop = false) {
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]); let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if (contentResource != null) { if(contentResource != null) {
if (contentResource.isStarted) { if(contentResource.isStarted) {
contentResource.exports.playCustomAudio(audioName, volume, loop); contentResource.exports.playCustomAudio(audioName, volume, loop);
} }
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: event.js // FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events // DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
@@ -10,91 +9,90 @@
function initEventScript() { function initEventScript() {
logToConsole(LOG_DEBUG, "[VRR.Event]: Initializing event script ..."); logToConsole(LOG_DEBUG, "[VRR.Event]: Initializing event script ...");
addCustomEvents();
addAllEventHandlers(); addAllEventHandlers();
logToConsole(LOG_DEBUG, "[VRR.Event]: Event script initialized!"); logToConsole(LOG_DEBUG, "[VRR.Event]: Event script initialized!");
} }
// =========================================================================== // ===========================================================================
function addCustomEvents() {
addEvent("OnLocalPlayerEnterSphere", 1);
addEvent("OnLocalPlayerExitSphere", 1);
addEvent("OnLocalPlayerEnteredVehicle", 1);
addEvent("OnLocalPlayerExitedVehicle", 1);
addEvent("OnLocalPlayerSwitchWeapon", 2);
}
// ===========================================================================
function addAllEventHandlers() { function addAllEventHandlers() {
addEventHandler("OnResourceStart", onResourceStart); bindEventHandler("OnResourceStart", thisResource, onResourceStart);
addEventHandler("OnResourceReady", onResourceReady); bindEventHandler("OnResourceReady", thisResource, onResourceReady);
addEventHandler("OnResourceStop", onResourceStop); bindEventHandler("OnResourceStop", thisResource, onResourceStop);
addEventHandler("OnProcess", onProcess); addEventHandler("OnProcess", onProcess);
addEventHandler("OnKeyUp", onKeyUp); addEventHandler("OnKeyUp", onKeyUp);
addEventHandler("OnDrawnHUD", onDrawnHUD); addEventHandler("OnDrawnHUD", onDrawnHUD);
addEventHandler("OnPedWasted", onPedWasted); addEventHandler("OnPedWasted", onPedWasted);
addEventHandler("OnElementStreamIn", onElementStreamIn); addEventHandler("OnElementStreamIn", onElementStreamIn);
addEventHandler("OnPedChangeWeapon", onPedChangeWeapon);
addEventHandler("OnLocalPlayerEnteredVehicle", onLocalPlayerEnteredVehicle);
addEventHandler("OnLocalPlayerExitedVehicle", onLocalPlayerExitedVehicle);
addEventHandler("OnLocalPlayerEnterSphere", onLocalPlayerEnterSphere);
addEventHandler("OnLocalPlayerExitSphere", onLocalPlayerExitSphere);
addEventHandler("OnLocalPlayerSwitchWeapon", onLocalPlayerSwitchWeapon);
addEventHandler("OnPedInflictDamage", onPedInflictDamage); addEventHandler("OnPedInflictDamage", onPedInflictDamage);
addEventHandler("OnLostFocus", onLostFocus); addEventHandler("OnLostFocus", onLostFocus);
addEventHandler("OnFocus", onFocus); addEventHandler("OnFocus", onFocus);
addEventHandler("OnCameraProcess", onCameraProcess);
addEventHandler("OnMouseWheel", onMouseWheel);
addEventHandler("OnEntityProcess", onEntityProcess);
if (findResourceByName("v-events") != null) { addEventHandler("OnCameraProcess", onCameraProcess);
if (findResourceByName("v-events").isStarted) {
addEventHandler("OnPedEnteredVehicleEx", onPedEnteredVehicle); addEventHandler("OnMouseWheel", onMouseWheel);
addEventHandler("OnPedExitedVehicleEx", onPedExitedVehicle);
addEventHandler("OnPedEnteredSphereEx", onPedEnteredSphere); addEventHandler("OnEntityProcess", onEntityProcess);
addEventHandler("OnPedExitedSphereEx", onPedExitedSphere);
}
}
} }
// =========================================================================== // ===========================================================================
function onResourceStart(event, resource) { function onResourceStart(event, resource) {
if (resource == thisResource) { sendResourceStartedSignalToServer();
sendResourceStartedSignalToServer();
}
if (resource == findResourceByName("v-events")) {
// Remove and re-add events, in case v-events was loaded after agrp_main
removeEventHandler("OnPedEnteredVehicleEx");
removeEventHandler("OnPedExitedVehicleEx");
removeEventHandler("OnPedEnteredSphereEx");
removeEventHandler("OnPedExitedSphereEx");
addEventHandler("OnPedEnteredVehicleEx", onPedEnteredVehicle);
addEventHandler("OnPedExitedVehicleEx", onPedExitedVehicle);
addEventHandler("OnPedEnteredSphereEx", onPedEnteredSphere);
addEventHandler("OnPedExitedSphereEx", onPedExitedSphere);
}
//garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60); //garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60);
} }
// =========================================================================== // ===========================================================================
function onResourceStop(event, resource) { function onResourceStop(event, resource) {
if (resource == thisResource) { sendResourceStoppedSignalToServer();
sendResourceStoppedSignalToServer();
}
} }
// =========================================================================== // ===========================================================================
function onResourceReady(event, resource) { function onResourceReady(event, resource) {
if (resource == thisResource) { sendResourceReadySignalToServer();
sendResourceReadySignalToServer();
}
} }
// =========================================================================== // ===========================================================================
function onProcess(event, deltaTime) { function onProcess(event, deltaTime) {
if (localPlayer == null) { if(localPlayer == null) {
return false; return false;
} }
if (!isSpawned) { if(!isSpawned) {
return false; return false;
} }
processSync(); processSync();
processLocalPlayerControlState(); processLocalPlayerControlState();
processLocalPlayerVehicleControlState(); processLocalPlayerVehicleControlState();
processLocalPlayerSphereEntryExitHandling();
processLocalPlayerVehicleEntryExitHandling();
processJobRouteSphere();
forceLocalPlayerEquippedWeaponItem(); forceLocalPlayerEquippedWeaponItem();
processWantedLevelReset(); processWantedLevelReset();
processGameSpecifics(); processGameSpecifics();
@@ -118,11 +116,11 @@ function onKeyUp(event, keyCode, scanCode, keyModifiers) {
// =========================================================================== // ===========================================================================
function onDrawnHUD(event) { function onDrawnHUD(event) {
if (!renderHUD) { if(!renderHUD) {
return false; return false;
} }
if (!localPlayer) { if(localPlayer == null) {
return false; return false;
} }
@@ -151,11 +149,11 @@ function onElementStreamIn(event, element) {
// =========================================================================== // ===========================================================================
function onPedExitedVehicle(event, ped, vehicle, seat) { function onLocalPlayerExitedVehicle(event, vehicle, seat) {
//logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited vehicle`); logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited vehicle`);
//sendNetworkEventToServer("agrp.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat); sendNetworkEventToServer("vrr.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
if (inVehicleSeat) { if(inVehicleSeat) {
parkedVehiclePosition = false; parkedVehiclePosition = false;
parkedVehicleHeading = false; parkedVehicleHeading = false;
} }
@@ -163,19 +161,18 @@ function onPedExitedVehicle(event, ped, vehicle, seat) {
// =========================================================================== // ===========================================================================
function onPedEnteredVehicle(event, ped, vehicle, seat) { function onLocalPlayerEnteredVehicle(event, vehicle, seat) {
logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered vehicle`); logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered vehicle`);
//sendNetworkEventToServer("agrp.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
if (areServerElementsSupported()) { sendNetworkEventToServer("vrr.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
if (inVehicleSeat == 0) {
setVehicleEngine(vehicle.id, false); //if(inVehicleSeat == 0) {
if (!inVehicle.engine) { //setVehicleEngine(vehicle, false);
parkedVehiclePosition = inVehicle.position; //if(!inVehicle.engine) {
parkedVehicleHeading = inVehicle.heading; // parkedVehiclePosition = inVehicle.position;
} // parkedVehicleHeading = inVehicle.heading;
} //}
} //}
} }
// =========================================================================== // ===========================================================================
@@ -184,13 +181,13 @@ function onPedInflictDamage(event, damagedEntity, damagerEntity, weaponId, healt
//let damagerEntityString = (!isNull(damagedEntity)) ? `${damagerEntity.name} (${damagerEntity.name}, ${damagerEntity.type} - ${typeof damagerEntity})` : `Unknown ped`; //let damagerEntityString = (!isNull(damagedEntity)) ? `${damagerEntity.name} (${damagerEntity.name}, ${damagerEntity.type} - ${typeof damagerEntity})` : `Unknown ped`;
//let damagedEntityString = (!isNull(damagedEntity)) ? `${damagedEntity.name} (${damagedEntity.name}, ${damagedEntity.type} - ${typeof damagedEntity})` : `Unknown ped`; //let damagedEntityString = (!isNull(damagedEntity)) ? `${damagedEntity.name} (${damagedEntity.name}, ${damagedEntity.type} - ${typeof damagedEntity})` : `Unknown ped`;
//logToConsole(LOG_DEBUG, `[VRR.Event] ${damagerEntityString} damaged ${damagedEntityString}'s '${pedPiece} with weapon ${weaponId}`); //logToConsole(LOG_DEBUG, `[VRR.Event] ${damagerEntityString} damaged ${damagedEntityString}'s '${pedPiece} with weapon ${weaponId}`);
if (!isNull(damagedEntity) && !isNull(damagerEntity)) { if(!isNull(damagedEntity) && !isNull(damagerEntity)) {
if (damagedEntity.isType(ELEMENT_PLAYER)) { if(damagedEntity.isType(ELEMENT_PLAYER)) {
if (damagedEntity == localPlayer) { if(damagedEntity == localPlayer) {
if (!weaponDamageEnabled[damagerEntity.name]) { //if(!weaponDamageEnabled[damagerEntity.name]) {
preventDefaultEventAction(event); preventDefaultEventAction(event);
} sendNetworkEventToServer("vrr.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss);
sendNetworkEventToServer("agrp.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss); //}
} }
} }
} }
@@ -198,16 +195,17 @@ function onPedInflictDamage(event, damagedEntity, damagerEntity, weaponId, healt
// =========================================================================== // ===========================================================================
function onPedEnteredSphere(event, ped, sphere) { function onLocalPlayerEnterSphere(event, sphere) {
if (sphere == jobRouteLocationSphere) { logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered sphere`);
if(sphere == jobRouteLocationSphere) {
enteredJobRouteSphere(); enteredJobRouteSphere();
} }
} }
// =========================================================================== // ===========================================================================
function onPedExitedSphere(event, ped, sphere) { function onLocalPlayerExitSphere(event, sphere) {
logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited sphere`);
} }
// =========================================================================== // ===========================================================================
@@ -224,7 +222,7 @@ function onFocus(event) {
// =========================================================================== // ===========================================================================
function onPedChangeWeapon(event, ped, oldWeapon, newWeapon) { function onLocalPlayerSwitchWeapon(oldWeapon, newWeapon) {
} }
@@ -243,7 +241,13 @@ function onMouseWheel(event, mouseId, deltaCoordinates, flipped) {
// =========================================================================== // ===========================================================================
function onEntityProcess(event, entity) { function onEntityProcess(event, entity) {
if(!isSpawned) {
return false;
}
//if(entity.isType(ELEMENT_PED) && !entity.isType(ELEMENT_PLAYER)) {
// processNPCMovement(entity);
//}
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: gps.js // FILE: gps.js
// DESC: Provides GPS functions and usage // DESC: Provides GPS functions and usage
@@ -18,8 +17,8 @@ let gpsBlipBlinkTimer = null;
function showGPSLocation(position, colour) { function showGPSLocation(position, colour) {
logToConsole(LOG_DEBUG, `[VRR.GPS] Showing gps location`); logToConsole(LOG_DEBUG, `[VRR.GPS] Showing gps location`);
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) { if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
// Server-side spheres don't show in GTA SA for some reason. // Server-side spheres don't show in GTA SA for some reason.
gpsSphere = game.createPickup(1318, position, 1); gpsSphere = game.createPickup(1318, position, 1);
} else { } else {
@@ -27,7 +26,7 @@ function showGPSLocation(position, colour) {
gpsSphere.colour = colour; gpsSphere.colour = colour;
} }
if (gpsBlip != null) { if(gpsBlip != null) {
destroyElement(gpsBlip); destroyElement(gpsBlip);
} }
@@ -41,16 +40,16 @@ function showGPSLocation(position, colour) {
function blinkGPSBlip(times, position, colour) { function blinkGPSBlip(times, position, colour) {
gpsBlipBlinkTimes = times; gpsBlipBlinkTimes = times;
gpsBlipBlinkTimer = setInterval(function () { gpsBlipBlinkTimer = setInterval(function() {
if (gpsBlip != null) { if(gpsBlip != null) {
destroyElement(gpsBlip); destroyElement(gpsBlip);
gpsBlip = null; gpsBlip = null;
} else { } else {
gpsBlip = game.createBlip(position, 0, 2, colour); gpsBlip = game.createBlip(position, 0, 2, colour);
} }
if (gpsBlipBlinkAmount >= gpsBlipBlinkTimes) { if(gpsBlipBlinkAmount >= gpsBlipBlinkTimes) {
if (gpsBlip != null) { if(gpsBlip != null) {
destroyElement(gpsBlip); destroyElement(gpsBlip);
gpsBlip = null; gpsBlip = null;
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: gui.js // FILE: gui.js
// DESC: Provides GUI functionality and styles (using MexUI) // DESC: Provides GUI functionality and styles (using MexUI)
@@ -69,8 +68,12 @@ function initGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] All GUI created successfully!`); logToConsole(LOG_DEBUG, `[VRR.GUI] All GUI created successfully!`);
loadLocaleConfig(); loadLocaleConfig();
loadAllLocaleStrings();
sendNetworkEventToServer("agrp.guiReady", true); resetGUIStrings();
resetLocaleChooserOptions();
sendNetworkEventToServer("vrr.guiReady", true);
}; };
// =========================================================================== // ===========================================================================
@@ -227,7 +230,7 @@ function processGUIKeyPress(keyCode) {
function processToggleGUIKeyPress(keyCode) { function processToggleGUIKeyPress(keyCode) {
if (keyCode == disableGUIKey) { if (keyCode == disableGUIKey) {
sendNetworkEventToServer("agrp.toggleGUI"); sendNetworkEventToServer("vrr.toggleGUI");
} }
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: 2fa.js // FILE: 2fa.js
// DESC: Provides two factor authentication GUI // DESC: Provides two factor authentication GUI
@@ -22,7 +21,7 @@ let twoFactorAuth = {
function initTwoFactorAuthenticationGUI() { function initTwoFactorAuthenticationGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating two factor auth GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating two factor auth GUI ...`);
twoFactorAuth.window = mexui.window(game.width / 2 - 150, game.height / 2 - 129, 300, 258, 'LOGIN', { twoFactorAuth.window = mexui.window(game.width/2-150, game.height/2-129, 300, 258, 'LOGIN', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
transitionTime: 500, transitionTime: 500,
@@ -39,7 +38,7 @@ function initTwoFactorAuthenticationGUI() {
borderColour: toColour(0, 0, 0, 0), borderColour: toColour(0, 0, 0, 0),
}, },
}); });
twoFactorAuth.window.titleBarIconSize = toVector2(0, 0); twoFactorAuth.window.titleBarIconSize = toVector2(0,0);
twoFactorAuth.window.titleBarHeight = 0; twoFactorAuth.window.titleBarHeight = 0;
twoFactorAuth.qrCode = twoFactorAuth.window.image(100, 20, 100, 100, mainLogoPath, { twoFactorAuth.qrCode = twoFactorAuth.window.image(100, 20, 100, 100, mainLogoPath, {
@@ -130,7 +129,7 @@ function twoFactorAuthSuccess() {
function checkTwoFactorAuth() { function checkTwoFactorAuth() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking two-factor authentication with server ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Checking two-factor authentication with server ...`);
sendNetworkEventToServer("agrp.2fa", twoFactorAuth.codeInput.lines[0]); sendNetworkEventToServer("vrr.2fa", twoFactorAuth.codeInput.lines[0]);
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: bizmgr.js // FILE: bizmgr.js
// DESC: Provides business manager GUI // DESC: Provides business manager GUI

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: changepass.js // FILE: changepass.js
// DESC: Provides change password GUI // DESC: Provides change password GUI
@@ -129,7 +128,7 @@ function passwordChangeFailed(errorMessage) {
function checkChangePassword() { function checkChangePassword() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password change with server ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password change with server ...`);
sendNetworkEventToServer("agrp.checkChangePassword", passwordChange.passwordInput.lines[0], passwordChange.confirmPasswordInput.lines[0]); sendNetworkEventToServer("vrr.checkChangePassword", passwordChange.passwordInput.lines[0], passwordChange.confirmPasswordInput.lines[0]);
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: charselect.js // FILE: charselect.js
// DESC: Provides character select GUI // DESC: Provides character select GUI
@@ -24,23 +23,23 @@ let characterSelect = {
// =========================================================================== // ===========================================================================
function initCharacterSelectGUI() { function initCharacterSelectGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating character select GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating character select GUI ...`);
characterSelect.window = mexui.window(game.width / 2 - 215, game.height / 2 - 83, 430, 190, 'SELECT CHARACTER', { characterSelect.window = mexui.window(game.width/2-215, game.height/2-83, 430, 190, 'SELECT CHARACTER', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
}, },
title: { title: {
textSize: 12.0, textSize: 12.0,
textFont: mainFont, textFont: mainFont,
textColour: toColour(0, 0, 0, 255), textColour: toColour(0, 0, 0, 255),
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
}, },
icon: { icon: {
textSize: 10.0, textSize: 10.0,
textFont: mainFont, textFont: mainFont,
textColour: toColour(0, 0, 0, 255), textColour: toColour(0, 0, 0, 255),
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
} }
}); });
characterSelect.window.titleBarIconSize = toVector2(0, 0); characterSelect.window.titleBarIconSize = toVector2(0, 0);
characterSelect.window.titleBarIconShown = false; characterSelect.window.titleBarIconShown = false;
@@ -172,7 +171,7 @@ function showCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, ski
guiLeftKey = selectPreviousCharacter; guiLeftKey = selectPreviousCharacter;
guiRightKey = selectNextCharacter; guiRightKey = selectNextCharacter;
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), characterSelect.window.position.y + characterSelect.window.size.y + 20)); showLocaleChooserGUI(new Vec2(getScreenWidth()/2-(localeChooser.window.size.x/2), characterSelect.window.position.y+characterSelect.window.size.y+20));
} }
// =========================================================================== // ===========================================================================
@@ -187,21 +186,21 @@ function showNewCharacter() {
function selectNextCharacter() { function selectNextCharacter() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Requesting next character info from server for character select window`); logToConsole(LOG_DEBUG, `[VRR.GUI] Requesting next character info from server for character select window`);
sendNetworkEventToServer("agrp.nextCharacter"); sendNetworkEventToServer("vrr.nextCharacter");
} }
// =========================================================================== // ===========================================================================
function selectPreviousCharacter() { function selectPreviousCharacter() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Requesting previous character info from server for character select window`); logToConsole(LOG_DEBUG, `[VRR.GUI] Requesting previous character info from server for character select window`);
sendNetworkEventToServer("agrp.previousCharacter"); sendNetworkEventToServer("vrr.previousCharacter");
} }
// =========================================================================== // ===========================================================================
function selectThisCharacter() { function selectThisCharacter() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Tell server the current shown character was selected in character select window`); logToConsole(LOG_DEBUG, `[VRR.GUI] Tell server the current shown character was selected in character select window`);
sendNetworkEventToServer("agrp.selectCharacter"); sendNetworkEventToServer("vrr.selectCharacter");
} }
// =========================================================================== // ===========================================================================
@@ -215,10 +214,10 @@ function switchCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, s
characterSelect.clanText.text = `Clan: ${clan}`; characterSelect.clanText.text = `Clan: ${clan}`;
characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`; characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`;
if (characterSelect.skinImage != null) { if(characterSelect.skinImage != null) {
characterSelect.skinImage.remove(); characterSelect.skinImage.remove();
} }
characterSelect.skinImage = (getGame() == AGRP_GAME_GTA_III) ? characterSelect.window.image(310, 32, 100, 90, `files/images/skins/gta3/${getSkinImage(skinId)}.png`) : characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png"); characterSelect.skinImage = (getGame() == VRR_GAME_GTA_III) ? characterSelect.window.image(310, 32, 100, 90, `files/images/skins/gta3/${getSkinImage(skinId)}.png`) : characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
characterSelect.window.shown = true; characterSelect.window.shown = true;
@@ -237,11 +236,11 @@ function characterSelectSuccess() {
// =========================================================================== // ===========================================================================
function getSkinImage(skinId, gameId = getGame()) { function getSkinImage(skinId, gameId = getGame()) {
if (skinId < 10) { if(skinId < 10) {
return `Skin_00${skinId}.png`; return `Skin_00${skinId}.png`;
} else if (skinId > 10 && skinId < 100) { } else if(skinId > 10 && skinId < 100) {
return `Skin_0${skinId}.png`; return `Skin_0${skinId}.png`;
} else if (skinId > 100) { } else if(skinId > 100) {
return `Skin_${skinId}.png`; return `Skin_${skinId}.png`;
} }
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: clanmgr.js // FILE: clanmgr.js
// DESC: Provides clan manager GUI // DESC: Provides clan manager GUI

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: error.js // FILE: error.js
// DESC: Provides error box GUI // DESC: Provides error box GUI
@@ -18,7 +17,7 @@ let errorDialog = {
function initErrorDialogGUI() { function initErrorDialogGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating error GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating error GUI ...`);
errorDialog.window = mexui.window(getScreenWidth() / 2 - 200, getScreenHeight() / 2 - 70, 400, 140, 'ERROR', { errorDialog.window = mexui.window(getScreenWidth()/2-200, getScreenHeight()/2-70, 400, 140, 'ERROR', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
transitionTime: 500, transitionTime: 500,

View File

@@ -1,147 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: betting.js
// DESC: Provides betting GUI (used for multiple casino games)
// TYPE: Client (JavaScript)
// ===========================================================================
let bettingGUI = {
window: null,
amountLabel: null,
fiveThousandLabel: null,
fiveThousandPlusButton: null,
fiveThousandMinusButton: null,
oneThousandLabel: null,
oneThousandPlusButton: null,
oneThousandMinusButton: null,
fiveHundredPlusButton: null,
fiveHundredMinusButton: null,
oneHundredLabel: null,
oneHundredPlusButton: null,
oneHundredMinusButton: null,
fiftyLabel: null,
fiftyPlusButton: null,
fiftyMinusButton: null,
twentyLabel: null,
twentyPlusButton: null,
twentyMinusButton: null,
tenLabel: null,
tenPlusButton: null,
tenMinusButton: null,
fiveLabel: null,
fivePlusButton: null,
fiveMinusButton: null,
oneLabel: null,
onePlusButton: null,
oneMinusButton: null,
}
// ===========================================================================
function initBettingGUI() {
bettingGUI.window = mexui.window(getScreenWidth() / 2 - 125, getScreenHeight() / 2 - 250, 250, 500, 'BETTING', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
transitionTime: 500,
},
title: {
textSize: 0.0,
textColour: toColour(0, 0, 0, 0),
},
icon: {
textSize: 0.0,
textColour: toColour(0, 0, 0, 0),
},
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
bettingGUI.window.titleBarIconSize = toVector2(0, 0);
bettingGUI.window.titleBarHeight = 0;
bettingGUI.window.titleBarShown = false;
bettingGUI.amountLabel = bettingGUI.window.text(10, 20, 230, 20, 'Amount: 0', {
main: {
textSize: 20.0,
textAlign: 0.5,
textColour: toColour(200, 200, 200, 255),
textFont: mainFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
bettingGUI.oneLabel = bettingGUI.window.text(10, 50, 230, 20, '1', {
main: {
textSize: 10.0,
textAlign: 0.5,
textColour: toColour(200, 200, 200, 255),
textFont: mainFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
bettingGUI.fiveLabel = bettingGUI.window.text(10, 65, 230, 20, '1', {
main: {
textSize: 10.0,
textAlign: 0.5,
textColour: toColour(200, 200, 200, 255),
textFont: mainFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
bettingGUI.tenLabel = bettingGUI.window.text(10, 80, 230, 20, '1', {
main: {
textSize: 10.0,
textAlign: 0.5,
textColour: toColour(200, 200, 200, 255),
textFont: mainFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
bettingGUI.fiftyLabel = bettingGUI.window.text(10, 95, 230, 20, '1', {
main: {
textSize: 10.0,
textAlign: 0.5,
textColour: toColour(200, 200, 200, 255),
textFont: mainFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
bettingGUI.hundredLabel = bettingGUI.window.text(10, 95, 230, 20, '1', {
main: {
textSize: 10.0,
textAlign: 0.5,
textColour: toColour(200, 200, 200, 255),
textFont: mainFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
bettingGUI.window.shown = false;
}
// ===========================================================================
function showBettingGUI() {
}
// ===========================================================================

View File

@@ -1,49 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: blackjack.js
// DESC: Provides blackjack game GUI
// TYPE: Client (JavaScript)
// ===========================================================================
let blackJackGUI = {
window: null,
dealerHand: [],
playerHand: [],
};
// ===========================================================================
let playerCards = [];
let dealerCards = [];
// ===========================================================================
function initBlackJackGUI() {
// Render a blackjack game in MexUI
//logToConsole(LOG_DEBUG, `[VRR.GUI] Creating blackjack GUI ...`);
blackJackGUI.window = mexui.window(game.width / 2 - 200, game.height - 150, 400, 400, 'Blackjack', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], 0),
},
title: {
textSize: 11.0,
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
},
icon: {
textSize: 0.0,
textColour: toColour(0, 0, 0, 0),
backgroundColour: toColour(0, 0, 0, 0),
},
});
blackJackGUI.window.titleBarShown = false;
blackJackGUI.window.shown = false;
//logToConsole(LOG_DEBUG, `[VRR.GUI] Created blackjack GUI`);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: housemgr.js // FILE: housemgr.js
// DESC: Provides house manager GUI // DESC: Provides house manager GUI

View File

@@ -0,0 +1,18 @@
<html>
<head>
<title>Connected RP: Login</title>
<style type="text/css" rel="stylesheet">
.input-box
{
font-family: "Roboto";
font-size: 14px;
border-style: solid;
border-colour: #0066AA;
border-radius: 2px;
color: #0066AA;
};
</style>
</head>
<body>
</body>
</html>

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: info.js // FILE: info.js
// DESC: Provides info dialog box GUI // DESC: Provides info dialog box GUI
@@ -17,8 +16,8 @@ let infoDialog = {
// =========================================================================== // ===========================================================================
function initInfoDialogGUI() { function initInfoDialogGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating info dialog GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating info dialog GUI ...`);
infoDialog.window = mexui.window(getScreenWidth() / 2 - 200, getScreenHeight() / 2 - 70, 400, 140, 'Information', { infoDialog.window = mexui.window(getScreenWidth()/2-200, getScreenHeight()/2-70, 400, 140, 'Information', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
}, },

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: list.js // FILE: list.js
// DESC: Provides simple list GUI // DESC: Provides simple list GUI
@@ -17,8 +16,8 @@ let listDialog = {
// =========================================================================== // ===========================================================================
function initListGUI() { function initListGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating list dialog GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating list dialog GUI ...`);
listDialog.window = mexui.window(game.width / 2 - 200, game.height / 2 - 70, 400, 500, 'List', { listDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 500, 'List', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
}, },
@@ -51,21 +50,21 @@ function initListGUI() {
listDialog.listGrid = listDialog.window.grid(5, 25, 390, 450, { listDialog.listGrid = listDialog.window.grid(5, 25, 390, 450, {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
}, },
column: { column: {
lineColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), lineColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
}, },
header: { header: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha - 50), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha-50),
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], windowTitleAlpha), textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], windowTitleAlpha),
}, },
cell: { cell: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], windowTitleAlpha), textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], windowTitleAlpha),
}, },
row: { row: {
lineColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), lineColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
hover: { hover: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 120), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 120),
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: localechooser.js // FILE: localechooser.js
// DESC: Provides locale chooser GUI // DESC: Provides locale chooser GUI
@@ -20,8 +19,8 @@ let flagImageGap = toVector2(5, 5);
// =========================================================================== // ===========================================================================
function initLocaleChooserGUI() { function initLocaleChooserGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating locale chooser GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating locale chooser GUI ...`);
localeChooser.window = mexui.window(game.width / 2 - 200, game.height - 150, 60, 60, 'Choose a language', { localeChooser.window = mexui.window(game.width/2-200, game.height-150, 60, 60, 'Choose a language', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], 0), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], 0),
}, },
@@ -38,8 +37,6 @@ function initLocaleChooserGUI() {
}); });
localeChooser.window.titleBarShown = false; localeChooser.window.titleBarShown = false;
localeChooser.window.shown = false;
loadLocaleConfig(); loadLocaleConfig();
logToConsole(LOG_DEBUG, `[VRR.GUI] Created locale chooser GUI`); logToConsole(LOG_DEBUG, `[VRR.GUI] Created locale chooser GUI`);
@@ -50,38 +47,28 @@ function initLocaleChooserGUI() {
function closeLocaleChooserGUI() { function closeLocaleChooserGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing locale chooser window`); logToConsole(LOG_DEBUG, `[VRR.GUI] Closing locale chooser window`);
localeChooser.window.shown = false; localeChooser.window.shown = false;
for (let i in localeChooser.flagImages) {
localeChooser.flagImages[i].shown = false;
}
mexui.setInput(false); mexui.setInput(false);
} }
// =========================================================================== // ===========================================================================
function showLocaleChooserGUI(position = toVector2(0.0, 0.0)) { function showLocaleChooserGUI(position = toVector2(0.0, 0.0)) {
// Disabled for now until image loading crash can be fixed if(position.x != 0.0 && position.y != 0.0) {
return false;
if (position.x != 0.0 && position.y != 0.0) {
localeChooser.window.position = position; localeChooser.window.position = position;
} else { } else {
localeChooser.window.position = toVector2((getScreenWidth() / 2) - (localeChooser.window.size.x / 2), getScreenHeight() - 100); localeChooser.window.position = toVector2((getScreenWidth()/2)-(localeChooser.window.size.x/2), getScreenHeight()-100);
} }
//closeAllWindows(); //closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing locale chooser window`); logToConsole(LOG_DEBUG, `[VRR.GUI] Showing locale chooser window`);
mexui.setInput(true); mexui.setInput(true);
localeChooser.window.shown = true; localeChooser.window.shown = true;
for (let i in localeChooser.flagImages) {
localeChooser.flagImages[i].shown = true;
}
} }
// =========================================================================== // ===========================================================================
function toggleLocaleChooserGUI() { function toggleLocaleChooserGUI() {
if (localeChooser.window.shown) { if(localeChooser.window.shown) {
closeLocaleChooserGUI(); closeLocaleChooserGUI();
} else { } else {
showLocaleChooserGUI(); showLocaleChooserGUI();
@@ -91,38 +78,36 @@ function toggleLocaleChooserGUI() {
// =========================================================================== // ===========================================================================
function localeChooserSetLocale(localeId) { function localeChooserSetLocale(localeId) {
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Asking server to change locale to ${localeId}`); logToConsole(LOG_DEBUG|LOG_WARN, `[VRR.GUI] Asking server to change locale to ${localeId}`);
sendLocaleSelectToServer(localeId); sendLocaleSelectToServer(localeId);
} }
// =========================================================================== // ===========================================================================
function resetLocaleChooserOptions() { function resetLocaleChooserOptions() {
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Resetting locale chooser options`); logToConsole(LOG_DEBUG|LOG_WARN, `[VRR.GUI] Resetting locale chooser options`);
// let tempLocaleOptions = getServerData().localeOptions; // getAvailableLocaleOptions(); // let tempLocaleOptions = getServerData().localeOptions; // getAvailableLocaleOptions();
let tempLocaleOptions = getAvailableLocaleOptions(); let tempLocaleOptions = getAvailableLocaleOptions();
localeChooser.window.size = toVector2((tempLocaleOptions.length * (flagImageSize.x + flagImageGap.x)) + flagImageGap.x, flagImageSize.y + flagImageGap.y * 2); localeChooser.window.size = toVector2((tempLocaleOptions.length*(flagImageSize.x+flagImageGap.x))+flagImageGap.x, flagImageSize.y+flagImageGap.y*2);
localeChooser.window.position = toVector2((getScreenWidth() / 2) - (localeChooser.window.size.x / 2), getScreenHeight() - 100); localeChooser.window.position = toVector2((getScreenWidth()/2)-(localeChooser.window.size.x/2), getScreenHeight()-100);
for (let i in localeChooser.flagImages) { for(let i in localeChooser.flagImages) {
localeChooser.flagImages[i].remove(); localeChooser.flagImages[i].remove();
} }
for (let i in tempLocaleOptions) { for(let i in tempLocaleOptions) {
let imagePath = `files/images/flags/${tempLocaleOptions[i].flagImageFile}`; let imagePath = `files/images/flags/${tempLocaleOptions[i].flagImageFile}`;
localeChooser.flagImages[i] = localeChooser.window.image((i * (flagImageSize.x + flagImageGap.x)) + flagImageGap.x, flagImageGap.y, flagImageSize.x, flagImageSize.y, imagePath, { localeChooser.flagImages[i] = localeChooser.window.image((i*(flagImageSize.x+flagImageGap.x))+flagImageGap.x, flagImageGap.y, flagImageSize.x, flagImageSize.y, imagePath, {
focused: { focused: {
borderColour: toColour(0, 0, 0, 0), borderColour: toColour(0, 0, 0, 0),
}, },
}, function () { }, function() {
localeChooserSetLocale(tempLocaleOptions[i].id); localeChooserSetLocale(tempLocaleOptions[i].id);
}); });
localeChooser.flagImages[i].shown = false; logToConsole(LOG_DEBUG|LOG_WARN, `[VRR.GUI] Created locale chooser option ${tempLocaleOptions[i].englishName} with image ${imagePath}`);
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Created locale chooser option ${tempLocaleOptions[i].englishName} with image ${imagePath}`);
//localeChooser.activeRingImages.push(activeRingImage); //localeChooser.activeRingImages.push(activeRingImage);
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: login.js // FILE: login.js
// DESC: Provides login GUI // DESC: Provides login GUI
@@ -21,7 +20,7 @@ let login = {
// =========================================================================== // ===========================================================================
let loginHTML = let loginHTML =
`<html> `<html>
<head> <head>
<title>Asshat Gaming Roleplay: Login</title> <title>Asshat Gaming Roleplay: Login</title>
<style type="text/css" rel="stylesheet"> <style type="text/css" rel="stylesheet">
@@ -43,8 +42,8 @@ let loginHTML =
// =========================================================================== // ===========================================================================
function initLoginGUI() { function initLoginGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating login GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating login GUI ...`);
login.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 135, 300, 275, 'LOGIN', { login.window = mexui.window(getScreenWidth()/2-150, getScreenHeight()/2-135, 300, 275, 'LOGIN', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
transitionTime: 500, transitionTime: 500,
@@ -61,7 +60,7 @@ function initLoginGUI() {
borderColour: toColour(0, 0, 0, 0), borderColour: toColour(0, 0, 0, 0),
}, },
}); });
login.window.titleBarIconSize = toVector2(0, 0); login.window.titleBarIconSize = toVector2(0,0);
login.window.titleBarHeight = 0; login.window.titleBarHeight = 0;
login.window.titleBarShown = false; login.window.titleBarShown = false;
@@ -158,7 +157,7 @@ function showLoginGUI() {
mexui.focusedControl = login.passwordInput; mexui.focusedControl = login.passwordInput;
guiSubmitKey = checkLogin; guiSubmitKey = checkLogin;
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), login.window.position.y + login.window.size.y + 20)); showLocaleChooserGUI(new Vec2(getScreenWidth()/2-(localeChooser.window.size.x/2), login.window.position.y+login.window.size.y+20));
//showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500); //showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500);
} }
@@ -166,7 +165,7 @@ function showLoginGUI() {
function checkLogin() { function checkLogin() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking login with server ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Checking login with server ...`);
sendNetworkEventToServer("agrp.checkLogin", login.passwordInput.lines[0]); sendNetworkEventToServer("vrr.checkLogin", login.passwordInput.lines[0]);
} }
// =========================================================================== // ===========================================================================
@@ -192,7 +191,7 @@ function switchToPasswordResetGUI() {
//closeAllWindows(); //closeAllWindows();
//logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset dialog window`); //logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset dialog window`);
//showResetPasswordGUI(); //showResetPasswordGUI();
sendNetworkEventToServer("agrp.checkResetPassword", ""); sendNetworkEventToServer("vrr.checkResetPassword", "");
return false; return false;
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: newchar.js // FILE: newchar.js
// DESC: Provides new character creation GUI // DESC: Provides new character creation GUI
@@ -21,7 +20,7 @@ let newCharacter = {
function initNewCharacterGUI() { function initNewCharacterGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating new character GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating new character GUI ...`);
newCharacter.window = mexui.window(getScreenWidth() / 2 - 130, getScreenHeight() / 2 - 115, 300, 230, 'NEW CHARACTER', { newCharacter.window = mexui.window(getScreenWidth()/2-130, getScreenHeight()/2-115, 300, 230, 'NEW CHARACTER', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
transitionTime: 500, transitionTime: 500,
@@ -123,7 +122,7 @@ function newCharacterFailed(errorMessage) {
newCharacter.firstNameInput.text = ""; newCharacter.firstNameInput.text = "";
newCharacter.lastNameInput.text = ""; newCharacter.lastNameInput.text = "";
if (!newCharacter.window.shown) { if(!newCharacter.window.shown) {
closeAllWindows(); closeAllWindows();
setChatWindowEnabled(false); setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
@@ -136,15 +135,15 @@ function newCharacterFailed(errorMessage) {
function checkNewCharacter() { function checkNewCharacter() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking new character with server ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Checking new character with server ...`);
if (newCharacter.firstNameInput.lines[0].length < 2) { if(newCharacter.firstNameInput.lines[0].length < 2) {
return false; return false;
} }
if (newCharacter.lastNameInput.lines[0].length < 2) { if(newCharacter.lastNameInput.lines[0].length < 2) {
return false; return false;
} }
sendNetworkEventToServer("agrp.checkNewCharacter", sendNetworkEventToServer("vrr.checkNewCharacter",
newCharacter.firstNameInput.lines[0], newCharacter.firstNameInput.lines[0],
newCharacter.lastNameInput.lines[0], newCharacter.lastNameInput.lines[0],
); );
@@ -161,7 +160,7 @@ function showNewCharacterGUI() {
mexui.focusedInput = newCharacter.firstNameInput; mexui.focusedInput = newCharacter.firstNameInput;
guiSubmitKey = checkNewCharacter; guiSubmitKey = checkNewCharacter;
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), newCharacter.window.position.y + newCharacter.window.size.y + 20)); showLocaleChooserGUI(new Vec2(getScreenWidth()/2-(localeChooser.window.size.x/2), newCharacter.window.position.y+newCharacter.window.size.y+20));
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: register.js // FILE: register.js
// DESC: Provides account registration GUI // DESC: Provides account registration GUI
@@ -21,8 +20,8 @@ let register = {
// =========================================================================== // ===========================================================================
function initRegisterGUI() { function initRegisterGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating register GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Creating register GUI ...`);
register.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 150, 300, 300, 'Register', { register.window = mexui.window(getScreenWidth()/2-150, getScreenHeight()/2-150, 300, 300, 'Register', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
transitionTime: 500, transitionTime: 500,
@@ -38,7 +37,7 @@ function initRegisterGUI() {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
} }
}); });
register.window.titleBarIconSize = toVector2(0, 0); register.window.titleBarIconSize = toVector2(0,0);
register.window.titleBarHeight = 0; register.window.titleBarHeight = 0;
register.window.titleBarShown = false; register.window.titleBarShown = false;
@@ -149,7 +148,7 @@ function registrationFailed(errorMessage) {
function checkRegistration() { function checkRegistration() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking registration with server ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Checking registration with server ...`);
sendNetworkEventToServer("agrp.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]); sendNetworkEventToServer("vrr.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]);
} }
// =========================================================================== // ===========================================================================
@@ -163,7 +162,7 @@ function showRegistrationGUI() {
mexui.focusedControl = register.passwordInput; mexui.focusedControl = register.passwordInput;
guiSubmitKey = checkRegistration; guiSubmitKey = checkRegistration;
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), register.window.position.y + register.window.size.y + 20)); showLocaleChooserGUI(new Vec2(getScreenWidth()/2-(localeChooser.window.size.x/2), register.window.position.y+register.window.size.y+20));
//showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500); //showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500);
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: resetpass.js // FILE: resetpass.js
// DESC: Provides password reset GUI // DESC: Provides password reset GUI
@@ -143,7 +142,7 @@ function showResetPasswordGUI() {
function checkResetPassword() { function checkResetPassword() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password reset with server (${passwordReset.emailInput.lines[0]}) ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password reset with server (${passwordReset.emailInput.lines[0]}) ...`);
sendNetworkEventToServer("agrp.checkResetPassword", passwordReset.emailInput.lines[0]); sendNetworkEventToServer("vrr.checkResetPassword", passwordReset.emailInput.lines[0]);
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: yesno.js // FILE: yesno.js
// DESC: Provides yes/no prompt dialog GUI // DESC: Provides yes/no prompt dialog GUI
@@ -10,17 +9,17 @@
let yesNoDialog = { let yesNoDialog = {
window: null, window: null,
messageLabel: null, messageLabel: null,
yesButton: null, yesButton: null,
noButton: null, noButton: null,
}; };
// =========================================================================== // ===========================================================================
function initYesNoDialogGUI() { function initYesNoDialogGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Created prompt GUI ...`); logToConsole(LOG_DEBUG, `[VRR.GUI] Created prompt GUI ...`);
yesNoDialog.window = mexui.window(game.width / 2 - 200, game.height / 2 - 70, 400, 140, 'Question', { yesNoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Question', {
main: { main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
transitionTime: 500, transitionTime: 500,
@@ -80,37 +79,37 @@ function initYesNoDialogGUI() {
// =========================================================================== // ===========================================================================
function showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonText) { function showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonText) {
closeAllWindows(); closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`); logToConsole(LOG_DEBUG, `[VRR.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
mexui.setInput(true); mexui.setInput(true);
yesNoDialog.messageLabel.text = ""; yesNoDialog.messageLabel.text = "";
yesNoDialog.yesButton.text = ""; yesNoDialog.yesButton.text = "";
yesNoDialog.noButton.text = ""; yesNoDialog.noButton.text = "";
yesNoDialog.window.title = ""; yesNoDialog.window.title = "";
yesNoDialog.messageLabel.text = promptMessage; yesNoDialog.messageLabel.text = promptMessage;
yesNoDialog.yesButton.text = yesButtonText; yesNoDialog.yesButton.text = yesButtonText;
yesNoDialog.noButton.text = noButtonText; yesNoDialog.noButton.text = noButtonText;
yesNoDialog.window.title = promptTitle; yesNoDialog.window.title = promptTitle;
yesNoDialog.window.shown = true; yesNoDialog.window.shown = true;
} }
// =========================================================================== // ===========================================================================
function yesNoDialogAnswerNo() { function yesNoDialogAnswerNo() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Responding with answer NO to server prompt`); logToConsole(LOG_DEBUG, `[VRR.GUI] Responding with answer NO to server prompt`);
sendNetworkEventToServer("agrp.promptAnswerNo"); sendNetworkEventToServer("vrr.promptAnswerNo");
closeAllWindows(); closeAllWindows();
} }
// =========================================================================== // ===========================================================================
function yesNoDialogAnswerYes() { function yesNoDialogAnswerYes() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Responding with answer YES to server prompt`); logToConsole(LOG_DEBUG, `[VRR.GUI] Responding with answer YES to server prompt`);
sendNetworkEventToServer("agrp.promptAnswerYes"); sendNetworkEventToServer("vrr.promptAnswerYes");
closeAllWindows(); closeAllWindows();
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: house.js // FILE: house.js
// DESC: Provides house functions and usage // DESC: Provides house functions and usage
@@ -26,8 +25,8 @@ class HouseData {
function receiveHouseFromServer(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior) { function receiveHouseFromServer(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior) {
logToConsole(LOG_DEBUG, `[VRR.House] Received house ${houseId} (${name}) from server`); logToConsole(LOG_DEBUG, `[VRR.House] Received house ${houseId} (${name}) from server`);
if (!areServerElementsSupported()) { if(!areServerElementsSupported()) {
if (getHouseData(houseId) != false) { if(getHouseData(houseId) != false) {
let houseData = getHouseData(houseId); let houseData = getHouseData(houseId);
houseData.description = description; houseData.description = description;
houseData.entrancePosition = entrancePosition; houseData.entrancePosition = entrancePosition;
@@ -36,10 +35,10 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
houseData.hasInterior = hasInterior; houseData.hasInterior = hasInterior;
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} already exists. Checking blip ...`); logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} already exists. Checking blip ...`);
if (blipModel == -1) { if(blipModel == -1) {
if (houseData.blipId != -1) { if(houseData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been removed by the server`); logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been removed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getHouseData(houseId).blipId); natives.removeBlipAndClearIndex(getHouseData(houseId).blipId);
} else { } else {
destroyElement(getElementFromId(blipId)); destroyElement(getElementFromId(blipId));
@@ -49,18 +48,18 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip is unchanged`); logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip is unchanged`);
} }
} else { } else {
if (houseData.blipId != -1) { if(houseData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been changed by the server`); logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been changed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
natives.setBlipCoordinates(houseData.blipId, houseData.entrancePosition); natives.setBlipCoordinates(houseData.blipId, houseData.entrancePosition);
natives.changeBlipSprite(houseData.blipId, houseData.blipModel); natives.changeBlipSprite(houseData.blipId, houseData.blipModel);
natives.setBlipMarkerLongDistance(houseData.blipId, false); natives.setBlipMarkerLongDistance(houseData.blipId, false);
natives.setBlipAsShortRange(houseData.blipId, true); natives.setBlipAsShortRange(houseData.blipId, true);
natives.changeBlipNameFromAscii(houseData.blipId, `${houseData.name.substr(0, 24)}${(houseData.name.length > 24) ? " ..." : ""}`); natives.changeBlipNameFromAscii(houseData.blipId, `${houseData.name.substr(0, 24)}${(houseData.name.length > 24) ? " ...": ""}`);
} }
} else { } else {
let blipId = createGameBlip(houseData.blipModel, houseData.entrancePosition, houseData.name); let blipId = createGameBlip(houseData.blipModel, houseData.entrancePosition, houseData.name);
if (blipId != -1) { if(blipId != -1) {
houseData.blipId = blipId; houseData.blipId = blipId;
} }
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`); logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
@@ -69,9 +68,9 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
} else { } else {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} doesn't exist. Adding ...`); logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} doesn't exist. Adding ...`);
let tempHouseData = new HouseData(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior); let tempHouseData = new HouseData(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior);
if (blipModel != -1) { if(blipModel != -1) {
let blipId = createGameBlip(tempHouseData.blipModel, tempHouseData.entrancePosition, "House"); let blipId = createGameBlip(tempHouseData.blipModel, tempHouseData.entrancePosition, "House");
if (blipId != -1) { if(blipId != -1) {
tempHouseData.blipId = blipId; tempHouseData.blipId = blipId;
} }
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`); logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
@@ -90,10 +89,10 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
* @param {number} houseId - The ID of the house (initially provided by server) * @param {number} houseId - The ID of the house (initially provided by server)
* @return {HouseData} The house's data (class instance) * @return {HouseData} The house's data (class instance)
*/ */
function getHouseData(houseId) { function getHouseData(houseId) {
let houses = getServerData().houses; let houses = getServerData().houses;
for (let i in houses) { for(let i in houses) {
if (houses[i].houseId == houseId) { if(houses[i].houseId == houseId) {
return houses[i]; return houses[i];
} }
} }
@@ -104,7 +103,7 @@ function getHouseData(houseId) {
// =========================================================================== // ===========================================================================
function setAllHouseDataIndexes() { function setAllHouseDataIndexes() {
for (let i in getServerData().houses) { for(let i in getServerData().houses) {
getServerData().houses[i].index = i; getServerData().houses[i].index = i;
} }
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: item.js // FILE: item.js
// DESC: Provides item action and hotbar functions // DESC: Provides item action and hotbar functions
@@ -11,7 +10,7 @@
let itemActionDelayDuration = 0; let itemActionDelayDuration = 0;
let itemActionDelayStart = 0; let itemActionDelayStart = 0;
let itemActionDelayEnabled = false; let itemActionDelayEnabled = false;
let itemActionDelayPosition = toVector2(game.width / 2 - 100, game.height - 10); let itemActionDelayPosition = toVector2(game.width/2-100, game.height-10);
let itemActionDelaySize = toVector2(200, 5); let itemActionDelaySize = toVector2(200, 5);
// =========================================================================== // ===========================================================================
@@ -24,22 +23,22 @@ function initItemScript() {
// =========================================================================== // ===========================================================================
function processItemActionRendering() { function processItemActionRendering() {
if (renderItemActionDelay) { if(renderItemActionDelay) {
if (itemActionDelayEnabled) { if(itemActionDelayEnabled) {
let finishTime = itemActionDelayStart + itemActionDelayDuration; let finishTime = itemActionDelayStart+itemActionDelayDuration;
if (sdl.ticks >= finishTime) { if(sdl.ticks >= finishTime) {
itemActionDelayEnabled = false; itemActionDelayEnabled = false;
itemActionDelayDuration = 0; itemActionDelayDuration = 0;
itemActionDelayStart = 0; itemActionDelayStart = 0;
tellServerItemActionDelayComplete(); tellServerItemActionDelayComplete();
} else { } else {
let currentTick = sdl.ticks - itemActionDelayStart; let currentTick = sdl.ticks-itemActionDelayStart;
let progressPercent = Math.ceil(currentTick * 100 / itemActionDelayDuration); let progressPercent = Math.ceil(currentTick*100/itemActionDelayDuration);
let width = Math.ceil(getPercentage(itemActionDelaySize.x, progressPercent)); let width = Math.ceil(getPercentage(itemActionDelaySize.x, progressPercent));
let backgroundColour = toColour(0, 0, 0, 255); let backgroundColour = toColour(0, 0, 0, 255);
graphics.drawRectangle(null, [itemActionDelayPosition.x - (itemActionDelaySize.x / 2) - 1, itemActionDelayPosition.y - (itemActionDelaySize.y / 2) - 1], [itemActionDelaySize.x + 2, itemActionDelaySize.y + 2], backgroundColour, backgroundColour, backgroundColour, backgroundColour); graphics.drawRectangle(null, [itemActionDelayPosition.x-(itemActionDelaySize.x/2)-1, itemActionDelayPosition.y-(itemActionDelaySize.y/2)-1], [itemActionDelaySize.x+2, itemActionDelaySize.y+2], backgroundColour, backgroundColour, backgroundColour, backgroundColour);
graphics.drawRectangle(null, [itemActionDelayPosition.x - (itemActionDelaySize.x / 2), itemActionDelayPosition.y - (itemActionDelaySize.y / 2) - 2], [width, itemActionDelaySize.y], COLOUR_LIME, COLOUR_LIME, COLOUR_LIME, COLOUR_LIME); graphics.drawRectangle(null, [itemActionDelayPosition.x-(itemActionDelaySize.x/2), itemActionDelayPosition.y-(itemActionDelaySize.y/2)-2], [width, itemActionDelaySize.y], COLOUR_LIME, COLOUR_LIME, COLOUR_LIME, COLOUR_LIME);
} }
} }
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: job.js // FILE: job.js
// DESC: Provides job functions and usage // DESC: Provides job functions and usage
@@ -57,10 +56,9 @@ function setLocalPlayerWorkingState(tempWorking) {
// =========================================================================== // ===========================================================================
function showJobRouteLocation(position, colour) { function showJobRouteLocation(position, colour) {
logToConsole(LOG_DEBUG, `[VRR.Job] Showing job route location at ${position.x}, ${position.y}, ${position.z}`); logToConsole(LOG_DEBUG, `[VRR.Job] Showing job route location`);
hideJobRouteLocation(); if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) { if(getGame() == VRR_GAME_GTA_SA) {
if (getGame() == AGRP_GAME_GTA_SA) {
// Server-side spheres don't show in GTA SA for some reason. // Server-side spheres don't show in GTA SA for some reason.
jobRouteLocationSphere = game.createPickup(1318, position, 1); jobRouteLocationSphere = game.createPickup(1318, position, 1);
} else { } else {
@@ -68,7 +66,7 @@ function showJobRouteLocation(position, colour) {
jobRouteLocationSphere.colour = colour; jobRouteLocationSphere.colour = colour;
} }
if (jobRouteLocationBlip != null) { if(jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip); destroyElement(jobRouteLocationBlip);
} }
@@ -82,7 +80,21 @@ function showJobRouteLocation(position, colour) {
function enteredJobRouteSphere() { function enteredJobRouteSphere() {
logToConsole(LOG_DEBUG, `[VRR.Job] Entered job route sphere`); logToConsole(LOG_DEBUG, `[VRR.Job] Entered job route sphere`);
hideJobRouteLocation();
clearInterval(jobBlipBlinkTimer);
jobBlipBlinkAmount = 0;
jobBlipBlinkTimes = 0;
if(jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip);
jobRouteLocationBlip = null;
}
if(jobRouteLocationSphere != null) {
destroyElement(jobRouteLocationSphere);
jobRouteLocationSphere = null;
}
tellServerPlayerArrivedAtJobRouteLocation(); tellServerPlayerArrivedAtJobRouteLocation();
} }
@@ -90,23 +102,23 @@ function enteredJobRouteSphere() {
function blinkJobRouteLocationBlip(times, position, colour) { function blinkJobRouteLocationBlip(times, position, colour) {
jobBlipBlinkTimes = times; jobBlipBlinkTimes = times;
jobBlipBlinkTimer = setInterval(function () { jobBlipBlinkTimer = setInterval(function() {
if (jobRouteLocationBlip != null) { if(jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip); destroyElement(jobRouteLocationBlip);
jobRouteLocationBlip = null; jobRouteLocationBlip = null;
} else { } else {
jobRouteLocationBlip = game.createBlip(position, 0, 3, colour); jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
} }
if (jobBlipBlinkAmount >= jobBlipBlinkTimes) { if(jobBlipBlinkAmount >= jobBlipBlinkTimes) {
if (jobRouteLocationBlip != null) { if(jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip); destroyElement(jobRouteLocationBlip);
jobRouteLocationBlip = null; jobRouteLocationBlip = null;
} }
jobBlipBlinkAmount = 0; jobBlipBlinkAmount = 0;
jobBlipBlinkTimes = 0; jobBlipBlinkTimes = 0;
jobRouteLocationBlip = game.createBlip(position, 0, 3, colour); jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
clearInterval(jobBlipBlinkTimer); clearInterval(jobBlipBlinkTimer);
} }
}, jobBlipBlinkInterval); }, jobBlipBlinkInterval);
@@ -115,24 +127,10 @@ function blinkJobRouteLocationBlip(times, position, colour) {
// =========================================================================== // ===========================================================================
function hideJobRouteLocation() { function hideJobRouteLocation() {
logToConsole(LOG_DEBUG, `[VRR.Job] Hiding job route location`); destroyElement(jobRouteLocationSphere);
destroyElement(jobRouteLocationBlip);
if (jobRouteLocationBlip != null) { jobRouteLocationSphere = null;
destroyElement(jobRouteLocationBlip); jobRouteLocationBlip = null;
jobRouteLocationBlip = null;
}
if (jobRouteLocationSphere != null) {
destroyElement(jobRouteLocationSphere);
jobRouteLocationSphere = null;
}
if (jobBlipBlinkTimer != null) {
clearInterval(jobBlipBlinkTimer);
}
jobBlipBlinkAmount = 0;
jobBlipBlinkTimes = 0;
} }
// =========================================================================== // ===========================================================================
@@ -140,8 +138,8 @@ function hideJobRouteLocation() {
function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, pickupModel) { function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, pickupModel) {
logToConsole(LOG_DEBUG, `[VRR.Job] Received job ${jobId} (${name}) from server`); logToConsole(LOG_DEBUG, `[VRR.Job] Received job ${jobId} (${name}) from server`);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (getJobData(jobId) != false) { if(getJobData(jobId) != false) {
let jobData = getJobData(jobId); let jobData = getJobData(jobId);
jobData.jobLocationId = jobLocationId; jobData.jobLocationId = jobLocationId;
jobData.name = name; jobData.name = name;
@@ -150,10 +148,10 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
jobData.pickupModel = pickupModel; jobData.pickupModel = pickupModel;
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} already exists. Checking blip ...`); logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} already exists. Checking blip ...`);
if (blipModel == -1) { if(blipModel == -1) {
if (jobData.blipId != -1) { if(jobData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been removed by the server`); logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been removed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getJobData(jobId).blipId); natives.removeBlipAndClearIndex(getJobData(jobId).blipId);
} else { } else {
destroyElement(getElementFromId(blipId)); destroyElement(getElementFromId(blipId));
@@ -163,18 +161,18 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip is unchanged`); logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip is unchanged`);
} }
} else { } else {
if (jobData.blipId != -1) { if(jobData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been changed by the server`); logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been changed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
natives.setBlipCoordinates(jobData.blipId, jobData.position); natives.setBlipCoordinates(jobData.blipId, jobData.position);
natives.changeBlipSprite(jobData.blipId, jobData.blipModel); natives.changeBlipSprite(jobData.blipId, jobData.blipModel);
natives.setBlipMarkerLongDistance(jobData.blipId, false); natives.setBlipMarkerLongDistance(jobData.blipId, false);
natives.setBlipAsShortRange(jobData.blipId, true); natives.setBlipAsShortRange(jobData.blipId, true);
natives.changeBlipNameFromAscii(jobData.blipId, `${jobData.name.substr(0, 24)}${(jobData.name.length > 24) ? " ..." : ""}`); natives.changeBlipNameFromAscii(jobData.blipId, `${jobData.name.substr(0, 24)}${(jobData.name.length > 24) ? " ...": ""}`);
} }
} else { } else {
let blipId = createGameBlip(jobData.blipModel, jobData.position, jobData.name); let blipId = createGameBlip(jobData.blipModel, jobData.position, jobData.name);
if (blipId != -1) { if(blipId != -1) {
jobData.blipId = blipId; jobData.blipId = blipId;
} }
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`); logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
@@ -183,9 +181,9 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
} else { } else {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} doesn't exist. Adding ...`); logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} doesn't exist. Adding ...`);
let tempJobData = new JobData(jobId, jobLocationId, name, position, blipModel, pickupModel); let tempJobData = new JobData(jobId, jobLocationId, name, position, blipModel, pickupModel);
if (blipModel != -1) { if(blipModel != -1) {
let blipId = createGameBlip(blipModel, tempJobData.position, tempJobData.name); let blipId = createGameBlip(blipModel, tempJobData.position, tempJobData.name);
if (blipId != -1) { if(blipId != -1) {
tempJobData.blipId = blipId; tempJobData.blipId = blipId;
} }
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`); logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
@@ -204,9 +202,9 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
* @param {number} job - The ID of the job (initially provided by server) * @param {number} job - The ID of the job (initially provided by server)
* @return {JobData} The job's data (class instance) * @return {JobData} The job's data (class instance)
*/ */
function getJobData(jobId) { function getJobData(jobId) {
for (let i in getServerData().jobs) { for(let i in getServerData().jobs) {
if (getServerData().jobs[i].jobId == jobId) { if(getServerData().jobs[i].jobId == jobId) {
return getServerData().jobs[i]; return getServerData().jobs[i];
} }
} }
@@ -217,7 +215,7 @@ function getJobData(jobId) {
// =========================================================================== // ===========================================================================
function setAllJobDataIndexes() { function setAllJobDataIndexes() {
for (let i in getServerData().jobs) { for(let i in getServerData().jobs) {
jobs[i].index = i; jobs[i].index = i;
} }
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: keybind.js // FILE: keybind.js
// DESC: Provides keybind features // DESC: Provides keybind features
@@ -26,13 +25,13 @@ function initKeyBindScript() {
function bindAccountKey(key, keyState) { function bindAccountKey(key, keyState) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Binded key ${toUpperCase(getKeyNameFromId(key))} (${key})`); logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Binded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
keyBinds.push(toInteger(key)); keyBinds.push(toInteger(key));
bindKey(toInteger(key), keyState, function (event) { bindKey(toInteger(key), keyState, function(event) {
if (isAnyGUIActive()) { if(isAnyGUIActive()) {
return false; return false;
} }
if (hasKeyBindDelayElapsed()) { if(hasKeyBindDelayElapsed()) {
if (canLocalPlayerUseKeyBinds()) { if(canLocalPlayerUseKeyBinds()) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Using keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key})`); logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Using keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
lastKeyBindUse = sdl.ticks; lastKeyBindUse = sdl.ticks;
tellServerPlayerUsedKeyBind(key); tellServerPlayerUsedKeyBind(key);
@@ -57,7 +56,7 @@ function unBindAccountKey(key) {
// =========================================================================== // ===========================================================================
function hasKeyBindDelayElapsed() { function hasKeyBindDelayElapsed() {
if (sdl.ticks - lastKeyBindUse >= keyBindDelayTime) { if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) {
return true; return true;
} }
@@ -67,15 +66,15 @@ function hasKeyBindDelayElapsed() {
// =========================================================================== // ===========================================================================
function canLocalPlayerUseKeyBinds() { function canLocalPlayerUseKeyBinds() {
if (isAnyGUIActive()) { if(isAnyGUIActive()) {
return false; return false;
} }
if (!isSpawned) { if(!isSpawned) {
return false; return false;
} }
if (itemActionDelayEnabled) { if(itemActionDelayEnabled) {
return false; return false;
} }
@@ -85,7 +84,7 @@ function canLocalPlayerUseKeyBinds() {
// =========================================================================== // ===========================================================================
function clearKeyBinds() { function clearKeyBinds() {
for (let i in keyBinds) { for(let i in keyBinds) {
unbindKey(keyBinds[i]); unbindKey(keyBinds[i]);
} }
keyBinds = []; keyBinds = [];

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: labels.js // FILE: labels.js
// DESC: Provides functionality for world labels (3D labels) // DESC: Provides functionality for world labels (3D labels)
@@ -67,25 +66,25 @@ function initLabelJobHelpFont() {
// =========================================================================== // ===========================================================================
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType) { function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType) {
if (localPlayer == null) { if(localPlayer == null) {
return false; return false;
} }
if (propertyLabelNameFont == null) { if(propertyLabelNameFont == null) {
return false; return false;
} }
if (propertyLabelLockedFont == null) { if(propertyLabelLockedFont == null) {
return false; return false;
} }
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) { if(!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false; return false;
} }
if (!natives.isViewportActive(natives.getGameViewportId())) { if(!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false; return false;
} }
@@ -94,45 +93,45 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0); let screenPosition = new Vec3(0.0, 0.0, 0.0);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId()); screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else { } else {
screenPosition = getScreenFromWorldPosition(tempPosition); screenPosition = getScreenFromWorldPosition(tempPosition);
} }
if (screenPosition.x < 0 || screenPosition.x > game.width) { if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false; return false;
} }
let text = ""; let text = "";
if (price > "0") { if(price > "0") {
text = getLocaleString("PropertyForSaleLabel", price); text = getLocaleString("PropertyForSaleLabel", price);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true); propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset; screenPosition.y -= propertyLabelPriceOffset;
} }
text = ""; text = "";
if (rentPrice != "0") { if(rentPrice != "0") {
text = getLocaleString("PropertyForRentLabel", rentPrice); text = getLocaleString("PropertyForRentLabel", rentPrice);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true); propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset; screenPosition.y -= propertyLabelPriceOffset;
} }
if (isBusiness) { if(isBusiness) {
text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open")); text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open"));
} else { } else {
text = (locked) ? toUpperCase(getLocaleString("Locked")) : toUpperCase(getLocaleString("Unlocked")); text = (locked) ? toUpperCase(getLocaleString("Locked")) : toUpperCase(getLocaleString("Unlocked"));
} }
if (!locked && labelInfoType != AGRP_PROPLABEL_INFO_NONE) { if(!locked && labelInfoType != VRR_PROPLABEL_INFO_NONE) {
let infoText = ""; let infoText = "";
switch (labelInfoType) { switch(labelInfoType) {
case AGRP_PROPLABEL_INFO_ENTER: { case VRR_PROPLABEL_INFO_ENTER: {
if (enterPropertyKey) { if(enterPropertyKey) {
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey))); infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
} else { } else {
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter"); infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
@@ -140,33 +139,33 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
break; break;
} }
case AGRP_PROPLABEL_INFO_BUY: { case VRR_PROPLABEL_INFO_BUY: {
infoText = getLocaleString("BusinessBuyItemsLabel", "/buy"); infoText = getLocaleString("BusinessBuyItemsLabel", "/buy");
break; break;
} }
case AGRP_PROPLABEL_INFO_BUYBIZ: { case VRR_PROPLABEL_INFO_BUYBIZ: {
infoText = getLocaleString("BuyBusinessLabel", "/bizbuy"); infoText = getLocaleString("BuyBusinessLabel", "/bizbuy");
break; break;
} }
case AGRP_PROPLABEL_INFO_BUYHOUSE: { case VRR_PROPLABEL_INFO_BUYHOUSE: {
infoText = getLocaleString("BuyHouseLabel", "/housebuy"); infoText = getLocaleString("BuyHouseLabel", "/housebuy");
break; break;
} }
case AGRP_PROPLABEL_INFO_RENTHOUSE: { case VRR_PROPLABEL_INFO_RENTHOUSE: {
infoText = getLocaleString("RentHouseLabel", "/houserent"); infoText = getLocaleString("RentHouseLabel", "/houserent");
break; break;
} }
case AGRP_PROPLABEL_INFO_ENTERVEHICLE: { case VRR_PROPLABEL_INFO_ENTERVEHICLE: {
infoText = getLocaleString("VehicleDealershipLabel"); infoText = getLocaleString("VehicleDealershipLabel");
break; break;
} }
default: { default: {
if (enterPropertyKey) { if(enterPropertyKey) {
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey))); infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
} else { } else {
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter"); infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
@@ -174,49 +173,45 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
break; break;
} }
} }
if (getDistance(localPlayer.position, position) <= renderLabelDistance - 2) { if(getDistance(localPlayer.position, position) <= renderLabelDistance-2) {
let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(infoText, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true); propertyLabelLockedFont.render(infoText, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true);
screenPosition.y -= propertyLabelLockedOffset; screenPosition.y -= propertyLabelLockedOffset;
} }
} }
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true); propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true);
screenPosition.y -= propertyLabelNameOffset; screenPosition.y -= propertyLabelNameOffset;
text = name || " "; text = name || " ";
if (profanityFilterEnabled) {
text = replaceProfanityInMessage(text);
}
size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true); size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
propertyLabelNameFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true); propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function renderPropertyExitLabel(position) { function renderPropertyExitLabel(position) {
if (localPlayer == null) { if(localPlayer == null) {
return false; return false;
} }
if (propertyLabelNameFont == null) { if(propertyLabelNameFont == null) {
return false; return false;
} }
if (propertyLabelLockedFont == null) { if(propertyLabelLockedFont == null) {
return false; return false;
} }
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) { if(!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false; return false;
} }
if (!natives.isViewportActive(natives.getGameViewportId())) { if(!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false; return false;
} }
@@ -225,43 +220,43 @@ function renderPropertyExitLabel(position) {
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0); let screenPosition = new Vec3(0.0, 0.0, 0.0);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId()); screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else { } else {
screenPosition = getScreenFromWorldPosition(tempPosition); screenPosition = getScreenFromWorldPosition(tempPosition);
} }
if (screenPosition.x < 0 || screenPosition.x > game.width) { if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false; return false;
} }
let text = "EXIT"; let text = "EXIT";
let size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true); let size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
propertyLabelNameFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true); propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function renderJobLabel(name, position, jobType) { function renderJobLabel(name, position, jobType) {
if (localPlayer == null) { if(localPlayer == null) {
return false; return false;
} }
if (jobNameLabelFont == null) { if(jobNameLabelFont == null) {
return false; return false;
} }
if (jobHelpLabelFont == null) { if(jobHelpLabelFont == null) {
return false; return false;
} }
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) { if(!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false; return false;
} }
if (!natives.isViewportActive(natives.getGameViewportId())) { if(!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false; return false;
} }
@@ -270,25 +265,25 @@ function renderJobLabel(name, position, jobType) {
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0); let screenPosition = new Vec3(0.0, 0.0, 0.0);
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId()); screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else { } else {
screenPosition = getScreenFromWorldPosition(tempPosition); screenPosition = getScreenFromWorldPosition(tempPosition);
} }
if (screenPosition.x < 0 || screenPosition.x > game.width) { if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false; return false;
} }
let text = ""; let text = "";
if (jobType == localPlayerJobType) { if(jobType == localPlayerJobType) {
if (localPlayerWorking) { if(localPlayerWorking) {
text = getLocaleString("JobEquipAndUniformLabel", "/equip", "/uniform", "/stopwork"); text = getLocaleString("JobEquipAndUniformLabel", "/equip", "/uniform", "/stopwork");
} else { } else {
text = getLocaleString("StartWorkLabel", "/startwork"); text = getLocaleString("StartWorkLabel", "/startwork");
} }
} else { } else {
if (localPlayerJobType == 0) { if(localPlayerJobType == 0) {
text = getLocaleString("TakeJobLabel", "/takejob"); text = getLocaleString("TakeJobLabel", "/takejob");
} else { } else {
text = getLocaleString("NotYourJobLabel", "/quitjob"); text = getLocaleString("NotYourJobLabel", "/quitjob");
@@ -296,37 +291,37 @@ function renderJobLabel(name, position, jobType) {
} }
let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true); let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true);
jobHelpLabelFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true); jobHelpLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true);
screenPosition.y -= 18; screenPosition.y -= 18;
text = getLocaleString("JobLabel", name); text = getLocaleString("JobLabel", name);
size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true); size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true);
jobNameLabelFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true); jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function processLabelRendering() { function processLabelRendering() {
if (renderLabels) { if(renderLabels) {
if (!areServerElementsSupported()) { if(!areServerElementsSupported()) {
if (localPlayer != null) { if(localPlayer != null) {
getServerData().businesses.forEach((business) => { getServerData().businesses.forEach((business) => {
if (getDistance(localPlayer.position, business.entrancePosition) <= 75.0) { if(getDistance(localPlayer.position, business.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255); natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255);
//renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, makeLargeNumberReadable(business.price), makeLargeNumberReadable(business.rentPrice), business.labelInfoType); //renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, makeLargeNumberReadable(business.price), makeLargeNumberReadable(business.rentPrice), business.labelInfoType);
} }
}); });
getServerData().houses.forEach((house) => { getServerData().houses.forEach((house) => {
if (getDistance(localPlayer.position, house.entrancePosition) <= 75.0) { if(getDistance(localPlayer.position, house.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255); natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255);
//renderPropertyEntranceLabel("House", house.entrancePosition, house.locked, true, makeLargeNumberReadable(house.price), makeLargeNumberReadable(house.rentPrice), 0); //renderPropertyEntranceLabel("House", house.entrancePosition, house.locked, true, makeLargeNumberReadable(house.price), makeLargeNumberReadable(house.rentPrice), 0);
} }
}); });
getServerData().jobs.forEach((job) => { getServerData().jobs.forEach((job) => {
if (getDistance(localPlayer.position, job.position) <= 75.0) { if(getDistance(localPlayer.position, job.position) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255); natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255);
//renderJobLabel(job.name, job.position, job.jobType); //renderJobLabel(job.name, job.position, job.jobType);
} }
@@ -334,45 +329,45 @@ function processLabelRendering() {
} }
} }
if (areWorldLabelsSupported()) { if(areWorldLabelsSupported()) {
if (localPlayer != null) { if(localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP); let pickups = getElementsByType(ELEMENT_PICKUP);
for (let i in pickups) { for(let i in pickups) {
if (pickups[i].getData("agrp.label.type") != null) { if(pickups[i].getData("vrr.label.type") != null) {
if (getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) { if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
if (!pickups[i].isOnScreen) { if(!pickups[i].isOnScreen) {
let price = "0"; let price = "0";
let rentPrice = "0"; let rentPrice = "0";
let labelInfoType = AGRP_PROPLABEL_INFO_NONE; let labelInfoType = VRR_PROPLABEL_INFO_NONE;
if (pickups[i].getData("agrp.label.price") != null) { if(pickups[i].getData("vrr.label.price") != null) {
price = makeLargeNumberReadable(pickups[i].getData("agrp.label.price")); price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price"));
} }
if (pickups[i].getData("agrp.label.rentprice") != null) { if(pickups[i].getData("vrr.label.rentprice") != null) {
rentPrice = makeLargeNumberReadable(pickups[i].getData("agrp.label.rentprice")); rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice"));
} }
if (pickups[i].getData("agrp.label.help") != null) { if(pickups[i].getData("vrr.label.help") != null) {
labelInfoType = pickups[i].getData("agrp.label.help"); labelInfoType = pickups[i].getData("vrr.label.help");
} }
switch (pickups[i].getData("agrp.label.type")) { switch(pickups[i].getData("vrr.label.type")) {
case AGRP_LABEL_BUSINESS: { case VRR_LABEL_BUSINESS: {
renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), true, price, rentPrice, labelInfoType); renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType);
break; break;
} }
case AGRP_LABEL_HOUSE: { case VRR_LABEL_HOUSE: {
renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), false, price, rentPrice, labelInfoType); renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), false, price, rentPrice, labelInfoType);
break; break;
} }
case AGRP_LABEL_JOB: { case VRR_LABEL_JOB: {
renderJobLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.jobType")); renderJobLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.jobType"));
break; break;
} }
case AGRP_LABEL_EXIT: { case VRR_LABEL_EXIT: {
renderPropertyExitLabel(pickups[i].position); renderPropertyExitLabel(pickups[i].position);
break; break;
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: locale.js // FILE: locale.js
// DESC: Provides locale functions and usage // DESC: Provides locale functions and usage
@@ -9,18 +8,18 @@
// =========================================================================== // ===========================================================================
function getLocaleString(stringName, ...args) { function getLocaleString(stringName, ...args) {
if (typeof getServerData().localeStrings[localLocaleId][stringName] == undefined) { if(typeof getServerData().localeStrings[localLocaleId][stringName] == undefined) {
return ""; return "";
} }
let tempString = getServerData().localeStrings[localLocaleId][stringName]; let tempString = getServerData().localeStrings[localLocaleId][stringName];
if (tempString == "" || tempString == null || tempString == undefined) { if(tempString == "" || tempString == null || tempString == undefined) {
return ""; return "";
} }
for (let i = 1; i <= args.length; i++) { for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i - 1]); tempString = tempString.replace(`{${i}}`, args[i-1]);
} }
return tempString; return tempString;
@@ -37,24 +36,19 @@ function getAvailableLocaleOptions() {
function loadLocaleConfig() { function loadLocaleConfig() {
let configFile = loadTextFile("config/client/locale.json"); let configFile = loadTextFile("config/client/locale.json");
getServerData().localeOptions = JSON.parse(configFile); getServerData().localeOptions = JSON.parse(configFile);
resetLocaleChooserOptions();
loadAllLocaleStrings();
} }
// =========================================================================== // ===========================================================================
function loadAllLocaleStrings() { function loadAllLocaleStrings() {
let localeOptions = getServerData().localeOptions; let localeOptions = getServerData().localeOptions;
for (let i in localeOptions) { for(let i in localeOptions) {
logToConsole(LOG_INFO, `[VRR.Locale] Loading locale strings for ${localeOptions[i].englishName} (${i})`); logToConsole(LOG_INFO, `[VRR.Locale] Loading locale strings for ${localeOptions[i].englishName} (${i})`);
let localeFile = loadTextFile(`locale/${localeOptions[i].stringsFile}`); let localeFile = loadTextFile(`locale/${localeOptions[i].stringsFile}`);
let localeData = JSON.parse(localeFile); let localeData = JSON.parse(localeFile);
getServerData().localeStrings[i] = localeData; getServerData().localeStrings[i] = localeData;
} }
resetGUIStrings();
} }
// =========================================================================== // ===========================================================================
@@ -64,3 +58,5 @@ function setLocale(tempLocaleId) {
localLocaleId = tempLocaleId; localLocaleId = tempLocaleId;
resetGUIStrings(); resetGUIStrings();
} }
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: logo.js // FILE: logo.js
// DESC: Provides logo rendering functions // DESC: Provides logo rendering functions
@@ -9,7 +8,7 @@
// =========================================================================== // ===========================================================================
let logoImage = null; let logoImage = null;
let logoPos = toVector2(game.width - 132, game.height - 132); let logoPos = toVector2(game.width-132, game.height-132);
let logoSize = toVector2(128, 128); let logoSize = toVector2(128, 128);
// =========================================================================== // ===========================================================================
@@ -25,7 +24,7 @@ function initLogoScript() {
function loadLogoImage() { function loadLogoImage() {
let logoStream = openFile(mainLogoPath); let logoStream = openFile(mainLogoPath);
let tempLogoImage = null; let tempLogoImage = null;
if (logoStream != null) { if(logoStream != null) {
tempLogoImage = graphics.loadPNG(logoStream); tempLogoImage = graphics.loadPNG(logoStream);
logoStream.close(); logoStream.close();
} }
@@ -36,8 +35,8 @@ function loadLogoImage() {
// =========================================================================== // ===========================================================================
function processLogoRendering() { function processLogoRendering() {
if (renderLogo) { if(renderLogo) {
if (logoImage != null) { if(logoImage != null) {
graphics.drawRectangle(logoImage, logoPos, logoSize); graphics.drawRectangle(logoImage, logoPos, logoSize);
} }
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: main.js // FILE: main.js
// DESC: Main client script (will be reorganized into individual files later) // DESC: Main client script (will be reorganized into individual files later)
@@ -31,7 +30,7 @@ let renderHotBar = true;
let renderItemActionDelay = true; let renderItemActionDelay = true;
let renderInteriorLights = true; let renderInteriorLights = true;
let logLevel = LOG_DEBUG; let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE;
let weaponDamageEnabled = {}; let weaponDamageEnabled = {};
let weaponDamageEvent = {}; let weaponDamageEvent = {};
@@ -64,7 +63,7 @@ let mouseCameraEnabled = false;
let currentPickup = false; let currentPickup = false;
let vehiclePurchaseState = AGRP_VEHBUYSTATE_NONE; let vehiclePurchaseState = VRR_VEHBUYSTATE_NONE;
let vehiclePurchasing = null; let vehiclePurchasing = null;
let vehiclePurchasePosition = null; let vehiclePurchasePosition = null;
@@ -79,8 +78,6 @@ let guiDownKey = false;
// Pre-cache all allowed skins // Pre-cache all allowed skins
let allowedSkins = getAllowedSkins(getGame()); let allowedSkins = getAllowedSkins(getGame());
let profanityFilterEnabled = false;
let localLocaleId = 0; let localLocaleId = 0;
let serverData = { let serverData = {

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: messaging.js // FILE: messaging.js
// DESC: Provides messaging/textdraw functions and usage // DESC: Provides messaging/textdraw functions and usage
@@ -34,7 +33,7 @@ function initMessagingScript() {
function loadSmallGameMessageFonts() { function loadSmallGameMessageFonts() {
let tempSmallGameMessageFonts = {}; let tempSmallGameMessageFonts = {};
let fontStream = openFile("files/fonts/pricedown.ttf"); let fontStream = openFile("files/fonts/pricedown.ttf");
if (fontStream != null) { if(fontStream != null) {
tempSmallGameMessageFonts["Pricedown"] = lucasFont.createFont(fontStream, 20.0); tempSmallGameMessageFonts["Pricedown"] = lucasFont.createFont(fontStream, 20.0);
fontStream.close(); fontStream.close();
} }
@@ -50,7 +49,7 @@ function loadSmallGameMessageFonts() {
function loadBigGameMessageFont() { function loadBigGameMessageFont() {
let tempBigGameMessageFonts = {}; let tempBigGameMessageFonts = {};
let fontStream = openFile("files/fonts/pricedown.ttf"); let fontStream = openFile("files/fonts/pricedown.ttf");
if (fontStream != null) { if(fontStream != null) {
tempBigGameMessageFonts["Pricedown"] = lucasFont.createFont(fontStream, 28.0); tempBigGameMessageFonts["Pricedown"] = lucasFont.createFont(fontStream, 28.0);
fontStream.close(); fontStream.close();
} }
@@ -64,12 +63,10 @@ function loadBigGameMessageFont() {
// =========================================================================== // ===========================================================================
function processSmallGameMessageRendering() { function processSmallGameMessageRendering() {
logToConsole(LOG_VERBOSE, "[VRR.Messaging]: Processing small game message rendering ..."); if(renderSmallGameMessage) {
if (renderSmallGameMessage) { if(smallGameMessageText != "") {
if (smallGameMessageText != "") { if(smallGameMessageFonts[smallGameMessageFontName] != null) {
logToConsole(LOG_VERBOSE, `[VRR.Messaging]: Rendering small game message: ${smallGameMessageText}`); smallGameMessageFonts[smallGameMessageFontName].render(smallGameMessageText, [0, game.height-90], game.width, 0.5, 0.0, smallGameMessageFonts[smallGameMessageFontName].size, smallGameMessageColour, true, true, false, true);
if (smallGameMessageFonts[smallGameMessageFontName] != null) {
smallGameMessageFonts[smallGameMessageFontName].render(smallGameMessageText, [0, game.height - 90], game.width, 0.5, 0.0, smallGameMessageFonts[smallGameMessageFontName].size, smallGameMessageColour, true, true, false, true);
} }
} }
} }
@@ -79,7 +76,7 @@ function processSmallGameMessageRendering() {
function showSmallGameMessage(text, colour, duration, fontName) { function showSmallGameMessage(text, colour, duration, fontName) {
logToConsole(LOG_DEBUG, `[VRR.Messaging] Showing small game message '${text}' using font ${fontName} for ${duration}ms`); logToConsole(LOG_DEBUG, `[VRR.Messaging] Showing small game message '${text}' using font ${fontName} for ${duration}ms`);
if (smallGameMessageText != "") { if(smallGameMessageText != "") {
clearTimeout(smallGameMessageTimer); clearTimeout(smallGameMessageTimer);
} }
@@ -87,7 +84,7 @@ function showSmallGameMessage(text, colour, duration, fontName) {
smallGameMessageColour = colour; smallGameMessageColour = colour;
smallGameMessageText = text; smallGameMessageText = text;
smallGameMessageTimer = setTimeout(function () { smallGameMessageTimer = setTimeout(function() {
smallGameMessageText = ""; smallGameMessageText = "";
smallGameMessageColour = COLOUR_WHITE; smallGameMessageColour = COLOUR_WHITE;
smallGameMessageTimer = null; smallGameMessageTimer = null;

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: nametags.js // FILE: nametags.js
// DESC: Provides nametag rendering // DESC: Provides nametag rendering
@@ -44,19 +43,15 @@ function loadPausedStatusFont() {
// =========================================================================== // ===========================================================================
function updatePlayerNameTag(clientName, characterName, colour, paused, ping) { function updatePlayerNameTag(clientName, characterName, colour, paused, ping) {
if (profanityFilterEnabled) {
characterName = replaceProfanityInMessage(characterName);
}
playerNames[clientName] = characterName; playerNames[clientName] = characterName;
playerColours[clientName] = colour; playerColours[clientName] = colour;
playerPaused[clientName] = paused; playerPaused[clientName] = paused;
playerPing[clientName] = ping; playerPing[clientName] = ping;
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
let client = getPlayerFromParams(clientName); let client = getPlayerFromParams(clientName);
if (client != false) { if(client != false) {
if (getPlayerPed(client) != null) { if(getPlayerPed(client) != null) {
getPlayerPed(client).setNametag(characterName, colour); getPlayerPed(client).setNametag(characterName, colour);
} }
} }
@@ -72,7 +67,7 @@ function updatePlayerPing(clientName, ping) {
// =========================================================================== // ===========================================================================
function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk, skin) { function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk, skin) {
if (nametagFont == null) { if(nametagFont == null) {
return false; return false;
} }
@@ -85,10 +80,10 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
// ------------------------------------------- // -------------------------------------------
// Health Bar // Health Bar
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) { if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
if (getGame() == AGRP_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
// Mickey Hamfists is ridiculously tall. Raise the nametag for him a bit // Mickey Hamfists is ridiculously tall. Raise the nametag for him a bit
if (skin == 109) { if(skin == 109) {
y -= 20; y -= 20;
} else { } else {
y -= 5; y -= 5;
@@ -100,43 +95,44 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
y -= 5; y -= 5;
} }
if (health > 0.0) { if(health > 0.0) {
let hx = x - width / 2; let hx = x-width/2;
let hy = y - 10 / 2; let hy = y-10/2;
let colourB = toColour(0, 0, 0, Math.floor(255.0 * alpha)); // Background colour (black) let colourB = toColour(0, 0, 0, Math.floor(255.0*alpha)); // Background colour (black)
graphics.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB); graphics.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB);
let colour = toColour(Math.floor(255.0 - (health * 255.0)), Math.floor(health * 255.0), 0, Math.floor(255.0 * alpha)); // Health bar colour (varies, depending on health) let colour = toColour(Math.floor(255.0-(health*255.0)), Math.floor(health*255.0), 0, Math.floor(255.0*alpha)); // Health bar colour (varies, depending on health)
graphics.drawRectangle(null, [hx + 2, hy + 2], [(width - 4) * health, 10 - 6], colour, colour, colour, colour); graphics.drawRectangle(null, [hx+2, hy+2], [(width-4)*health, 10-6], colour, colour, colour, colour);
} }
// Armour Bar // Armour Bar
if (armour > 0.0) { if (armour > 0.0)
{
// Go up 10 pixels to draw the next part // Go up 10 pixels to draw the next part
y -= 10; y -= 10;
let hx = x - width / 2; let hx = x-width/2;
let hy = y - 10 / 2; let hy = y-10/2;
let colourB = toColour(255, 0, 0, 0); // Background colour (black) let colourB = toColour(255, 0, 0, 0); // Background colour (black)
graphics.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB); graphics.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB);
let colour = toColour(255, 255, 255, 255); // Armour bar colour (white) let colour = toColour(255, 255, 255, 255); // Armour bar colour (white)
graphics.drawRectangle(null, [hx + 2, hy + 2], [(width - 4) * armour, 10 - 6], colour, colour, colour, colour); graphics.drawRectangle(null, [hx+2, hy+2], [(width-4)*armour, 10-6], colour, colour, colour, colour);
} }
y -= 20; y -= 20;
// Nametag // Nametag
if (nametagFont != null) { if(nametagFont != null) {
let size = nametagFont.measure(text, game.width, 0.0, 0.0, nametagFont.size, false, false); let size = nametagFont.measure(text, game.width, 0.0, 0.0, nametagFont.size, false, false);
nametagFont.render(text, [x - size[0] / 2, y - size[1] / 2], game.width, 0.0, 0.0, nametagFont.size, colour, false, false, false, true); nametagFont.render(text, [x-size[0]/2, y-size[1]/2], game.width, 0.0, 0.0, nametagFont.size, colour, false, false, false, true);
} }
// Go up another 10 pixels for the next part // Go up another 10 pixels for the next part
y -= 20; y -= 20;
// AFK Status // AFK Status
if (afkStatusFont != null) { if(afkStatusFont != null) {
if (afk) { if(afk) {
let size = afkStatusFont.measure(getLocaleString(client, "Paused"), game.width, 0.0, 0.0, afkStatusFont.size, false, false); let size = afkStatusFont.measure("PAUSED", game.width, 0.0, 0.0, afkStatusFont.size, false, false);
afkStatusFont.render(getLocaleString(client, "Paused"), [x - size[0] / 2, y - size[1] / 2], game.width, 0.0, 0.0, afkStatusFont.size, toColour(255, 0, 0, 255), false, false, false, true); afkStatusFont.render("PAUSED", [x-size[0]/2, y-size[1]/2], game.width, 0.0, 0.0, afkStatusFont.size, toColour(255, 0, 0, 255), false, false, false, true);
} }
} }
} }
@@ -144,11 +140,11 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
// =========================================================================== // ===========================================================================
function updateNametag(element) { function updateNametag(element) {
if (!areWorldLabelsSupported()) { if(!areWorldLabelsSupported()) {
return false; return false;
} }
if (localPlayer != null) { if(localPlayer != null) {
let playerPos = localPlayer.position; let playerPos = localPlayer.position;
let elementPos = element.position; let elementPos = element.position;
@@ -158,50 +154,50 @@ function updateNametag(element) {
let screenPos = getScreenFromWorldPosition(elementPos); let screenPos = getScreenFromWorldPosition(elementPos);
if (screenPos[2] >= 0.0) { if (screenPos[2] >= 0.0) {
let health = element.health / 100.0; let health = element.health/100.0;
if (health > 1.0) { if(health > 1.0) {
health = 1.0; health = 1.0;
} }
let armour = element.armour / 100.0; let armour = element.armour/100.0;
if (armour > 1.0) { if(armour > 1.0) {
armour = 1.0; armour = 1.0;
} }
let distance = playerPos.distance(elementPos); let distance = playerPos.distance(elementPos);
if (distance <= nametagDistance) { if(distance <= nametagDistance) {
if (typeof game.processLineOfSight != "undefined") { if(typeof game.processLineOfSight != "undefined") {
let losCheck = game.processLineOfSight(playerPos, elementPos, true, false, false, true, true, false, true, true); let losCheck = game.processLineOfSight(playerPos, elementPos, true, false, false, true, true, false, true, true);
if (losCheck != null) { if(losCheck != null) {
return false; return false;
} }
} }
if (element.type == ELEMENT_PLAYER) { if(element.type == ELEMENT_PLAYER) {
let name = element.name; let name = element.name;
let colour = COLOUR_WHITE; let colour = COLOUR_WHITE;
let paused = false; let paused = false;
let ping = -1; let ping = -1;
if (element.isType(ELEMENT_PLAYER)) { if(element.isType(ELEMENT_PLAYER)) {
if (typeof playerNames[element.name] != "undefined") { if(typeof playerNames[element.name] != "undefined") {
name = playerNames[element.name]; name = playerNames[element.name];
} }
if (typeof playerPaused[element.name] != "undefined") { if(typeof playerPaused[element.name] != "undefined") {
paused = playerPaused[element.name]; paused = playerPaused[element.name];
} }
if (typeof playerColours[element.name] != "undefined") { if(typeof playerColours[element.name] != "undefined") {
colour = playerColours[element.name]; colour = playerColours[element.name];
} }
if (typeof playerPing[element.name] != "undefined") { if(typeof playerPing[element.name] != "undefined") {
ping = playerPing[element.name]; ping = playerPing[element.name];
} }
} }
drawNametag(screenPos[0], screenPos[1], health, armour, name, ping, 1.0 - distance / nametagDistance, distance, colour, paused, element.skin); drawNametag(screenPos[0], screenPos[1], health, armour, name, ping, 1.0-distance/nametagDistance, distance, colour, paused, element.skin);
} }
} }
} }
@@ -211,8 +207,8 @@ function updateNametag(element) {
// =========================================================================== // ===========================================================================
function getClientFromPlayer(player) { function getClientFromPlayer(player) {
getClients().forEach(function (client) { getClients().forEach(function(client) {
if (getPlayerPed(client) == player) { if(getPlayerPed(client) == player) {
return client; return client;
} }
}); });
@@ -225,8 +221,8 @@ function processNameTagRendering(event) {
// return false; // return false;
//} //}
getElementsByType(ELEMENT_PED).forEach(function (ped) { getElementsByType(ELEMENT_PED).forEach(function(ped) {
if (ped != localPlayer) { if(ped != localPlayer) {
updateNametag(ped); updateNametag(ped);
} }
}); });

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: connected.js // FILE: connected.js
// DESC: Provides wrapped natives for GTA Connected and Mafia Connected mods // DESC: Provides wrapped natives for GTA Connected and Mafia Connected mods
@@ -38,7 +37,7 @@ function getPlayerPosition() {
// =========================================================================== // ===========================================================================
function setPlayerPosition(position) { function setPlayerPosition(position) {
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
natives.setCharCoordinates(localPlayer, position); natives.setCharCoordinates(localPlayer, position);
} else { } else {
localPlayer.position = position; localPlayer.position = position;
@@ -60,11 +59,11 @@ function getElementHeading(elementId) {
// =========================================================================== // ===========================================================================
function setElementPosition(elementId, position) { function setElementPosition(elementId, position) {
if (getElementFromId(elementId) == null) { if(getElementFromId(elementId) == null) {
return false; return false;
} }
if (!getElementFromId(elementId).isSyncer) { if(!getElementFromId(elementId).isSyncer) {
return false; return false;
} }
@@ -73,8 +72,8 @@ function setElementPosition(elementId, position) {
// =========================================================================== // ===========================================================================
function deleteGameElement(elementId, position = toVector3(0.0, 0.0, 0.0)) { function deleteGameElement(elementId, position) {
if (!getElementFromId(elementId).isOwner) { if(!getElementFromId(elementId).isOwner) {
return false; return false;
} }
@@ -83,25 +82,8 @@ function deleteGameElement(elementId, position = toVector3(0.0, 0.0, 0.0)) {
// =========================================================================== // ===========================================================================
function deleteLocalGameElement(element) {
destroyGameElement(element);
}
// ===========================================================================
function createGameVehicle(modelIndex, position, heading) { function createGameVehicle(modelIndex, position, heading) {
if (getGame() != AGRP_GAME_GTA_IV) { return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading);
return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading);
} else {
let modelId = getGameConfig().vehicles[getGame()][modelIndex][0];
if (natives.isModelInCdimage(modelId)) {
natives.requestModel(modelId);
natives.loadAllObjectsNow();
return natives.createCar(modelId, position, true);
}
}
return null;
} }
// =========================================================================== // ===========================================================================
@@ -128,8 +110,8 @@ function getElementId(element) {
function getClientFromIndex(index) { function getClientFromIndex(index) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (clients[i].index == index) { if(clients[i].index == index) {
return clients[i]; return clients[i];
} }
} }
@@ -188,8 +170,8 @@ function is2dPositionOnScreen(pos2d) {
function getVehiclesInRange(position, range) { function getVehiclesInRange(position, range) {
let vehicles = getElementsByType(ELEMENT_VEHICLE); let vehicles = getElementsByType(ELEMENT_VEHICLE);
let inRangeVehicles = []; let inRangeVehicles = [];
for (let i in vehicles) { for(let i in vehicles) {
if (getDistance(position, vehicles[i].position) <= range) { if(getDistance(position, vehicles[i].position) <= range) {
inRangeVehicles.push(vehicles[i]); inRangeVehicles.push(vehicles[i]);
} }
} }
@@ -199,13 +181,13 @@ function getVehiclesInRange(position, range) {
// =========================================================================== // ===========================================================================
function createGameBlip(blipModel, position, name = "") { function createGameBlip(blipModel, position, name = "") {
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
let blipId = natives.addBlipForCoord(position); let blipId = natives.addBlipForCoord(position);
if (blipId) { if(blipId) {
natives.changeBlipSprite(blipId, blipModel); natives.changeBlipSprite(blipId, blipModel);
natives.setBlipMarkerLongDistance(blipId, false); natives.setBlipMarkerLongDistance(blipId, false);
natives.setBlipAsShortRange(blipId, true); natives.setBlipAsShortRange(blipId, true);
natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ..." : ""}`); natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
return blipId; return blipId;
} }
} }
@@ -216,7 +198,7 @@ function createGameBlip(blipModel, position, name = "") {
// =========================================================================== // ===========================================================================
function setEntityData(entity, dataName, dataValue, syncToClients = true) { function setEntityData(entity, dataName, dataValue, syncToClients = true) {
if (entity != null) { if(entity != null) {
return entity.setData(dataName, dataValue); return entity.setData(dataName, dataValue);
} }
} }
@@ -242,64 +224,64 @@ function repairVehicle(syncId) {
// =========================================================================== // ===========================================================================
function syncVehicleProperties(vehicle) { function syncVehicleProperties(vehicle) {
if (doesEntityDataExist(vehicle, "agrp.lights")) { if(doesEntityDataExist(vehicle, "vrr.lights")) {
let lightStatus = getEntityData(vehicle, "agrp.lights"); let lightStatus = getEntityData(vehicle, "vrr.lights");
vehicle.lights = lightStatus; vehicle.lights = lightStatus;
} }
if (doesEntityDataExist(vehicle, "agrp.invincible")) { if(doesEntityDataExist(vehicle, "vrr.invincible")) {
let invincible = getEntityData(vehicle, "agrp.invincible"); let invincible = getEntityData(vehicle, "vrr.invincible");
element.setProofs(invincible, invincible, invincible, invincible, invincible); element.setProofs(invincible, invincible, invincible, invincible, invincible);
} }
if (doesEntityDataExist(vehicle, "agrp.panelStatus")) { if(doesEntityDataExist(vehicle, "vrr.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "agrp.panelStatus"); let panelsStatus = getEntityData(vehicle, "vrr.panelStatus");
for (let i in panelsStatus) { for(let i in panelsStatus) {
vehicle.setPanelStatus(i, panelsStatus[i]); vehicle.setPanelStatus(i, panelsStatus[i]);
} }
} }
if (doesEntityDataExist(vehicle, "agrp.wheelStatus")) { if(doesEntityDataExist(vehicle, "vrr.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "agrp.wheelStatus"); let wheelsStatus = getEntityData(vehicle, "vrr.wheelStatus");
for (let i in wheelsStatus) { for(let i in wheelsStatus) {
vehicle.setWheelStatus(i, wheelsStatus[i]); vehicle.setWheelStatus(i, wheelsStatus[i]);
} }
} }
if (doesEntityDataExist(vehicle, "agrp.lightStatus")) { if(doesEntityDataExist(vehicle, "vrr.lightStatus")) {
let lightStatus = getEntityData(vehicle, "agrp.lightStatus"); let lightStatus = getEntityData(vehicle, "vrr.lightStatus");
for (let i in lightStatus) { for(let i in lightStatus) {
vehicle.setLightStatus(i, lightStatus[i]); vehicle.setLightStatus(i, lightStatus[i]);
} }
} }
if (doesEntityDataExist(vehicle, "agrp.suspensionHeight")) { if(doesEntityDataExist(vehicle, "vrr.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "agrp.suspensionHeight"); let suspensionHeight = getEntityData(vehicle, "vrr.suspensionHeight");
vehicle.setSuspensionHeight(suspensionHeight); vehicle.setSuspensionHeight(suspensionHeight);
} }
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
let allUpgrades = getGameConfig().vehicleUpgrades[getGame()]; let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
for (let i in allUpgrades) { for(let i in allUpgrades) {
vehicle.removeUpgrade(i); vehicle.removeUpgrade(i);
} }
if (doesEntityDataExist(vehicle, "agrp.upgrades")) { if(doesEntityDataExist(vehicle, "vrr.upgrades")) {
let upgrades = getEntityData(vehicle, "agrp.upgrades"); let upgrades = getEntityData(vehicle, "vrr.upgrades");
for (let i in upgrades) { for(let i in upgrades) {
if (upgrades[i] != 0) { if(upgrades[i] != 0) {
vehicle.addUpgrade(upgrades[i]); vehicle.addUpgrade(upgrades[i]);
} }
} }
} }
} }
if (getGame() == AGRP_GAME_GTA_SA || getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(vehicle, "agrp.livery")) { if(doesEntityDataExist(vehicle, "vrr.livery")) {
let livery = getEntityData(vehicle, "agrp.livery"); let livery = getEntityData(vehicle, "vrr.livery");
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
vehicle.setPaintJob(livery); vehicle.setPaintJob(livery);
} else if (getGame() == AGRP_GAME_GTA_IV) { } else if(getGame() == VRR_GAME_GTA_IV) {
vehicle.livery = livery; vehicle.livery = livery;
} }
} }
@@ -309,7 +291,7 @@ function syncVehicleProperties(vehicle) {
// =========================================================================== // ===========================================================================
function removeEntityData(entity, dataName) { function removeEntityData(entity, dataName) {
if (entity != null) { if(entity != null) {
return entity.removeData(dataName); return entity.removeData(dataName);
} }
return null; return null;
@@ -318,7 +300,7 @@ function removeEntityData(entity, dataName) {
// =========================================================================== // ===========================================================================
function doesEntityDataExist(entity, dataName) { function doesEntityDataExist(entity, dataName) {
if (entity != null) { if(entity != null) {
return (entity.getData(dataName) != null); return (entity.getData(dataName) != null);
} }
return null; return null;
@@ -327,9 +309,9 @@ function doesEntityDataExist(entity, dataName) {
// =========================================================================== // ===========================================================================
function syncCivilianProperties(civilian) { function syncCivilianProperties(civilian) {
if (getGame() == AGRP_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "agrp.scale")) { if(doesEntityDataExist(civilian, "vrr.scale")) {
let scaleFactor = getEntityData(civilian, "agrp.scale"); let scaleFactor = getEntityData(civilian, "vrr.scale");
let tempMatrix = civilian.matrix; let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z)); tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = civilian.position; let tempPosition = civilian.position;
@@ -339,79 +321,79 @@ function syncCivilianProperties(civilian) {
} }
} }
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
if (doesEntityDataExist(civilian, "agrp.fightStyle")) { if(doesEntityDataExist(civilian, "vrr.fightStyle")) {
let fightStyle = getEntityData(civilian, "agrp.fightStyle"); let fightStyle = getEntityData(civilian, "vrr.fightStyle");
civilian.setFightStyle(fightStyle[0], fightStyle[1]); civilian.setFightStyle(fightStyle[0], fightStyle[1]);
} }
} }
if (getGame() == AGRP_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "agrp.walkStyle")) { if(doesEntityDataExist(civilian, "vrr.walkStyle")) {
let walkStyle = getEntityData(civilian, "agrp.walkStyle"); let walkStyle = getEntityData(civilian, "vrr.walkStyle");
civilian.walkStyle = walkStyle; civilian.walkStyle = walkStyle;
} }
} }
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(civilian, "agrp.bodyPropHair")) { if(doesEntityDataExist(civilian, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "agrp.bodyPropHair"); let bodyPropHair = getEntityData(civilian, "vrr.bodyPropHair");
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]); civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropHead")) { if(doesEntityDataExist(civilian, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "agrp.bodyPropHead"); let bodyPropHead = getEntityData(civilian, "vrr.bodyPropHead");
civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]); civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropEyes")) { if(doesEntityDataExist(civilian, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "agrp.bodyPropEyes"); let bodyPropEyes = getEntityData(civilian, "vrr.bodyPropEyes");
civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]); civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftHand")) { if(doesEntityDataExist(civilian, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "agrp.bodyPropLeftHand"); let bodyPropLeftHand = getEntityData(civilian, "vrr.bodyPropLeftHand");
civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]); civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropRightHand")) { if(doesEntityDataExist(civilian, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "agrp.bodyPropRightHand"); let bodyPropRightHand = getEntityData(civilian, "vrr.bodyPropRightHand");
civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]); civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftWrist")) { if(doesEntityDataExist(civilian, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "agrp.bodyPropLeftWrist"); let bodyPropLeftWrist = getEntityData(civilian, "vrr.bodyPropLeftWrist");
civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]); civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropRightWrist")) { if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "agrp.bodyPropRightWrist"); let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]); civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropRightWrist")) { if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "agrp.bodyPropRightWrist"); let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]); civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropHip")) { if(doesEntityDataExist(civilian, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "agrp.bodyPropHip"); let bodyPropHip = getEntityData(civilian, "vrr.bodyPropHip");
civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]); civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftFoot")) { if(doesEntityDataExist(civilian, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "agrp.bodyPropLeftFoot"); let bodyPropLeftFoot = getEntityData(civilian, "vrr.bodyPropLeftFoot");
civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]); civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropRightFoot")) { if(doesEntityDataExist(civilian, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "agrp.bodyPropRightFoot"); let bodyPropRightFoot = getEntityData(civilian, "vrr.bodyPropRightFoot");
civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]); civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
} }
} }
if (doesEntityDataExist(civilian, "agrp.anim")) { if(doesEntityDataExist(civilian, "vrr.anim")) {
let animData = getEntityData(vehicle, "agrp.anim"); let animData = getEntityData(vehicle, "vrr.anim");
civilian.addAnimation(animData[0], animData[1]); civilian.addAnimation(animData[0], animData[1]);
} }
} }
@@ -425,9 +407,9 @@ function preventDefaultEventAction(event) {
// =========================================================================== // ===========================================================================
function syncPlayerProperties(player) { function syncPlayerProperties(player) {
if (getGame() == AGRP_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(player, "agrp.scale")) { if(doesEntityDataExist(player, "vrr.scale")) {
let scaleFactor = getEntityData(player, "agrp.scale"); let scaleFactor = getEntityData(player, "vrr.scale");
let tempMatrix = player.matrix; let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z)); tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = player.position; let tempPosition = player.position;
@@ -437,95 +419,95 @@ function syncPlayerProperties(player) {
} }
} }
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
if (doesEntityDataExist(player, "agrp.fightStyle")) { if(doesEntityDataExist(player, "vrr.fightStyle")) {
let fightStyle = getEntityData(player, "agrp.fightStyle"); let fightStyle = getEntityData(player, "vrr.fightStyle");
player.setFightStyle(fightStyle[0], fightStyle[1]); player.setFightStyle(fightStyle[0], fightStyle[1]);
} }
} }
//if(getGame() == AGRP_GAME_GTA_SA) { //if(getGame() == VRR_GAME_GTA_SA) {
// if(doesEntityDataExist(player, "agrp.walkStyle")) { // if(doesEntityDataExist(player, "vrr.walkStyle")) {
// let walkStyle = getEntityData(player, "agrp.walkStyle"); // let walkStyle = getEntityData(player, "vrr.walkStyle");
// player.walkStyle = walkStyle; // player.walkStyle = walkStyle;
// } // }
//} //}
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(player, "agrp.bodyPartHair")) { if(doesEntityDataExist(player, "vrr.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "agrp.bodyPartHair"); let bodyPartHead = getEntityData(player, "vrr.bodyPartHair");
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]); player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPartHead")) { if(doesEntityDataExist(player, "vrr.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "agrp.bodyPartHead"); let bodyPartHead = getEntityData(player, "vrr.bodyPartHead");
player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]); player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPartUpper")) { if(doesEntityDataExist(player, "vrr.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "agrp.bodyPartUpper"); let bodyPartUpper = getEntityData(player, "vrr.bodyPartUpper");
player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]); player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPartLower")) { if(doesEntityDataExist(player, "vrr.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "agrp.bodyPartLower"); let bodyPartLower = getEntityData(player, "vrr.bodyPartLower");
player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]); player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]);
} }
} }
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(player, "agrp.bodyPropHair")) { if(doesEntityDataExist(player, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "agrp.bodyPropHair"); let bodyPropHair = getEntityData(player, "vrr.bodyPropHair");
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]); player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropHead")) { if(doesEntityDataExist(player, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "agrp.bodyPropHead"); let bodyPropHead = getEntityData(player, "vrr.bodyPropHead");
player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]); player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropEyes")) { if(doesEntityDataExist(player, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "agrp.bodyPropEyes"); let bodyPropEyes = getEntityData(player, "vrr.bodyPropEyes");
player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]); player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropLeftHand")) { if(doesEntityDataExist(player, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "agrp.bodyPropLeftHand"); let bodyPropLeftHand = getEntityData(player, "vrr.bodyPropLeftHand");
player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]); player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropRightHand")) { if(doesEntityDataExist(player, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "agrp.bodyPropRightHand"); let bodyPropRightHand = getEntityData(player, "vrr.bodyPropRightHand");
player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]); player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropLeftWrist")) { if(doesEntityDataExist(player, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "agrp.bodyPropLeftWrist"); let bodyPropLeftWrist = getEntityData(player, "vrr.bodyPropLeftWrist");
player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]); player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropRightWrist")) { if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "agrp.bodyPropRightWrist"); let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]); player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropRightWrist")) { if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "agrp.bodyPropRightWrist"); let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]); player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropHip")) { if(doesEntityDataExist(player, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "agrp.bodyPropHip"); let bodyPropHip = getEntityData(player, "vrr.bodyPropHip");
player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]); player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropLeftFoot")) { if(doesEntityDataExist(player, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "agrp.bodyPropLeftFoot"); let bodyPropLeftFoot = getEntityData(player, "vrr.bodyPropLeftFoot");
player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]); player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropRightFoot")) { if(doesEntityDataExist(player, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "agrp.bodyPropRightFoot"); let bodyPropRightFoot = getEntityData(player, "vrr.bodyPropRightFoot");
player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]); player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
} }
} }
@@ -534,9 +516,9 @@ function syncPlayerProperties(player) {
// =========================================================================== // ===========================================================================
function syncObjectProperties(object) { function syncObjectProperties(object) {
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) { if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
if (doesEntityDataExist(object, "agrp.scale")) { if(doesEntityDataExist(object, "vrr.scale")) {
let scaleFactor = getEntityData(object, "agrp.scale"); let scaleFactor = getEntityData(object, "vrr.scale");
let tempMatrix = object.matrix; let tempMatrix = object.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z)); tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = object.position; let tempPosition = object.position;
@@ -586,13 +568,13 @@ function getPlayerId(client) {
// =========================================================================== // ===========================================================================
function syncElementProperties(element) { function syncElementProperties(element) {
if (doesEntityDataExist(element, "agrp.interior")) { if(doesEntityDataExist(element, "vrr.interior")) {
if (typeof element.interior != "undefined") { if(typeof element.interior != "undefined") {
element.interior = getEntityData(element, "agrp.interior"); element.interior = getEntityData(element, "vrr.interior");
} }
} }
switch (element.type) { switch(element.type) {
case ELEMENT_VEHICLE: case ELEMENT_VEHICLE:
syncVehicleProperties(element); syncVehicleProperties(element);
break; break;
@@ -637,23 +619,23 @@ function getScreenHeight() {
// =========================================================================== // ===========================================================================
function openAllGarages() { function openAllGarages() {
switch (getGame()) { switch(getGame()) {
case AGRP_GAME_GTA_III: case VRR_GAME_GTA_III:
for (let i = 0; i <= 26; i++) { for(let i=0;i<=26;i++) {
openGarage(i); openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
} }
break; break;
case AGRP_GAME_GTA_VC: case VRR_GAME_GTA_VC:
for (let i = 0; i <= 32; i++) { for(let i=0;i<=32;i++) {
openGarage(i); openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
} }
break; break;
case AGRP_GAME_GTA_SA: case VRR_GAME_GTA_SA:
for (let i = 0; i <= 44; i++) { for(let i=0;i<=44;i++) {
openGarage(i); openGarage(i);
} }
break; break;
@@ -666,23 +648,23 @@ function openAllGarages() {
// =========================================================================== // ===========================================================================
function closeAllGarages() { function closeAllGarages() {
switch (getGame()) { switch(getGame()) {
case AGRP_GAME_GTA_III: case VRR_GAME_GTA_III:
for (let i = 0; i <= 26; i++) { for(let i=0;i<=26;i++) {
closeGarage(i); closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
} }
break; break;
case AGRP_GAME_GTA_VC: case VRR_GAME_GTA_VC:
for (let i = 0; i <= 32; i++) { for(let i=0;i<=32;i++) {
closeGarage(i); closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
} }
break; break;
case AGRP_GAME_GTA_SA: case VRR_GAME_GTA_SA:
for (let i = 0; i <= 44; i++) { for(let i=0;i<=44;i++) {
closeGarage(i); closeGarage(i);
} }
break; break;
@@ -701,7 +683,7 @@ function setPedInvincible(ped, state) {
// =========================================================================== // ===========================================================================
function setPedLookAt(ped, position) { function setPedLookAt(ped, position) {
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
ped.lookAt(position, 10000); ped.lookAt(position, 10000);
return true; return true;
} else { } else {
@@ -716,9 +698,3 @@ function setElementHeading(elementId, heading) {
} }
// =========================================================================== // ===========================================================================
function deleteLocalPlayerPed() {
destroyElement(localPlayer);
}
// ===========================================================================

View File

@@ -1,438 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: netevents.js
// DESC: Provides server communication and cross-endpoint network events
// TYPE: Client (JavaScript)
// ===========================================================================
function initServerScript() {
logToConsole(LOG_DEBUG, "[VRR.Server]: Initializing server script ...");
addAllNetworkHandlers();
logToConsole(LOG_DEBUG, "[VRR.Server]: Server script initialized!");
}
// ===========================================================================
function addAllNetworkHandlers() {
logToConsole(LOG_DEBUG, "[VRR.Server]: Adding network handlers ...");
// Chat Box
addNetworkEventHandler("m", receiveChatBoxMessageFromServer); // Not prefixed with VRR to make it as small as possible
addNetworkEventHandler("agrp.chatScrollLines", setChatScrollLines);
addNetworkEventHandler("agrp.chatAutoHideDelay", setChatAutoHideDelay);
addNetworkEventHandler("agrp.chatTimeStamps", setChatTimeStampsState);
addNetworkEventHandler("agrp.chatEmoji", setChatEmojiState);
// Messaging (like textdraws and stuff)
addNetworkEventHandler("agrp.smallGameMessage", showSmallGameMessage);
// Job
addNetworkEventHandler("agrp.job", receiveJobFromServer);
addNetworkEventHandler("agrp.working", setLocalPlayerWorkingState);
addNetworkEventHandler("agrp.jobType", setLocalPlayerJobType);
addNetworkEventHandler("agrp.showJobRouteLocation", showJobRouteLocation);
addNetworkEventHandler("agrp.hideJobRouteLocation", hideJobRouteLocation);
// Local player states and values
addNetworkEventHandler("agrp.restoreCamera", restoreLocalCamera);
addNetworkEventHandler("agrp.cameraLookAt", setLocalCameraLookAt);
addNetworkEventHandler("agrp.freeze", setLocalPlayerFrozenState);
addNetworkEventHandler("agrp.control", setLocalPlayerControlState);
addNetworkEventHandler("agrp.fadeCamera", fadeLocalCamera);
addNetworkEventHandler("agrp.removeFromVehicle", removeLocalPlayerFromVehicle);
addNetworkEventHandler("agrp.clearWeapons", clearLocalPlayerWeapons);
addNetworkEventHandler("agrp.giveWeapon", giveLocalPlayerWeapon);
addNetworkEventHandler("agrp.position", setLocalPlayerPosition);
addNetworkEventHandler("agrp.heading", setLocalPlayerHeading);
addNetworkEventHandler("agrp.interior", setLocalPlayerInterior);
addNetworkEventHandler("agrp.spawned", onServerSpawnedLocalPlayer);
addNetworkEventHandler("agrp.money", setLocalPlayerCash);
addNetworkEventHandler("agrp.armour", setLocalPlayerArmour);
addNetworkEventHandler("agrp.localPlayerSkin", setLocalPlayerSkin);
addNetworkEventHandler("agrp.pedSpeak", makeLocalPlayerPedSpeak);
addNetworkEventHandler("agrp.infiniteRun", setLocalPlayerInfiniteRun);
addNetworkEventHandler("agrp.playerCop", setLocalPlayerAsCopState);
addNetworkEventHandler("agrp.health", setLocalPlayerHealth);
addNetworkEventHandler("agrp.wantedLevel", setLocalPlayerWantedLevel);
addNetworkEventHandler("agrp.playerPedId", sendLocalPlayerNetworkIdToServer);
addNetworkEventHandler("agrp.ped", setLocalPlayerPedPartsAndProps);
addNetworkEventHandler("agrp.spawn", serverRequestedLocalPlayerSpawn);
addNetworkEventHandler("agrp.clearPedState", clearLocalPedState);
addNetworkEventHandler("agrp.drunkEffect", setLocalPlayerDrunkEffect);
addNetworkEventHandler("agrp.deleteLocalPlayerPed", deleteLocalPlayerPed);
// Vehicle
addNetworkEventHandler("agrp.vehicle", receiveVehicleFromServer);
addNetworkEventHandler("agrp.veh.lights", setVehicleLights);
addNetworkEventHandler("agrp.veh.engine", setVehicleEngine);
addNetworkEventHandler("agrp.veh.repair", repairVehicle);
addNetworkEventHandler("agrp.cruiseControl", toggleVehicleCruiseControl);
// Radio
addNetworkEventHandler("agrp.radioStream", playStreamingRadio);
addNetworkEventHandler("agrp.audioFileStream", playAudioFile);
addNetworkEventHandler("agrp.stopRadioStream", stopStreamingRadio);
addNetworkEventHandler("agrp.radioVolume", setStreamingRadioVolume);
// Key Bindings
addNetworkEventHandler("agrp.delKeyBind", unBindAccountKey);
addNetworkEventHandler("agrp.addKeyBind", bindAccountKey);
addNetworkEventHandler("agrp.clearKeyBinds", clearKeyBinds);
// Weapon Damage
addNetworkEventHandler("agrp.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
addNetworkEventHandler("agrp.weaponDamageEvent", setPlayerWeaponDamageEvent);
// GUI
addNetworkEventHandler("agrp.showRegistration", showRegistrationGUI);
addNetworkEventHandler("agrp.showNewCharacter", showNewCharacterGUI);
addNetworkEventHandler("agrp.showLogin", showLoginGUI);
addNetworkEventHandler("agrp.2fa", showTwoFactorAuthGUI);
addNetworkEventHandler("agrp.showResetPasswordCodeInput", resetPasswordCodeInputGUI);
addNetworkEventHandler("agrp.showResetPasswordEmailInput", resetPasswordEmailInputGUI);
addNetworkEventHandler("agrp.showChangePassword", showChangePasswordGUI);
addNetworkEventHandler("agrp.showCharacterSelect", showCharacterSelectGUI);
addNetworkEventHandler("agrp.switchCharacterSelect", switchCharacterSelectGUI);
addNetworkEventHandler("agrp.showError", showErrorGUI);
addNetworkEventHandler("agrp.showInfo", showInfoGUI);
addNetworkEventHandler("agrp.showPrompt", showYesNoPromptGUI);
addNetworkEventHandler("agrp.loginSuccess", loginSuccess);
addNetworkEventHandler("agrp.characterSelectSuccess", characterSelectSuccess);
addNetworkEventHandler("agrp.loginFailed", loginFailed);
addNetworkEventHandler("agrp.registrationSuccess", registrationSuccess);
addNetworkEventHandler("agrp.registrationFailed", registrationFailed);
addNetworkEventHandler("agrp.newCharacterFailed", newCharacterFailed);
addNetworkEventHandler("agrp.changePassword", showChangePasswordGUI);
addNetworkEventHandler("agrp.showLocaleChooser", showLocaleChooserGUI);
addNetworkEventHandler("agrp.guiColour", setGUIColours);
// Business
addNetworkEventHandler("agrp.business", receiveBusinessFromServer);
// House
addNetworkEventHandler("agrp.house", receiveHouseFromServer);
// GPS
addNetworkEventHandler("agrp.showGPSBlip", showGPSLocation);
// Locale
addNetworkEventHandler("agrp.locale", setLocale);
addNetworkEventHandler("agrp.localeChooser", toggleLocaleChooserGUI);
// Misc
addNetworkEventHandler("agrp.mouseCursor", toggleMouseCursor);
addNetworkEventHandler("agrp.mouseCamera", toggleMouseCamera);
addNetworkEventHandler("agrp.clearPeds", clearLocalPlayerOwnedPeds);
addNetworkEventHandler("agrp.clearPickups", clearLocalPlayerOwnedPickups);
addNetworkEventHandler("agrp.passenger", enterVehicleAsPassenger);
addNetworkEventHandler("agrp.logo", setServerLogoRenderState);
addNetworkEventHandler("agrp.ambience", setCityAmbienceState);
addNetworkEventHandler("agrp.runCode", runClientCode);
addNetworkEventHandler("agrp.minuteDuration", setMinuteDuration);
addNetworkEventHandler("agrp.snow", setSnowState);
addNetworkEventHandler("agrp.enterPropertyKey", setEnterPropertyKey);
addNetworkEventHandler("agrp.skinSelect", toggleSkinSelect);
addNetworkEventHandler("agrp.hotbar", updatePlayerHotBar);
addNetworkEventHandler("agrp.showItemActionDelay", showItemActionDelay);
addNetworkEventHandler("agrp.set2DRendering", set2DRendering);
addNetworkEventHandler("agrp.mouseCameraForce", setMouseCameraState);
addNetworkEventHandler("agrp.logLevel", setLogLevel);
addNetworkEventHandler("agrp.hideAllGUI", hideAllGUI);
addNetworkEventHandler("agrp.nametag", updatePlayerNameTag);
addNetworkEventHandler("agrp.nametagDistance", setNameTagDistance);
addNetworkEventHandler("agrp.ping", updatePlayerPing);
addNetworkEventHandler("agrp.anim", makePedPlayAnimation);
addNetworkEventHandler("agrp.stopAnim", makePedStopAnimation);
addNetworkEventHandler("agrp.forceAnim", forcePedAnimation);
addNetworkEventHandler("agrp.clientInfo", serverRequestedClientInfo);
addNetworkEventHandler("agrp.interiorLights", updateInteriorLightsState);
addNetworkEventHandler("agrp.cutsceneInterior", setCutsceneInterior);
addNetworkEventHandler("agrp.syncElement", forceSyncElementProperties);
addNetworkEventHandler("agrp.elementPosition", setElementPosition);
addNetworkEventHandler("agrp.elementCollisions", setElementCollisionsEnabled);
addNetworkEventHandler("agrp.vehBuyState", setVehiclePurchaseState);
addNetworkEventHandler("agrp.holdObject", makePedHoldObject);
addNetworkEventHandler("agrp.profanityFilter", setProfanityFilterState);
}
// ===========================================================================
function sendResourceReadySignalToServer() {
sendNetworkEventToServer("agrp.clientReady");
}
// ===========================================================================
function sendResourceStartedSignalToServer() {
sendNetworkEventToServer("agrp.clientStarted");
}
// ===========================================================================
function sendResourceStoppedSignalToServer() {
if (isConnected) {
sendNetworkEventToServer("agrp.clientStopped");
}
}
// ===========================================================================
function set2DRendering(hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState) {
logToConsole(LOG_DEBUG, `[VRR.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`);
renderHUD = hudState;
if (getGame() == AGRP_GAME_GTA_IV) {
natives.displayCash(hudState);
natives.displayAmmo(hudState);
natives.displayHud(hudState);
natives.displayRadar(hudState);
natives.displayAreaName(hudState);
} else {
if (typeof setHUDEnabled != "undefined") {
setHUDEnabled(hudState);
}
}
renderLabels = labelState;
renderSmallGameMessage = smallGameMessageState;
renderScoreBoard = scoreboardState;
renderHotBar = hotBarState;
renderItemActionDelay = itemActionDelayState;
}
// ===========================================================================
function onServerSpawnedLocalPlayer(state) {
logToConsole(LOG_DEBUG, `[VRR.Main] Setting spawned state to ${state}`);
isSpawned = state;
setUpInitialGame();
if (state) {
setTimeout(function () {
calledDeathEvent = false;
}, 1000);
getElementsByType(ELEMENT_PED).filter(ped => !ped.isType(ELEMENT_PLAYER)).forEach(ped => {
syncCivilianProperties(ped);
});
getElementsByType(ELEMENT_PLAYER).forEach(player => {
syncPlayerProperties(player);
});
getElementsByType(ELEMENT_VEHICLE).forEach(vehicle => {
syncVehicleProperties(vehicle);
});
}
}
// ===========================================================================
function tellServerPlayerUsedKeyBind(key) {
sendNetworkEventToServer("agrp.useKeyBind", key);
}
// ===========================================================================
function tellServerPlayerArrivedAtJobRouteLocation() {
sendNetworkEventToServer("agrp.arrivedAtJobRouteLocation");
}
// ===========================================================================
function tellServerItemActionDelayComplete() {
sendNetworkEventToServer("agrp.itemActionDelayComplete");
}
// ===========================================================================
function sendServerClientInfo() {
let clientVersion = "0.0.0.0";
if (typeof CLIENT_VERSION_MAJOR != "undefined") {
clientVersion = `${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_PATCH}.${CLIENT_VERSION_BUILD}`;
}
sendNetworkEventToServer("agrp.clientInfo", clientVersion, game.width, game.height);
}
// ===========================================================================
function sendServerNewAFKStatus(state) {
sendNetworkEventToServer("agrp.afk", state);
}
// ===========================================================================
function anchorBoat(vehicleId) {
}
// ===========================================================================
function setEnterPropertyKey(key) {
enterPropertyKey = key;
}
// ===========================================================================
function serverRequestedClientInfo() {
sendServerClientInfo();
}
// ===========================================================================
function updateInteriorLightsState(state) {
interiorLightsEnabled = state;
}
// ===========================================================================
function forceSyncElementProperties(elementId) {
if (getElementFromId(elementId) == null) {
return false;
}
syncElementProperties(getElementFromId(elementId));
}
// ===========================================================================
function setElementCollisionsEnabled(elementId, state) {
if (getElementFromId(elementId) == null) {
return false;
}
getElementFromId(elementId).collisionsEnabled = state;
}
// ===========================================================================
function setLocalPlayerArmour(armour) {
if (typeof localPlayer.armour != "undefined") {
localPlayer.armour = armour;
}
}
// ===========================================================================
function setLocalPlayerWantedLevel(wantedLevel) {
forceWantedLevel = toInteger(wantedLevel);
}
// ===========================================================================
function setLogLevel(level) {
logLevel = level;
}
// ===========================================================================
function setLocalPlayerInfiniteRun(state) {
if (localPlayer != null) {
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), boolToInt(state));
}
}
}
// ===========================================================================
function setLocalPlayerSkin(skinId) {
logToConsole(LOG_INFO, `[VRR.Server] Setting locale player skin to ${skinId}`);
if (getGame() == AGRP_GAME_GTA_IV) {
if (natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId);
natives.loadAllObjectsNow();
if (natives.hasModelLoaded(skinId)) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
}
}
} else {
localPlayer.skin = skinId;
}
}
// ===========================================================================
function makePedHoldObject(pedId, modelIndex) {
if (getGame() == AGRP_GAME_GTA_IV) {
natives.givePedAmbientObject(natives.getPedFromNetworkId(pedId), getGameConfig().objects[getGame()][modelIndex][1])
}
}
// ===========================================================================
function sendLocalPlayerNetworkIdToServer() {
sendNetworkEventToServer("agrp.playerPedId", natives.getNetworkIdFromPed(localPlayer));
}
// ===========================================================================
function setCutsceneInterior(cutsceneName) {
if (getGame() == AGRP_GAME_GTA_IV) {
if (cutsceneName == "") {
natives.clearCutscene();
} else {
if (natives.isInteriorScene()) {
natives.clearCutscene();
}
natives.initCutscene(cutsceneName);
}
}
}
// ===========================================================================
function makeLocalPlayerPedSpeak(speechName) {
if (getGame() == AGRP_GAME_GTA_IV) {
// if player is in vehicle, allow megaphone (if last arg is "1", it will cancel megaphone echo)
// Only speeches with _MEGAPHONE will have the bullhorn effect
// Afaik it only works on police voices anyway
if (localPlayer.vehicle != null) {
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 0);
} else {
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 1);
}
} else if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
// Don't have a way to get the ped ref ID and can't use ped in arg
//game.SET_CHAR_SAY(game.GET_PLAYER_ID(), int);
}
}
// ===========================================================================
function setLocalPlayerAsCopState(state) {
if (getGame() == AGRP_GAME_GTA_IV) {
natives.setPlayerAsCop(natives.getPlayerId(), state);
natives.setPoliceIgnorePlayer(natives.getPlayerId(), state);
}
}
// ===========================================================================
function serverRequestedLocalPlayerSpawn(skinId, position) {
if (getGame() == AGRP_GAME_GTA_IV) {
natives.createPlayer(skinId, position);
//if(isCustomCameraSupported()) {
// game.restoreCamera(true);
//}
}
}
// ===========================================================================
function sendLocaleSelectToServer(localeId) {
sendNetworkEventToServer("agrp.localeSelect", localeId);
}
// ===========================================================================
function clearLocalPlayerOwnedPickups() {
let pickups = getPickups().filter(pickup => pickup.isLocal == true);
for (let i in pickups) {
deleteLocalGameElement(pickups[i]);
}
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: npc.js // FILE: npc.js
// DESC: Provides NPC functions and processing // DESC: Provides NPC functions and processing
@@ -10,10 +9,10 @@
function processNPCMovement(npc) { function processNPCMovement(npc) {
//if(npc.isSyncer == true) { //if(npc.isSyncer == true) {
if (getEntityData(npc, "agrp.lookAtClosestPlayer") == true) { if(getEntityData(npc, "vrr.lookAtClosestPlayer") == true) {
let closestPlayer = getClosestPlayer(getElementPosition(npc.id)); let closestPlayer = getClosestPlayer(getElementPosition(npc.id));
setPedLookAt(npc, getElementPosition(closestPlayer.id)); setPedLookAt(npc, getElementPosition(closestPlayer.id));
} }
//} //}
} }

View File

@@ -1,39 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: object.js
// DESC: Provides object functions and processing
// TYPE: Client (JavaScript)
// ===========================================================================
let movingObject = null;
// ===========================================================================
function startMovingObject(object) {
}
// ===========================================================================
function stopMovingObject(object, save = true) {
if (save) {
sendNetworkEventToServer("agrp.objectSave", object.id, object.position, object.rotation);
}
}
// ===========================================================================
function isMovingObject() {
return movingObject != null;
}
// ===========================================================================
function getMovingObject() {
return movingObject;
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: radio.js // FILE: radio.js
// DESC: Provides internet streaming radio functions and usage // DESC: Provides internet streaming radio functions and usage
@@ -9,21 +8,21 @@
// =========================================================================== // ===========================================================================
function playStreamingRadio(url, loop, volume, element = false) { function playStreamingRadio(url, loop, volume, element = false) {
if (streamingRadio != null) { if(streamingRadio != null) {
streamingRadio.stop(); streamingRadio.stop();
} }
streamingRadioVolume = volume; streamingRadioVolume = volume;
streamingRadio = audio.createSoundFromURL(url, loop); streamingRadio = audio.createSoundFromURL(url, loop);
streamingRadio.volume = volume / 100; streamingRadio.volume = volume/100;
streamingRadio.play(); streamingRadio.play();
} }
// =========================================================================== // ===========================================================================
function stopStreamingRadio() { function stopStreamingRadio() {
if (streamingRadio != null) { if(streamingRadio != null) {
streamingRadio.stop(); streamingRadio.stop();
} }
streamingRadio = null; streamingRadio = null;
@@ -32,16 +31,16 @@ function stopStreamingRadio() {
// =========================================================================== // ===========================================================================
function setStreamingRadioVolume(volume) { function setStreamingRadioVolume(volume) {
if (streamingRadio != null) { if(streamingRadio != null) {
streamingRadioVolume = volume; streamingRadioVolume = volume;
streamingRadio.volume = volume / 100; streamingRadio.volume = volume/100;
} }
} }
// =========================================================================== // ===========================================================================
function playAudioFile(audioName, loop, volume) { function playAudioFile(audioName, loop, volume) {
findResourceByName("connectedrp-extra").exports.playCustomAudio(audioName, volume / 100, loop); findResourceByName("connectedrp-extra").exports.playCustomAudio(audioName, volume/100, loop);
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: scoreboard.js // FILE: scoreboard.js
// DESC: Provides scoreboard features and rendering // DESC: Provides scoreboard features and rendering
@@ -39,63 +38,63 @@ function initScoreBoardListFont() {
// =========================================================================== // ===========================================================================
function processScoreBoardRendering() { function processScoreBoardRendering() {
if (isAnyGUIActive()) { if(isAnyGUIActive()) {
return false; return false;
} }
if (renderScoreBoard) { if(renderScoreBoard) {
if (isKeyDown(SDLK_TAB)) { if(isKeyDown(SDLK_TAB)) {
if (scoreBoardListFont != null && scoreBoardTitleFont != null) { if(scoreBoardListFont != null && scoreBoardTitleFont != null) {
let scoreboardStart = (game.height / 2) - (Math.floor(getClients().length / 2) * 20); let scoreboardStart = (game.height/2)-(Math.floor(getClients().length/2)*20);
let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false); let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false);
scoreBoardTitleFont.render("PLAYERS", [game.width / 2, scoreboardStart - 50], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true); scoreBoardTitleFont.render("PLAYERS", [game.width/2, scoreboardStart-50], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
titleSize = scoreBoardTitleFont.measure("____________________________", game.width, 0.0, 1.0, 10, false, false); titleSize = scoreBoardTitleFont.measure("____________________________", game.width, 0.0, 1.0, 10, false, false);
scoreBoardTitleFont.render("____________________________", [game.width / 2, scoreboardStart - 35], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true); scoreBoardTitleFont.render("____________________________", [game.width/2, scoreboardStart-35], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (!clients[i].console) { if(!clients[i].console) {
let name = clients[i].name; let name = clients[i].name;
let colour = COLOUR_WHITE; let colour = COLOUR_WHITE;
let paused = false; let paused = false;
let ping = "-1"; let ping = "-1";
if (typeof playerNames[clients[i].name] != "undefined") { if(typeof playerNames[clients[i].name] != "undefined") {
name = playerNames[clients[i].name]; name = playerNames[clients[i].name];
} }
if (typeof playerPaused[clients[i].name] != "undefined") { if(typeof playerPaused[clients[i].name] != "undefined") {
paused = playerPaused[clients[i].name]; paused = playerPaused[clients[i].name];
} }
if (typeof playerColours[clients[i].name] != "undefined") { if(typeof playerColours[clients[i].name] != "undefined") {
colour = playerColours[clients[i].name]; colour = playerColours[clients[i].name];
} }
if (typeof playerPing[clients[i].name] != "undefined") { if(typeof playerPing[clients[i].name] != "undefined") {
ping = toString(playerPing[clients[i].name]); ping = toString(playerPing[clients[i].name]);
} }
// Player ID // Player ID
let text = String(clients[i].index); let text = String(clients[i].index);
let size = scoreBoardListFont.measure(text, 75, 0.0, 1.0, 10, false, false); let size = scoreBoardListFont.measure(text, 75, 0.0, 1.0, 10, false, false);
scoreBoardListFont.render(text, [game.width / 2 - 100, scoreboardStart + (i * 20)], 0, 0.5, 0.0, scoreBoardListFont.size, COLOUR_WHITE, false, false, false, true); scoreBoardListFont.render(text, [game.width/2-100, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, COLOUR_WHITE, false, false, false, true);
// Player Name // Player Name
text = name; text = name;
size = scoreBoardListFont.measure(text, 100, 0.0, 1.0, 10, false, false); size = scoreBoardListFont.measure(text, 100, 0.0, 1.0, 10, false, false);
scoreBoardListFont.render(text, [game.width / 2, scoreboardStart + (i * 20)], 0, 0.5, 0.0, scoreBoardListFont.size, colour, false, false, false, true); scoreBoardListFont.render(text, [game.width/2, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, colour, false, false, false, true);
// Ping // Ping
text = ping; text = ping;
size = scoreBoardListFont.measure(ping, 75, 0.0, 1.0, 10, false, false); size = scoreBoardListFont.measure(ping, 75, 0.0, 1.0, 10, false, false);
scoreBoardListFont.render(ping, [game.width / 2 + 100, scoreboardStart + (i * 20)], 0, 0.5, 0.0, scoreBoardListFont.size, COLOUR_WHITE, false, false, false, true); scoreBoardListFont.render(ping, [game.width/2+100, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, COLOUR_WHITE, false, false, false, true);
// PAUSED Status (depends on resource "afk") // PAUSED Status (depends on resource "afk")
if (paused == true) { if(paused == true) {
size = scoreBoardListFont.measure("PAUSED", 100, 0.0, 1.0, 10, false, false); size = scoreBoardListFont.measure("PAUSED", 100, 0.0, 1.0, 10, false, false);
scoreBoardListFont.render("PAUSED", [game.width / 2 + 200, scoreboardStart + (i * 20)], 0, 0.5, 0.0, scoreBoardListFont.size, pausedColour, false, false, false, true); scoreBoardListFont.render("PAUSED", [game.width/2+200, scoreboardStart + (i*20)], 0, 0.5, 0.0, scoreBoardListFont.size, pausedColour, false, false, false, true);
} }
} }
} }

416
scripts/client/server.js Normal file
View File

@@ -0,0 +1,416 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: server.js
// DESC: Provides server communication and cross-endpoint operations
// TYPE: Client (JavaScript)
// ===========================================================================
function initServerScript() {
logToConsole(LOG_DEBUG, "[VRR.Server]: Initializing server script ...");
addAllNetworkHandlers();
logToConsole(LOG_DEBUG, "[VRR.Server]: Server script initialized!");
}
// ===========================================================================
function addAllNetworkHandlers() {
logToConsole(LOG_DEBUG, "[VRR.Server]: Adding network handlers ...");
// Chat history
addNetworkEventHandler("m", receiveChatBoxMessageFromServer); // Not prefixed with VRR to make it as small as possible
addNetworkEventHandler("vrr.chatScrollLines", setChatScrollLines);
addNetworkEventHandler("vrr.chatAutoHideDelay", setChatAutoHideDelay);
// Messaging (like textdraws and stuff)
addNetworkEventHandler("vrr.smallGameMessage", showSmallGameMessage);
// Job
addNetworkEventHandler("vrr.job", receiveJobFromServer);
addNetworkEventHandler("vrr.working", setLocalPlayerWorkingState);
addNetworkEventHandler("vrr.jobType", setLocalPlayerJobType);
addNetworkEventHandler("vrr.showJobRouteLocation", showJobRouteLocation);
addNetworkEventHandler("vrr.hideJobRouteLocation", hideJobRouteLocation);
// Local player states and values
addNetworkEventHandler("vrr.restoreCamera", restoreLocalCamera);
addNetworkEventHandler("vrr.cameraLookAt", setLocalCameraLookAt);
addNetworkEventHandler("vrr.freeze", setLocalPlayerFrozenState);
addNetworkEventHandler("vrr.control", setLocalPlayerControlState);
addNetworkEventHandler("vrr.fadeCamera", fadeLocalCamera);
addNetworkEventHandler("vrr.removeFromVehicle", removeLocalPlayerFromVehicle);
addNetworkEventHandler("vrr.clearWeapons", clearLocalPlayerWeapons);
addNetworkEventHandler("vrr.giveWeapon", giveLocalPlayerWeapon);
addNetworkEventHandler("vrr.position", setLocalPlayerPosition);
addNetworkEventHandler("vrr.heading", setLocalPlayerHeading);
addNetworkEventHandler("vrr.interior", setLocalPlayerInterior);
addNetworkEventHandler("vrr.spawned", onServerSpawnedLocalPlayer);
addNetworkEventHandler("vrr.money", setLocalPlayerCash);
addNetworkEventHandler("vrr.armour", setLocalPlayerArmour);
addNetworkEventHandler("vrr.localPlayerSkin", setLocalPlayerSkin);
addNetworkEventHandler("vrr.pedSpeak", makeLocalPlayerPedSpeak);
addNetworkEventHandler("vrr.infiniteRun", setLocalPlayerInfiniteRun);
addNetworkEventHandler("vrr.playerCop", setLocalPlayerAsCopState);
addNetworkEventHandler("vrr.health", setLocalPlayerHealth);
addNetworkEventHandler("vrr.wantedLevel", setLocalPlayerWantedLevel);
addNetworkEventHandler("vrr.playerPedId", sendLocalPlayerNetworkIdToServer);
addNetworkEventHandler("vrr.ped", setLocalPlayerPedPartsAndProps);
addNetworkEventHandler("vrr.spawn", serverRequestedLocalPlayerSpawn);
addNetworkEventHandler("vrr.clearPedState", clearLocalPedState);
addNetworkEventHandler("vrr.drunkEffect", setLocalPlayerDrunkEffect);
// Vehicle
addNetworkEventHandler("vrr.vehicle", receiveVehicleFromServer);
addNetworkEventHandler("vrr.veh.lights", setVehicleLights);
addNetworkEventHandler("vrr.veh.engine", setVehicleEngine);
addNetworkEventHandler("vrr.veh.repair", repairVehicle);
// Radio
addNetworkEventHandler("vrr.radioStream", playStreamingRadio);
addNetworkEventHandler("vrr.audioFileStream", playAudioFile);
addNetworkEventHandler("vrr.stopRadioStream", stopStreamingRadio);
addNetworkEventHandler("vrr.radioVolume", setStreamingRadioVolume);
// Key Bindings
addNetworkEventHandler("vrr.delKeyBind", unBindAccountKey);
addNetworkEventHandler("vrr.addKeyBind", bindAccountKey);
addNetworkEventHandler("vrr.clearKeyBinds", clearKeyBinds);
// Weapon Damage
addNetworkEventHandler("vrr.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
addNetworkEventHandler("vrr.weaponDamageEvent", setPlayerWeaponDamageEvent);
// GUI
addNetworkEventHandler("vrr.showRegistration", showRegistrationGUI);
addNetworkEventHandler("vrr.showNewCharacter", showNewCharacterGUI);
addNetworkEventHandler("vrr.showLogin", showLoginGUI);
addNetworkEventHandler("vrr.2fa", showTwoFactorAuthGUI);
addNetworkEventHandler("vrr.showResetPasswordCodeInput", resetPasswordCodeInputGUI);
addNetworkEventHandler("vrr.showResetPasswordEmailInput", resetPasswordEmailInputGUI);
addNetworkEventHandler("vrr.showChangePassword", showChangePasswordGUI);
addNetworkEventHandler("vrr.showCharacterSelect", showCharacterSelectGUI);
addNetworkEventHandler("vrr.switchCharacterSelect", switchCharacterSelectGUI);
addNetworkEventHandler("vrr.showError", showErrorGUI);
addNetworkEventHandler("vrr.showInfo", showInfoGUI);
addNetworkEventHandler("vrr.showPrompt", showYesNoPromptGUI);
addNetworkEventHandler("vrr.loginSuccess", loginSuccess);
addNetworkEventHandler("vrr.characterSelectSuccess", characterSelectSuccess);
addNetworkEventHandler("vrr.loginFailed", loginFailed);
addNetworkEventHandler("vrr.registrationSuccess", registrationSuccess);
addNetworkEventHandler("vrr.registrationFailed", registrationFailed);
addNetworkEventHandler("vrr.newCharacterFailed", newCharacterFailed);
addNetworkEventHandler("vrr.changePassword", showChangePasswordGUI);
addNetworkEventHandler("vrr.showLocaleChooser", showLocaleChooserGUI);
addNetworkEventHandler("vrr.guiColour", setGUIColours);
// Business
addNetworkEventHandler("vrr.business", receiveBusinessFromServer);
// House
addNetworkEventHandler("vrr.house", receiveHouseFromServer);
// GPS
addNetworkEventHandler("vrr.showGPSBlip", showGPSLocation);
// Locale
addNetworkEventHandler("vrr.locale", setLocale);
addNetworkEventHandler("vrr.localeChooser", toggleLocaleChooserGUI);
// Misc
addNetworkEventHandler("vrr.mouseCursor", toggleMouseCursor);
addNetworkEventHandler("vrr.mouseCamera", toggleMouseCamera);
addNetworkEventHandler("vrr.clearPeds", clearLocalPlayerOwnedPeds);
addNetworkEventHandler("vrr.passenger", enterVehicleAsPassenger);
addNetworkEventHandler("vrr.logo", setServerLogoRenderState);
addNetworkEventHandler("vrr.ambience", setCityAmbienceState);
addNetworkEventHandler("vrr.runCode", runClientCode);
addNetworkEventHandler("vrr.minuteDuration", setMinuteDuration);
addNetworkEventHandler("vrr.snow", setSnowState);
addNetworkEventHandler("vrr.enterPropertyKey", setEnterPropertyKey);
addNetworkEventHandler("vrr.skinSelect", toggleSkinSelect);
addNetworkEventHandler("vrr.hotbar", updatePlayerHotBar);
addNetworkEventHandler("vrr.showItemActionDelay", showItemActionDelay);
addNetworkEventHandler("vrr.set2DRendering", set2DRendering);
addNetworkEventHandler("vrr.mouseCameraForce", setMouseCameraState);
addNetworkEventHandler("vrr.logLevel", setLogLevel);
addNetworkEventHandler("vrr.hideAllGUI", hideAllGUI);
addNetworkEventHandler("vrr.nametag", updatePlayerNameTag);
addNetworkEventHandler("vrr.nametagDistance", setNameTagDistance);
addNetworkEventHandler("vrr.ping", updatePlayerPing);
addNetworkEventHandler("vrr.anim", makePedPlayAnimation);
addNetworkEventHandler("vrr.stopAnim", makePedStopAnimation);
addNetworkEventHandler("vrr.forceAnim", forcePedAnimation);
addNetworkEventHandler("vrr.clientInfo", serverRequestedClientInfo);
addNetworkEventHandler("vrr.interiorLights", updateInteriorLightsState);
addNetworkEventHandler("vrr.cutsceneInterior", setCutsceneInterior);
addNetworkEventHandler("vrr.syncElement", forceSyncElementProperties);
addNetworkEventHandler("vrr.elementPosition", setElementPosition);
addNetworkEventHandler("vrr.elementCollisions", setElementCollisionsEnabled);
addNetworkEventHandler("vrr.vehBuyState", setVehiclePurchaseState);
addNetworkEventHandler("vrr.holdObject", makePedHoldObject);
}
// ===========================================================================
function sendResourceReadySignalToServer() {
sendNetworkEventToServer("vrr.clientReady");
}
// ===========================================================================
function sendResourceStartedSignalToServer() {
sendNetworkEventToServer("vrr.clientStarted");
}
// ===========================================================================
function sendResourceStoppedSignalToServer() {
if(isConnected) {
sendNetworkEventToServer("vrr.clientStopped");
}
}
// ===========================================================================
function set2DRendering(hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState) {
logToConsole(LOG_DEBUG, `[VRR.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`);
renderHUD = hudState;
if(getGame() == VRR_GAME_GTA_IV) {
natives.displayCash(hudState);
natives.displayAmmo(hudState);
natives.displayHud(hudState);
natives.displayRadar(hudState);
natives.displayAreaName(hudState);
} else {
if(typeof setHUDEnabled != "undefined") {
setHUDEnabled(hudState);
}
}
renderLabels = labelState;
renderSmallGameMessage = smallGameMessageState;
renderScoreBoard = scoreboardState;
renderHotBar = hotBarState;
renderItemActionDelay = itemActionDelayState;
}
// ===========================================================================
function onServerSpawnedLocalPlayer(state) {
logToConsole(LOG_DEBUG, `[VRR.Main] Setting spawned state to ${state}`);
isSpawned = state;
setUpInitialGame();
if(state) {
setTimeout(function() {
calledDeathEvent = false;
}, 1000);
getElementsByType(ELEMENT_PED).filter(ped => !ped.isType(ELEMENT_PLAYER)).forEach(ped => {
syncCivilianProperties(ped);
});
getElementsByType(ELEMENT_PLAYER).forEach(player => {
syncPlayerProperties(player);
});
getElementsByType(ELEMENT_VEHICLE).forEach(vehicle => {
syncVehicleProperties(vehicle);
});
}
}
// ===========================================================================
function tellServerPlayerUsedKeyBind(key) {
sendNetworkEventToServer("vrr.useKeyBind", key);
}
// ===========================================================================
function tellServerPlayerArrivedAtJobRouteLocation() {
sendNetworkEventToServer("vrr.arrivedAtJobRouteLocation");
}
// ===========================================================================
function tellServerItemActionDelayComplete() {
sendNetworkEventToServer("vrr.itemActionDelayComplete");
}
// ===========================================================================
function sendServerClientInfo() {
let clientVersion = "0.0.0.0";
if(typeof CLIENT_VERSION_MAJOR != "undefined") {
clientVersion = `${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_PATCH}.${CLIENT_VERSION_BUILD}`;
}
sendNetworkEventToServer("vrr.clientInfo", clientVersion, game.width, game.height);
}
// ===========================================================================
function sendServerNewAFKStatus(state) {
sendNetworkEventToServer("vrr.afk", state);
}
// ===========================================================================
function anchorBoat(vehicleId) {
}
// ===========================================================================
function setEnterPropertyKey(key) {
enterPropertyKey = key;
}
// ===========================================================================
function serverRequestedClientInfo() {
sendServerClientInfo();
}
// ===========================================================================
function updateInteriorLightsState(state) {
interiorLightsEnabled = state;
}
// ===========================================================================
function forceSyncElementProperties(elementId) {
if(getElementFromId(elementId) == null) {
return false;
}
syncElementProperties(getElementFromId(elementId));
}
// ===========================================================================
function setElementCollisionsEnabled(elementId, state) {
if(getElementFromId(elementId) == null) {
return false;
}
getElementFromId(elementId).collisionsEnabled = state;
}
// ===========================================================================
function setLocalPlayerArmour(armour) {
if(typeof localPlayer.armour != "undefined") {
localPlayer.armour = armour;
}
}
// ===========================================================================
function setLocalPlayerWantedLevel(wantedLevel) {
forceWantedLevel = toInteger(wantedLevel);
}
// ===========================================================================
function setLogLevel(level) {
logLevel = level;
}
// ===========================================================================
function setLocalPlayerInfiniteRun(state) {
if(localPlayer != null) {
if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), boolToInt(state));
}
}
}
// ===========================================================================
function setLocalPlayerSkin(skinId) {
logToConsole(LOG_INFO, `[VRR.Server] Setting locale player skin to ${skinId}`);
if(getGame() == VRR_GAME_GTA_IV) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
} else {
localPlayer.skin = skinId;
}
}
// ===========================================================================
function makePedHoldObject(pedId, modelIndex) {
if(getGame() == VRR_GAME_GTA_IV) {
natives.givePedAmbientObject(natives.getPedFromNetworkId(pedId), getGameConfig().objects[getGame()][modelIndex][1])
}
}
// ===========================================================================
function sendLocalPlayerNetworkIdToServer() {
sendNetworkEventToServer("vrr.playerPedId", natives.getNetworkIdFromPed(localPlayer));
}
// ===========================================================================
function setCutsceneInterior(cutsceneName) {
if(getGame() == VRR_GAME_GTA_IV) {
if(cutsceneName == "") {
natives.clearCutscene();
} else {
if(natives.isInteriorScene()) {
natives.clearCutscene();
}
natives.initCutscene(cutsceneName);
}
}
}
// ===========================================================================
function makeLocalPlayerPedSpeak(speechName) {
if(getGame() == VRR_GAME_GTA_IV) {
// if player is in vehicle, allow megaphone (if last arg is "1", it will cancel megaphone echo)
// Only speeches with _MEGAPHONE will have the bullhorn effect
// Afaik it only works on police voices anyway
if(localPlayer.vehicle != null) {
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 0);
} else {
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 1);
}
} else if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
// Don't have a way to get the ped ref ID and can't use ped in arg
//game.SET_CHAR_SAY(game.GET_PLAYER_ID(), int);
}
}
// ===========================================================================
function setLocalPlayerAsCopState(state) {
if(getGame() == VRR_GAME_GTA_IV) {
natives.setPlayerAsCop(natives.getPlayerId(), state);
natives.setPoliceIgnorePlayer(natives.getPlayerId(), state);
}
}
// ===========================================================================
function serverRequestedLocalPlayerSpawn(skinId, position) {
if(getGame() == VRR_GAME_GTA_IV) {
natives.createPlayer(skinId, position);
//if(isCustomCameraSupported()) {
// game.restoreCamera(true);
//}
}
}
// ===========================================================================
function sendLocaleSelectToServer(localeId) {
sendNetworkEventToServer("vrr.localeSelect", localeId);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: skin-select.js // FILE: skin-select.js
// DESC: Provides skin-selector functions and usage // DESC: Provides skin-selector functions and usage
@@ -45,31 +44,53 @@ function loadSkinSelectMessageFontBottom() {
// =========================================================================== // ===========================================================================
function processSkinSelectKeyPress(keyCode) { function processSkinSelectKeyPress(keyCode) {
if (usingSkinSelector) { if(usingSkinSelector) {
if (keyCode == SDLK_LEFT || keyCode == SDLK_A) { if(keyCode == SDLK_PAGEUP) {
if (skinSelectorIndex >= allowedSkins.length - 1) { if(skinSelectorIndex >= allowedSkins.length-1) {
skinSelectorIndex = 1; skinSelectorIndex = 1;
} else { } else {
skinSelectorIndex = skinSelectorIndex + 1; skinSelectorIndex = skinSelectorIndex + 1;
} }
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`); logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1]; skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
setLocalPlayerSkin(allowedSkins[skinSelectorIndex][0]); if(getGame() == VRR_GAME_GTA_IV) {
} else if (keyCode == SDLK_RIGHT || keyCode == SDLK_D) { let skinId = allowedSkins[skinSelectorIndex][0];
if (skinSelectorIndex <= 0) { if(natives.isModelInCdimage(skinId)) {
skinSelectorIndex = allowedSkins.length - 1; natives.requestModel(skinId);
natives.loadAllObjectsNow();
if(natives.hasModelLoaded(skinId)) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
}
}
} else {
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
}
} else if(keyCode == SDLK_PAGEDOWN) {
if(skinSelectorIndex <= 0) {
skinSelectorIndex = allowedSkins.length-1;
} else { } else {
skinSelectorIndex = skinSelectorIndex - 1; skinSelectorIndex = skinSelectorIndex - 1;
} }
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`); logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1]; skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
setLocalPlayerSkin(allowedSkins[skinSelectorIndex][0]); if(getGame() == VRR_GAME_GTA_IV) {
} else if (keyCode == SDLK_RETURN) { let skinId = allowedSkins[skinSelectorIndex][0];
sendNetworkEventToServer("agrp.skinSelected", skinSelectorIndex); if(natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId);
natives.loadAllObjectsNow();
if(natives.hasModelLoaded(skinId)) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
}
}
} else {
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
}
} else if(keyCode == SDLK_RETURN) {
sendNetworkEventToServer("vrr.skinSelected", skinSelectorIndex);
toggleSkinSelect(false); toggleSkinSelect(false);
return true; return true;
} else if (keyCode == SDLK_BACKSPACE) { } else if(keyCode == SDLK_BACKSPACE) {
sendNetworkEventToServer("agrp.skinSelected", -1); sendNetworkEventToServer("vrr.skinSelected", -1);
toggleSkinSelect(false); toggleSkinSelect(false);
return true; return true;
} }
@@ -80,11 +101,11 @@ function processSkinSelectKeyPress(keyCode) {
// =========================================================================== // ===========================================================================
function processSkinSelectRendering() { function processSkinSelectRendering() {
if (usingSkinSelector) { if(usingSkinSelector) {
if (skinSelectMessageFontTop != null && skinSelectMessageFontBottom != null) { if(skinSelectMessageFontTop != null && skinSelectMessageFontBottom != null) {
if (skinSelectMessageTextTop != "" && skinSelectMessageTextBottom != "") { if(skinSelectMessageTextTop != "" && skinSelectMessageTextBottom != "") {
skinSelectMessageFontTop.render(skinSelectMessageTextTop, [0, game.height - 100], game.width, 0.5, 0.0, skinSelectMessageFontTop.size, skinSelectMessageColourTop, true, true, false, true); skinSelectMessageFontTop.render(skinSelectMessageTextTop, [0, game.height-100], game.width, 0.5, 0.0, skinSelectMessageFontTop.size, skinSelectMessageColourTop, true, true, false, true);
skinSelectMessageFontBottom.render(skinSelectMessageTextBottom, [0, game.height - 65], game.width, 0.5, 0.0, skinSelectMessageFontBottom.size, skinSelectMessageColourBottom, true, true, false, true); skinSelectMessageFontBottom.render(skinSelectMessageTextBottom, [0, game.height-65], game.width, 0.5, 0.0, skinSelectMessageFontBottom.size, skinSelectMessageColourBottom, true, true, false, true);
} }
} }
} }
@@ -93,9 +114,9 @@ function processSkinSelectRendering() {
// =========================================================================== // ===========================================================================
function toggleSkinSelect(state) { function toggleSkinSelect(state) {
if (state) { if(state) {
skinSelectorIndex = getAllowedSkinIndexFromSkin(localPlayer.skin); skinSelectorIndex = getAllowedSkinIndexFromSkin(localPlayer.skin);
if (!skinSelectorIndex) { if(!skinSelectorIndex) {
skinSelectorIndex = 0; skinSelectorIndex = 0;
} }
@@ -103,19 +124,19 @@ function toggleSkinSelect(state) {
skinSelectPosition = localPlayer.position; skinSelectPosition = localPlayer.position;
skinSelectHeading = localPlayer.heading; skinSelectHeading = localPlayer.heading;
if (isCustomCameraSupported()) { if(isCustomCameraSupported()) {
let tempPosition = localPlayer.position; let tempPosition = localPlayer.position;
tempPosition.z += 0.5; tempPosition.z += 0.5;
let frontCameraPosition = getPosInFrontOfPos(tempPosition, localPlayer.heading, 3); let frontCameraPosition = getPosInFrontOfPos(tempPosition, localPlayer.heading, 3);
game.setCameraLookAt(frontCameraPosition, localPlayer.position, true); game.setCameraLookAt(frontCameraPosition, localPlayer.position, true);
} }
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
let skinId = allowedSkins[skinSelectorIndex][0]; let skinId = allowedSkins[skinSelectorIndex][0];
if (natives.isModelInCdimage(skinId)) { if(natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId); natives.requestModel(skinId);
natives.loadAllObjectsNow(); natives.loadAllObjectsNow();
if (natives.hasModelLoaded(skinId)) { if(natives.hasModelLoaded(skinId)) {
natives.changePlayerModel(natives.getPlayerId(), skinId); natives.changePlayerModel(natives.getPlayerId(), skinId);
} }
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: startup.js // FILE: startup.js
// DESC: Provides startup/shutdown procedures // DESC: Provides startup/shutdown procedures
@@ -26,8 +25,8 @@ function initClientScripts() {
// =========================================================================== // ===========================================================================
function setUpInitialGame() { function setUpInitialGame() {
if (getGame() == AGRP_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA III ..."); logToConsole(LOG_DEBUG|LOG_WARN, "Setting up initial game stuff for GTA III ...");
// Turn off unlimited sprint // Turn off unlimited sprint
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), 0); game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), 0);
@@ -45,8 +44,8 @@ function setUpInitialGame() {
// Provided by mouse camera script (mousecam.js) // Provided by mouse camera script (mousecam.js)
SetStandardControlsEnabled(true); SetStandardControlsEnabled(true);
} else if (getGame() == AGRP_GAME_GTA_VC) { } else if(getGame() == VRR_GAME_GTA_VC) {
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA Vice City ..."); logToConsole(LOG_DEBUG|LOG_WARN, "Setting up initial game stuff for GTA Vice City ...");
// Turn off unlimited sprint // Turn off unlimited sprint
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), 0); game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), 0);
@@ -88,8 +87,8 @@ function setUpInitialGame() {
// Provided by mouse camera script (mousecam.js) // Provided by mouse camera script (mousecam.js)
SetStandardControlsEnabled(true); SetStandardControlsEnabled(true);
} else if (getGame() == AGRP_GAME_GTA_SA) { } else if(getGame() == VRR_GAME_GTA_SA) {
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA San Andreas ..."); logToConsole(LOG_DEBUG|LOG_WARN, "Setting up initial game stuff for GTA San Andreas ...");
// Turn weapon skills down a bit // Turn weapon skills down a bit
game.setGameStat(STAT_WEAPONTYPE_PISTOL_SKILL, 400); game.setGameStat(STAT_WEAPONTYPE_PISTOL_SKILL, 400);
game.setGameStat(STAT_WEAPONTYPE_PISTOL_SILENCED_SKILL, 400); game.setGameStat(STAT_WEAPONTYPE_PISTOL_SILENCED_SKILL, 400);
@@ -125,7 +124,7 @@ function setUpInitialGame() {
// Disables taxi/vigilante/etc and other start mission triggers // Disables taxi/vigilante/etc and other start mission triggers
game.onMission = true; game.onMission = true;
} else if (getGame() == AGRP_GAME_GTA_IV) { } else if(getGame() == VRR_GAME_GTA_IV) {
natives.allowEmergencyServices(false); natives.allowEmergencyServices(false);
natives.setCreateRandomCops(true); natives.setCreateRandomCops(true);
natives.setMaxWantedLevel(0); natives.setMaxWantedLevel(0);
@@ -187,7 +186,7 @@ function setUpInitialGame() {
// Some last steps // Some last steps
//natives.loadAllObjectsNow(); //natives.loadAllObjectsNow();
} else if (getGame() == AGRP_GAME_MAFIA_ONE) { } else if(getGame() == VRR_GAME_MAFIA_ONE) {
game.mapEnabled = false; game.mapEnabled = false;
game.setTrafficEnabled(false); game.setTrafficEnabled(false);
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: sync.js // FILE: sync.js
// DESC: Provides some elements and data sync // DESC: Provides some elements and data sync
@@ -9,37 +8,37 @@
// =========================================================================== // ===========================================================================
function processSync(event, deltaTime) { function processSync(event, deltaTime) {
if (localPlayer != null) { if(localPlayer != null) {
if (!areServerElementsSupported()) { if(!areServerElementsSupported()) {
sendNetworkEventToServer("agrp.plr.pos", (localPlayer.vehicle != null) ? localPlayer.vehicle.position : localPlayer.position); sendNetworkEventToServer("vrr.plr.pos", (localPlayer.vehicle != null) ? localPlayer.vehicle.position : localPlayer.position);
sendNetworkEventToServer("agrp.plr.rot", (localPlayer.vehicle != null) ? localPlayer.vehicle.heading : localPlayer.heading); sendNetworkEventToServer("vrr.plr.rot", (localPlayer.vehicle != null) ? localPlayer.vehicle.heading : localPlayer.heading);
//if(localPlayer.vehicle != null) { //if(localPlayer.vehicle != null) {
// sendNetworkEventToServer("agrp.veh.pos", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.position); // sendNetworkEventToServer("vrr.veh.pos", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.position);
// sendNetworkEventToServer("agrp.veh.rot", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.heading); // sendNetworkEventToServer("vrr.veh.rot", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.heading);
//} //}
} }
if (localPlayer.health <= 0) { if(localPlayer.health <= 0) {
if (!calledDeathEvent) { if(!calledDeathEvent) {
logToConsole(LOG_DEBUG, `Local player died`); logToConsole(LOG_DEBUG, `Local player died`);
localPlayer.clearWeapons(); localPlayer.clearWeapons();
calledDeathEvent = true; calledDeathEvent = true;
sendNetworkEventToServer("agrp.playerDeath"); sendNetworkEventToServer("vrr.playerDeath");
} }
} }
} }
if (localPlayer.health <= 0) { if(localPlayer.health <= 0) {
if (!calledDeathEvent) { if(!calledDeathEvent) {
logToConsole(LOG_DEBUG, `Local player died`); logToConsole(LOG_DEBUG, `Local player died`);
localPlayer.clearWeapons(); localPlayer.clearWeapons();
calledDeathEvent = true; calledDeathEvent = true;
sendNetworkEventToServer("agrp.playerDeath"); sendNetworkEventToServer("vrr.playerDeath");
} }
} }
if (streamingRadioElement) { if(streamingRadioElement) {
streamingRadio.position = getElementPosition(streamingRadioElement.id); streamingRadio.position = getElementPosition(streamingRadioElement.id);
//streamingRadio.volume = getStreamingRadioVolumeForPosition(streamingRadio.position); //streamingRadio.volume = getStreamingRadioVolumeForPosition(streamingRadio.position);
} }
@@ -47,21 +46,27 @@ function processSync(event, deltaTime) {
// =========================================================================== // ===========================================================================
function setVehicleEngine(vehicleId, state) {
getElementFromId(vehicleId).engine = state;
}
// ===========================================================================
function setVehicleLights(vehicleId, state) { function setVehicleLights(vehicleId, state) {
if (getGame() != AGRP_GAME_MAFIA_ONE) { if(getGame() != VRR_GAME_MAFIA_ONE) {
if (!state) { if(!state) {
getElementFromId(vehicleId).lightStatus = 2; getElementFromId(vehicleId).lightStatus = 2;
} else { } else {
getElementFromId(vehicleId).lightStatus = 1; getElementFromId(vehicleId).lightStatus = 1;
} }
} else if (getGame() == AGRP_GAME_GTA_IV) { } else if(getGame() == VRR_GAME_GTA_IV) {
if (!state) { if(!state) {
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0)); natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0));
} else { } else {
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 1)); natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 1));
} }
} else { } else {
if (!state) { if(!state) {
getElementFromId(vehicleId).lights = false; getElementFromId(vehicleId).lights = false;
} else { } else {
getElementFromId(vehicleId).lights = true; getElementFromId(vehicleId).lights = true;
@@ -78,72 +83,72 @@ function repairVehicle(syncId) {
// =========================================================================== // ===========================================================================
function syncVehicleProperties(vehicle) { function syncVehicleProperties(vehicle) {
if (!areServerElementsSupported()) { if(!areServerElementsSupported()) {
return false; return false;
} }
if (doesEntityDataExist(vehicle, "agrp.lights")) { if(doesEntityDataExist(vehicle, "vrr.lights")) {
let lightStatus = getEntityData(vehicle, "agrp.lights"); let lightStatus = getEntityData(vehicle, "vrr.lights");
if (!lightStatus) { if(!lightStatus) {
vehicle.lightStatus = 2; vehicle.lightStatus = 2;
} else { } else {
vehicle.lightStatus = 1; vehicle.lightStatus = 1;
} }
} }
if (doesEntityDataExist(vehicle, "agrp.invincible")) { if(doesEntityDataExist(vehicle, "vrr.invincible")) {
let invincible = getEntityData(vehicle, "agrp.invincible"); let invincible = getEntityData(vehicle, "vrr.invincible");
element.setProofs(invincible, invincible, invincible, invincible, invincible); element.setProofs(invincible, invincible, invincible, invincible, invincible);
} }
if (doesEntityDataExist(vehicle, "agrp.panelStatus")) { if(doesEntityDataExist(vehicle, "vrr.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "agrp.panelStatus"); let panelsStatus = getEntityData(vehicle, "vrr.panelStatus");
for (let i in panelsStatus) { for(let i in panelsStatus) {
vehicle.setPanelStatus(i, panelsStatus[i]); vehicle.setPanelStatus(i, panelsStatus[i]);
} }
} }
if (doesEntityDataExist(vehicle, "agrp.wheelStatus")) { if(doesEntityDataExist(vehicle, "vrr.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "agrp.wheelStatus"); let wheelsStatus = getEntityData(vehicle, "vrr.wheelStatus");
for (let i in wheelsStatus) { for(let i in wheelsStatus) {
vehicle.setWheelStatus(i, wheelsStatus[i]); vehicle.setWheelStatus(i, wheelsStatus[i]);
} }
} }
if (doesEntityDataExist(vehicle, "agrp.lightStatus")) { if(doesEntityDataExist(vehicle, "vrr.lightStatus")) {
let lightStatus = getEntityData(vehicle, "agrp.lightStatus"); let lightStatus = getEntityData(vehicle, "vrr.lightStatus");
for (let i in lightStatus) { for(let i in lightStatus) {
vehicle.setLightStatus(i, lightStatus[i]); vehicle.setLightStatus(i, lightStatus[i]);
} }
} }
if (doesEntityDataExist(vehicle, "agrp.suspensionHeight")) { if(doesEntityDataExist(vehicle, "vrr.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "agrp.suspensionHeight"); let suspensionHeight = getEntityData(vehicle, "vrr.suspensionHeight");
vehicle.setSuspensionHeight(suspensionHeight); vehicle.setSuspensionHeight(suspensionHeight);
} }
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
//let allUpgrades = getGameConfig().vehicleUpgrades[getGame()]; //let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
//for(let i in allUpgrades) { //for(let i in allUpgrades) {
// vehicle.removeUpgrade(i); // vehicle.removeUpgrade(i);
//} //}
if (doesEntityDataExist(vehicle, "agrp.upgrades")) { if(doesEntityDataExist(vehicle, "vrr.upgrades")) {
let upgrades = getEntityData(vehicle, "agrp.upgrades"); let upgrades = getEntityData(vehicle, "vrr.upgrades");
for (let i in upgrades) { for(let i in upgrades) {
if (upgrades[i] != 0) { if(upgrades[i] != 0) {
vehicle.addUpgrade(upgrades[i]); vehicle.addUpgrade(upgrades[i]);
} }
} }
} }
} }
if (getGame() == AGRP_GAME_GTA_SA || getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(vehicle, "agrp.livery")) { if(doesEntityDataExist(vehicle, "vrr.livery")) {
let livery = getEntityData(vehicle, "agrp.livery"); let livery = getEntityData(vehicle, "vrr.livery");
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
vehicle.setPaintJob(livery); vehicle.setPaintJob(livery);
} else if (getGame() == AGRP_GAME_GTA_IV) { } else if(getGame() == VRR_GAME_GTA_IV) {
vehicle.livery = livery; vehicle.livery = livery;
} }
} }
@@ -153,13 +158,13 @@ function syncVehicleProperties(vehicle) {
// =========================================================================== // ===========================================================================
function syncCivilianProperties(civilian) { function syncCivilianProperties(civilian) {
if (!areServerElementsSupported()) { if(!areServerElementsSupported()) {
return false; return false;
} }
if (getGame() == AGRP_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "agrp.scale")) { if(doesEntityDataExist(civilian, "vrr.scale")) {
let scaleFactor = getEntityData(civilian, "agrp.scale"); let scaleFactor = getEntityData(civilian, "vrr.scale");
let tempMatrix = civilian.matrix; let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z)); tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = civilian.position; let tempPosition = civilian.position;
@@ -169,79 +174,79 @@ function syncCivilianProperties(civilian) {
} }
} }
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
if (doesEntityDataExist(civilian, "agrp.fightStyle")) { if(doesEntityDataExist(civilian, "vrr.fightStyle")) {
let fightStyle = getEntityData(civilian, "agrp.fightStyle"); let fightStyle = getEntityData(civilian, "vrr.fightStyle");
civilian.setFightStyle(fightStyle[0], fightStyle[1]); civilian.setFightStyle(fightStyle[0], fightStyle[1]);
} }
} }
if (getGame() == AGRP_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "agrp.walkStyle")) { if(doesEntityDataExist(civilian, "vrr.walkStyle")) {
let walkStyle = getEntityData(civilian, "agrp.walkStyle"); let walkStyle = getEntityData(civilian, "vrr.walkStyle");
civilian.walkStyle = walkStyle; civilian.walkStyle = walkStyle;
} }
} }
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(civilian, "agrp.bodyPropHair")) { if(doesEntityDataExist(civilian, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "agrp.bodyPropHair"); let bodyPropHair = getEntityData(civilian, "vrr.bodyPropHair");
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]); civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropHead")) { if(doesEntityDataExist(civilian, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "agrp.bodyPropHead"); let bodyPropHead = getEntityData(civilian, "vrr.bodyPropHead");
civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]); civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropEyes")) { if(doesEntityDataExist(civilian, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "agrp.bodyPropEyes"); let bodyPropEyes = getEntityData(civilian, "vrr.bodyPropEyes");
civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]); civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftHand")) { if(doesEntityDataExist(civilian, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "agrp.bodyPropLeftHand"); let bodyPropLeftHand = getEntityData(civilian, "vrr.bodyPropLeftHand");
civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]); civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropRightHand")) { if(doesEntityDataExist(civilian, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "agrp.bodyPropRightHand"); let bodyPropRightHand = getEntityData(civilian, "vrr.bodyPropRightHand");
civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]); civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftWrist")) { if(doesEntityDataExist(civilian, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "agrp.bodyPropLeftWrist"); let bodyPropLeftWrist = getEntityData(civilian, "vrr.bodyPropLeftWrist");
civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]); civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropRightWrist")) { if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "agrp.bodyPropRightWrist"); let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]); civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropRightWrist")) { if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "agrp.bodyPropRightWrist"); let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]); civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropHip")) { if(doesEntityDataExist(civilian, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "agrp.bodyPropHip"); let bodyPropHip = getEntityData(civilian, "vrr.bodyPropHip");
civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]); civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftFoot")) { if(doesEntityDataExist(civilian, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "agrp.bodyPropLeftFoot"); let bodyPropLeftFoot = getEntityData(civilian, "vrr.bodyPropLeftFoot");
civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]); civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
} }
if (doesEntityDataExist(civilian, "agrp.bodyPropRightFoot")) { if(doesEntityDataExist(civilian, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "agrp.bodyPropRightFoot"); let bodyPropRightFoot = getEntityData(civilian, "vrr.bodyPropRightFoot");
civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]); civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
} }
} }
if (doesEntityDataExist(civilian, "agrp.anim")) { if(doesEntityDataExist(civilian, "vrr.anim")) {
let animationSlot = getEntityData(civilian, "agrp.anim"); let animationSlot = getEntityData(civilian, "vrr.anim");
let animationData = getAnimationData(animationSlot); let animationData = getAnimationData(animationSlot);
civilian.addAnimation(animationData.groupId, animationData.animId); civilian.addAnimation(animationData.groupId, animationData.animId);
} }
@@ -250,13 +255,13 @@ function syncCivilianProperties(civilian) {
// =========================================================================== // ===========================================================================
function syncPlayerProperties(player) { function syncPlayerProperties(player) {
if (!areServerElementsSupported()) { if(!areServerElementsSupported()) {
return false; return false;
} }
if (getGame() == AGRP_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(player, "agrp.scale")) { if(doesEntityDataExist(player, "vrr.scale")) {
let scaleFactor = getEntityData(player, "agrp.scale"); let scaleFactor = getEntityData(player, "vrr.scale");
let tempMatrix = player.matrix; let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z)); tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = player.position; let tempPosition = player.position;
@@ -266,95 +271,95 @@ function syncPlayerProperties(player) {
} }
} }
if (getGame() == AGRP_GAME_GTA_SA) { if(getGame() == VRR_GAME_GTA_SA) {
if (doesEntityDataExist(player, "agrp.fightStyle")) { if(doesEntityDataExist(player, "vrr.fightStyle")) {
let fightStyle = getEntityData(player, "agrp.fightStyle"); let fightStyle = getEntityData(player, "vrr.fightStyle");
player.setFightStyle(fightStyle[0], fightStyle[1]); player.setFightStyle(fightStyle[0], fightStyle[1]);
} }
} }
//if(getGame() == AGRP_GAME_GTA_SA) { //if(getGame() == VRR_GAME_GTA_SA) {
// if(doesEntityDataExist(player, "agrp.walkStyle")) { // if(doesEntityDataExist(player, "vrr.walkStyle")) {
// let walkStyle = getEntityData(player, "agrp.walkStyle"); // let walkStyle = getEntityData(player, "vrr.walkStyle");
// player.walkStyle = walkStyle; // player.walkStyle = walkStyle;
// } // }
//} //}
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(player, "agrp.bodyPartHair")) { if(doesEntityDataExist(player, "vrr.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "agrp.bodyPartHair"); let bodyPartHead = getEntityData(player, "vrr.bodyPartHair");
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]); player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPartHead")) { if(doesEntityDataExist(player, "vrr.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "agrp.bodyPartHead"); let bodyPartHead = getEntityData(player, "vrr.bodyPartHead");
player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]); player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPartUpper")) { if(doesEntityDataExist(player, "vrr.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "agrp.bodyPartUpper"); let bodyPartUpper = getEntityData(player, "vrr.bodyPartUpper");
player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]); player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPartLower")) { if(doesEntityDataExist(player, "vrr.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "agrp.bodyPartLower"); let bodyPartLower = getEntityData(player, "vrr.bodyPartLower");
player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]); player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]);
} }
} }
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(player, "agrp.bodyPropHair")) { if(doesEntityDataExist(player, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "agrp.bodyPropHair"); let bodyPropHair = getEntityData(player, "vrr.bodyPropHair");
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]); player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropHead")) { if(doesEntityDataExist(player, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "agrp.bodyPropHead"); let bodyPropHead = getEntityData(player, "vrr.bodyPropHead");
player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]); player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropEyes")) { if(doesEntityDataExist(player, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "agrp.bodyPropEyes"); let bodyPropEyes = getEntityData(player, "vrr.bodyPropEyes");
player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]); player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropLeftHand")) { if(doesEntityDataExist(player, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "agrp.bodyPropLeftHand"); let bodyPropLeftHand = getEntityData(player, "vrr.bodyPropLeftHand");
player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]); player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropRightHand")) { if(doesEntityDataExist(player, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "agrp.bodyPropRightHand"); let bodyPropRightHand = getEntityData(player, "vrr.bodyPropRightHand");
player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]); player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropLeftWrist")) { if(doesEntityDataExist(player, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "agrp.bodyPropLeftWrist"); let bodyPropLeftWrist = getEntityData(player, "vrr.bodyPropLeftWrist");
player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]); player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropRightWrist")) { if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "agrp.bodyPropRightWrist"); let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]); player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropRightWrist")) { if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "agrp.bodyPropRightWrist"); let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]); player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropHip")) { if(doesEntityDataExist(player, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "agrp.bodyPropHip"); let bodyPropHip = getEntityData(player, "vrr.bodyPropHip");
player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]); player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropLeftFoot")) { if(doesEntityDataExist(player, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "agrp.bodyPropLeftFoot"); let bodyPropLeftFoot = getEntityData(player, "vrr.bodyPropLeftFoot");
player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]); player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
} }
if (doesEntityDataExist(player, "agrp.bodyPropRightFoot")) { if(doesEntityDataExist(player, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "agrp.bodyPropRightFoot"); let bodyPropRightFoot = getEntityData(player, "vrr.bodyPropRightFoot");
player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]); player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
} }
} }
@@ -363,18 +368,18 @@ function syncPlayerProperties(player) {
// =========================================================================== // ===========================================================================
function syncElementProperties(element) { function syncElementProperties(element) {
if (!areServerElementsSupported()) { if(!areServerElementsSupported()) {
return false; return false;
} }
if (doesEntityDataExist(element, "agrp.interior")) { if(doesEntityDataExist(element, "vrr.interior")) {
if (typeof element.interior != "undefined") { if(typeof element.interior != "undefined") {
element.interior = getEntityData(element, "agrp.interior"); element.interior = getEntityData(element, "vrr.interior");
} }
} }
if (getGame() == AGRP_GAME_MAFIA_ONE) { if(getGame() == VRR_GAME_MAFIA_ONE) {
switch (element.type) { switch(element.type) {
case ELEMENT_VEHICLE: case ELEMENT_VEHICLE:
syncVehicleProperties(element); syncVehicleProperties(element);
break; break;
@@ -391,7 +396,7 @@ function syncElementProperties(element) {
break; break;
} }
} else { } else {
switch (element.type) { switch(element.type) {
case ELEMENT_VEHICLE: case ELEMENT_VEHICLE:
syncVehicleProperties(element); syncVehicleProperties(element);
break; break;
@@ -414,7 +419,7 @@ function syncElementProperties(element) {
// =========================================================================== // ===========================================================================
function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupModel, hasInterior) { function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupModel, hasInterior) {
if (getGame() == AGRP_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
} }
} }
@@ -422,11 +427,11 @@ function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupMode
// =========================================================================== // ===========================================================================
function setLocalPlayerPedPartsAndProps(parts, props) { function setLocalPlayerPedPartsAndProps(parts, props) {
for (let i in parts) { for(let i in parts) {
localPlayer.changeBodyPart(parts[i][0], parts[i][1], parts[i][2]); localPlayer.changeBodyPart(parts[i][0], parts[i][1], parts[i][2]);
} }
for (let j in props) { for(let j in props) {
localPlayer.changeBodyProp(props[j][0], props[j][1]); localPlayer.changeBodyProp(props[j][0], props[j][1]);
} }
} }

View File

@@ -1,8 +0,0 @@
function getCurrentUnixTimeStampSquirrel() {
return time();
}
function getTimeStampOutput(timeStamp) {
local dateObj = date(timeStamp);
return dateObj.hour + ":" + dateObj.minute + ":" + dateObj.second;
}

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: utilities.js // FILE: utilities.js
// DESC: Provides util functions and arrays with data // DESC: Provides util functions and arrays with data
@@ -18,9 +17,9 @@ function setLocalPlayerFrozenState(state) {
function setLocalPlayerControlState(controlState, cursorState = false) { function setLocalPlayerControlState(controlState, cursorState = false) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`);
controlsEnabled = controlState; controlsEnabled = controlState;
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) { if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
game.SET_PLAYER_CONTROL(game.GET_PLAYER_ID(), boolToInt(controlState)); game.SET_PLAYER_CONTROL(game.GET_PLAYER_ID(), boolToInt(controlState));
} else if (getGame() != AGRP_GAME_GTA_IV) { } else if (getGame() != VRR_GAME_GTA_IV) {
setElementCollisionsEnabled(localPlayer, controlState); setElementCollisionsEnabled(localPlayer, controlState);
setPedInvincible(localPlayer, true); setPedInvincible(localPlayer, true);
} }
@@ -48,7 +47,7 @@ function removeLocalPlayerFromVehicle() {
function restoreLocalCamera() { function restoreLocalCamera() {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Camera restored`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Camera restored`);
if (isGameFeatureSupported("customCamera")) { if (isCustomCameraSupported()) {
game.restoreCamera(true); game.restoreCamera(true);
} }
}; };
@@ -76,9 +75,9 @@ function setCityAmbienceState(state, clearElements = false) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`);
game.setTrafficEnabled(state); game.setTrafficEnabled(state);
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) { if (getMultiplayerMod() == VRR_MPMOD_GTAC) {
game.setGenerateCarsAroundCamera(state); game.setGenerateCarsAroundCamera(state);
if (getGame() != AGRP_GAME_GTA_SA) { if (getGame() != VRR_GAME_GTA_SA) {
game.setCiviliansEnabled(state); game.setCiviliansEnabled(state);
} }
@@ -96,7 +95,7 @@ function runClientCode(code, returnTo) {
try { try {
returnValue = eval("(" + code + ")"); returnValue = eval("(" + code + ")");
} catch (error) { } catch (error) {
sendNetworkEventToServer("agrp.runCodeFail", returnTo, error.toString()); sendNetworkEventToServer("vrr.runCodeFail", returnTo, error.toString());
return false; return false;
} }
let returnValueString = returnValue; let returnValueString = returnValue;
@@ -105,7 +104,7 @@ function runClientCode(code, returnTo) {
} else { } else {
returnValueString = "null/undefined"; returnValueString = "null/undefined";
} }
sendNetworkEventToServer("agrp.runCodeSuccess", returnTo, returnValueString); sendNetworkEventToServer("vrr.runCodeSuccess", returnTo, returnValueString);
} }
// =========================================================================== // ===========================================================================
@@ -113,20 +112,19 @@ function runClientCode(code, returnTo) {
function enterVehicleAsPassenger() { function enterVehicleAsPassenger() {
if (localPlayer.vehicle == null) { if (localPlayer.vehicle == null) {
let tempVehicle = getClosestVehicle(localPlayer.position); let tempVehicle = getClosestVehicle(localPlayer.position);
if (getGame() != AGRP_GAME_GTA_IV) { if (getGame() != VRR_GAME_GTA_IV) {
if (tempVehicle != null) { if (tempVehicle != null) {
localPlayer.enterVehicle(tempVehicle, false); localPlayer.enterVehicle(tempVehicle, false);
} }
} } else {
// else { // Disable for now. GTA IV has built-in passenger entry
// Disable for now. GTA IV has built-in passenger entry
//for(let i = 0 ; i <= natives.getMaximumNumberOfPassengers(tempVehicle); i++) { //for(let i = 0 ; i <= natives.getMaximumNumberOfPassengers(tempVehicle); i++) {
// if(natives.isCarPassengerSeatFree(tempVehicle, i)) { // if(natives.isCarPassengerSeatFree(tempVehicle, i)) {
// natives.taskEnterCarAsPassenger(localPlayer, tempVehicle, i, 10000); // natives.taskEnterCarAsPassenger(localPlayer, tempVehicle, i, 10000);
// } // }
//} //}
//} }
} }
} }
@@ -135,13 +133,13 @@ function enterVehicleAsPassenger() {
function giveLocalPlayerWeapon(weaponId, ammo, active) { function giveLocalPlayerWeapon(weaponId, ammo, active) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Giving weapon ${weaponId} with ${ammo} ammo`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Giving weapon ${weaponId} with ${ammo} ammo`);
forceWeapon = weaponId; forceWeapon = weaponId;
if (getGame() == AGRP_GAME_MAFIA_ONE) { if (getGame() == VRR_GAME_MAFIA_ONE) {
localPlayer.giveWeapon(weaponId, 0, ammo); localPlayer.giveWeapon(weaponId, 0, ammo);
forceWeaponAmmo = 0; forceWeaponAmmo = 0;
forceWeaponClipAmmo = ammo; forceWeaponClipAmmo = ammo;
} else { } else {
localPlayer.giveWeapon(weaponId, ammo, active); localPlayer.giveWeapon(weaponId, ammo, active);
if (getGame() < AGRP_GAME_GTA_IV) { if (getGame() < VRR_GAME_GTA_IV) {
forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(weaponId)); forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(weaponId));
forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(weaponId)); forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(weaponId));
} else { } else {
@@ -165,12 +163,6 @@ function clearLocalPlayerWeapons(clearData) {
// =========================================================================== // ===========================================================================
function getClosestVehicle(pos) {
return getElementsByType(ELEMENT_VEHICLE).reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
}
// ===========================================================================
function setLocalPlayerPosition(position) { function setLocalPlayerPosition(position) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting position to ${position.x}, ${position.y}, ${position.z}`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting position to ${position.x}, ${position.y}, ${position.z}`);
if (typeof localPlayer.velocity != "undefined") { if (typeof localPlayer.velocity != "undefined") {
@@ -195,7 +187,7 @@ function setLocalPlayerHeading(heading) {
function setLocalPlayerInterior(interior) { function setLocalPlayerInterior(interior) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting interior to ${interior}`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting interior to ${interior}`);
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) { if (getMultiplayerMod() == VRR_MPMOD_GTAC) {
if (!isGTAIV()) { if (!isGTAIV()) {
localPlayer.interior = interior; localPlayer.interior = interior;
game.cameraInterior = interior; game.cameraInterior = interior;
@@ -213,8 +205,8 @@ function setLocalPlayerInterior(interior) {
if (areServerElementsSupported() && isGameFeatureSupported("interior")) { if (areServerElementsSupported() && isGameFeatureSupported("interior")) {
let vehicles = getElementsByType(ELEMENT_VEHICLE); let vehicles = getElementsByType(ELEMENT_VEHICLE);
for (let i in vehicles) { for (let i in vehicles) {
if (getEntityData(vehicles[i], "agrp.interior")) { if (getEntityData(vehicles[i], "vrr.interior")) {
vehicles[i].interior = getEntityData(vehicles[i], "agrp.interior"); vehicles[i].interior = getEntityData(vehicles[i], "vrr.interior");
} }
} }
} }
@@ -241,7 +233,7 @@ function setLocalPlayerHealth(health) {
function playPedSpeech(pedName, speechId) { function playPedSpeech(pedName, speechId) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Making ${pedName}'s ped talk (${speechId})`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Making ${pedName}'s ped talk (${speechId})`);
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) { if (getMultiplayerMod() == VRR_MPMOD_GTAC) {
game.SET_CHAR_SAY(int, int); game.SET_CHAR_SAY(int, int);
} }
} }
@@ -262,7 +254,7 @@ function getWeaponSlot(weaponId) {
// =========================================================================== // ===========================================================================
function setLocalPlayerDrunkEffect(amount, duration) { function setLocalPlayerDrunkEffect(amount, duration) {
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) { if (getMultiplayerMod() == VRR_MPMOD_GTAC) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Drunk effect set to ${amount} for ${duration} ms`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Drunk effect set to ${amount} for ${duration} ms`);
drunkEffectAmount = 0; drunkEffectAmount = 0;
drunkEffectDurationTimer = setInterval(function () { drunkEffectDurationTimer = setInterval(function () {
@@ -350,15 +342,11 @@ function setPlayerWeaponDamageEnabled(clientName, state) {
function setLocalPlayerCash(amount) { function setLocalPlayerCash(amount) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting local player money`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting local player money`);
if (localPlayer == null) {
return false;
}
if (typeof localPlayer.money != "undefined") { if (typeof localPlayer.money != "undefined") {
localPlayer.money = toInteger(amount); localPlayer.money = toInteger(amount);
} }
if (getGame() == AGRP_GAME_GTA_IV) { if (getGame() == VRR_GAME_GTA_IV) {
natives.setMultiplayerHudCash(amount); natives.setMultiplayerHudCash(amount);
} }
} }
@@ -412,8 +400,8 @@ function processWantedLevelReset() {
function processLocalPlayerVehicleControlState() { function processLocalPlayerVehicleControlState() {
if (areServerElementsSupported()) { if (areServerElementsSupported()) {
if (inVehicle && localPlayer.vehicle != null) { if (inVehicle && localPlayer.vehicle != null) {
if (doesEntityDataExist(localPlayer.vehicle, "agrp.engine")) { if (doesEntityDataExist(localPlayer.vehicle, "vrr.engine")) {
if (getEntityData(localPlayer.vehicle, "agrp.engine") == false) { if (getEntityData(localPlayer.vehicle, "vrr.engine") == false) {
localPlayer.vehicle.engine = false; localPlayer.vehicle.engine = false;
if (!localPlayer.vehicle.engine) { if (!localPlayer.vehicle.engine) {
if (typeof localPlayer.vehicle.velocity != "undefined") { if (typeof localPlayer.vehicle.velocity != "undefined") {
@@ -434,17 +422,52 @@ function processLocalPlayerVehicleControlState() {
// =========================================================================== // ===========================================================================
function processLocalPlayerSphereEntryExitHandling() {
let position = getLocalPlayerPosition();
if (areMarkersSupported()) {
getElementsByType(ELEMENT_MARKER).forEach(function (sphere) {
if (getDistance(position, sphere.position) <= sphere.radius) {
if (!inSphere) {
inSphere = sphere;
triggerEvent("OnLocalPlayerEnterSphere", null, sphere);
}
} else {
if (inSphere) {
inSphere = false;
triggerEvent("OnLocalPlayerExitSphere", null, sphere);
}
}
});
}
}
// ===========================================================================
function processJobRouteSphere() {
if (getGame() == VRR_GAME_GTA_SA) {
let position = getLocalPlayerPosition();
if (jobRouteLocationSphere != null) {
if (getDistance(position, jobRouteLocationSphere.position) <= 2.0) {
enteredJobRouteSphere();
}
}
}
}
// ===========================================================================
function forceLocalPlayerEquippedWeaponItem() { function forceLocalPlayerEquippedWeaponItem() {
if (typeof localPlayer.weapon != "undefined") { if (typeof localPlayer.weapon != "undefined") {
if (forceWeapon != 0) { if (forceWeapon != 0) {
if (localPlayer.weapon != forceWeapon) { if (localPlayer.weapon != forceWeapon) {
localPlayer.weapon = forceWeapon; localPlayer.weapon = forceWeapon;
if (getGame() < AGRP_GAME_GTA_IV) { if (getGame() < VRR_GAME_GTA_IV) {
localPlayer.setWeaponClipAmmunition(getWeaponSlot(forceWeapon), forceWeaponClipAmmo); localPlayer.setWeaponClipAmmunition(getWeaponSlot(forceWeapon), forceWeaponClipAmmo);
localPlayer.setWeaponAmmunition(getWeaponSlot(forceWeapon), forceWeaponAmmo); localPlayer.setWeaponAmmunition(getWeaponSlot(forceWeapon), forceWeaponAmmo);
} }
} else { } else {
//if(getGame() < AGRP_GAME_GTA_IV) { //if(getGame() < VRR_GAME_GTA_IV) {
// forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(forceWeapon)); // forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(forceWeapon));
// forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(forceWeapon)); // forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(forceWeapon));
//} //}
@@ -470,8 +493,26 @@ function getLocalPlayerPosition() {
// =========================================================================== // ===========================================================================
function processLocalPlayerVehicleEntryExitHandling() {
if (localPlayer.vehicle) {
if (!inVehicle) {
inVehicle = localPlayer.vehicle;
inVehicleSeat = getLocalPlayerVehicleSeat();
triggerEvent("OnLocalPlayerEnteredVehicle", inVehicle, inVehicleSeat);
}
} else {
if (inVehicle) {
triggerEvent("OnLocalPlayerExitedVehicle", inVehicle, inVehicleSeat);
inVehicle = false;
inVehicleSeat = false;
}
}
}
// ===========================================================================
function getVehicleForNetworkEvent(vehicle) { function getVehicleForNetworkEvent(vehicle) {
if (getGame() == AGRP_GAME_GTA_IV) { if (getGame() == VRR_GAME_GTA_IV) {
return natives.getNetworkIdFromVehicle(vehicle); return natives.getNetworkIdFromVehicle(vehicle);
} }
return vehicle.id; return vehicle.id;
@@ -543,7 +584,7 @@ function processNearbyPickups() {
//if(pickups[i].interior == localPlayer.interior && pickups[i].dimension == localPlayer.dimension) { //if(pickups[i].interior == localPlayer.interior && pickups[i].dimension == localPlayer.dimension) {
if (currentPickup != pickups[i]) { if (currentPickup != pickups[i]) {
currentPickup = pickups[i]; currentPickup = pickups[i];
sendNetworkEventToServer("agrp.pickup", pickups[i].id); sendNetworkEventToServer("vrr.pickup", pickups[i].id);
} }
//} //}
} }
@@ -554,7 +595,7 @@ function processNearbyPickups() {
// =========================================================================== // ===========================================================================
function processGameSpecifics() { function processGameSpecifics() {
if (getGame() < AGRP_GAME_GTA_IV) { if (getGame() < VRR_GAME_GTA_IV) {
game.clearMessages(); game.clearMessages();
} }
@@ -568,10 +609,3 @@ function getServerData() {
} }
// =========================================================================== // ===========================================================================
function setProfanityFilterState(state) {
profanityFilterEnabled = state;
updateChatBox();
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: vehicle.js // FILE: vehicle.js
// DESC: Provides vehicle functions and arrays with data // DESC: Provides vehicle functions and arrays with data
@@ -30,14 +29,14 @@ class VehicleData {
// =========================================================================== // ===========================================================================
function receiveVehicleFromServer(vehicleId, networkId, position, model, colour1, colour2, colour3 = 0, colour4 = 0, locked = false, lights = false, engine = false, licensePlate = "") { function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2, colour3 = 0, colour4 = 0, locked = false, lights = false, engine = false, licensePlate = "") {
logToConsole(LOG_DEBUG, `[VRR.Vehicle] Received vehicle ${vehicleId} (${getVehicleNameFromModel(model, getGame())}) from server`); logToConsole(LOG_DEBUG, `[VRR.Vehicle] Received vehicle ${vehicleId} (${getVehicleNameFromModel(model, getGame())}) from server`);
if (getGame() != AGRP_GAME_GTA_IV) { if(getGame() != VRR_GAME_GTA_IV) {
return false; return false;
} }
if (getVehicleData(vehicleId) != false) { if(getVehicleData(vehicleId) != false) {
let vehicleData = getVehicleData(vehicleId); let vehicleData = getVehicleData(vehicleId);
//vehicleData.position = position; //vehicleData.position = position;
//vehicleData.heading = heading; //vehicleData.heading = heading;
@@ -50,16 +49,8 @@ function receiveVehicleFromServer(vehicleId, networkId, position, model, colour1
vehicleData.lights = lights; vehicleData.lights = lights;
vehicleData.locked = locked; vehicleData.locked = locked;
vehicleData.licensePlate = ""; vehicleData.licensePlate = "";
vehicleData.networkId = networkId;
if (natives.getVehicleFromNetworkId(vehicleId.ivNetworkId) != null) { let vehicle = natives.getVehicleFromNetworkId(vehicleId.ivNetworkId);
vehicleData.vehicle = natives.getVehicleFromNetworkId(vehicleId.ivNetworkId);
} else {
let vehicle = createGameVehicle(model, position, heading, colour1, colour2, colour3, colour4);
vehicleData.vehicle = vehicle;
sendNetworkEventToServer("agrp.vehicleCreated", vehicleId, natives.getNetworkIdFromVehicle(vehicle));
}
} else { } else {
//logToConsole(LOG_DEBUG, `[VRR.Vehicle] Vehicle ${vehicleId} doesn't exist. Adding ...`); //logToConsole(LOG_DEBUG, `[VRR.Vehicle] Vehicle ${vehicleId} doesn't exist. Adding ...`);
//let tempVehicleData = new VehicleData(vehicleId, name, position, blipModel, pickupModel); //let tempVehicleData = new VehicleData(vehicleId, name, position, blipModel, pickupModel);
@@ -72,20 +63,20 @@ function receiveVehicleFromServer(vehicleId, networkId, position, model, colour1
// =========================================================================== // ===========================================================================
function processVehiclePurchasing() { function processVehiclePurchasing() {
if (vehiclePurchaseState == AGRP_VEHBUYSTATE_TESTDRIVE) { if(vehiclePurchaseState == VRR_VEHBUYSTATE_TESTDRIVE) {
if (getLocalPlayerVehicle() == false) { if(getLocalPlayerVehicle() == false) {
vehiclePurchaseState = AGRP_VEHBUYSTATE_EXITVEH; vehiclePurchaseState = VRR_VEHBUYSTATE_EXITVEH;
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_EXITVEH); sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_EXITVEH);
return false; return false;
} else { } else {
if (vehiclePurchasing == getLocalPlayerVehicle()) { if(vehiclePurchasing == getLocalPlayerVehicle()) {
if (getDistance(getLocalPlayerVehicle().position, vehiclePurchasePosition) >= 25) { if(getDistance(getLocalPlayerVehicle().position, vehiclePurchasePosition) >= 25) {
vehiclePurchaseState = AGRP_VEHBUYSTATE_FARENOUGH; vehiclePurchaseState = VRR_VEHBUYSTATE_FARENOUGH;
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_FARENOUGH); sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_FARENOUGH);
} }
} else { } else {
vehiclePurchaseState = AGRP_VEHBUYSTATE_WRONGVEH; vehiclePurchaseState = VRR_VEHBUYSTATE_WRONGVEH;
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_WRONGVEH); sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_WRONGVEH);
} }
} }
} }
@@ -104,7 +95,7 @@ function processVehicleBurning() {
function setVehiclePurchaseState(state, vehicleId, position) { function setVehiclePurchaseState(state, vehicleId, position) {
vehiclePurchaseState = state; vehiclePurchaseState = state;
if (vehicleId != null) { if(vehicleId != null) {
vehiclePurchasing = getElementFromId(vehicleId); vehiclePurchasing = getElementFromId(vehicleId);
} else { } else {
vehiclePurchasing = null; vehiclePurchasing = null;
@@ -119,9 +110,9 @@ function setVehiclePurchaseState(state, vehicleId, position) {
* @param {number} vehicleId - The ID of the job (initially provided by server) * @param {number} vehicleId - The ID of the job (initially provided by server)
* @return {VehicleData} The vehicle's data (class instance) * @return {VehicleData} The vehicle's data (class instance)
*/ */
function getVehicleData(vehicleId) { function getVehicleData(vehicleId) {
for (let i in getServerData().vehicles) { for(let i in getServerData().vehicles) {
if (getServerData().vehicles[i].vehicleId == vehicleId) { if(getServerData().vehicles[i].vehicleId == vehicleId) {
return getServerData().vehicles[i]; return getServerData().vehicles[i];
} }
} }
@@ -132,45 +123,9 @@ function getVehicleData(vehicleId) {
// =========================================================================== // ===========================================================================
function setAllVehicleDataIndexes() { function setAllVehicleDataIndexes() {
for (let i in getServerData().vehicles) { for(let i in getServerData().vehicles) {
getServerData().vehicles[i].index = i; getServerData().vehicles[i].index = i;
} }
} }
// =========================================================================== // ===========================================================================
function toggleVehicleCruiseControl(vehicle) {
if (!vehicle.isSyncer) {
return false;
}
cruiseControl = !cruiseControl;
}
// ===========================================================================
function getVehicleSpeed(vehicle) {
let matrix = vehicle.matrix;
let frontSpeed = true;
let vecMoveSpeed = vehicle.velocity;
let speed;
if (frontSpeed) {
speed = getDotProduct(vecMoveSpeed[0], vecMoveSpeed[1], vecMoveSpeed[2], matrix.getElement(1 * 4 + 0), matrix.getElement(1 * 4 + 1), matrix.getElement(1 * 4 + 2));
} else {
speed = getLength(vecMoveSpeed[0], vecMoveSpeed[1], vecMoveSpeed[2]);
}
if (getGame() == AGRP_GAME_GTA_IV || getGame() == AGRP_GAME_GTA_IV_EFLC) {
speed /= 40.0;
}
speed = speed * 90;
speed = Math.abs(speed);
return speed;
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: accent.js // FILE: accent.js
// DESC: Provides accent functions and usage // DESC: Provides accent functions and usage
@@ -28,7 +27,7 @@ function doesPlayerHaveAccent(client) {
function getPlayerAccentInlineOutput(client) { function getPlayerAccentInlineOutput(client) {
let outputText = ""; let outputText = "";
if (doesPlayerHaveAccent(client)) { if(doesPlayerHaveAccent(client)) {
outputText = `[${getPlayerAccentText(client)}] `; outputText = `[${getPlayerAccentText(client)}] `;
} }
@@ -38,14 +37,14 @@ function getPlayerAccentInlineOutput(client) {
// =========================================================================== // ===========================================================================
function setAccentCommand(command, params, client) { function setAccentCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let accentId = getAccentFromParams(params); let accentId = getAccentFromParams(params);
if (!accentId) { if(!accentId) {
messagePlayerError(client, getLocaleString(client, "AccentNotFound")); messagePlayerError(client, getLocaleString(client, "AccentNotFound"));
return false; return false;
} }
@@ -65,7 +64,7 @@ function listAccentsCommand(command, params, client) {
let chunkedList = splitArrayIntoChunks(accentList, 8); let chunkedList = splitArrayIntoChunks(accentList, 8);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "AccentsListHeader"))); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "AccentsListHeader")));
for (let i in chunkedList) { for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", ")); messagePlayerInfo(client, chunkedList[i].join(", "));
} }
} }
@@ -73,14 +72,14 @@ function listAccentsCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function getAccentFromParams(params) { function getAccentFromParams(params) {
if (isNaN(params)) { if(isNaN(params)) {
for (let i in getGlobalConfig().accents) { for(let i in getGlobalConfig().accents) {
if (toLowerCase(getGlobalConfig().accents[i]).indexOf(toLowerCase(params)) != -1) { if(toLowerCase(getGlobalConfig().accents[i]).indexOf(toLowerCase(params)) != -1) {
return i; return i;
} }
} }
} else { } else {
if (typeof getGlobalConfig().accents[params] != "undefined") { if(typeof getGlobalConfig().accents[params] != "undefined") {
return toInteger(params); return toInteger(params);
} }
} }
@@ -98,14 +97,14 @@ function reloadAccentConfigurationCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function addAccentCommand(command, params, client) { function addAccentCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let newAccentName = params; let newAccentName = params;
if (getAccentFromParams(newAccentName) != false) { if(getAccentFromParams(newAccentName) != false) {
messagePlayerError(client, `That accent already exists!`) messagePlayerError(client, `That accent already exists!`)
return false; return false;
} }
@@ -118,14 +117,14 @@ function addAccentCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function removeAccentCommand(command, params, client) { function removeAccentCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let newAccentName = params; let newAccentName = params;
if (!getAccentFromParams(newAccentName)) { if(!getAccentFromParams(newAccentName)) {
messagePlayerError(client, `That accent doesn't exist!`) messagePlayerError(client, `That accent doesn't exist!`)
return false; return false;
} }

View File

@@ -1,197 +1,12 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: account.js // FILE: account.js
// DESC: Provides account functions and usage // DESC: Provides account functions and usage
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// Account Contact Types
const AGRP_CONTACT_NONE = 0;
const AGRP_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
const AGRP_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
const AGRP_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
// ===========================================================================
// Account Authentication Methods
const AGRP_ACCT_AUTHMETHOD_NONE = 0; // None
const AGRP_ACCT_AUTHMETHOD_EMAIL = 1; // Email
const AGRP_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
const AGRP_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
const AGRP_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
const AGRP_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
// ===========================================================================
// Two-Factor Authentication States
const AGRP_2FA_STATE_NONE = 0; // None
const AGRP_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
const AGRP_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
const AGRP_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
// ===========================================================================
// Reset Password States
const AGRP_RESETPASS_STATE_NONE = 0; // None
const AGRP_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
const AGRP_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
// ===========================================================================
/**
* @class Representing an account, loaded/saved in the database
*/
class AccountData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.password = "";
this.registerDate = 0;
this.flags = {
moderation: 0,
admin: 0,
};
this.staffTitle = "";
this.ircAccount = "";
this.discordAccount = 0;
this.settings = 0;
this.emailAddress = "";
this.ipAddress = 0;
this.notes = [];
this.messages = [];
this.contacts = [];
this.subAccounts = [];
this.emailVerificationCode = "";
this.twoFactorAuthVerificationCode = "";
this.chatScrollLines = 1;
this.streamingRadioVolume = 20;
this.locale = 0;
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["acct_id"]);
this.name = toString(dbAssoc["acct_name"]);
this.password = toString(dbAssoc["acct_pass"]);
this.registerDate = toInteger(dbAssoc["acct_when_registered"]);
this.flags = {
moderation: toInteger(dbAssoc["acct_svr_mod_flags"]),
admin: toInteger(dbAssoc["acct_svr_staff_flags"]),
};
this.staffTitle = toString(dbAssoc["acct_svr_staff_title"]);
this.ircAccount = toInteger(dbAssoc["acct_irc"]);
this.discordAccount = toInteger(dbAssoc["acct_discord"]);
this.settings = toInteger(dbAssoc["acct_svr_settings"]);
this.emailAddress = toString(dbAssoc["acct_email"]);
this.ipAddress = toString(dbAssoc["acct_ip"]);
this.notes = [];
this.messages = [];
this.contacts = [];
this.subAccounts = [];
this.emailVerificationCode = toString(dbAssoc["acct_code_verifyemail"]);
this.twoFactorAuthVerificationCode = toString(dbAssoc["acct_code_2fa"]);
this.chatScrollLines = toInteger(dbAssoc["acct_svr_chat_scroll_lines"]);
this.streamingRadioVolume = toInteger(dbAssoc["acct_streaming_radio_volume"]);
this.locale = toInteger(dbAssoc["acct_locale"]);
}
}
};
// ===========================================================================
/**
* @class Representing an account's contact list, loaded/saved in the database
*/
class AccountContactData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.accountId = 0;
this.contactAccountId = 0;
this.type = 0;
this.whenAdded = 0;
this.needsSaved = false;
if (dbAssoc) {
this.databaseId = dbAssoc["acct_contact_id"];
this.accountId = dbAssoc["acct_contact_acct"];
this.contactAccountId = dbAssoc["acct_contact_contact"];
this.type = dbAssoc["acct_contact_type"];
this.whenAdded = dbAssoc["acct_contact_when_added"];
}
}
};
// ===========================================================================
/**
* @class Representing an account's messages, loaded/saved in the database
*/
class AccountMessageData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.account = 0;
this.whoSent = 0;
this.whenSent = 0;
this.whenRead = 0;
this.deleted = false;
this.whenDeleted = 0;
this.folder = 0;
this.message = "";
this.needsSaved = false;
if (dbAssoc) {
this.databaseId = dbAssoc["acct_msg_id"];
this.account = dbAssoc["acct_msg_acct"];
this.whoSent = dbAssoc["acct_msg_who_sent"];
this.whenSent = dbAssoc["acct_msg_when_sent"];
this.whenRead = dbAssoc["acct_msg_when_read"];
this.deleted = intToBool(dbAssoc["acct_msg_deleted"]);
this.whenDeleted = dbAssoc["acct_msg_when_deleted"];
this.folder = dbAssoc["acct_msg_folder"];
this.message = dbAssoc["acct_msg_message"];
}
}
};
// ===========================================================================
/**
* @class Representing an account's staff notes. Visible only to staff and loaded/saved in the database
*/
class AccountStaffNoteData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.account = 0;
this.whoAdded = 0;
this.whenAdded = 0;
this.deleted = false;
this.whenDeleted = 0;
this.serverId = 0;
this.note = "";
this.needsSaved = false;
if (dbAssoc) {
this.databaseId = dbAssoc["acct_note_id"];
this.account = dbAssoc["acct_note_acct"];
this.whoAdded = dbAssoc["acct_note_who_added"];
this.whenAdded = dbAssoc["acct_note_when_added"];
this.deleted = intToBool(dbAssoc["acct_note_deleted"]);
this.whenDeleted = dbAssoc["acct_note_when_deleted"];
this.serverId = dbAssoc["acct_note_server"];
this.note = dbAssoc["acct_note_message"];
}
}
};
// ===========================================================================
function initAccountScript() { function initAccountScript() {
logToConsole(LOG_DEBUG, "[VRR.Account]: Initializing account script ..."); logToConsole(LOG_DEBUG, "[VRR.Account]: Initializing account script ...");
logToConsole(LOG_DEBUG, "[VRR.Account]: Account script initialized!"); logToConsole(LOG_DEBUG, "[VRR.Account]: Account script initialized!");
@@ -387,74 +202,6 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function toggleChatBoxTimeStampsCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("ChatBoxTimestamps");
if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "ChatBoxTimestampsToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
sendPlayerChatBoxTimeStampsState(client, false);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "ChatBoxTimestampsToggle", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
sendPlayerChatBoxTimeStampsState(client, true);
}
return true;
}
// ===========================================================================
function toggleAccountProfanityFilterCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("ProfanityFilter");
if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "ProfanityFilterSet", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
sendPlayerProfanityFilterState(client, false);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "ProfanityFilterSet", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
sendPlayerProfanityFilterState(client, true);
}
return true;
}
// ===========================================================================
function toggleAccountReplaceEmojiCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("ChatEmoji");
if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "ChatEmojiSet", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
sendPlayerChatEmojiState(client, false);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "ChatEmojiSet", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
sendPlayerChatEmojiState(client, true);
}
return true;
}
// ===========================================================================
function toggleAccountHideBloodCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("NoBlood");
if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "HideBloodSet", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
sendPlayerChatBoxTimeStampsState(client, false);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "HideBloodSet", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
sendPlayerChatBoxTimeStampsState(client, true);
}
return true;
}
// ===========================================================================
function registerCommand(command, params, client) { function registerCommand(command, params, client) {
if (isPlayerRegistered(client)) { if (isPlayerRegistered(client)) {
messagePlayerError(client, getLocaleString(client, "AccountNameAlreadyRegistered")); messagePlayerError(client, getLocaleString(client, "AccountNameAlreadyRegistered"));
@@ -743,7 +490,7 @@ function loadAccountFromName(accountName, fullLoad = false) {
function loadAccountFromId(accountId, fullLoad = false) { function loadAccountFromId(accountId, fullLoad = false) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let dbQueryString = `SELECT acct_main.*, acct_svr.* FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_id = ${accountId} LIMIT 1;`; let dbQueryString = `SELECT *, acct_ip AS ipstring FROM acct_main WHERE acct_id = ${accountId} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString); let dbQuery = queryDatabase(dbConnection, dbQueryString);
if (dbQuery) { if (dbQuery) {
let dbAssoc = fetchQueryAssoc(dbQuery); let dbAssoc = fetchQueryAssoc(dbQuery);
@@ -833,11 +580,6 @@ function loginSuccess(client) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} successfully logged in.`); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} successfully logged in.`);
getPlayerData(client).loggedIn = true; getPlayerData(client).loggedIn = true;
if (getPlayerData(client).loginTimeout != null) {
clearTimeout(getPlayerData(client).loginTimeout);
getPlayerData(client).loginTimeout = null;
}
updateConnectionLogOnAuth(client, getPlayerData(client).accountData.databaseId); updateConnectionLogOnAuth(client, getPlayerData(client).accountData.databaseId);
if (doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) { if (doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) {
@@ -867,7 +609,7 @@ function loginSuccess(client) {
if (getPlayerData(client).subAccounts.length == 0) { if (getPlayerData(client).subAccounts.length == 0) {
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_CREATEFIRSTCHAR; getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else { } else {
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage", `{ALTCOLOUR}/newchar{MAINCOLOUR}`)); messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage", `{ALTCOLOUR}/newchar{MAINCOLOUR}`));
@@ -920,12 +662,12 @@ function saveAccountToDatabase(accountData) {
]; ];
let data2 = [ let data2 = [
["acct_svr_settings", (accountData.settings != NaN) ? toInteger(accountData.settings) : 0], ["acct_svr_settings", accountData.settings],
["acct_svr_staff_title", toString(safeStaffTitle)], ["acct_svr_staff_title", safeStaffTitle],
["acct_svr_staff_flags", (accountData.flags.admin != NaN) ? toInteger(accountData.flags.admin) : 0], ["acct_svr_staff_flags", accountData.flags.admin],
["acct_svr_mod_flags", (accountData.flags.moderation != NaN) ? toInteger(accountData.flags.moderation) : 0], ["acct_svr_mod_flags", accountData.flags.moderation],
["acct_svr_chat_scroll_lines", (accountData.chatScrollLines != NaN) ? toInteger(accountData.chatScrollLines) : 1], ["acct_svr_chat_scroll_lines", accountData.chatScrollLines],
//["acct_svr_chat_auto_hide_delay", accountData.chatAutoHideDelay], ["acct_svr_chat_auto_hide_delay", accountData.chatAutoHideDelay],
]; ];
let queryString1 = createDatabaseUpdateQuery("acct_main", data, `acct_id=${accountData.databaseId}`); let queryString1 = createDatabaseUpdateQuery("acct_main", data, `acct_id=${accountData.databaseId}`);
@@ -1044,10 +786,8 @@ function createAccount(name, password, email = "") {
let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email, acct_when_registered) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}', CURRENT_TIMESTAMP())`); let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email, acct_when_registered) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}', CURRENT_TIMESTAMP())`);
if (getDatabaseInsertId(dbConnection) > 0) { if (getDatabaseInsertId(dbConnection) > 0) {
let insertId = getDatabaseInsertId(dbConnection); let tempAccountData = loadAccountFromId(getDatabaseInsertId(dbConnection), false);
createDefaultAccountServerData(insertId); createDefaultAccountServerData(tempAccountData.databaseId);
let tempAccountData = loadAccountFromId(insertId, false);
tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId); tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId);
tempAccountData.notes = loadAccountStaffNotesFromDatabase(tempAccountData.databaseId); tempAccountData.notes = loadAccountStaffNotesFromDatabase(tempAccountData.databaseId);
tempAccountData.contacts = loadAccountContactsFromDatabase(tempAccountData.databaseId); tempAccountData.contacts = loadAccountContactsFromDatabase(tempAccountData.databaseId);
@@ -1061,7 +801,7 @@ function createAccount(name, password, email = "") {
// =========================================================================== // ===========================================================================
function checkLogin(client, password) { async function checkLogin(client, password) {
getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining - 1; getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining - 1;
if (getPlayerData(client).loginAttemptsRemaining <= 0) { if (getPlayerData(client).loginAttemptsRemaining <= 0) {
getPlayerData(client).customDisconnectReason = "Kicked - Failed to login"; getPlayerData(client).customDisconnectReason = "Kicked - Failed to login";
@@ -1102,9 +842,9 @@ function checkLogin(client, password) {
} }
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); // await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
} //}
return false; return false;
} }
@@ -1119,15 +859,14 @@ function checkLogin(client, password) {
} }
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); // await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
} //}
return false; return false;
} }
if (doesPlayerHaveTwoFactorAuthEnabled(client) && checkForSMTPModule() && getEmailConfig().enabled) { if (doesPlayerHaveTwoFactorAuthEnabled(client) && checkForSMTPModule() && getEmailConfig().enabled) {
//getPlayerData(client).twoFactorAuthCode = toUpperCase(generateRandomString(6)); getPlayerData(client).twoFactorAuthCode = toUpperCase(generateRandomString(6));
getPlayerData(client).twoFactorAuthCode = getRandom(100000, 999999);
showPlayerTwoFactorAuthenticationGUI(client); showPlayerTwoFactorAuthenticationGUI(client);
sendAccountTwoFactorAuthCode(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerData(client).twoFactorAuthCode); sendAccountTwoFactorAuthCode(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerData(client).twoFactorAuthCode);
return true; return true;
@@ -1141,7 +880,7 @@ function checkLogin(client, password) {
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
//if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
// sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); // await sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
//} //}
} }
@@ -1237,8 +976,6 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
getPlayerData(client).accountData = accountData; getPlayerData(client).accountData = accountData;
getPlayerData(client).loggedIn = true; getPlayerData(client).loggedIn = true;
getPlayerData(client).accountData.settings = 0;
getPlayerData(client).accountData.needsSaved = true;
messagePlayerSuccess(client, getLocaleString(client, "RegistrationSuccess")); messagePlayerSuccess(client, getLocaleString(client, "RegistrationSuccess"));
if (checkForSMTPModule() && getEmailConfig().enabled) { if (checkForSMTPModule() && getEmailConfig().enabled) {
@@ -1269,8 +1006,8 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationSuccessGUI(client); showPlayerRegistrationSuccessGUI(client);
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); showPlayerPrompt(client, getLocaleString(client, "NoCharactersMessage"), getLocaleString(client, "NoCharactersWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_CREATEFIRSTCHAR; getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
} else { } else {
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage"), `{ALTCOLOUR}/newchar{MAINCOLOUR}`); messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage"), `{ALTCOLOUR}/newchar{MAINCOLOUR}`);
} }
@@ -1285,7 +1022,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
} }
switch (getPlayerData(client).passwordResetState) { switch (getPlayerData(client).passwordResetState) {
case AGRP_RESETPASS_STATE_EMAILCONFIRM: { case VRR_RESETPASS_STATE_EMAILCONFIRM: {
if (toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) { if (toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) {
logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`); logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`);
showPlayerErrorGUI(client, getLocaleString(client, "GUIErrorResetPasswordFailedInvalidEmail"), getLocaleString(client, "GUIErrorTitle"), getLocaleString(client, "GUIOkButton")); showPlayerErrorGUI(client, getLocaleString(client, "GUIErrorResetPasswordFailedInvalidEmail"), getLocaleString(client, "GUIErrorTitle"), getLocaleString(client, "GUIOkButton"));
@@ -1293,7 +1030,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
} }
let passwordResetCode = toUpperCase(generateEmailVerificationCode()); let passwordResetCode = toUpperCase(generateEmailVerificationCode());
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_CODEINPUT; getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_CODEINPUT;
getPlayerData(client).passwordResetCode = passwordResetCode; getPlayerData(client).passwordResetCode = passwordResetCode;
showPlayerResetPasswordCodeInputGUI(client); showPlayerResetPasswordCodeInputGUI(client);
sendPasswordResetEmail(client, passwordResetCode); sendPasswordResetEmail(client, passwordResetCode);
@@ -1301,11 +1038,11 @@ function checkAccountResetPasswordRequest(client, inputText) {
break; break;
} }
case AGRP_RESETPASS_STATE_CODEINPUT: { case VRR_RESETPASS_STATE_CODEINPUT: {
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted code for password reset (${inputText}) ...`); logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted code for password reset (${inputText}) ...`);
if (inputText != "") { if (inputText != "") {
if (getPlayerData(client).passwordResetCode == toUpperCase(inputText)) { if (getPlayerData(client).passwordResetCode == toUpperCase(inputText)) {
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_SETPASS; getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_SETPASS;
showPlayerChangePasswordGUI(client); showPlayerChangePasswordGUI(client);
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`); logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`);
} else { } else {
@@ -1322,10 +1059,10 @@ function checkAccountResetPasswordRequest(client, inputText) {
break; break;
} }
case AGRP_RESETPASS_STATE_NONE: { case VRR_RESETPASS_STATE_NONE: {
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} requested a password reset. Awaiting email input ...`); logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} requested a password reset. Awaiting email input ...`);
showPlayerResetPasswordEmailInputGUI(client); showPlayerResetPasswordEmailInputGUI(client);
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_EMAILCONFIRM; getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_EMAILCONFIRM;
break; break;
} }
} }
@@ -1337,8 +1074,8 @@ function checkAccountResetPasswordRequest(client, inputText) {
function checkAccountChangePassword(client, newPassword, confirmNewPassword) { function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
if (!isPlayerLoggedIn(client)) { if (!isPlayerLoggedIn(client)) {
if (getPlayerData(client).passwordResetState != AGRP_RESETPASS_STATE_SETPASS) { if (getPlayerData(client).passwordResetState != VRR_RESETPASS_STATE_SETPASS) {
//getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_NONE; //getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
//disconnectPlayer(client); //disconnectPlayer(client);
logToConsole(LOG_DEBUG | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`); logToConsole(LOG_DEBUG | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`);
return false; return false;
@@ -1374,8 +1111,8 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
saveAccountToDatabase(getPlayerData(client).accountData); saveAccountToDatabase(getPlayerData(client).accountData);
if (getPlayerData(client).passwordResetState == AGRP_RESETPASS_STATE_SETPASS) { if (getPlayerData(client).passwordResetState == VRR_RESETPASS_STATE_SETPASS) {
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_NONE; getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
} }
messagePlayerSuccess(client, getLocaleString(client, "PasswordChanged")); messagePlayerSuccess(client, getLocaleString(client, "PasswordChanged"));
@@ -1416,7 +1153,7 @@ function savePlayerToDatabase(client) {
//let subAccountData = getPlayerCurrentSubAccount(client); //let subAccountData = getPlayerCurrentSubAccount(client);
if (getPlayerPed(client) != null) { if (getPlayerPed(client) != null) {
if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != AGRP_RETURNTO_TYPE_ADMINGET) { if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != VRR_RETURNTO_TYPE_ADMINGET) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition; getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition;
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z; getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z;
getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior; getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior;
@@ -1452,12 +1189,11 @@ function initClient(client) {
return false; return false;
} }
playerInitialized[client.index] = true; setEntityData(client, "vrr.isInitialized", true, false);
//setEntityData(client, "agrp.isInitialized", true, false); sendPlayerGUIColours(client);
logToConsole(LOG_DEBUG, `[VRR.Account] Initializing GUI for ${getPlayerDisplayForConsole(client)} ...`); logToConsole(LOG_DEBUG, `[VRR.Account] Initializing GUI for ${getPlayerDisplayForConsole(client)} ...`);
sendPlayerGUIColours(client);
sendPlayerGUIInit(client); sendPlayerGUIInit(client);
updatePlayerSnowState(client); updatePlayerSnowState(client);
@@ -1500,9 +1236,8 @@ function initClient(client) {
// let iso = module.geoip.getCountryISO(getPlayerIP(client)); // let iso = module.geoip.getCountryISO(getPlayerIP(client));
// let localeId = getLocaleFromCountryISO(iso); // let localeId = getLocaleFromCountryISO(iso);
//} //}
//showSmallGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto"); //showGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto");
} }
startLoginTimeoutForPlayer(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
} }
} else { } else {
@@ -1520,6 +1255,7 @@ function initClient(client) {
getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId); getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId);
sendAccountKeyBindsToClient(client); sendAccountKeyBindsToClient(client);
} }
}, 2500); }, 2500);
} }
@@ -1741,8 +1477,7 @@ function setAccountEmailVerificationCode(accountData, emailVerificationCode) {
// =========================================================================== // ===========================================================================
function generateEmailVerificationCode() { function generateEmailVerificationCode() {
//return toUpperCase(generateRandomString(6)); return generateRandomString(10);
return getRandom(100000, 999999);
} }
// =========================================================================== // ===========================================================================
@@ -1822,13 +1557,6 @@ function isAccountSettingFlagEnabled(accountData, flagValue) {
return hasBitFlag(accountData.settings, flagValue); return hasBitFlag(accountData.settings, flagValue);
} }
// ===========================================================================
function isPlayerAccountSettingEnabled(client, flagName) {
return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue(flagName));
}
// =========================================================================== // ===========================================================================
function doesPlayerHaveRandomTipsDisabled(client) { function doesPlayerHaveRandomTipsDisabled(client) {
@@ -1869,14 +1597,3 @@ function sendAccountTwoFactorAuthCode(emailAddress, name, twoFactorAuthCode) {
} }
// =========================================================================== // ===========================================================================
function startLoginTimeoutForPlayer(client) {
getPlayerData(client).loginTimeout = setTimeout(function () {
if (isPlayerLoggedIn(client) == false) {
getPlayerData(client).customDisconnectReason = "Kicked - Login timeout";
disconnectPlayer(client);
}
}, getGlobalConfig().loginTimeout);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: animation.js // FILE: animation.js
// DESC: Provides animation functions and usage // DESC: Provides animation functions and usage
@@ -16,7 +15,7 @@ function initAnimationScript() {
// =========================================================================== // ===========================================================================
function playPlayerAnimationCommand(command, params, client) { function playPlayerAnimationCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -24,22 +23,22 @@ function playPlayerAnimationCommand(command, params, client) {
let animationSlot = getAnimationFromParams(getParam(params, " ", 1)); let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
let animationPositionOffset = 1; let animationPositionOffset = 1;
if (!animationSlot) { if(!animationSlot) {
messagePlayerError(client, getLocaleString(client, "InvalidAnimation")); messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
messagePlayerInfo(client, getLocaleString(client, "AnimationCommandTip", `{ALTCOLOUR}/animlist{MAINCOLOUR}`)); messagePlayerInfo(client, getLocaleString(client, "AnimationCommandTip", `{ALTCOLOUR}/animlist{MAINCOLOUR}`));
return false; return false;
} }
if (toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) { if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance")); messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
return false; return false;
} }
if (getAnimationData(animationSlot)[3] == AGRP_ANIMTYPE_SURRENDER) { if(getAnimationData(animationSlot)[3] == VRR_ANIMTYPE_SURRENDER) {
getPlayerData(client).pedState = AGRP_PEDSTATE_HANDSUP; getPlayerData(client).pedState = VRR_PEDSTATE_HANDSUP;
} }
if (isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) { if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
messagePlayerError(client, getLocaleString(client, "UnableToDoThat")); messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
return false; return false;
} }
@@ -51,7 +50,7 @@ function playPlayerAnimationCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function stopPlayerAnimationCommand(command, params, client) { function stopPlayerAnimationCommand(command, params, client) {
if (isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) { if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
messagePlayerError(client, getLocaleString(client, "UnableToDoThat")); messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
return false; return false;
} }
@@ -71,19 +70,29 @@ function stopPlayerAnimationCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function showAnimationListCommand(command, params, client) { function showAnimationListCommand(command, params, client) {
let animList = getGameConfig().animations[getGame()].map(function (x) { return x.name; }); let animList = getGameConfig().animations[getGame()].map(function(x) { return x.name; });
let chunkedList = splitArrayIntoChunks(animList, 10); let chunkedList = splitArrayIntoChunks(animList, 10);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAnimationsList"))); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAnimationsList")));
for (let i in chunkedList) { for(let i in chunkedList) {
messagePlayerNormal(client, chunkedList[i].join(", ")); messagePlayerNormal(client, chunkedList[i].join(", "));
} }
} }
// =========================================================================== // ===========================================================================
/**
* @param {number} animationSlot - The slot index of the animation
* @return {Array} The animation's data (array)
*/
function getAnimationData(animationSlot, gameId = getGame()) {
return getGameConfig().animations[gameId][animationSlot];
}
// ===========================================================================
function isPlayerInForcedAnimation(client) { function isPlayerInForcedAnimation(client) {
return getPlayerData(client).animationForced; return getPlayerData(client).animationForced;
} }
@@ -98,9 +107,9 @@ function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).animationForced = false; getPlayerData(client).animationForced = false;
makePedPlayAnimation(getPlayerPed(client), animationSlot, offsetPosition); makePedPlayAnimation(getPlayerPed(client), animationSlot, offsetPosition);
setEntityData(getPlayerPed(client), "agrp.anim", animationSlot, true); setEntityData(getPlayerPed(client), "vrr.anim", animationSlot, true);
//if(getAnimationData(animationSlot)[9] != AGRP_ANIMMOVE_NONE) { //if(getAnimationData(animationSlot)[9] != VRR_ANIMMOVE_NONE) {
// if(getGame() < AGRP_GAME_GTA_SA) { // if(getGame() < VRR_GAME_GTA_SA) {
// setPlayerMouseCameraState(client, true); // setPlayerMouseCameraState(client, true);
// } // }
//} //}
@@ -116,7 +125,7 @@ function forcePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).animationForced = true; getPlayerData(client).animationForced = true;
setPlayerControlState(client, false); setPlayerControlState(client, false);
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition); forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);
} }
// =========================================================================== // ===========================================================================
@@ -133,3 +142,22 @@ function makePlayerStopAnimation(client) {
} }
// =========================================================================== // ===========================================================================
function getAnimationFromParams(params) {
let animations = getGameConfig().animations[getGame()];
if(isNaN(params)) {
for(let i in animations) {
if(toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if(typeof getGameConfig().animations[getGame()][params] != "undefined") {
return toInteger(params);
}
}
return false;
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: anticheat.js // FILE: anticheat.js
// DESC: Provides anticheat functions and usage // DESC: Provides anticheat functions and usage
@@ -16,10 +15,10 @@ function initAntiCheatScript() {
// =========================================================================== // ===========================================================================
function clearPlayerStateToEnterExitProperty(client) { function clearPlayerStateToEnterExitProperty(client) {
if (getPlayerData(client).pedState != AGRP_PEDSTATE_READY) { if(getPlayerData(client).pedState != VRR_PEDSTATE_READY) {
if (getPlayerData(client).pedState == AGRP_PEDSTATE_ENTERINGVEHICLE) { if(getPlayerData(client).pedState == VRR_PEDSTATE_ENTERINGVEHICLE) {
sendPlayerClearPedState(client); sendPlayerClearPedState(client);
getPlayerData(client).pedState = AGRP_PEDSTATE_READY; getPlayerData(client).pedState = VRR_PEDSTATE_READY;
} else { } else {
return false; return false;
} }
@@ -29,7 +28,7 @@ function clearPlayerStateToEnterExitProperty(client) {
// =========================================================================== // ===========================================================================
function isPlayerExemptFromAntiCheat(client) { function isPlayerExemptFromAntiCheat(client) {
if (hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("ExemptFromAntiCheat"))) { if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("ExemptFromAntiCheat"))) {
return true; return true;
} }
@@ -39,7 +38,7 @@ function isPlayerExemptFromAntiCheat(client) {
// =========================================================================== // ===========================================================================
function canPlayerUsePoliceJob(client) { function canPlayerUsePoliceJob(client) {
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.policeBanned) { if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.policeBanned) {
return false; return false;
} }
@@ -49,7 +48,7 @@ function canPlayerUsePoliceJob(client) {
// =========================================================================== // ===========================================================================
function canClientUseFireJob(client) { function canClientUseFireJob(client) {
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.fireBanned) { if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.fireBanned) {
return false; return false;
} }
@@ -59,7 +58,7 @@ function canClientUseFireJob(client) {
// =========================================================================== // ===========================================================================
function canClientUseAmmunations(client) { function canClientUseAmmunations(client) {
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.AmmuBanned) { if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.AmmuBanned) {
return false; return false;
} }
@@ -69,7 +68,7 @@ function canClientUseAmmunations(client) {
// =========================================================================== // ===========================================================================
function canClientUseGuns(client) { function canClientUseGuns(client) {
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.GunBanned) { if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.GunBanned) {
return false; return false;
} }

View File

@@ -1,43 +1,12 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: bans.js // FILE: bans.js
// DESC: Provides ban functions and usage // DESC: Provides ban functions and usage
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// Ban Types
const AGRP_BANTYPE_NONE = 0;
const AGRP_BANTYPE_ACCOUNT = 1;
const AGRP_BANTYPE_SUBACCOUNT = 2;
const AGRP_BANTYPE_IPADDRESS = 3;
const AGRP_BANTYPE_SUBNET = 4;
// ===========================================================================
class BanData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.type = AGRP_BANTYPE_NONE;
this.detail = "";
this.ipAddress = "";
this.name = "";
this.reason = "";
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["ban_id"]);
this.type = dbAssoc["ban_type"];
this.detail = toInteger(dbAssoc["ban_detail"]);
this.ipAddress = toInteger(dbAssoc["ban_ip"]);
this.reason = toInteger(dbAssoc["ban_reason"]);
}
}
}
// ===========================================================================
function initBanScript() { function initBanScript() {
logToConsole(LOG_INFO, "[VRR.Ban]: Initializing ban script ..."); logToConsole(LOG_INFO, "[VRR.Ban]: Initializing ban script ...");
logToConsole(LOG_INFO, "[VRR.Ban]: Ban script initialized!"); logToConsole(LOG_INFO, "[VRR.Ban]: Ban script initialized!");
@@ -175,7 +144,7 @@ function banAccount(accountId, adminAccountId, reason) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let safeReason = dbConnection.escapetoString(reason); let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`); let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
dbConnection.close(); dbConnection.close();
return true; return true;
@@ -190,7 +159,7 @@ function banSubAccount(subAccountId, adminAccountId, reason) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let safeReason = dbConnection.escapetoString(reason); let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`); let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
dbConnection.close(); dbConnection.close();
return true; return true;
@@ -205,7 +174,7 @@ function banIPAddress(ipAddress, adminAccountId, reason) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let safeReason = dbConnection.escapetoString(reason); let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`); let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
dbConnection.close(); dbConnection.close();
return true; return true;
@@ -220,7 +189,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let safeReason = dbConnection.escapetoString(reason); let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`); let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
dbConnection.close(); dbConnection.close();
return true; return true;
@@ -234,7 +203,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
function unbanAccount(accountId, adminAccountId) { function unbanAccount(accountId, adminAccountId) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`); let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
dbConnection.close(); dbConnection.close();
return true; return true;
@@ -248,7 +217,7 @@ function unbanAccount(accountId, adminAccountId) {
function unbanSubAccount(subAccountId, adminAccountId) { function unbanSubAccount(subAccountId, adminAccountId) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`); let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
dbConnection.close(); dbConnection.close();
return true; return true;
@@ -262,7 +231,7 @@ function unbanSubAccount(subAccountId, adminAccountId) {
function unbanIPAddress(ipAddress, adminAccountId) { function unbanIPAddress(ipAddress, adminAccountId) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`); let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
dbConnection.close(); dbConnection.close();
return true; return true;
@@ -276,7 +245,7 @@ function unbanIPAddress(ipAddress, adminAccountId) {
function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) { function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`); let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
dbConnection.close(); dbConnection.close();
return true; return true;
@@ -288,7 +257,7 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
// =========================================================================== // ===========================================================================
function isAccountBanned(accountId) { function isAccountBanned(accountId) {
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_ACCOUNT && ban.detail === accountId); let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_ACCOUNT && ban.detail === accountId);
if (bans.length > 0) { if (bans.length > 0) {
return true; return true;
} }
@@ -299,7 +268,7 @@ function isAccountBanned(accountId) {
// =========================================================================== // ===========================================================================
function isSubAccountBanned(subAccountId) { function isSubAccountBanned(subAccountId) {
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_SUBACCOUNT && ban.detail === subAccountId); let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
if (bans.length > 0) { if (bans.length > 0) {
return true; return true;
} }
@@ -310,7 +279,7 @@ function isSubAccountBanned(subAccountId) {
// =========================================================================== // ===========================================================================
function isIpAddressBanned(ipAddress) { function isIpAddressBanned(ipAddress) {
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_IPADDRESS && ban.detail === ipAddress); let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_IPADDRESS && ban.detail === ipAddress);
if (bans.length > 0) { if (bans.length > 0) {
return true; return true;
} }

View File

@@ -1,80 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: bank.js
// DESC: Provides banking functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// House Owner Types
const AGRP_BANK_ACCT_OWNER_NONE = 0; // Not owned
const AGRP_BANK_ACCT_OWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const AGRP_BANK_ACCT_OWNER_JOB = 2; // Owned by a job
const AGRP_BANK_ACCT_OWNER_CLAN = 3; // Owned by a clan
const AGRP_BANK_ACCT_OWNER_FACTION = 4; // Owned by a faction
const AGRP_BANK_ACCT_OWNER_BIZ = 4; // Owned by a faction
const AGRP_BANK_ACCT_OWNER_PUBLIC = 5; // Is a public bank account. Technically not owned. This probably won't be used.
// ===========================================================================
function isPlayerAtBank(client) {
if (isPositionAtATM(getPlayerPosition(client))) {
return true;
}
let businessId = getPlayerBusiness(client);
if (getBusinessData(client) != false) {
if (getBusinessData(businessId).type == AGRP_BIZ_TYPE_BANK) {
return true;
}
}
return false;
}
// ===========================================================================
function isPositionAtATM(position) {
let atmId = getClosestATM(position);
let atmData = getServerData().atmLocationCache[atmId];
if (getDistance(position, atmData[2]) <= getGlobalConfig().atmDistance) {
return true;
}
return false;
}
// ===========================================================================
function getClosestATM(position) {
let atmLocations = getServerData().atmLocationCache;
let closest = 0;
for (let i in atmLocations) {
if (getDistance(position, atmLocations[i]) < getDistance(position, atmLocations[closest])) {
closest = i;
}
}
return closest;
}
// ===========================================================================
function isPositionAtATM(position) {
let atmId = getClosestATM(position);
let atmData = getServerData().atmLocationCache[atmId];
if (getDistance(position, atmData[2]) <= getGlobalConfig().atmDistance) {
return true;
}
return false;
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: bitflags.js // FILE: bitflags.js
// DESC: Provides bitwise operations, functions and usage // DESC: Provides bitwise operations, functions and usage
@@ -65,7 +64,6 @@ let serverBitFlagKeys = {
"DontSyncClientElements", "DontSyncClientElements",
"IsTester" "IsTester"
], ],
/*
factionFlagKeys: [ factionFlagKeys: [
"None", "None",
"Police", "Police",
@@ -74,7 +72,6 @@ let serverBitFlagKeys = {
"Government", "Government",
"Generic", "Generic",
], ],
*/
clanTypeFlagKeys: [ clanTypeFlagKeys: [
"None", "None",
"Illegal", "Illegal",
@@ -104,24 +101,6 @@ let serverBitFlagKeys = {
"ManageRanks", "ManageRanks",
"Owner", "Owner",
], ],
clanDiscordWebhookFlagKeys: [
"None",
"ClanName",
"ClanMOTD",
"ClanTag",
"ClanRankEdit",
"ClanRankSet",
"ClanVehicleEdit",
"ClanHouseEdit",
"ClanBusinessEdit",
"ClanNPCEdit",
"ClanMemberInvite",
"ClanMemberRemove",
"ClanMemberSuspend",
"ClanRankFlagSet",
"ClanTurfWar",
"ClanPointWar",
],
accountSettingsFlagKeys: [ accountSettingsFlagKeys: [
"None", "None",
"UseWhiteList", "UseWhiteList",
@@ -138,12 +117,6 @@ let serverBitFlagKeys = {
"NoKeyBinds", "NoKeyBinds",
"NoRandomTips", "NoRandomTips",
"NoActionTips", "NoActionTips",
"ChatBoxTimestamps",
"ProfanityFilter",
"ChatAutoHide",
"NoPlayerContent",
"ChatEmoji",
//"NoBlood",
], ],
// Not going to be used. Use trigger, condition, and response stuff in trigger.js // Not going to be used. Use trigger, condition, and response stuff in trigger.js
@@ -247,38 +220,22 @@ let serverBitFlagKeys = {
"ShowItemsAfterPurchase", "ShowItemsAfterPurchase",
"BuyCommandAfterEnterBusiness", "BuyCommandAfterEnterBusiness",
], ],
jobRankKeys: [
"None",
"PublicAccess",
"WhiteList",
"BlackList",
"SetRank",
"SetPay",
"ManageUniforms",
"ManageEquipment",
"ManageVehicles",
"ManageBusinesses",
"Leader",
],
}; };
// =========================================================================== // ===========================================================================
function initBitFlagScript() { function initBitFlagScript() {
logToConsole(LOG_DEBUG, "[VRR.BitFlag]: Initializing bit flag script ..."); logToConsole(LOG_INFO, "[VRR.BitFlag]: Initializing bit flag script ...");
serverBitFlags.staffFlags = createBitFlagTable(serverBitFlagKeys.staffFlagKeys); serverBitFlags.staffFlags = createBitFlagTable(serverBitFlagKeys.staffFlagKeys);
serverBitFlags.moderationFlags = createBitFlagTable(serverBitFlagKeys.moderationFlagKeys); serverBitFlags.moderationFlags = createBitFlagTable(serverBitFlagKeys.moderationFlagKeys);
serverBitFlags.accountSettingsFlags = createBitFlagTable(serverBitFlagKeys.accountSettingsFlagKeys); serverBitFlags.accountSettingsFlags = createBitFlagTable(serverBitFlagKeys.accountSettingsFlagKeys);
//serverBitFlags.subAccountSettingsFlags = createBitFlagTable(getServerData().subAccountSettingsFlagKeys); //serverBitFlags.subAccountSettingsFlags = createBitFlagTable(getServerData().subAccountSettingsFlagKeys);
serverBitFlags.clanFlags = createBitFlagTable(serverBitFlagKeys.clanFlagKeys); serverBitFlags.clanFlags = createBitFlagTable(serverBitFlagKeys.clanFlagKeys);
serverBitFlags.clanTypeFlags = createBitFlagTable(serverBitFlagKeys.clanTypeFlagKeys); serverBitFlags.clanTypeFlagKeys = createBitFlagTable(serverBitFlagKeys.clanTypeFlagKeys);
serverBitFlags.clanDiscordWebhookFlags = createBitFlagTable(serverBitFlagKeys.clanDiscordWebhookFlagKeys); serverBitFlags.factionFlags = createBitFlagTable(serverBitFlagKeys.factionFlagKeys);
//serverBitFlags.factionFlags = createBitFlagTable(serverBitFlagKeys.factionFlagKeys);
serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys); serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys);
serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys); serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys);
serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys); serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys);
serverBitFlags.seenHelpTips = createBitFlagTable(serverBitFlagKeys.seenHelpTipsKeys);
serverBitFlags.jobRankFlags = createBitFlagTable(serverBitFlagKeys.jobRankKeys);
logToConsole(LOG_INFO, "[VRR.BitFlag]: Bit flag script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.BitFlag]: Bit flag script initialized successfully!");
return true; return true;
} }
@@ -286,25 +243,25 @@ function initBitFlagScript() {
// =========================================================================== // ===========================================================================
function doesPlayerHaveStaffPermission(client, requiredFlags) { function doesPlayerHaveStaffPermission(client, requiredFlags) {
if (isConsole(client)) { if(isConsole(client)) {
return true; return true;
} }
if (requiredFlags == getStaffFlagValue("None")) { if(requiredFlags == getStaffFlagValue("None")) {
return true; return true;
} }
let staffFlags = 0; let staffFlags = 0;
if (getPlayerData(client)) { if(getPlayerData(client)) {
staffFlags = getPlayerData(client).accountData.flags.admin; staffFlags = getPlayerData(client).accountData.flags.admin;
} }
// -1 is automatic override (having -1 for staff flags is basically god mode admin level) // -1 is automatic override (having -1 for staff flags is basically god mode admin level)
if (staffFlags == getStaffFlagValue("All")) { if(staffFlags == getStaffFlagValue("All")) {
return true; return true;
} }
if (hasBitFlag(staffFlags, requiredFlags)) { if(hasBitFlag(staffFlags, requiredFlags)) {
return true; return true;
} }
@@ -314,57 +271,27 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
// =========================================================================== // ===========================================================================
function doesPlayerHaveClanPermission(client, requiredFlags) { function doesPlayerHaveClanPermission(client, requiredFlags) {
if (isConsole(client)) { if(isConsole(client)) {
return true; return true;
} }
if (requiredFlags == getClanFlagValue("None")) { if(requiredFlags == getClanFlagValue("None")) {
return true; return true;
} }
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) { if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
return true; return true;
} }
let clanFlags = 0; let clanFlags = 0;
clanFlags = getPlayerCurrentSubAccount(client).clanFlags | getClanRankData(getPlayerClan(client), getPlayerClanRank(client)).flags; clanFlags = getPlayerCurrentSubAccount(client).clanFlags | getClanRankFlags(getPlayerCurrentSubAccount(client).clanRank);
// -1 is automatic override (having -1 for staff flags is basically god mode admin level) // -1 is automatic override (having -1 for staff flags is basically god mode admin level)
if (clanFlags == getClanFlagValue("All")) { if(clanFlags == getClanFlagValue("All")) {
return true; return true;
} }
if (hasBitFlag(clanFlags, requiredFlags)) { if(hasBitFlag(clanFlags, requiredFlags)) {
return true;
}
return false;
}
// ===========================================================================
function doesPlayerHaveJobPermission(client, requiredFlags) {
if (isConsole(client)) {
return true;
}
if (requiredFlags == getClanFlagValue("None")) {
return true;
}
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
return true;
}
let jobFlags = 0;
jobFlags = getPlayerCurrentSubAccount(client).jobFlags | getJobRankData(getPlayerJob(client), getPlayerJobRank(client)).flags;
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
if (jobFlags == getJobFlagValue("All")) {
return true;
}
if (hasBitFlag(jobFlags, requiredFlags)) {
return true; return true;
} }
@@ -374,11 +301,11 @@ function doesPlayerHaveJobPermission(client, requiredFlags) {
// =========================================================================== // ===========================================================================
function getStaffFlagValue(flagName) { function getStaffFlagValue(flagName) {
if (flagName == "All") { if(flagName == "All") {
return -1; return -1;
} }
if (typeof serverBitFlags.staffFlags[flagName] == "undefined") { if(typeof serverBitFlags.staffFlags[flagName] == "undefined") {
return false; return false;
} }
@@ -388,11 +315,11 @@ function getStaffFlagValue(flagName) {
// =========================================================================== // ===========================================================================
function getClanFlagValue(flagName) { function getClanFlagValue(flagName) {
if (flagName == "All") { if(flagName == "All") {
return -1; return -1;
} }
if (typeof getServerBitFlags().clanFlags[flagName] == "undefined") { if(typeof getServerBitFlags().clanFlags[flagName] == "undefined") {
return false; return false;
} }
@@ -402,11 +329,11 @@ function getClanFlagValue(flagName) {
// =========================================================================== // ===========================================================================
function getAccountSettingsFlagValue(flagName) { function getAccountSettingsFlagValue(flagName) {
if (flagName == "All") { if(flagName == "All") {
return -1; return -1;
} }
if (typeof serverBitFlags.accountSettingsFlags[flagName] == "undefined") { if(typeof serverBitFlags.accountSettingsFlags[flagName] == "undefined") {
return false; return false;
} }
@@ -416,11 +343,11 @@ function getAccountSettingsFlagValue(flagName) {
// =========================================================================== // ===========================================================================
function getModerationFlagValue(flagName) { function getModerationFlagValue(flagName) {
if (flagName == "All") { if(flagName == "All") {
return -1; return -1;
} }
if (typeof serverBitFlags.moderationFlags[flagName] == "undefined") { if(typeof serverBitFlags.moderationFlags[flagName] == "undefined") {
return false; return false;
} }
@@ -429,22 +356,8 @@ function getModerationFlagValue(flagName) {
// =========================================================================== // ===========================================================================
function getClanDiscordWebhookValue(flagName) {
if (flagName == "All") {
return -1;
}
if (typeof serverBitFlags.clanDiscordWebhookFlags[flagName] == "undefined") {
return false;
}
return serverBitFlags.clanDiscordWebhookFlags[flagName];
}
// ===========================================================================
function givePlayerStaffFlag(client, flagName) { function givePlayerStaffFlag(client, flagName) {
if (!getStaffFlagValue(flagName)) { if(!getStaffFlagValue(flagName)) {
return false; return false;
} }
@@ -456,7 +369,7 @@ function givePlayerStaffFlag(client, flagName) {
function takePlayerStaffFlag(client, flagName) { function takePlayerStaffFlag(client, flagName) {
let flagValue = getStaffFlagValue(flagName); let flagValue = getStaffFlagValue(flagName);
if (!flagValue) { if(!flagValue) {
return false; return false;
} }
@@ -467,7 +380,7 @@ function takePlayerStaffFlag(client, flagName) {
// =========================================================================== // ===========================================================================
function takePlayerStaffFlag(client, flagName) { function takePlayerStaffFlag(client, flagName) {
if (!getStaffFlagValue(flagName)) { if(!getStaffFlagValue(flagName)) {
return false; return false;
} }

View File

@@ -1,188 +1,16 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: business.js // FILE: business.js
// DESC: Provides business functions and usage // DESC: Provides business functions and usage
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// Business Types
const AGRP_BIZ_TYPE_NONE = 0; // None (invalid)
const AGRP_BIZ_TYPE_NORMAL = 1; // Normal business (sells items)
const AGRP_BIZ_TYPE_BANK = 2; // Bank
const AGRP_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc)
const AGRP_BIZ_TYPE_PAINTBALL = 4; // Paintball arena. Player joins paintball/airsoft when they enter
const AGRP_BIZ_TYPE_DEALERSHIP = 5; // Vehicle Dealership (also for airplane, boat, etc)
// ===========================================================================
// Business Location Types
const AGRP_BIZ_LOC_NONE = 0; // None
const AGRP_BIZ_LOC_GATE = 1; // Center of any moveable gate that belongs to the biz
const AGRP_BIZ_LOC_GARAGE = 2; // Location for attached garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
const AGRP_BIZ_LOC_FUEL = 3; // Fuel pump
const AGRP_BIZ_LOC_DRIVETHRU = 4; // Drivethrough
const AGRP_BIZ_LOC_VENDMACHINE = 5; // Vending machine
const AGRP_BIZ_LOC_ATM = 6; // ATM
const AGRP_BIZ_LOC_PAYPHONE = 7; // Payphone
// ===========================================================================
// Business Owner Types
const AGRP_BIZ_OWNER_NONE = 0; // Not owned
const AGRP_BIZ_OWNER_PLAYER = 1; // Owned by a player (character/subaccount)
const AGRP_BIZ_OWNER_JOB = 2; // Owned by a job
const AGRP_BIZ_OWNER_CLAN = 3; // Owned by a clan
const AGRP_BIZ_OWNER_FACTION = 4; // Owned by a faction (not used at the moment)
const AGRP_BIZ_OWNER_PUBLIC = 5; // Public Business. Used for goverment/official places like police, fire, city hall, DMV, etc
// ===========================================================================
/**
* @class Representing a businesses' data. Loaded and saved in the database
* @property {Array.<BusinessLocationData>} locations
* @property {Array.<Number>} floorItemCache
* @property {Array.<Number>} storageItemCache
*/
class BusinessData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.ownerType = AGRP_BIZ_OWNER_NONE;
this.ownerId = 0;
this.buyPrice = 0;
this.locked = false;
this.hasInterior = false;
this.index = -1;
this.needsSaved = false;
this.interiorLights = true;
this.type = AGRP_BIZ_TYPE_NONE;
this.floorItemCache = [];
this.storageItemCache = [];
this.locations = [];
//this.gameScripts = [];
this.entrancePosition = false;
this.entranceRotation = 0.0;
this.entranceInterior = 0;
this.entranceDimension = 0;
this.entrancePickupModel = -1;
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.exitPosition = false;
this.exitRotation = 0.0;
this.exitInterior = 0;
this.exitDimension = 0;
this.exitPickupModel = -1;
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.entranceFee = 0;
this.till = 0;
this.streamingRadioStation = 0;
//this.streamingRadioStationIndex = -1;
this.labelHelpType = AGRP_PROPLABEL_INFO_NONE;
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["biz_id"]);
this.name = toString(dbAssoc["biz_name"]);
this.ownerType = toInteger(dbAssoc["biz_owner_type"]);
this.ownerId = toInteger(dbAssoc["biz_owner_id"]);
this.buyPrice = toInteger(dbAssoc["biz_buy_price"]);
this.locked = intToBool(toInteger(dbAssoc["biz_locked"]));
this.hasInterior = intToBool(toInteger(dbAssoc["biz_has_interior"]));
this.interiorLights = intToBool(toInteger(dbAssoc["biz_interior_lights"]));
this.type = toInteger(dbAssoc["biz_type"]);
this.entrancePosition = toVector3(toFloat(dbAssoc["biz_entrance_pos_x"]), toFloat(dbAssoc["biz_entrance_pos_y"]), toFloat(dbAssoc["biz_entrance_pos_z"]));
this.entranceRotation = toInteger(dbAssoc["biz_entrance_rot_z"]);
this.entranceInterior = toInteger(dbAssoc["biz_entrance_int"]);
this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["biz_entrance_blip"]);
this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]);
this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]);
this.exitInterior = toInteger(dbAssoc["biz_exit_int"]);
this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]);
this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]);
this.till = toInteger(dbAssoc["biz_till"]);
this.labelHelpType = toInteger(dbAssoc["biz_label_help_type"]);
this.streamingRadioStation = toInteger(dbAssoc["biz_radio_station"]);
}
};
};
/**
* @class Representing a business's location data. Multiple can be used for a single business. Used for things like doors, fuel pumps, drive thru positions, etc. Loaded and saved in the database
*/
class BusinessLocationData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.type = 0;
this.business = 0;
this.enabled = false;
this.index = -1;
this.businessIndex = -1;
this.needsSaved = false;
this.position = toVector3(0.0, 0.0, 0.0);
this.interior = 0;
this.dimension = 0;
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["biz_loc_id"]);
this.name = toString(dbAssoc["biz_loc_name"]);
this.type = toInteger(dbAssoc["biz_loc_type"]);
this.business = toInteger(dbAssoc["biz_loc_biz"]);
this.enabled = intToBool(toInteger(dbAssoc["biz_loc_enabled"]));
this.position = toVector3(toFloat(dbAssoc["biz_loc_pos_x"]), toFloat(dbAssoc["biz_loc_pos_y"]), toFloat(dbAssoc["biz_loc_pos_z"]));
this.interior = toInteger(dbAssoc["biz_loc_int"]);
this.dimension = toInteger(dbAssoc["biz_loc_vw"]);
}
}
};
/**
* @class Representing a business's game scripts. Multiple can be used for a single business. Used for things like bar and club NPCs and other actions
*/
class BusinessGameScriptData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.business = 0;
this.enabled = false;
this.index = -1;
this.businessIndex = -1;
this.needsSaved = false;
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["biz_script_id"]);
this.name = toString(dbAssoc["biz_script_name"]);
this.state = toInteger(dbAssoc["biz_script_state"]);
this.business = toInteger(dbAssoc["biz_script_biz"]);
}
}
};
// ===========================================================================
function initBusinessScript() { function initBusinessScript() {
logToConsole(LOG_INFO, "[VRR.Business]: Initializing business script ..."); logToConsole(LOG_INFO, "[VRR.Business]: Initializing business script ...");
logToConsole(LOG_INFO, "[VRR.Business]: Business script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.Business]: Business script initialized successfully!");
return true; return true;
} }
@@ -221,7 +49,7 @@ function loadBusinessesFromDatabase() {
if (dbQuery.numRows > 0) { if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) { while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempBusinessData = new BusinessData(dbAssoc); let tempBusinessData = new BusinessData(dbAssoc);
tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId); //tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
//tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId); //tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId);
tempBusinesses.push(tempBusinessData); tempBusinesses.push(tempBusinessData);
logToConsole(LOG_VERBOSE, `[VRR.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`); logToConsole(LOG_VERBOSE, `[VRR.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`);
@@ -408,8 +236,8 @@ function deleteBusinessCommand(command, params, client) {
return false; return false;
} }
deleteBusiness(businessId, getPlayerData(client).accountData.databaseId);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} deleted business {businessBlue}${getBusinessData(businessId).name}`); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} deleted business {businessBlue}${getBusinessData(businessId).name}`);
deleteBusiness(businessId, getPlayerData(client).accountData.databaseId);
} }
// =========================================================================== // ===========================================================================
@@ -457,7 +285,7 @@ function setBusinessNameCommand(command, params, client) {
let oldBusinessName = getBusinessData(businessId).name; let oldBusinessName = getBusinessData(businessId).name;
getBusinessData(businessId).name = newBusinessName; getBusinessData(businessId).name = newBusinessName;
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.name", getBusinessData(businessId).name, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.name", getBusinessData(businessId).name, true);
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} renamed business {businessBlue}${oldBusinessName}{MAINCOLOUR} to {businessBlue}${newBusinessName}`); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} renamed business {businessBlue}${oldBusinessName}{MAINCOLOUR} to {businessBlue}${newBusinessName}`);
} }
@@ -497,7 +325,7 @@ function setBusinessOwnerCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_PLAYER; getBusinessData(businessId).ownerType = VRR_BIZOWNER_PLAYER;
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(newBusinessOwner).databaseId; getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(newBusinessOwner).databaseId;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
@@ -539,7 +367,7 @@ function setBusinessJobCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_JOB; getBusinessData(businessId).ownerType = VRR_BIZOWNER_JOB;
getBusinessData(businessId).ownerId = getJobData(jobId).databaseId; getBusinessData(businessId).ownerId = getJobData(jobId).databaseId;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
@@ -572,7 +400,7 @@ function setBusinessClanCommand(command, params, client) {
return false; return false;
} }
if (getBusinessData(business).ownerType != AGRP_VEHOWNER_PLAYER) { if (getBusinessData(business).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness")); messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
return false; return false;
} }
@@ -583,9 +411,9 @@ function setBusinessClanCommand(command, params, client) {
} }
showPlayerPrompt(client, getLocaleString(client, "SetBusinessClanConfirmMessage"), getLocaleString(client, "SetBusinessClanConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); showPlayerPrompt(client, getLocaleString(client, "SetBusinessClanConfirmMessage"), getLocaleString(client, "SetBusinessClanConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_BIZGIVETOCLAN; getPlayerData(client).promptType = VRR_PROMPT_BIZGIVETOCLAN;
//getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_CLAN; //getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
//getBusinessData(businessId).ownerId = getClanData(clanId).databaseId; //getBusinessData(businessId).ownerId = getClanData(clanId).databaseId;
//getBusinessData(businessId).needsSaved = true; //getBusinessData(businessId).needsSaved = true;
} }
@@ -616,16 +444,16 @@ function setBusinessRankCommand(command, params, client) {
return false; return false;
} }
if (getVehicleData(vehicle).ownerType == AGRP_VEHOWNER_CLAN) { if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) {
let clanId = getClanIndexFromDatabaseId(getBusinessData(businessId).ownerId); let clanId = getClanIdFromDatabaseId(getBusinessData(businessId).ownerId);
rankId = getClanRankFromParams(clanId, params); rankId = getClanRankFromParams(clanId, params);
if (!getClanRankData(clanId, rankId)) { if (!getClanRankData(clanId, rankId)) {
messagePlayerError(client, getLocaleString(client, "InvalidClanRank")); messagePlayerError(client, getLocaleString(client, "ClanRankInvalid"));
return false; return false;
} }
getBusinessData(businessId).rank = getClanRankData(clanId, rankId).databaseId; getBusinessData(businessId).rank = getClanRankData(clanId, rankId).databaseId;
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${getClanRankData(clanId, rankId).name} {MAINCOLOUR}of the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`); messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${getClanRankData(clanId, rankId).name} {MAINCOLOUR}of the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`);
} else if (getBusinessData(businessId).ownerType == AGRP_VEHOWNER_JOB) { } else if (getBusinessData(businessId).ownerType == VRR_VEHOWNER_JOB) {
getBusinessData(businessId).rank = rankId; getBusinessData(businessId).rank = rankId;
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${rankId} {MAINCOLOUR}of the {jobYellow}${getJobData(getJobIdFromDatabaseId(getBusinessData(businessId).ownerId)).name} {MAINCOLOUR}job!`); messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${rankId} {MAINCOLOUR}of the {jobYellow}${getJobData(getJobIdFromDatabaseId(getBusinessData(businessId).ownerId)).name} {MAINCOLOUR}job!`);
} }
@@ -667,7 +495,7 @@ function setBusinessRankCommand(command, params, client) {
let clanRankId = getClanRankFromParams(clanId, params); let clanRankId = getClanRankFromParams(clanId, params);
if (!getClanRankData(clanId, clanRankId)) { if (!getClanRankData(clanId, clanRankId)) {
messagePlayerError(client, getLocaleString(client, "InvalidClanRank")); messagePlayerError(client, getLocaleString(client, "ClanRankInvalid"));
return false; return false;
} }
@@ -722,7 +550,7 @@ function setBusinessJobCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_JOB; getBusinessData(businessId).ownerType = VRR_BIZOWNER_JOB;
getBusinessData(businessId).ownerId = getJobData(jobId).databaseId; getBusinessData(businessId).ownerId = getJobData(jobId).databaseId;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
@@ -752,7 +580,7 @@ function setBusinessPublicCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_PUBLIC; getBusinessData(businessId).ownerType = VRR_BIZOWNER_PUBLIC;
getBusinessData(businessId).ownerId = 0; getBusinessData(businessId).ownerId = 0;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
@@ -782,7 +610,7 @@ function removeBusinessOwnerCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_NONE; getBusinessData(businessId).ownerType = VRR_BIZOWNER_NONE;
getBusinessData(businessId).ownerId = -1; getBusinessData(businessId).ownerId = -1;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
@@ -847,36 +675,7 @@ function setBusinessEntranceFeeCommand(command, params, client) {
getBusinessData(businessId).entranceFee = entranceFee; getBusinessData(businessId).entranceFee = entranceFee;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} entrance fee to [#AAAAAAA]$${entranceFee}`); messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}entrance fee to [#AAAAAAA]$${entranceFee}`);
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setBusinessPaintBallCommand(command, params, client) {
let businessId = getPlayerBusiness(client);
if (!getBusinessData(businessId)) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
return false;
}
if (!canPlayerManageBusiness(client, businessId)) {
messagePlayerError(client, getLocaleString(client, "CantModifyBusiness"));
return false;
}
getBusinessData(businessId).type = AGRP_BIZ_TYPE_PAINTBALL;
getBusinessData(businessId).needsSaved = true;
messagePlayerSuccess(client, getLocaleString(client, "BusinessIsNowPaintBall"));
} }
// =========================================================================== // ===========================================================================
@@ -906,24 +705,24 @@ function getBusinessInfoCommand(command, params, client) {
let ownerName = "Unknown"; let ownerName = "Unknown";
switch (businessData.ownerType) { switch (businessData.ownerType) {
case AGRP_BIZ_OWNER_CLAN: case VRR_BIZOWNER_CLAN:
ownerName = getClanData(businessData.ownerId).name; ownerName = getClanData(businessData.ownerId).name;
break; break;
case AGRP_BIZ_OWNER_JOB: case VRR_BIZOWNER_JOB:
ownerName = getJobData(businessData.ownerId).name; ownerName = getJobData(businessData.ownerId).name;
break; break;
case AGRP_BIZ_OWNER_PLAYER: case VRR_BIZOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(businessData.ownerId); let subAccountData = loadSubAccountFromId(businessData.ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`; ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`;
break; break;
case AGRP_BIZ_OWNER_PUBLIC: case VRR_BIZOWNER_PUBLIC:
ownerName = "Public"; ownerName = "Public";
break; break;
case AGRP_BIZ_OWNER_NONE: case VRR_BIZOWNER_NONE:
//submitBugReport(client, `[AUTOMATED REPORT] getBusinessInfoCommand() - Invalid ownerType for business ${businessId}/${getBusinessData(businessId).databaseId}`); //submitBugReport(client, `[AUTOMATED REPORT] getBusinessInfoCommand() - Invalid ownerType for business ${businessId}/${getBusinessData(businessId).databaseId}`);
ownerName = "None"; ownerName = "None";
break; break;
@@ -1276,7 +1075,7 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
let itemTypeId = getItemTypeFromParams(getGameConfig().defaultBusinessItems[getGame()][typeParam][i][0]); let itemTypeId = getItemTypeFromParams(getGameConfig().defaultBusinessItems[getGame()][typeParam][i][0]);
let itemTypeData = getItemTypeData(itemTypeId); let itemTypeData = getItemTypeData(itemTypeId);
if (itemTypeData) { if (itemTypeData) {
let newItemIndex = createItem(itemTypeId, itemTypeData.orderValue, AGRP_ITEM_OWNER_BIZFLOOR, getBusinessData(businessId).databaseId, getGameConfig().defaultBusinessItems[getGame()][typeParam][i][1]); let newItemIndex = createItem(itemTypeId, itemTypeData.orderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(businessId).databaseId, getGameConfig().defaultBusinessItems[getGame()][typeParam][i][1]);
getItemData(newItemIndex).buyPrice = applyServerInflationMultiplier(itemTypeData.orderPrice) * getGameConfig().defaultBusinessItems[getGame()][typeParam][i][2]; getItemData(newItemIndex).buyPrice = applyServerInflationMultiplier(itemTypeData.orderPrice) * getGameConfig().defaultBusinessItems[getGame()][typeParam][i][2];
} }
} }
@@ -1297,7 +1096,7 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
* @return {bool} Whether or not the command was successful * @return {bool} Whether or not the command was successful
* *
*/ */
function setBusinessDealershipCommand(command, params, client) { function setBusinessEntranceLabelToDealershipCommand(command, params, client) {
let businessId = getPlayerBusiness(client); let businessId = getPlayerBusiness(client);
if (!getBusinessData(businessId)) { if (!getBusinessData(businessId)) {
@@ -1305,8 +1104,7 @@ function setBusinessDealershipCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).labelHelpType == AGRP_PROPLABEL_INFO_ENTERVEHICLE; getBusinessData(businessId).labelHelpType == VRR_PROPLABEL_INFO_ENTERVEHICLE;
getBusinessData(businessId).type = AGRP_BIZ_TYPE_DEALERSHIP;
updateBusinessPickupLabelData(businessId); updateBusinessPickupLabelData(businessId);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the business type of {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to dealership`); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the business type of {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to dealership`);
} }
@@ -1448,7 +1246,7 @@ function setBusinessBuyPriceCommand(command, params, client) {
} }
getBusinessData(businessId).buyPrice = amount; getBusinessData(businessId).buyPrice = amount;
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.price", getBusinessData(businessId).buyPrice, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.price", getBusinessData(businessId).buyPrice, true);
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}'s {MAINCOLOUR}for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`); messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}'s {MAINCOLOUR}for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
@@ -1548,7 +1346,7 @@ function orderItemForBusinessCommand(command, params, client) {
let orderTotalCost = pricePerItem * amount; let orderTotalCost = pricePerItem * amount;
//getPlayerData(client).promptType = AGRP_PROMPT_BIZORDER; //getPlayerData(client).promptType = VRR_PROMPT_BIZORDER;
getPlayerData(client).businessOrderAmount = amount; getPlayerData(client).businessOrderAmount = amount;
getPlayerData(client).businessOrderBusiness = businessId; getPlayerData(client).businessOrderBusiness = businessId;
getPlayerData(client).businessOrderItem = itemType; getPlayerData(client).businessOrderItem = itemType;
@@ -1557,7 +1355,7 @@ function orderItemForBusinessCommand(command, params, client) {
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
showPlayerPrompt(client, `Ordering ${amount} ${getPluralForm(getItemTypeData(itemType).name)} (${getItemValueDisplay(itemType, value)}) at $${makeLargeNumberReadable(pricePerItem)} each will cost a total of $${makeLargeNumberReadable(orderTotalCost)}`, "Business Order Cost"); showPlayerPrompt(client, `Ordering ${amount} ${getPluralForm(getItemTypeData(itemType).name)} (${getItemValueDisplay(itemType, value)}) at $${makeLargeNumberReadable(pricePerItem)} each will cost a total of $${makeLargeNumberReadable(orderTotalCost)}`, "Business Order Cost");
getPlayerData(client).promptType = AGRP_PROMPT_BIZORDER; getPlayerData(client).promptType = VRR_PROMPT_BIZORDER;
} }
// =========================================================================== // ===========================================================================
@@ -1644,7 +1442,7 @@ function buyBusinessCommand(command, params, client) {
} }
showPlayerPrompt(client, getLocaleString(client, "BuyBusinessConfirmMessage"), getLocaleString(client, "BuyBusinessConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); showPlayerPrompt(client, getLocaleString(client, "BuyBusinessConfirmMessage"), getLocaleString(client, "BuyBusinessConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_BIZBUY; getPlayerData(client).promptType = VRR_PROMPT_BIZBUY;
} }
// =========================================================================== // ===========================================================================
@@ -1728,11 +1526,7 @@ function moveBusinessExitCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function getBusinessDataFromDatabaseId(databaseId) { function getBusinessDataFromDatabaseId(databaseId) {
if (databaseId <= 0) { let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId)
return false;
}
let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == databaseId)
if (matchingBusinesses.length == 1) { if (matchingBusinesses.length == 1) {
return matchingBusinesses[0]; return matchingBusinesses[0];
} }
@@ -1895,7 +1689,7 @@ function saveBusinessToDatabase(businessId) {
["biz_entrance_vw", tempBusinessData.entranceDimension], ["biz_entrance_vw", tempBusinessData.entranceDimension],
["biz_entrance_pickup", tempBusinessData.entrancePickupModel], ["biz_entrance_pickup", tempBusinessData.entrancePickupModel],
["biz_entrance_blip", tempBusinessData.entranceBlipModel], ["biz_entrance_blip", tempBusinessData.entranceBlipModel],
//["biz_entrance_cutscene", tempBusinessData.entranceCutscene], ["biz_entrance_cutscene", tempBusinessData.entranceCutscene],
["biz_exit_pos_x", tempBusinessData.exitPosition.x], ["biz_exit_pos_x", tempBusinessData.exitPosition.x],
["biz_exit_pos_y", tempBusinessData.exitPosition.y], ["biz_exit_pos_y", tempBusinessData.exitPosition.y],
["biz_exit_pos_z", tempBusinessData.exitPosition.z], ["biz_exit_pos_z", tempBusinessData.exitPosition.z],
@@ -1904,14 +1698,14 @@ function saveBusinessToDatabase(businessId) {
["biz_exit_vw", tempBusinessData.exitDimension], ["biz_exit_vw", tempBusinessData.exitDimension],
["biz_exit_pickup", tempBusinessData.exitPickupModel], ["biz_exit_pickup", tempBusinessData.exitPickupModel],
["biz_exit_blip", tempBusinessData.exitBlipModel], ["biz_exit_blip", tempBusinessData.exitBlipModel],
//["biz_exit_cutscene", tempBusinessData.exitCutscene], ["biz_exit_cutscene", tempBusinessData.exitCutscene],
["biz_has_interior", boolToInt(tempBusinessData.hasInterior)], ["biz_has_interior", boolToInt(tempBusinessData.hasInterior)],
["biz_interior_lights", boolToInt(tempBusinessData.interiorLights)], ["biz_interior_lights", boolToInt(tempBusinessData.interiorLights)],
["biz_label_help_type", tempBusinessData.labelHelpType], ["biz_label_help_type", tempBusinessData.labelHelpType],
["biz_radio_station", toInteger(tempBusinessData.streamingRadioStation)], ["biz_radiostation", tempBusinessData.streamingRadioStation],
["biz_custom_interior", boolToInt(tempBusinessData.customInterior)], ["biz_custom_interior", boolToInt(tempBusinessData.customInterior)],
["biz_buy_price", tempBusinessData.buyPrice], ["biz_buy_price", boolToInt(tempBusinessData.buyPrice)],
//["biz_rent_price", tempBusinessData.rentPrice], //["biz_rent_price", boolToInt(tempBusinessData.rentPrice)],
]; ];
let dbQuery = null; let dbQuery = null;
@@ -1948,7 +1742,7 @@ function createAllBusinessPickups() {
return false; return false;
} }
if (!isGameFeatureSupported("pickup")) { if (!isGameFeatureSupported("pickups")) {
return false; return false;
} }
@@ -1974,7 +1768,7 @@ function createAllBusinessBlips() {
return false; return false;
} }
if (!isGameFeatureSupported("blip")) { if (!isGameFeatureSupported("blips")) {
return false; return false;
} }
@@ -2002,7 +1796,7 @@ function createBusinessEntrancePickup(businessId) {
return false; return false;
} }
if (!isGameFeatureSupported("pickup")) { if (!isGameFeatureSupported("pickups")) {
return false; return false;
} }
@@ -2074,7 +1868,7 @@ function createBusinessEntranceBlip(businessId) {
return false; return false;
} }
if (!isGameFeatureSupported("blip")) { if (!isGameFeatureSupported("blips")) {
return false; return false;
} }
@@ -2136,7 +1930,7 @@ function createBusinessExitPickup(businessId) {
return false; return false;
} }
if (!isGameFeatureSupported("pickup")) { if (!isGameFeatureSupported("pickups")) {
return false; return false;
} }
@@ -2197,7 +1991,7 @@ function createBusinessExitBlip(businessId) {
return false; return false;
} }
if (!isGameFeatureSupported("blip")) { if (!isGameFeatureSupported("blips")) {
return false; return false;
} }
@@ -2249,7 +2043,7 @@ function createBusinessExitBlip(businessId) {
* *
*/ */
function deleteBusiness(businessId, whoDeleted = 0) { function deleteBusiness(businessId, whoDeleted = 0) {
let tempBusinessData = getBusinessData(businessId); let tempBusinessData = getServerData().businesses[businessId];
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
let dbQuery = null; let dbQuery = null;
@@ -2258,7 +2052,7 @@ function deleteBusiness(businessId, whoDeleted = 0) {
deleteBusinessPickups(businessId); deleteBusinessPickups(businessId);
if (dbConnection) { if (dbConnection) {
dbQuery = queryDatabase(dbConnection, `UPDATE biz_main SET biz_deleted = 1, biz_when_deleted = UNIX_TIMESTAMP(), biz_who_deleted = ${whoDeleted} WHERE biz_id = ${tempBusinessData.databaseId}`); dbQuery = queryDatabase(dbConnection, `UPDATE biz_main WHERE biz_deleted = 1, biz_when_deleted = UNIX_TIMESTAMP(), biz_who_deleted = ${whoDeleted} WHERE biz_id ${tempBusinessData.databaseId}`);
if (dbQuery) { if (dbQuery) {
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
} }
@@ -2344,17 +2138,17 @@ function exitBusiness(client) {
*/ */
function getBusinessOwnerTypeText(ownerType) { function getBusinessOwnerTypeText(ownerType) {
switch (ownerType) { switch (ownerType) {
case AGRP_BIZ_OWNER_CLAN: case VRR_BIZOWNER_CLAN:
return "clan"; return "clan";
case AGRP_BIZ_OWNER_JOB: case VRR_BIZOWNER_JOB:
return "job"; return "job";
case AGRP_BIZ_OWNER_PLAYER: case VRR_BIZOWNER_PLAYER:
return "player"; return "player";
case AGRP_BIZ_OWNER_NONE: case VRR_BIZOWNER_NONE:
case AGRP_BIZ_OWNER_PUBLIC: case VRR_BIZOWNER_PUBLIC:
return "not owned"; return "not owned";
default: default:
@@ -2369,10 +2163,6 @@ function getBusinessOwnerTypeText(ownerType) {
* @return {BusinessData} The business's data (class instance) * @return {BusinessData} The business's data (class instance)
*/ */
function getBusinessData(businessId) { function getBusinessData(businessId) {
if (businessId == -1) {
return false;
}
if (typeof getServerData().businesses[businessId] != null) { if (typeof getServerData().businesses[businessId] != null) {
return getServerData().businesses[businessId]; return getServerData().businesses[businessId];
} }
@@ -2402,7 +2192,7 @@ function deleteBusinessEntrancePickup(businessId) {
return false; return false;
} }
if (!isGameFeatureSupported("pickup")) { if (!isGameFeatureSupported("pickups")) {
return false; return false;
} }
@@ -2429,7 +2219,7 @@ function deleteBusinessExitPickup(businessId) {
return false; return false;
} }
if (!isGameFeatureSupported("pickup")) { if (!isGameFeatureSupported("pickups")) {
return false; return false;
} }
@@ -2452,7 +2242,7 @@ function deleteBusinessEntranceBlip(businessId) {
return false; return false;
} }
if (!isGameFeatureSupported("blip")) { if (!isGameFeatureSupported("blips")) {
return false; return false;
} }
@@ -2531,19 +2321,6 @@ function reloadAllBusinessesCommand(command, params, client) {
function setBusinessDataIndexes() { function setBusinessDataIndexes() {
for (let i in getServerData().businesses) { for (let i in getServerData().businesses) {
getServerData().businesses[i].index = i; getServerData().businesses[i].index = i;
//if (getServerData().businesses[i].streamingRadioStation > 0) {
// let radioStationIndex = getRadioStationFromDatabaseId(getServerData().businesses[i].streamingRadioStation);
// if (radioStationIndex != -1) {
// getServerData().businesses[i].streamingRadioStationIndex = radioStationIndex;
// }
//}
for (let j in getServerData().businesses[i].locations) {
if (getServerData().businesses[i].locations[j].type == AGRP_BIZ_LOC_ATM) {
getServerData().atmLocationCache.push([i, j, getServerData().businesses[i].locations[j].position]);
}
}
} }
} }
@@ -2556,7 +2333,7 @@ function addToBusinessInventory(businessId, itemType, amount, buyPrice) {
tempItemData.buyPrice = buyPrice; tempItemData.buyPrice = buyPrice;
tempItemData.itemType = getItemTypeData(itemType).databaseId; tempItemData.itemType = getItemTypeData(itemType).databaseId;
tempItemData.ownerId = getBusinessData(business).databaseId; tempItemData.ownerId = getBusinessData(business).databaseId;
tempItemData.ownerType = AGRP_ITEMOWNER_BIZ; tempItemData.ownerType = VRR_ITEMOWNER_BIZ;
tempItemData.ownerIndex = businessId; tempItemData.ownerIndex = businessId;
tempItemData.itemTypeIndex = itemType; tempItemData.itemTypeIndex = itemType;
saveItemToDatabase(tempItemData); saveItemToDatabase(tempItemData);
@@ -2648,7 +2425,7 @@ function buyFromBusinessCommand(command, params, client) {
} }
takePlayerCash(client, totalCost); takePlayerCash(client, totalCost);
createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).value, AGRP_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount); createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount);
cachePlayerHotBarItems(client); cachePlayerHotBarItems(client);
getBusinessData(businessId).till = getBusinessData(businessId).till + totalCost; getBusinessData(businessId).till = getBusinessData(businessId).till + totalCost;
@@ -2658,7 +2435,7 @@ function buyFromBusinessCommand(command, params, client) {
} }
let useType = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).useType; let useType = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).useType;
if (useType == AGRP_ITEM_USE_TYPE_WEAPON || AGRP_ITEM_USE_TYPE_TAZER || useType == AGRP_ITEM_USE_TYPE_AMMO_CLIP) { if (useType == VRR_ITEM_USETYPE_WEAPON || VRR_ITEM_USETYPE_TAZER || useType == VRR_ITEM_USETYPE_AMMO_CLIP) {
if (isPlayerWeaponBanned(client) && !isPlayerExemptFromAntiCheat(client)) { if (isPlayerWeaponBanned(client) && !isPlayerExemptFromAntiCheat(client)) {
messagePlayerError(client, getLocaleString(client, "WeaponBanned")); messagePlayerError(client, getLocaleString(client, "WeaponBanned"));
return false; return false;
@@ -2757,7 +2534,7 @@ function storeItemInBusinessStorageCommand(command, params, client) {
return false; return false;
} }
getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).ownerType = AGRP_ITEM_OWNER_BIZSTORAGE; getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).ownerType = VRR_ITEM_OWNER_BIZSTORAGE;
getBusinessData(businessId).storageItemCache[firstSlot] = getBusinessData(businessId).floorItemCache[itemSlot - 1]; getBusinessData(businessId).storageItemCache[firstSlot] = getBusinessData(businessId).floorItemCache[itemSlot - 1];
getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1; getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1;
messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} to the business storage in slot ${firstSlot}`); messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} to the business storage in slot ${firstSlot}`);
@@ -2801,7 +2578,7 @@ function stockItemOnBusinessFloorCommand(command, params, client) {
return false; return false;
} }
getItemData(getBusinessData(businessId).storageItemCache[itemSlot - 1]).ownerType = AGRP_ITEM_OWNER_BIZFLOOR; getItemData(getBusinessData(businessId).storageItemCache[itemSlot - 1]).ownerType = VRR_ITEM_OWNER_BIZFLOOR;
getBusinessData(businessId).floorItemCache[firstSlot] = getBusinessData(businessId).storageItemCache[itemSlot - 1]; getBusinessData(businessId).floorItemCache[firstSlot] = getBusinessData(businessId).storageItemCache[itemSlot - 1];
getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1; getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1;
messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} of the business storage to the business floor slot ${firstSlot}`); messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} of the business storage to the business floor slot ${firstSlot}`);
@@ -2841,14 +2618,14 @@ function cacheBusinessItems(businessId) {
//let businessData = getBusinessData(businessId); //let businessData = getBusinessData(businessId);
//logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${businessData.name}) ...`); //logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${businessData.name}) ...`);
//getBusinessData(businessId).floorItemCache = getServerData().items.filter(item => item.ownerType == AGRP_ITEM_OWNER_BIZFLOOR && item.ownerId == businessData.databaseId).map(i => i.index); //getBusinessData(businessId).floorItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZFLOOR && item.ownerId == businessData.databaseId).map(i => i.index);
//getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == AGRP_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId); //getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId);
logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${getBusinessData(businessId).name}) ...`); logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${getBusinessData(businessId).name}) ...`);
for (let i in getServerData().items) { for (let i in getServerData().items) {
if (getItemData(i).ownerType == AGRP_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { if (getItemData(i).ownerType == VRR_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) {
getBusinessData(businessId).floorItemCache.push(i); getBusinessData(businessId).floorItemCache.push(i);
} else if (getItemData(i).ownerType == AGRP_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { } else if (getItemData(i).ownerType == VRR_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) {
getBusinessData(businessId).storageItemCache.push(i); getBusinessData(businessId).storageItemCache.push(i);
} }
} }
@@ -2872,50 +2649,50 @@ function updateBusinessPickupLabelData(businessId) {
} }
if (getBusinessData(businessId).exitPickup != null) { if (getBusinessData(businessId).exitPickup != null) {
setEntityData(getBusinessData(businessId).exitPickup, "agrp.owner.type", AGRP_PICKUP_BUSINESS_EXIT, false); setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_EXIT, false);
setEntityData(getBusinessData(businessId).exitPickup, "agrp.owner.id", businessId, false); setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.id", businessId, false);
setEntityData(getBusinessData(businessId).exitPickup, "agrp.label.type", AGRP_LABEL_EXIT, true); setEntityData(getBusinessData(businessId).exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true);
} }
if (getBusinessData(businessId).entrancePickup != null) { if (getBusinessData(businessId).entrancePickup != null) {
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.owner.type", AGRP_PICKUP_BUSINESS_ENTRANCE, false); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_ENTRANCE, false);
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.owner.id", businessId, false); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.id", businessId, false);
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.type", AGRP_LABEL_BUSINESS, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.type", VRR_LABEL_BUSINESS, true);
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.name", getBusinessData(businessId).name, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.name", getBusinessData(businessId).name, true);
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.locked", getBusinessData(businessId).locked, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.locked", getBusinessData(businessId).locked, true);
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_NONE, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_NONE, true);
switch (getBusinessData(businessId).labelHelpType) { switch (getBusinessData(businessId).labelHelpType) {
case AGRP_PROPLABEL_INFO_ENTERVEHICLE: { case VRR_PROPLABEL_INFO_ENTERVEHICLE: {
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_ENTERVEHICLE, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTERVEHICLE, true);
break; break;
} }
case AGRP_PROPLABEL_INFO_ENTER: { case VRR_PROPLABEL_INFO_ENTER: {
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_ENTER, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTER, true);
break; break;
} }
case AGRP_PROPLABEL_INFO_REPAIR: { case VRR_PROPLABEL_INFO_REPAIR: {
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_REPAIR, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_REPAIR, true);
break; break;
} }
default: { default: {
if (getBusinessData(businessId).hasInterior) { if (getBusinessData(businessId).hasInterior) {
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_ENTER, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTER, true);
} else { } else {
if (doesBusinessHaveAnyItemsToBuy(businessId)) { if (doesBusinessHaveAnyItemsToBuy(businessId)) {
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_BUY, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUY, true);
} else { } else {
removeEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help"); removeEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help");
} }
} }
break; break;
} }
} }
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.price", getBusinessData(businessId).buyPrice, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.price", getBusinessData(businessId).buyPrice, true);
} }
} }
@@ -2993,7 +2770,7 @@ function doesBusinessHaveAnyItemsToBuy(businessId) {
//function clearPlayerBusinessGameScripts(client, businessId) { //function clearPlayerBusinessGameScripts(client, businessId) {
// for(let i in getBusinessData(businessId).gameScripts) { // for(let i in getBusinessData(businessId).gameScripts) {
// sendPlayerGameScriptState(client, AGRP_GAMESCRIPT_DENY); // sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY);
// } // }
//} //}
@@ -3015,11 +2792,11 @@ function canPlayerWithdrawFromBusinessTill(client, businessId) {
return true; return true;
} }
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true; return true;
} }
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) {
return true; return true;
} }
@@ -3035,11 +2812,11 @@ function canPlayerSetBusinessInteriorLights(client, businessId) {
return true; return true;
} }
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true; return true;
} }
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) {
return true; return true;
} }
@@ -3055,11 +2832,11 @@ function canPlayerLockUnlockBusiness(client, businessId) {
return true; return true;
} }
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true; return true;
} }
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) {
return true; return true;
} }
@@ -3075,13 +2852,13 @@ function canPlayerManageBusiness(client, businessId) {
return true; return true;
} }
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_PLAYER) { if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER) {
if (getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true; return true;
} }
} }
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_CLAN) { if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN) {
if (getBusinessData(businessId).ownerId == getPlayerClan(client)) { if (getBusinessData(businessId).ownerId == getPlayerClan(client)) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) {
return true; return true;
@@ -3174,7 +2951,6 @@ function getClosestBusinessWithBuyableItemOfUseType(position, useType) {
function getBusinessesWithBuyableItemOfUseType(useType) { function getBusinessesWithBuyableItemOfUseType(useType) {
let businesses = getServerData().businesses; let businesses = getServerData().businesses;
let availableBusinesses = [];
for (let i in businesses) { for (let i in businesses) {
if (doesBusinessHaveBuyableItemOfUseType(i, useType)) { if (doesBusinessHaveBuyableItemOfUseType(i, useType)) {
availableBusinesses.push(i); availableBusinesses.push(i);

View File

@@ -1,177 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: casino.js
// DESC: Provides casino games functions and commands
// TYPE: Server (JavaScript)
// ===========================================================================
const AGRP_CASINO_GAME_NONE = 0;
const AGRP_CASINO_GAME_BLACKJACK = 1;
const AGRP_CASINO_GAME_POKER = 2;
const AGRP_CASINO_GAME_BACCARAT = 3;
const AGRP_CASINO_GAME_ROULETTE = 4;
const AGRP_CASINO_GAME_CRAPS = 5;
const AGRP_CASINO_GAME_HOLDEM = 6;
// ===========================================================================
const AGRP_CASINO_DECK_SUIT_NONE = 1;
const AGRP_CASINO_DECK_SUIT_CLUBS = 1;
const AGRP_CASINO_DECK_SUIT_DIAMONDS = 2;
const AGRP_CASINO_DECK_SUIT_HEARTS = 3;
const AGRP_CASINO_DECK_SUIT_SPADES = 4;
// ===========================================================================
class DeckCard {
constructor(suit, value, imageName) {
this.suit = suit;
this.value = value;
this.imageName = imageName;
}
}
// ===========================================================================
let cardDeck = [
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 1, "deckCardClubAce"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 2, "deckCardClubTwo"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 3, "deckCardClubThree"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 4, "deckCardClubFour"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 5, "deckCardClubFive"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 6, "deckCardClubSix"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 7, "deckCardClubSeven"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 8, "deckCardClubEight"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 9, "deckCardClubNine"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 10, "deckCardClubTen"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 11, "deckCardClubJack"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 12, "deckCardClubQueen"),
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 13, "deckCardClubKing"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 1, "deckCardDiamondAce"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 2, "deckCardDiamondTwo"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 3, "deckCardDiamondThree"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 4, "deckCardDiamondFour"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 5, "deckCardDiamondFive"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 6, "deckCardDiamondSix"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 7, "deckCardDiamondSeven"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 8, "deckCardDiamondEight"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 9, "deckCardDiamondNine"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 10, "deckCardDiamondTen"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 11, "deckCardDiamondJack"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 12, "deckCardDiamondQueen"),
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 13, "deckCardDiamondKing"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 1, "deckCardHeartAce"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 2, "deckCardHeartTwo"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 3, "deckCardHeartThree"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 4, "deckCardHeartFour"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 5, "deckCardHeartFive"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 6, "deckCardHeartSix"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 7, "deckCardHeartSeven"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 8, "deckCardHeartEight"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 9, "deckCardHeartNine"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 10, "deckCardHeartTen"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 11, "deckCardHeartJack"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 12, "deckCardHeartQueen"),
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 13, "deckCardHeartKing"),
];
// ===========================================================================
function createBlackJackDeck() {
let deck = [];
for (let i in cardDeck) {
deck.push(cardDeck[i]);
}
return deck;
}
// ===========================================================================
function shuffleBlackJackDeck(deck) {
// For 1000 turns, switch the values of two random cards
// This may need to be lowered for a more optimized shuffling algorithm (reduces server load)
for (var i = 0; i < 1000; i++) {
var location1 = Math.floor((Math.random() * deck.length));
var location2 = Math.floor((Math.random() * deck.length));
var tmp = deck[location1];
deck[location1] = deck[location2];
deck[location2] = tmp;
}
}
// ===========================================================================
function blackJackHitCommand(command, params, client) {
if (!isPlayerPlayingBlackJack(client)) {
return false;
}
if (isPlayersTurnInBlackJack(client)) {
return false;
}
let hand = getPlayerData(client).casinoCardHand;
hand.push(deck.pop());
let tempHandValue = 0;
for (let i in hand) {
if (hand[i].value == 1) {
if ((tempHandValue + 11) > 21) {
tempHandValue += 1;
} else {
tempHandValue += 11;
}
} else {
tempHandValue += hand[i].value;
}
}
if (handValue > 21) {
playerBustBlackJack(client);
return false;
}
}
// ===========================================================================
function blackJackStandCommand(command, params, client) {
if (!isPlayerPlayingBlackJack(client)) {
return false;
}
if (isPlayersTurnInBlackJack(client)) {
return false;
}
return true;
}
// ===========================================================================
function blackJackHit(hand, deck) {
return handValue;
}
// ===========================================================================
function dealPlayerBlackJackHand(deck, players) {
// Alternate handing cards to each player, 2 cards each
for (var i = 0; i < 2; i++) {
for (var x = 0; x < players.length; x++) {
var card = deck.pop();
getPlayerData(players[i]).casinoCardHand.push(card);
updateCasinoCardHand(players[i]);
}
}
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: chat.js // FILE: chat.js
// DESC: Provides chat functions and usage // DESC: Provides chat functions and usage
@@ -17,23 +16,23 @@ function initChatScript() {
// =========================================================================== // ===========================================================================
function processPlayerChat(client, messageText) { function processPlayerChat(client, messageText) {
if (!isConsole(client)) { if(!isConsole(client)) {
if (!getPlayerData(client)) { if(!getPlayerData(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat")); messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
return false; return false;
} }
if (!isPlayerLoggedIn(client)) { if(!isPlayerLoggedIn(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat")); messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
return false; return false;
} }
if (!isPlayerSpawned(client)) { if(!isPlayerSpawned(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat")); messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
return false; return false;
} }
if (isPlayerMuted(client)) { if(isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat")); messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false; return false;
} }
@@ -62,7 +61,7 @@ function processPlayerChat(client, messageText) {
// =========================================================================== // ===========================================================================
function meActionCommand(command, params, client) { function meActionCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -74,12 +73,12 @@ function meActionCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function doActionCommand(command, params, client) { function doActionCommand(command, params, client) {
if (isPlayerMuted(client)) { if(isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat")); messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false; return false;
} }
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -91,12 +90,12 @@ function doActionCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function shoutCommand(command, params, client) { function shoutCommand(command, params, client) {
if (isPlayerMuted(client)) { if(isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat")); messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false; return false;
} }
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -108,17 +107,17 @@ function shoutCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function megaphoneChatCommand(command, params, client) { function megaphoneChatCommand(command, params, client) {
if (isPlayerMuted(client)) { if(isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat")); messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false; return false;
} }
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
if (!canPlayerUseMegaphone(client)) { if(!canPlayerUseMegaphone(client)) {
messagePlayerError(client, getLocaleString(client, "CantUseMegaphone")); messagePlayerError(client, getLocaleString(client, "CantUseMegaphone"));
return false; return false;
} }
@@ -130,12 +129,12 @@ function megaphoneChatCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function talkCommand(command, params, client) { function talkCommand(command, params, client) {
if (isPlayerMuted(client)) { if(isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat")); messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false; return false;
} }
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -147,12 +146,12 @@ function talkCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function whisperCommand(command, params, client) { function whisperCommand(command, params, client) {
if (isPlayerMuted(client)) { if(isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat")); messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false; return false;
} }
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -164,12 +163,12 @@ function whisperCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function adminChatCommand(command, params, client) { function adminChatCommand(command, params, client) {
if (isPlayerMuted(client)) { if(isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat")); messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false; return false;
} }
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -180,12 +179,12 @@ function adminChatCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function clanChatCommand(command, params, client) { function clanChatCommand(command, params, client) {
if (isPlayerMuted(client)) { if(isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat")); messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false; return false;
} }
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -195,77 +194,24 @@ function clanChatCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function privateMessageCommand(command, params, client) {
if (isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
if (areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(splitParams[0]);
let messageText = splitParams.slice(1).join(" ");
if (!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
getPlayerData(targetClient).privateMessageReplyTo = client;
messagePlayerPrivateMessage(targetClient, client, messageText);
messagePlayerTip(client, getLocaleString(client, "PrivateMessageReplyCommandTip", "{ALTCOLOUR}/reply{MAINCOLOUR}"))
}
// ===========================================================================
function replyToLastPrivateMessageCommand(command, params, client) {
if (isPlayerMuted(client)) {
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
if (areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if (getPlayerData(client).privateMessageReplyTo == null) {
messagePlayerError(client, getLocaleString(client, "NoPrivateMessageToReply"));
return false;
}
getPlayerData(targetClient).privateMessageReplyTo = client;
messagePlayerPrivateMessage(targetClient, client, messageText);
}
// ===========================================================================
function talkToNearbyPlayers(client, messageText) { function talkToNearbyPlayers(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
messagePlayerTalk(clients[i], client, messageText); messagePlayerTalk(clients[i], client, messageText);
} }
} }
} }
if (getGlobalConfig().discord.sendLocalChat) {
messageDiscordChatChannel(`🗣️ ${getPlayerAccentInlineOutput(talkingClient)}${getClientSubAccountName(talkingClient)} says: ${messageText}`);
}
} }
// =========================================================================== // ===========================================================================
function phoneOutgoingToNearbyPlayers(client, messageText) { function phoneOutgoingToNearbyPlayers(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to phone): {MAINCOLOUR}${messageText}`); messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to phone): {MAINCOLOUR}${messageText}`);
} }
} }
@@ -276,9 +222,9 @@ function phoneOutgoingToNearbyPlayers(client, messageText) {
function phoneIncomingToNearbyPlayers(client, messageText) { function phoneIncomingToNearbyPlayers(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().phoneSpeakerDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().phoneSpeakerDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(from phone): {MAINCOLOUR}${messageText}`); messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(from phone): {MAINCOLOUR}${messageText}`);
} }
} }
@@ -289,115 +235,91 @@ function phoneIncomingToNearbyPlayers(client, messageText) {
function whisperToNearbyPlayers(client, messageText) { function whisperToNearbyPlayers(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().whisperDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().whisperDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
messagePlayerWhisper(clients[i], client, messageText); messagePlayerWhisper(clients[i], client, messageText);
} }
} }
} }
if (getGlobalConfig().discord.sendLocalChat) {
messageDiscordChatChannel(`🤫 ${getPlayerAccentInlineOutput(whisperingClient)}${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`);
}
} }
// =========================================================================== // ===========================================================================
function shoutToNearbyPlayers(client, messageText) { function shoutToNearbyPlayers(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().shoutDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().shoutDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
messagePlayerShout(clients[i], client, messageText); messagePlayerShout(clients[i], client, messageText);
} }
} }
} }
if (getGlobalConfig().discord.sendLocalChat) {
messageDiscordChatChannel(`🗣️ ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`);
}
} }
// =========================================================================== // ===========================================================================
function megaPhoneToNearbyPlayers(client, messageText) { function megaPhoneToNearbyPlayers(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().megaphoneDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().megaphoneDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
messagePlayerMegaPhone(clients[i], client, messageText); messagePlayerMegaPhone(clients[i], client, messageText);
} }
} }
} }
if (getGlobalConfig().discord.sendLocalChat) {
messageDiscordChatChannel(`📢 ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} (megaphone): ${messageText}!`);
}
} }
// =========================================================================== // ===========================================================================
function doActionToNearbyPlayers(client, messageText) { function doActionToNearbyPlayers(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().doActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().doActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
messagePlayerDoAction(clients[i], client, messageText); messagePlayerDoAction(clients[i], client, messageText);
} }
} }
} }
if (getGlobalConfig().discord.sendAction) {
messageDiscordChatChannel(`🙋 *${messageText} (${getCharacterFullName(client)})*`);
}
} }
// =========================================================================== // ===========================================================================
function meActionToNearbyPlayers(client, messageText) { function meActionToNearbyPlayers(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().meActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().meActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
messagePlayerMeAction(clients[i], client, messageText); messagePlayerMeAction(clients[i], client, messageText);
} }
} }
} }
if (getGlobalConfig().discord.sendAction) {
messageDiscordChatChannel(`🙋 *${getCharacterFullName(client)} ${messageText}*`);
}
} }
// =========================================================================== // ===========================================================================
function clanChat(client, messageText) { function clanChat(client, messageText) {
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (isPlayerSpawned(clients[i])) { if(isPlayerSpawned(clients[i])) {
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || arePlayersInSameClan(client, clients[i])) { if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || arePlayersInSameClan(client, clients[i])) {
messagePlayerClanChat(clients[i], client, messageText); messagePlayerClanChat(clients[i], client, messageText);
} }
} }
} }
//if (getGlobalConfig().discord.sendClan) {
// messageDiscordClanWebhook(getPlayerClan(client), getClanDiscordWebhookFlagValue("ClanChat"), fullString);
//}
} }
// =========================================================================== // ===========================================================================
function canPlayerUseMegaphone(client) { function canPlayerUseMegaphone(client) {
if (getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_MEGAPHONE) != -1) { if(getPlayerFirstItemSlotByUseType(client, VRR_ITEM_USETYPE_MEGAPHONE) != -1) {
if (isPlayerActiveItemEnabled(client)) { if(isPlayerActiveItemEnabled(client)) {
return true; return true;
} }
} }
if (getPlayerVehicle(client)) { if(getPlayerVehicle(client)) {
if (doesVehicleHaveMegaphone(getPlayerVehicle(client))) { if(doesVehicleHaveMegaphone(getPlayerVehicle(client))) {
return true; return true;
} }
} }

File diff suppressed because it is too large Load Diff

1723
scripts/server/class.js Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,48 +1,12 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: command.js // FILE: command.js
// DESC: Provides command data, functions and usage // DESC: Provides command data, functions and usage
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
/**
* @class Representing a command's data. Loaded and saved in the database
*/
class CommandData {
enable() {
this.enabled = true;
}
disable() {
this.enabled = false;
}
toggleEnabled() {
this.enabled = !this.enabled;
}
constructor(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, helpDescription) {
this.command = command;
this.handlerFunction = handlerFunction;
this.syntaxString = syntaxString;
this.requiredStaffFlags = requiredStaffFlags;
this.enabled = true;
this.requireLogin = requireLogin;
this.allowOnDiscord = allowOnDiscord;
this.helpDescription = helpDescription;
this.aliases = [];
}
};
// ===========================================================================
let serverCommands = [];
// ===========================================================================
function initCommandScript() { function initCommandScript() {
logToConsole(LOG_INFO, "[VRR.Command]: Initializing commands script ..."); logToConsole(LOG_INFO, "[VRR.Command]: Initializing commands script ...");
logToConsole(LOG_INFO, "[VRR.Command]: Initialized commands script!"); logToConsole(LOG_INFO, "[VRR.Command]: Initialized commands script!");
@@ -70,17 +34,8 @@ function loadCommands() {
new CommandData("notips", toggleNoRandomTipsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off random tips"), new CommandData("notips", toggleNoRandomTipsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off random tips"),
new CommandData("loginalert", toggleAccountLoginAttemptNotificationsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off email notifications for attempts to login to your account"), new CommandData("loginalert", toggleAccountLoginAttemptNotificationsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off email notifications for attempts to login to your account"),
new CommandData("scrolllines", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"), new CommandData("scrolllines", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
new CommandData("chatscrolllines", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
new CommandData("chatscroll", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
new CommandData("chatautohide", setAccountChatAutoHideDelayCommand, "<time in seconds>", getStaffFlagValue("None"), true, false, "Sets how long to wait to hide the chatbox after last use (in seconds)"), new CommandData("chatautohide", setAccountChatAutoHideDelayCommand, "<time in seconds>", getStaffFlagValue("None"), true, false, "Sets how long to wait to hide the chatbox after last use (in seconds)"),
new CommandData("chattimestamp", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
new CommandData("chattimestamps", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
new CommandData("chattime", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
new CommandData("chattimes", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
new CommandData("chatfilter", toggleAccountProfanityFilterCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off profanity filter"),
new CommandData("chatemoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
new CommandData("emoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
//new CommandData("noblood", toggleAccountHideBloodCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off blood in-game"),
], ],
ammunation: [], ammunation: [],
animation: [ animation: [
@@ -144,8 +99,7 @@ function loadCommands() {
new CommandData("bizdefaultitems", giveDefaultItemsToBusinessCommand, "<item template>", getStaffFlagValue("ManageItems"), true, true, "Gives the business the default items based on template name"), new CommandData("bizdefaultitems", giveDefaultItemsToBusinessCommand, "<item template>", getStaffFlagValue("ManageItems"), true, true, "Gives the business the default items based on template name"),
new CommandData("bizdelflooritems", deleteBusinessFloorItemsCommand, "", getStaffFlagValue("ManageItems"), true, true, "Destroys all items on the business floor (for-sale items)"), new CommandData("bizdelflooritems", deleteBusinessFloorItemsCommand, "", getStaffFlagValue("ManageItems"), true, true, "Destroys all items on the business floor (for-sale items)"),
new CommandData("bizdelstorageitems", deleteBusinessStorageItemsCommand, "", getStaffFlagValue("ManageItems"), true, true, "Destroys all items in the business's storage"), new CommandData("bizdelstorageitems", deleteBusinessStorageItemsCommand, "", getStaffFlagValue("ManageItems"), true, true, "Destroys all items in the business's storage"),
new CommandData("bizdealership", setBusinessDealershipCommand, "", getStaffFlagValue("None"), true, true, "Sets the business's door label to vehicle dealership"), new CommandData("bizdealership", setBusinessEntranceLabelToDealershipCommand, "", getStaffFlagValue("ManageBusinesses"), true, true, "Sets the business's door label to vehicle dealership"),
//new CommandData("bizpaintball", setBusinessPaintBallCommand, "", getStaffFlagValue("None"), true, true, "Sets the business to a paintball arena"),
], ],
chat: [ chat: [
new CommandData("me", meActionCommand, "<message>", getStaffFlagValue("None"), true, false, "Shows a custom action message in chat"), new CommandData("me", meActionCommand, "<message>", getStaffFlagValue("None"), true, false, "Shows a custom action message in chat"),
@@ -164,10 +118,6 @@ function loadCommands() {
new CommandData("a", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"), new CommandData("a", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
new CommandData("achat", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"), new CommandData("achat", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
new CommandData("m", megaphoneChatCommand, "<message>", getStaffFlagValue("None"), true, true, "Shouts a message over a megaphone (portable bullhorn/loudspeaker)"), new CommandData("m", megaphoneChatCommand, "<message>", getStaffFlagValue("None"), true, true, "Shouts a message over a megaphone (portable bullhorn/loudspeaker)"),
new CommandData("pm", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
new CommandData("dm", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
new CommandData("msg", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
new CommandData("reply", replyToLastPrivateMessageCommand, "<message>", getStaffFlagValue("None"), true, true, "Replies to the last private message you received"),
], ],
clan: [ clan: [
new CommandData("clans", listClansCommand, "[search text]", getStaffFlagValue("None"), true, true, "List clans (search by partial name, if provided)"), new CommandData("clans", listClansCommand, "[search text]", getStaffFlagValue("None"), true, true, "List clans (search by partial name, if provided)"),
@@ -265,8 +215,6 @@ function loadCommands() {
email: [ email: [
new CommandData("testemail", testEmailCommand, "<email address>", getStaffFlagValue("Developer"), true, true), new CommandData("testemail", testEmailCommand, "<email address>", getStaffFlagValue("Developer"), true, true),
], ],
fishing: [],
forensics: [],
gate: [ gate: [
new CommandData("gate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("gate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
@@ -275,8 +223,8 @@ function loadCommands() {
new CommandData("bizgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("bizgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("businessgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("businessgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("door", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("door", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
//new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
//new CommandData("closegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("closegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("opendoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("opendoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("closedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("closedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("garagedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"), new CommandData("garagedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
@@ -319,7 +267,6 @@ function loadCommands() {
new CommandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("ManageHouses"), true, true, "Moves a house's exit (inside/interior location to exit the house)"), new CommandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("ManageHouses"), true, true, "Moves a house's exit (inside/interior location to exit the house)"),
new CommandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("ManageHouses"), true, true, "Sets a house's interior to a pre-defined type"), new CommandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("ManageHouses"), true, true, "Sets a house's interior to a pre-defined type"),
], ],
insurance: [],
item: [ item: [
new CommandData("i", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("None"), true, false, "Switches to the item in the specified slot of your inventory."), new CommandData("i", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("None"), true, false, "Switches to the item in the specified slot of your inventory."),
new CommandData("item", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("None"), true, false, "Switches to the item in the specified slot of your inventory."), new CommandData("item", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("None"), true, false, "Switches to the item in the specified slot of your inventory."),
@@ -352,17 +299,9 @@ function loadCommands() {
new CommandData("additemtype", createItemTypeCommand, "<name>", getStaffFlagValue("ManageItems"), true, false, "Adds a new item type"), new CommandData("additemtype", createItemTypeCommand, "<name>", getStaffFlagValue("ManageItems"), true, false, "Adds a new item type"),
new CommandData("itemtypeusetype", setItemTypeUseTypeCommand, "<item type> <use type>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-type (what kind of action is performed when using it)"), new CommandData("itemtypeusetype", setItemTypeUseTypeCommand, "<item type> <use type>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-type (what kind of action is performed when using it)"),
new CommandData("itemtypeuseval", setItemTypeUseValueCommand, "<item type> <use value>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-value (how much gets subtracted when using it)"), new CommandData("itemtypeuseval", setItemTypeUseValueCommand, "<item type> <use value>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-value (how much gets subtracted when using it)"),
new CommandData("itemtypeorderprice", setItemTypeOrderPriceCommand, "<item type> <order price>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's order price (base price when ordering for a business"), new CommandData("itemtypeorderprice", setItemTypeOrderPriceCommand, "<item type> <price>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's order price (base price when ordering for a business"),
new CommandData("itemtyperiskmult", setItemTypeRiskMultiplierCommand, "<item type> <risk multiplier>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's risk multiplayer (higher value for more dangerous or rare illegal items)"), new CommandData("itemtyperiskmult", setItemTypeRiskMultiplierCommand, "<item type> <risk multiplier>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's risk multiplayer (higher value for more dangerous or rare illegal items)"),
new CommandData("itemtypeenabled", toggleItemTypeEnabledCommand, "<item type>", getStaffFlagValue("ManageItems"), true, false, "Toggles an item type on or off (if off, any items with that type can't be interacted with)"), new CommandData("itemtypeenabled", toggleItemTypeEnabledCommand, "<item type>", getStaffFlagValue("ManageItems"), true, false, "Toggles an item type on or off (if off, any items with that type can't be interacted with)"),
new CommandData("itemtypedroppos", setItemTypeDropPositionCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the offset position for the object of an item type when dropped"),
new CommandData("itemtypedroprot", setItemTypeDropRotationCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the rotation for the object of an item type when dropped"),
new CommandData("itemtypedropscale", setItemTypeDropScaleCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the scale for the object of an item type when dropped"),
new CommandData("itemtypedropfrontdistance", setItemTypeDropFrontDistanceCommand, "<item type> <distance>", getStaffFlagValue("ManageItems"), true, false, "Sets how far in front of a player an item type will be dropped"),
new CommandData("itemtypemaxval", setItemTypeMaxValueCommand, "<item type> <max value>", getStaffFlagValue("ManageItems"), true, false, "Sets the maximum value an item type can have"),
new CommandData("itemtypeorderval", setItemTypeOrderValueCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets the initial value of an item type when ordered by a business"),
new CommandData("itemtypesize", setItemTypeSizeCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets the item type's size"),
new CommandData("itemtypecapacity", setItemTypeSizeCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's capacity (how much it can hold)"),
new CommandData("delplritem", deleteItemInPlayerInventoryCommand, "<player name/id> <item slot>", getStaffFlagValue("ManageItems"), true, false, "Removes an item by slot from a player's personal inventory"), new CommandData("delplritem", deleteItemInPlayerInventoryCommand, "<player name/id> <item slot>", getStaffFlagValue("ManageItems"), true, false, "Removes an item by slot from a player's personal inventory"),
new CommandData("delplritems", deleteAllItemsInPlayerInventoryCommand, "<player name/id>", getStaffFlagValue("ManageItems"), true, false, "Removes all items from a player's personal inventory"), new CommandData("delplritems", deleteAllItemsInPlayerInventoryCommand, "<player name/id>", getStaffFlagValue("ManageItems"), true, false, "Removes all items from a player's personal inventory"),
@@ -416,14 +355,11 @@ function loadCommands() {
new CommandData("jobroutepay", setJobRoutePayCommand, "<amount>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutepay", setJobRoutePayCommand, "<amount>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutestartmsg", setJobRouteStartMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutestartmsg", setJobRouteStartMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutefinishmsg", setJobRouteFinishMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutefinishmsg", setJobRouteFinishMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutearrivemsg", setJobRouteDefaultLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutelocarrivemsg", setJobRouteLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutenextmsg", setJobRouteDefaultLocationNextMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutelocnextmsg", setJobRouteLocationNextMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutelocarrivemsg", setJobRouteNextLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutelocnextmsg", setJobRouteNextLocationGotoMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobrouteenabled", toggleJobRouteEnabledCommand, "", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobrouteenabled", toggleJobRouteEnabledCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutevehcolours", setJobRouteVehicleColoursCommand, "<colour 1> <colour 2>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutevehcolours", setJobRouteVehicleColoursCommand, "<colour 1> <colour 2>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutedelays", setJobRouteAllLocationDelaysCommand, "<time in milliseconds>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutedelays", setJobRouteAllLocationDelaysCommand, "<time in milliseconds>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutelocdelay", setJobRouteNextLocationDelayCommand, "<time in milliseconds>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobcolour", setJobColourCommand, "<job id/name> <red> <green> <blue>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobcolour", setJobColourCommand, "<job id/name> <red> <green> <blue>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobblip", setJobBlipCommand, "<job id/name> <blip id/name>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobblip", setJobBlipCommand, "<job id/name> <blip id/name>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobpickup", setJobPickupCommand, "<job id/name> <pickup id/name>", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobpickup", setJobPickupCommand, "<job id/name> <pickup id/name>", getStaffFlagValue("ManageJobs"), true, false),
@@ -470,13 +406,7 @@ function loadCommands() {
new CommandData("gps", gpsCommand, "[item or place name]", getStaffFlagValue("None"), true, false, "Shows you locations for special places or where to buy items"), new CommandData("gps", gpsCommand, "[item or place name]", getStaffFlagValue("None"), true, false, "Shows you locations for special places or where to buy items"),
new CommandData("speak", playerPedSpeakCommand, "<speech name>", getStaffFlagValue("None"), true, false, "Makes your ped say something in their game voice (IV only)"), new CommandData("speak", playerPedSpeakCommand, "<speech name>", getStaffFlagValue("None"), true, false, "Makes your ped say something in their game voice (IV only)"),
new CommandData("lock", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"), new CommandData("lock", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
new CommandData("locks", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
new CommandData("doorlock", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
new CommandData("lockdoor", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
new CommandData("lights", lightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights for your vehicle, house, or business"), new CommandData("lights", lightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights for your vehicle, house, or business"),
new CommandData("light", lightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights for your vehicle, house, or business"),
new CommandData("kill", suicideCommand, "", getStaffFlagValue("None"), true, false, "Kills yourself"),
new CommandData("suicide", suicideCommand, "", getStaffFlagValue("None"), true, false, "Kills yourself"),
], ],
npc: [ npc: [
new CommandData("addnpc", createNPCCommand, "<skin id/name>", getStaffFlagValue("ManageNPCs"), true, false, "Creates an NPC with the specified skin"), new CommandData("addnpc", createNPCCommand, "<skin id/name>", getStaffFlagValue("ManageNPCs"), true, false, "Creates an NPC with the specified skin"),
@@ -488,7 +418,6 @@ function loadCommands() {
//new CommandData("npcrespawnall", respawnAllNPCsCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns all NPCs"), //new CommandData("npcrespawnall", respawnAllNPCsCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns all NPCs"),
//new CommandData("npcrespawn", respawnNPCCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns the nearest NPC"), //new CommandData("npcrespawn", respawnNPCCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns the nearest NPC"),
], ],
paintball: [],
race: [ race: [
// Unfinished! // Unfinished!
//new CommandData("addrace", createRaceCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race"), //new CommandData("addrace", createRaceCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race"),
@@ -498,18 +427,14 @@ function loadCommands() {
//new CommandData("delracestart", deleteRaceStartPositionCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest starting position for a race"), //new CommandData("delracestart", deleteRaceStartPositionCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest starting position for a race"),
//new CommandData("delracecp", deleteRaceCheckPointCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest race checkpoint"), //new CommandData("delracecp", deleteRaceCheckPointCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest race checkpoint"),
//new CommandData("racename", setRaceNameCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Sets a race's name"), //new CommandData("racename", setRaceNameCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Sets a race's name"),
//new CommandData("racestart", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
//new CommandData("startrace", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"), //new CommandData("startrace", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
//new CommandData("racestop", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
//new CommandData("stoprace", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"), //new CommandData("stoprace", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
//new CommandData("racestopall", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops all active races"), //new CommandData("stopAllRacesCommand", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops a race"),
//new CommandData("stopallraces", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops all active races"),
], ],
radio: [ radio: [
new CommandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("None"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"), new CommandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("None"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"),
new CommandData("radiostations", showRadioStationListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all available radio stations"), new CommandData("radiostations", showRadioStationListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all available radio stations"),
new CommandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level 0-100>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."), new CommandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."),
new CommandData("radiovol", setStreamingRadioVolumeCommand, "<volume level 0-100>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."),
new CommandData("radioreloadall", reloadAllRadioStationsCommand, "", getStaffFlagValue("ManageServer"), true, false, "Reloads all radio stations from database (use after making changes)"), new CommandData("radioreloadall", reloadAllRadioStationsCommand, "", getStaffFlagValue("ManageServer"), true, false, "Reloads all radio stations from database (use after making changes)"),
], ],
security: [], security: [],
@@ -543,25 +468,18 @@ function loadCommands() {
new CommandData("int", playerInteriorCommand, "<player name/id> [interior id]", getStaffFlagValue("BasicModeration"), true, true, "Gets or sets a player's game interior."), new CommandData("int", playerInteriorCommand, "<player name/id> [interior id]", getStaffFlagValue("BasicModeration"), true, true, "Gets or sets a player's game interior."),
new CommandData("vw", playerVirtualWorldCommand, "<player name/id> [virtual world id]", getStaffFlagValue("BasicModeration"), true, true, "Gets or sets a player's virtual world/dimension."), new CommandData("vw", playerVirtualWorldCommand, "<player name/id> [virtual world id]", getStaffFlagValue("BasicModeration"), true, true, "Gets or sets a player's virtual world/dimension."),
new CommandData("addplrstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."), new CommandData("addplrstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
new CommandData("addplayerstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
new CommandData("addstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
new CommandData("delplrstaffflag", removePlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Takes a player's staff flag by name (this server only)."), new CommandData("delplrstaffflag", removePlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Takes a player's staff flag by name (this server only)."),
new CommandData("delstaffflag", removePlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Takes a player's staff flag by name (this server only)."), new CommandData("plrstaffflags", getPlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all staff flags a player has (this server only)."),
new CommandData("getplrstaffflags", getPlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all staff flags a player has (this server only)."), new CommandData("clearstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
new CommandData("delplrstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
new CommandData("delstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
new CommandData("allstaffflags", getStaffFlagsCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all valid staff flag names."), new CommandData("allstaffflags", getStaffFlagsCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all valid staff flag names."),
new CommandData("staffflags", getStaffFlagsCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all valid staff flag names."),
new CommandData("plrstafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."), new CommandData("plrstafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
new CommandData("playerstafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
new CommandData("stafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
new CommandData("givemoney", givePlayerMoneyCommand, "<player name/id> <amount>", getStaffFlagValue("serverManager"), true, true), new CommandData("givemoney", givePlayerMoneyCommand, "<player name/id> <amount>", getStaffFlagValue("serverManager"), true, true),
new CommandData("nonrpname", forceCharacterNameChangeCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to change their current character's name."), new CommandData("nonrpname", forceCharacterNameChangeCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to change their current character's name."),
new CommandData("setname", forceCharacterNameCommand, "<player name/id> <first name> <last name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's name directly."), new CommandData("setname", setCharacterNameCommand, "<player name/id> <first name> <last name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's name directly."),
new CommandData("setskin", forcePlayerSkinCommand, "<player name/id> <skin id/name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's skin."), new CommandData("setskin", setPlayerSkinCommand, "<player name/id> <skin id/name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's skin."),
new CommandData("setaccent", forcePlayerAccentCommand, "<player name/id> <accent name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's accent."), new CommandData("setaccent", setPlayerAccentCommand, "<player name/id> <accent name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's accent."),
new CommandData("setfightstyle", forcePlayerFightStyleCommand, "<player name/id> <fight style name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's fight style."), //new CommandData("setfightstyle", setPlayerFightStyleCommand, "<player name/id> <fight style name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's fight style."),
new CommandData("setstars", forcePlayerWantedLevelCommand, "<player name/id> <wanted level>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to have a wanted level"), new CommandData("setstars", setPlayerWantedLevelCommand, "<player name/id> <wanted level>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to have a wanted level"),
new CommandData("plrinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"), new CommandData("plrinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"),
new CommandData("playerinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"), new CommandData("playerinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"),
new CommandData("getplrhouses", getHousesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all houses owned by the player"), new CommandData("getplrhouses", getHousesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all houses owned by the player"),
@@ -576,20 +494,13 @@ function loadCommands() {
new CommandData("getplayervehicles", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"), new CommandData("getplayervehicles", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
new CommandData("geoip", getPlayerGeoIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves GeoIP information on a player (country & city)"), new CommandData("geoip", getPlayerGeoIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves GeoIP information on a player (country & city)"),
new CommandData("ip", getPlayerIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves IP information on a player"), new CommandData("ip", getPlayerIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves IP information on a player"),
new CommandData("getgeoip", getPlayerGeoIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves GeoIP information on a player (country & city)"),
new CommandData("getip", getPlayerIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves IP information on a player"),
new CommandData("plrsync", toggleSyncForElementsSpawnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Sets whether elements spawned by a player are synced (traffic, peds, etc)"), new CommandData("plrsync", toggleSyncForElementsSpawnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Sets whether elements spawned by a player are synced (traffic, peds, etc)"),
new CommandData("health", forcePlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"), new CommandData("health", setPlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
new CommandData("armour", forcePlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"), new CommandData("armour", setPlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
new CommandData("sethealth", forcePlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
new CommandData("setarmour", forcePlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
new CommandData("infiniterun", setPlayerInfiniteRunCommand, "<player name/id> <state>", getStaffFlagValue("BasicModeration"), true, true, "Toggles a player's infinite sprint"), new CommandData("infiniterun", setPlayerInfiniteRunCommand, "<player name/id> <state>", getStaffFlagValue("BasicModeration"), true, true, "Toggles a player's infinite sprint"),
new CommandData("atbiz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"), new CommandData("atbiz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("atbusiness", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"), new CommandData("atbusiness", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("athouse", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"), new CommandData("athouse", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
new CommandData("biz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("business", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("house", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
], ],
startup: [], startup: [],
subAccount: [ subAccount: [
@@ -701,17 +612,14 @@ function loadCommands() {
function addAllCommandHandlers() { function addAllCommandHandlers() {
let commandCount = 0; let commandCount = 0;
let commands = getCommands(); let commands = getCommands();
for (let i in commands) { for(let i in commands) {
for (let j in commands[i]) { for(let j in commands[i]) {
logToConsole(LOG_DEBUG, `[VRR.Command] Adding command handler for ${i} - ${commands[i][j].command}`); logToConsole(LOG_DEBUG, `[VRR.Command] Adding command handler for ${i} - ${commands[i][j].command}`);
addCommandHandler(commands[i][j].command, processPlayerCommand); addCommandHandler(commands[i][j].command, processPlayerCommand);
commandCount++; commandCount++;
} }
} }
removeCommandHandler("help");
addCommandHandler("help", helpCommand);
logToConsole(LOG_INFO, `[VRR.Command] ${commandCount} command handlers added!`); logToConsole(LOG_INFO, `[VRR.Command] ${commandCount} command handlers added!`);
} }
@@ -719,10 +627,10 @@ function addAllCommandHandlers() {
function getCommand(command) { function getCommand(command) {
let commandGroups = getCommands() let commandGroups = getCommands()
for (let i in commandGroups) { for(let i in commandGroups) {
let commandGroup = commandGroups[i]; let commandGroup = commandGroups[i];
for (let j in commandGroup) { for(let j in commandGroup) {
if (toLowerCase(commandGroup[j].command) == toLowerCase(command)) { if(toLowerCase(commandGroup[j].command) == toLowerCase(command)) {
return commandGroup[j]; return commandGroup[j];
} }
} }
@@ -776,14 +684,14 @@ function isCommandAllowedOnDiscord(command) {
// =========================================================================== // ===========================================================================
function disableCommand(command, params, client) { function disableCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
params = toLowerCase(params); params = toLowerCase(params);
if (!getCommand(params)) { if(!getCommand(params)) {
messagePlayerError(client, `The command {ALTCOLOUR}/${params} {MAINCOLOUR} does not exist!`); messagePlayerError(client, `The command {ALTCOLOUR}/${params} {MAINCOLOUR} does not exist!`);
return false; return false;
} }
@@ -796,14 +704,14 @@ function disableCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function enableCommand(command, params, client) { function enableCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
params = toLowerCase(params); params = toLowerCase(params);
if (!getCommand(params)) { if(!getCommand(params)) {
messagePlayerError(client, `The command {ALTCOLOUR}/${params} {MAINCOLOUR} does not exist!`); messagePlayerError(client, `The command {ALTCOLOUR}/${params} {MAINCOLOUR} does not exist!`);
return false; return false;
} }
@@ -816,19 +724,19 @@ function enableCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function disableAllCommandsByType(command, params, client) { function disableAllCommandsByType(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
params = toLowerCase(params); params = toLowerCase(params);
if (isNull(getServerData().commands[params])) { if(isNull(getServerData().commands[params])) {
messagePlayerError(client, `Command type {ALTCOLOUR}${params} {MAINCOLOUR}does not exist!`); messagePlayerError(client, `Command type {ALTCOLOUR}${params} {MAINCOLOUR}does not exist!`);
return false; return false;
} }
for (let i in getServerData().commands[params]) { for(let i in getServerData().commands[params]) {
getServerData().commands[params][i].enabled = false; getServerData().commands[params][i].enabled = false;
} }
@@ -839,19 +747,19 @@ function disableAllCommandsByType(command, params, client) {
// =========================================================================== // ===========================================================================
function enableAllCommandsByType(command, params, client) { function enableAllCommandsByType(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
params = toLowerCase(params); params = toLowerCase(params);
if (isNull(getServerData().commands[params])) { if(isNull(getServerData().commands[params])) {
messagePlayerError(client, `Command type {ALTCOLOUR}${params} {MAINCOLOUR}does not exist!`); messagePlayerError(client, `Command type {ALTCOLOUR}${params} {MAINCOLOUR}does not exist!`);
return false; return false;
} }
for (let i in getServerData().commands[params]) { for(let i in getServerData().commands[params]) {
getServerData().commands[params][i].enabled = true; getServerData().commands[params][i].enabled = true;
} }
@@ -868,22 +776,22 @@ function enableAllCommandsByType(command, params, client) {
// =========================================================================== // ===========================================================================
function processPlayerCommand(command, params, client) { function processPlayerCommand(command, params, client) {
if (builtInCommands.indexOf(toLowerCase(command)) != -1) { if(builtInCommands.indexOf(toLowerCase(command)) != -1) {
return true; return true;
} }
let commandData = getCommand(toLowerCase(command)); let commandData = getCommand(toLowerCase(command));
let paramsDisplay = params; let paramsDisplay = params;
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
paramsDisplay = ""; paramsDisplay = "";
} }
if (!doesCommandExist(toLowerCase(command))) { if(!doesCommandExist(toLowerCase(command))) {
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`); logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`);
let possibleCommand = getCommandFromParams(command); let possibleCommand = getCommandFromParams(command);
if (possibleCommand != false && doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(possibleCommand.command)))) { if(possibleCommand != false && doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(possibleCommand.command)))) {
messagePlayerError(client, getLocaleString(client, "InvalidCommandPossibleMatchTip", `{ALTCOLOUR}/${command}{MAINCOLOUR}`, `{ALTCOLOUR}${toLowerCase(possibleCommand.command)}{MAINCOLOUR}`)); messagePlayerError(client, getLocaleString(client, "InvalidCommandPossibleMatchTip", `{ALTCOLOUR}/${command}{MAINCOLOUR}`, `{ALTCOLOUR}${toLowerCase(possibleCommand.command)}{MAINCOLOUR}`));
} else { } else {
messagePlayerError(client, getLocaleString(client, "InvalidCommandHelpTip", `{ALTCOLOUR}/${command}{MAINCOLOUR}`, `{ALTCOLOUR}/help{MAINCOLOUR}`)); messagePlayerError(client, getLocaleString(client, "InvalidCommandHelpTip", `{ALTCOLOUR}/${command}{MAINCOLOUR}`, `{ALTCOLOUR}/help{MAINCOLOUR}`));
@@ -891,31 +799,31 @@ function processPlayerCommand(command, params, client) {
return false; return false;
} }
if (!commandData.enabled) { if(!commandData.enabled) {
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (command is disabled): /${command} ${paramsDisplay}`); logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (command is disabled): /${command} ${paramsDisplay}`);
messagePlayerError(client, `The command {ALTCOLOUR}/${command}{MAINCOLOUR} is disabled!`); messagePlayerError(client, `The command {ALTCOLOUR}/${command}{MAINCOLOUR} is disabled!`);
messagePlayerError(client, getLocaleString(client, "CommandDisabled", `{ALTCOLOUR}/${command}{MAINCOLOUR}`)); messagePlayerError(client, getLocaleString(client, "CommandDisabled", `{ALTCOLOUR}/${command}{MAINCOLOUR}`));
return false; return false;
} }
if (doesCommandRequireLogin(toLowerCase(command))) { if(doesCommandRequireLogin(toLowerCase(command))) {
if (!isPlayerLoggedIn(client)) { if(!isPlayerLoggedIn(client)) {
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (requires login first): /${command} ${paramsDisplay}`); logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (requires login first): /${command} ${paramsDisplay}`);
messagePlayerError(client, getLocaleString(client, "CommandRequiresLogin", `{ALTCOLOUR}/${command}{MAINCOLOUR}`)); messagePlayerError(client, getLocaleString(client, "CommandRequiresLogin", `{ALTCOLOUR}/${command}{MAINCOLOUR}`));
return false; return false;
} }
} }
if (isClientFromDiscord(client)) { if(isClientFromDiscord(client)) {
if (!isCommandAllowedOnDiscord(command)) { if(!isCommandAllowedOnDiscord(command)) {
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command from discord, but failed (not available on discord): /${command} ${paramsDisplay}`); logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command from discord, but failed (not available on discord): /${command} ${paramsDisplay}`);
messagePlayerError(client, `The {ALTCOLOUR}/${command}{MAINCOLOUR} command isn't available on discord!`); messagePlayerError(client, `The {ALTCOLOUR}/${command}{MAINCOLOUR} command isn't available on discord!`);
return false; return false;
} }
} }
if (!isConsole(client)) { if(!isConsole(client)) {
if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) { if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) {
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`); logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`);
messagePlayerError(client, getLocaleString(client, "CommandNoPermissions", `{ALTCOLOUR}/${toLowerCase(command)}{MAINCOLOUR}`)); messagePlayerError(client, getLocaleString(client, "CommandNoPermissions", `{ALTCOLOUR}/${toLowerCase(command)}{MAINCOLOUR}`));
return false; return false;
@@ -928,8 +836,8 @@ function processPlayerCommand(command, params, client) {
// =========================================================================== // ===========================================================================
addCommandHandler("cmd", function (command, params, client) { addCommandHandler("cmd", function(command, params, client) {
if (!isConsole(client)) { if(!isConsole(client)) {
return false; return false;
} }
@@ -944,8 +852,8 @@ addCommandHandler("cmd", function (command, params, client) {
function listAllCommands() { function listAllCommands() {
let commands = getCommands(); let commands = getCommands();
for (let i in commands) { for(let i in commands) {
for (let j in commands[i]) { for(let j in commands[i]) {
logToConsole(LOG_DEBUG, commands[i][j].command); logToConsole(LOG_DEBUG, commands[i][j].command);
} }
} }
@@ -956,8 +864,8 @@ function listAllCommands() {
function getAllCommandsInSingleArray() { function getAllCommandsInSingleArray() {
let tempCommands = []; let tempCommands = [];
let commands = getCommands(); let commands = getCommands();
for (let i in commands) { for(let i in commands) {
for (let j in commands[i]) { for(let j in commands[i]) {
tempCommands.push(commands[i][j].command); tempCommands.push(commands[i][j].command);
} }
} }
@@ -970,8 +878,8 @@ function getAllCommandsInSingleArray() {
function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") { function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") {
let tempCommands = []; let tempCommands = [];
let commands = getCommands(); let commands = getCommands();
for (let i in commands[groupName]) { for(let i in commands[groupName]) {
if (getCommandRequiredPermissions(commands[groupName][i].command) == 0) { if(getCommandRequiredPermissions(commands[groupName][i].command) == 0) {
tempCommands.push(commands[groupName][i].command); tempCommands.push(commands[groupName][i].command);
} }
} }
@@ -984,10 +892,10 @@ function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") {
function getAllCommandsForStaffFlagInSingleArray(staffFlagName) { function getAllCommandsForStaffFlagInSingleArray(staffFlagName) {
let tempCommands = []; let tempCommands = [];
let commands = getCommands(); let commands = getCommands();
for (let i in commands) { for(let i in commands) {
for (let j in commands[i]) { for(let j in commands[i]) {
if (getCommandRequiredPermissions(commands[i][j].command) != 0) { if(getCommandRequiredPermissions(commands[i][j].command) != 0) {
if (hasBitFlag(getCommandRequiredPermissions(commands[i][j].command), getStaffFlagValue(staffFlagName))) { if(hasBitFlag(getCommandRequiredPermissions(commands[i][j].command), getStaffFlagValue(staffFlagName))) {
tempCommands.push(commands[i][j].command); tempCommands.push(commands[i][j].command);
} }
} }
@@ -1000,7 +908,7 @@ function getAllCommandsForStaffFlagInSingleArray(staffFlagName) {
// =========================================================================== // ===========================================================================
function doesCommandExist(command) { function doesCommandExist(command) {
if (getCommandData(command)) { if(getCommandData(command)) {
return true; return true;
} }
@@ -1011,11 +919,11 @@ function doesCommandExist(command) {
function cacheAllCommandsAliases() { function cacheAllCommandsAliases() {
let commands = getCommands(); let commands = getCommands();
for (let i in commands) { for(let i in commands) {
for (let j in commands[i]) { for(let j in commands[i]) {
for (let k in commands) { for(let k in commands) {
for (let m in commands[k]) { for(let m in commands[k]) {
if (commands[i][j].handlerFunction == commands[k][m].handlerFunction) { if(commands[i][j].handlerFunction == commands[k][m].handlerFunction) {
commands[i][j].aliases.push(commands[k][m]); commands[i][j].aliases.push(commands[k][m]);
commands[k][m].aliases.push(commands[i][j]); commands[k][m].aliases.push(commands[i][j]);
} }
@@ -1029,7 +937,7 @@ function cacheAllCommandsAliases() {
function getCommandAliasesNames(command) { function getCommandAliasesNames(command) {
let commandAliases = []; let commandAliases = [];
for (let i in command.aliases) { for(let i in command.aliases) {
commandAliases.push(command.aliases[i].name); commandAliases.push(command.aliases[i].name);
} }
@@ -1039,7 +947,7 @@ function getCommandAliasesNames(command) {
// =========================================================================== // ===========================================================================
function areParamsEmpty(params) { function areParamsEmpty(params) {
if (!params || params == "" || params.length == 0 || typeof params == "undefined") { if(!params || params == "" || params.length == 0 || typeof params == "undefined") {
return true; return true;
} }
@@ -1061,16 +969,16 @@ function areThereEnoughParams(params, requiredAmount, delimiter = " ") {
// =========================================================================== // ===========================================================================
function getParam(params, delimiter, index) { function getParam(params, delimiter, index) {
return params.split(delimiter)[index - 1]; return params.split(delimiter)[index-1];
} }
// =========================================================================== // ===========================================================================
function getCommandFromParams(params) { function getCommandFromParams(params) {
let commands = getCommands(); let commands = getCommands();
for (let i in commands) { for(let i in commands) {
for (let j in commands[i]) { for(let j in commands[i]) {
if (toLowerCase(commands[i][j].command).indexOf(toLowerCase(params)) != -1) { if(toLowerCase(commands[i][j].command).indexOf(toLowerCase(params)) != -1) {
return commands[i][j]; return commands[i][j];
} }
} }

View File

@@ -1,154 +1,12 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: config.js // FILE: config.js
// DESC: Provides server configuration // DESC: Provides server configuration
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
/**
* @class Representing data for server configuration
*/
class ServerConfigData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.needsSaved = false;
this.newCharacter = {
spawnPosition: toVector3(0.0, 0.0, 0.0),
spawnHeading: 0.0,
spawnInterior: 0,
spawnDimension: 0,
money: 0,
bank: 0,
skin: 0,
};
this.connectCameraPosition = toVector3(0.0, 0.0, 0.0);
this.connectCameraLookAt = toVector3(0.0, 0.0, 0.0);
this.characterSelectCameraPosition = toVector3(0.0, 0.0, 0.0);
this.characterSelectCameraLookAt = toVector3(0.0, 0.0, 0.0);
this.characterSelectPedPosition = toVector3(0.0, 0.0, 0.0);
this.characterSelectPedHeading = 0.0;
this.characterSelectInterior = 0;
this.characterSelectDimension = 0;
this.name = "";
this.password = "";
this.hour = 0;
this.minute = 0
this.minuteDuration = 1000;
this.weather = 0
this.fallingSnow = false;
this.groundSnow = false;
this.useGUI = true;
this.guiColourPrimary = [200, 200, 200];
this.guiColourSecondary = [200, 200, 200];
this.guiTextColourPrimary = [0, 0, 0];
this.guiTextColourSecondary = [0, 0, 0];
this.showLogo = true;
this.inflationMultiplier = 1;
this.testerOnly = false;
this.devServer = false;
this.nameTagDistance = 50.0;
this.antiCheat = {
enabled: false,
//checkGameScripts: false,
//gameScriptWhiteListEnabled: false,
//gameScriptBlackListEnabled: false,
//gameScriptWhiteList: [],
//gameScriptBlackList: [],
};
this.discordBotToken = "";
this.discordEnabled = false;
this.createJobPickups = false;
this.createBusinessPickups = false;
this.createHousePickups = false;
this.createJobBlips = false;
this.createBusinessBlips = false;
this.createHouseBlips = false;
this.introMusicURL = "";
this.pauseSavingToDatabase = false;
this.useRealTime = false;
this.realTimeZone = 0;
this.discordConfig = {
sendEvents: true,
sendChat: true,
sendAdmin: true,
};
if (dbAssoc) {
this.databaseId = dbAssoc["svr_id"];
this.newCharacter = {
spawnPosition: toVector3(dbAssoc["svr_newchar_pos_x"], dbAssoc["svr_newchar_pos_y"], dbAssoc["svr_newchar_pos_z"]),
spawnHeading: dbAssoc["svr_newchar_rot_z"],
money: dbAssoc["svr_newchar_money"],
bank: dbAssoc["svr_newchar_bank"],
skin: dbAssoc["svr_newchar_skin"],
};
this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]);
this.connectCameraLookAt = toVector3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]);
this.name = toInteger(dbAssoc["svr_name"]);
this.password = toInteger(dbAssoc["svr_password"]);
this.hour = toInteger(dbAssoc["svr_start_time_hour"]);
this.minute = toInteger(dbAssoc["svr_start_time_min"]);
this.minuteDuration = toInteger(dbAssoc["svr_time_min_duration"]);
this.weather = toInteger(dbAssoc["svr_start_weather"]);
this.fallingSnow = intToBool(toInteger(dbAssoc["svr_snow_falling"]));
this.groundSnow = intToBool(toInteger(dbAssoc["svr_snow_ground"]));
this.useGUI = intToBool(toInteger(dbAssoc["svr_gui"]));
this.showLogo = intToBool(toInteger(dbAssoc["svr_logo"]));
this.createJobPickups = intToBool(toInteger(dbAssoc["svr_job_pickups"]));
this.createBusinessPickups = intToBool(toInteger(dbAssoc["svr_biz_pickups"]));
this.createHousePickups = intToBool(toInteger(dbAssoc["svr_house_pickups"]));
this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips"]));
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips"]));
this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips"]));
this.createPlayerBlips = intToBool(toInteger(dbAssoc["svr_player_blips"]));
this.guiColourPrimary = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])];
this.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])];
this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])];
//this.guiTextColourSecondary = [toInteger(dbAssoc["svr_gui_textcol2_r"]), toInteger(dbAssoc["svr_gui_textcol2_g"]), toInteger(dbAssoc["svr_gui_textcol2_b"])];
this.inflationMultiplier = toFloat(dbAssoc["svr_inflation_multiplier"]);
this.nameTagDistance = toFloat(dbAssoc["svr_nametag_distance"]);
this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]);
this.introMusicURL = dbAssoc["svr_intro_music"];
//this.useRealTime = intToBool(toInteger(dbAssoc["svr_real_time_enabled"]));
//this.realTimeZone = dbAssoc["svr_real_time_timezone"];
this.discord = {
sendEvents: intToBool(dbAssoc["svr_discord_send_events"]),
sendChat: intToBool(dbAssoc["svr_discord_send_chat"]),
sendAdmin: intToBool(dbAssoc["svr_discord_send_admin"]),
};
this.economy = {
inflationMultiplier: toFloat(dbAssoc["svr_inflation_multiplier"]),
incomeTaxRate: toFloat(dbAssoc["svr_income_tax_rate"]),
passiveIncome: toFloat(dbAssoc["svr_passive_income"]),
}
this.devServer = intToBool(toInteger(server.getCVar("agrp_devserver")));
this.testerOnly = intToBool(toInteger(server.getCVar("agrp_testeronly")));
}
}
};
// ===========================================================================
let serverConfig = false; let serverConfig = false;
let gameConfig = false; let gameConfig = false;
@@ -198,18 +56,18 @@ let globalConfig = {
geoIPCityDatabaseFilePath: "geoip-city.mmdb", geoIPCityDatabaseFilePath: "geoip-city.mmdb",
randomTipInterval: 600000, randomTipInterval: 600000,
weaponEquippableTypes: [ weaponEquippableTypes: [
AGRP_ITEM_USE_TYPE_WEAPON, VRR_ITEM_USETYPE_WEAPON,
AGRP_ITEM_USE_TYPE_TAZER, VRR_ITEM_USETYPE_TAZER,
AGRP_ITEM_USE_TYPE_EXTINGUISHER, VRR_ITEM_USETYPE_EXTINGUISHER,
AGRP_ITEM_USE_TYPE_SPRAYPAINT, VRR_ITEM_USETYPE_SPRAYPAINT,
AGRP_ITEM_USE_TYPE_PEPPERSPRAY, VRR_ITEM_USETYPE_PEPPERSPRAY,
], ],
onFootOnlyItems: [ onFootOnlyItems: [
AGRP_ITEM_USE_TYPE_VEHREPAIR, VRR_ITEM_USETYPE_VEHREPAIR,
AGRP_ITEM_USE_TYPE_VEHCOLOUR, VRR_ITEM_USETYPE_VEHCOLOUR,
AGRP_ITEM_USE_TYPE_VEHUPGRADE_PART, VRR_ITEM_USETYPE_VEHUPGRADE_PART,
AGRP_ITEM_USE_TYPE_VEHLIVERY, VRR_ITEM_USETYPE_VEHLIVERY,
AGRP_ITEM_USE_TYPE_VEHTIRE, VRR_ITEM_USETYPE_VEHTIRE,
], ],
vehicleInactiveRespawnDelay: 1800000, // 20 minutes vehicleInactiveRespawnDelay: 1800000, // 20 minutes
chatSectionHeaderLength: 96, chatSectionHeaderLength: 96,
@@ -227,8 +85,6 @@ let globalConfig = {
houseBlipStreamOutDistance: 120, houseBlipStreamOutDistance: 120,
jobBlipStreamInDistance: -1, jobBlipStreamInDistance: -1,
jobBlipStreamOutDistance: -1, jobBlipStreamOutDistance: -1,
playerStreamInDistance: -1,
playerStreamOutDistance: -1,
playerBlipStreamInDistance: -1, playerBlipStreamInDistance: -1,
playerBlipStreamOutDistance: -1, playerBlipStreamOutDistance: -1,
handcuffPlayerDistance: 3, handcuffPlayerDistance: 3,
@@ -239,13 +95,6 @@ let globalConfig = {
passwordRequiredSymbols: 0, passwordRequiredSymbols: 0,
minChatLines: 1, minChatLines: 1,
maxChatLines: 6, maxChatLines: 6,
vehicleTrunkDistance: 2.0,
fishingSpotDistance: 10.0,
atmDistance: 1.5,
loginTimeout: 60000,
fishingCastMaxStrength: 100,
fishingCastMinStrength: 30,
jobRouteLocationSphereRadius: 3,
}; };
// =========================================================================== // ===========================================================================
@@ -333,26 +182,6 @@ function loadServerConfigFromGameAndPort(gameId, port) {
// =========================================================================== // ===========================================================================
function loadServerConfigFromGame(gameId) {
let dbConnection = connectToDatabase();
if (dbConnection) {
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if (dbQuery) {
if (dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
}
disconnectFromDatabase(dbConnection);
}
return false;
}
// ===========================================================================
function loadServerConfigFromId(tempServerId) { function loadServerConfigFromId(tempServerId) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
@@ -1127,18 +956,11 @@ function getDatabaseConfig() {
function loadServerConfig() { function loadServerConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading server configuration"); logToConsole(LOG_DEBUG, "[VRR.Config] Loading server configuration");
try { try {
if (toInteger(server.getCVar("agrp_devserver")) == 1) { serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort());
serverConfig = loadServerConfigFromGame(getGame());
} else {
serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort());
}
} catch (error) { } catch (error) {
logToConsole(LOG_ERROR, `[VRR.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort}`); logToConsole(LOG_ERROR, `[VRR.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort}`);
thisResource.stop(); thisResource.stop();
} }
logToConsole(LOG_DEBUG | LOG_WARN, `Server ID: ${serverConfig.databaseId}`);
} }
// =========================================================================== // ===========================================================================

371
scripts/server/const.js Normal file
View File

@@ -0,0 +1,371 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: const.js
// DESC: Provides constants
// TYPE: Server (JavaScript)
// ===========================================================================
// Prompts (used for client GUI prompt responses)
const VRR_PROMPT_NONE = 0;
const VRR_PROMPT_CREATEFIRSTCHAR = 1;
const VRR_PROMPT_BIZORDER = 2;
const VRR_PROMPT_VEHGIVETOCLAN = 3;
const VRR_PROMPT_HOUSEGIVETOCLAN = 4;
const VRR_PROMPT_BIZGIVETOCLAN = 5;
const VRR_PROMPT_HOUSEBUY = 6;
const VRR_PROMPT_BIZBUY = 7;
// Job Types
const VRR_JOB_NONE = 0;
const VRR_JOB_POLICE = 1;
const VRR_JOB_MEDICAL = 2;
const VRR_JOB_FIRE = 3;
const VRR_JOB_BUS = 4;
const VRR_JOB_TAXI = 5;
const VRR_JOB_GARBAGE = 6;
const VRR_JOB_WEAPON = 7;
const VRR_JOB_DRUG = 8;
const VRR_JOB_PIZZA = 9;
const VRR_JOB_GENERIC = 10;
// Pickup Types
const VRR_PICKUP_NONE = 0;
const VRR_PICKUP_JOB = 1;
const VRR_PICKUP_BUSINESS_ENTRANCE = 2;
const VRR_PICKUP_BUSINESS_EXIT = 3;
const VRR_PICKUP_HOUSE_ENTRANCE = 4;
const VRR_PICKUP_HOUSE_EXIT = 5;
const VRR_PICKUP_EXIT = 6;
// Vehicle Owner Types
const VRR_VEHOWNER_NONE = 0; // Not owned
const VRR_VEHOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
const VRR_VEHOWNER_JOB = 2; // Owned by a job
const VRR_VEHOWNER_CLAN = 3; // Owned by a clan
const VRR_VEHOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
const VRR_VEHOWNER_PUBLIC = 5; // Public vehicle. Anybody can drive it.
const VRR_VEHOWNER_BIZ = 6; // Owned by a business (also includes dealerships since they're businesses)
// Business Owner Types
const VRR_BIZOWNER_NONE = 0; // Not owned
const VRR_BIZOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
const VRR_BIZOWNER_JOB = 2; // Owned by a job
const VRR_BIZOWNER_CLAN = 3; // Owned by a clan
const VRR_BIZOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
const VRR_BIZOWNER_PUBLIC = 5; // Public Business. Used for goverment/official places like police, fire, city hall, DMV, etc
// House Owner Types
const VRR_HOUSEOWNER_NONE = 0; // Not owned
const VRR_HOUSEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const VRR_HOUSEOWNER_JOB = 2; // Owned by a job
const VRR_HOUSEOWNER_CLAN = 3; // Owned by a clan
const VRR_HOUSEOWNER_FACTION = 4; // Owned by a faction
const VRR_HOUSEOWNER_PUBLIC = 5; // Is a public house. Technically not owned. This probably won't be used.
const VRR_HOUSEOWNER_BIZ = 6; // Owned by a business. Used for apartment buildings where rent goes to business.
// Gate Owner Types
const VRR_GATEOWNER_NONE = 0; // Not owned
const VRR_GATEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const VRR_GATEOWNER_JOB = 2; // Owned by a job
const VRR_GATEOWNER_CLAN = 3; // Owned by a clan
const VRR_GATEOWNER_FACTION = 4; // Owned by a faction
const VRR_GATEOWNER_PUBLIC = 5; // Public gate. Technically not owned. This probably won't be used.
const VRR_GATEOWNER_BUSINESS = 6; // Owned by a business. Back lots, unloading areas, and other stuff like that
const VRR_GATEOWNER_HOUSE = 7; // Owned by a house. Like for mansions with closed private areas.
// Business Location Types
const VRR_BIZLOC_NONE = 0; // None
const VRR_BIZLOC_GATE = 1; // Center of any moveable gate that belongs to the biz
const VRR_BIZLOC_GARAGE = 2; // Location for attached garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
const VRR_BIZLOC_FUEL = 3; // Fuel pump
const VRR_BIZLOC_DRIVETHRU = 4; // Drivethrough
const VRR_BIZLOC_VENDMACHINE = 5; // Vending machine
// House Location Types
const VRR_HOUSELOC_NONE = 0; // None
const VRR_HOUSELOC_GATE = 1; // Center of any moveable gate that belongs to the house
const VRR_HOUSELOC_GARAGE = 2; // Location for garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
// Account Contact Types
const VRR_CONTACT_NONE = 0;
const VRR_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
const VRR_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
const VRR_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
// Job Work Types (Currently Unused)
const VRR_JOBWORKTYPE_NONE = 0;
const VRR_JOBWORKTYPE_ROUTE = 1; // Jobs that use routes. Bus, trash collector, mail, etc
const VRR_JOBWORKTYPE_SELL = 2; // Jobs that sell items to other players and NPCs. Drugs, guns, etc
const VRR_JOBWORKTYPE_SERVICE = 3; // Services to other players and NPCs. Taxi ride, mechanic fix, etc
// Vehicle Seats
const VRR_VEHSEAT_DRIVER = 0;
const VRR_VEHSEAT_FRONTPASSENGER = 1;
const VRR_VEHSEAT_REARLEFTPASSENGER = 2;
const VRR_VEHSEAT_REARRIGHTPASSENGER = 3;
// Ban Types
const VRR_BANTYPE_NONE = 0;
const VRR_BANTYPE_ACCOUNT = 1;
const VRR_BANTYPE_SUBACCOUNT = 2;
const VRR_BANTYPE_IPADDRESS = 3;
const VRR_BANTYPE_SUBNET = 4;
// Blip Owner Types
const VRR_BLIP_NONE = 0;
const VRR_BLIP_JOB = 1;
const VRR_BLIP_BUSINESS_ENTRANCE = 2;
const VRR_BLIP_BUSINESS_EXIT = 3;
const VRR_BLIP_HOUSE_ENTRANCE = 4;
const VRR_BLIP_HOUSE_EXIT = 5;
const VRR_BLIP_EXIT = 6;
// Insurance Account Owner Types
const VRR_INS_ACCT_OWNER_NONE = 0; // None
const VRR_INS_ACCT_OWNER_PLAYER = 1; // Player owns insurance company
const VRR_INS_ACCT_OWNER_BIZ = 2; // Business owns insurance company
const VRR_INS_ACCT_OWNER_CLAN = 3; // Clan owns insurance company
// Insurance Account Entity Types
const VRR_INS_ACCT_ENTITY_NONE = 0; // None
const VRR_INS_ACCT_ENTITY_PLAYER_HEALTH = 1; // Health Insurance
const VRR_INS_ACCT_ENTITY_PLAYER_LIFE = 2; // Life Insurance
const VRR_INS_ACCT_ENTITY_VEH = 3; // Vehicle Insurance
const VRR_INS_ACCT_ENTITY_BIZ = 4; // Business Insurance
const VRR_INS_ACCT_ENTITY_HOUSE = 5; // House Insurance
// Insurance Account History Types
const VRR_INS_ACCT_HISTORY_NONE = 0; // None
const VRR_INS_ACCT_HISTORY_PLAYER_MEDICAL = 1; // Medical insurance was used (player disease/injury)
const VRR_INS_ACCT_HISTORY_PLAYER_DEATH = 2; // Life insurance was used (player death)
const VRR_INS_ACCT_HISTORY_VEH_DAMAGE = 3; // Vehicle was damaged, but not destroyed
const VRR_INS_ACCT_HISTORY_VEH_WRECKED = 4; // Vehicle was completely destroyed
const VRR_INS_ACCT_HISTORY_VEH_THEFT = 5; // Vehicle was stolen
const VRR_INS_ACCT_HISTORY_BIZ_DAMAGE = 6; // Business was damaged (broken items/window/door)
const VRR_INS_ACCT_HISTORY_BIZ_THEFT = 7; // Business was stolen from
const VRR_INS_ACCT_HISTORY_HOUSE_DAMAGE = 8; // House was damaged
const VRR_INS_ACCT_HISTORY_HOUSE_THEFT = 9; // House was stolen from
// Islands
const VRR_ISLAND_NONE = 0; // None
const VRR_ISLAND_PORTLAND = 0; // Portland Island
const VRR_ISLAND_STAUNTON = 1; // Staunton Island
const VRR_ISLAND_SHORESIDEVALE = 2; // Shoreside Vale
const VRR_ISLAND_VICEWEST = 0; // Western Island of VC
const VRR_ISLAND_VICEEAST = 1; // Eastern Island of VC
const VRR_ISLAND_LOSSANTOS = 0; // Los Santos
const VRR_ISLAND_LASVENTURAS = 1; // Las Venturas
const VRR_ISLAND_SANFIERRO = 2; // San Fierro
const VRR_ISLAND_REDCOUNTYNORTH = 4; // Red County North (spans all the way from Palamino/shore on the east east to border of Flint County on the west)
const VRR_ISLAND_BONECOUNTYNORTH = 5; // Bone County North (usually called Tierra Robada)
const VRR_ISLAND_BONECOUNTYSOUTH = 6; // Bone County South
// Item Owners
const VRR_ITEM_OWNER_NONE = 0; // None
const VRR_ITEM_OWNER_PLAYER = 1; // Item is in a player's inventory
const VRR_ITEM_OWNER_VEHTRUNK = 2; // Item is in a vehicle's trunk
const VRR_ITEM_OWNER_VEHDASH = 3; // Item is in a vehicle's glove compartment
const VRR_ITEM_OWNER_BIZFLOOR = 4; // Item is in the public area of a business (on the floor = ready to buy)
const VRR_ITEM_OWNER_BIZSTORAGE = 5; // Item is in a business's storage area (stock room)
const VRR_ITEM_OWNER_HOUSE = 6; // Item is in a house
const VRR_ITEM_OWNER_SAFE = 7; // Item is in a safe (safes can be anywhere)
const VRR_ITEM_OWNER_ITEM = 8; // Item is in another item (trashbag, briefcase, wallet, suitcase, crate/box, barrel, etc)
const VRR_ITEM_OWNER_GROUND = 9; // Item is on the ground
const VRR_ITEM_OWNER_JOBLOCKER = 10; // Item is in player's job locker
const VRR_ITEM_OWNER_LOCKER = 10; // Item is in player's locker
// Item Use Types
const VRR_ITEM_USETYPE_NONE = 0; // Has no effect
const VRR_ITEM_USETYPE_WEAPON = 1; // Equips weapon
const VRR_ITEM_USETYPE_AMMO_CLIP = 2; // Magazine for weapon. If in inventory, R will load it into gun
const VRR_ITEM_USETYPE_PHONE = 3; // Pulls out phone
const VRR_ITEM_USETYPE_GPS = 4; // Not sure how I want this to work yet
const VRR_ITEM_USETYPE_MAP = 5; // Shows minimap on HUD
const VRR_ITEM_USETYPE_SKIN = 6; // Changes skin (uses skin changer)
const VRR_ITEM_USETYPE_PEDPART = 7; // Changes ped part (clothing, skin, hair, etc) (UNUSED)
const VRR_ITEM_USETYPE_PEDPROP = 8; // Changes ped prop (watches, glasses, hats, etc) (UNUSED)
const VRR_ITEM_USETYPE_STORAGE = 9; // Shows stored items. Backpack, crate, briefcase, wallet, etc
const VRR_ITEM_USETYPE_VEHKEY = 10; // Locks/unlocks a vehicle and allows starting engine without hotwire
const VRR_ITEM_USETYPE_BIZKEY = 11; // Locks/unlocks a business
const VRR_ITEM_USETYPE_HOUSEKEY = 12; // Locks/unlocks a house
const VRR_ITEM_USETYPE_SEED = 13; // Plants a seed
const VRR_ITEM_USETYPE_WEED = 14; // Light drug effect (short term relief of addiction symptoms?)
const VRR_ITEM_USETYPE_COKE = 15; // Medium drug effect (medium term relief of addiction symptoms?)
const VRR_ITEM_USETYPE_METH = 16; // Heavy drug effect (extended term relief of addiction symptoms?)
const VRR_ITEM_USETYPE_CIGAR = 17; // Just for appearance. Makes people look cool I guess
const VRR_ITEM_USETYPE_WATER = 18; // Replenishes small amount of health
const VRR_ITEM_USETYPE_FOOD = 19; // Eat food. Replenishes a small amount of health
const VRR_ITEM_USETYPE_BEER = 20; // Subtle drunk effect. Replenishes small amount of health.
const VRR_ITEM_USETYPE_WINE = 21; // Moderate drunk effect. Replenishes moderate amount of health.
const VRR_ITEM_USETYPE_LIQUOR = 22; // Heavy drunk effect. Replenishes large amount of health.
const VRR_ITEM_USETYPE_COFFEE = 23; // Replenishes moderate amount of health.
const VRR_ITEM_USETYPE_AMMO_ROUND = 23; // Bullet. Loads into magazine. Not used at the moment
const VRR_ITEM_USETYPE_HANDCUFF = 24; //
const VRR_ITEM_USETYPE_ROPE = 25; //
const VRR_ITEM_USETYPE_BLINDFOLD = 26; //
const VRR_ITEM_USETYPE_TAZER = 27; //
const VRR_ITEM_USETYPE_ARMOUR = 28; //
const VRR_ITEM_USETYPE_HEALTH = 29; //
const VRR_ITEM_USETYPE_AED = 30; //
const VRR_ITEM_USETYPE_WALKIETALKIE = 31; //
const VRR_ITEM_USETYPE_AREARADIO = 32; //
const VRR_ITEM_USETYPE_PERSONALRADIO = 33; //
const VRR_ITEM_USETYPE_BADGE = 34; //
const VRR_ITEM_USETYPE_DRINK = 35; // Drinkable item. Action output shows "Player_Name drinks some (drink name)"
const VRR_ITEM_USETYPE_EXTINGUISHER = 36; // Extinguisher item. Allows putting out fires
const VRR_ITEM_USETYPE_SPRAYPAINT = 37; // Spraypaint item. Allows spraying custom clan tags on walls
const VRR_ITEM_USETYPE_PEPPERSPRAY = 38; // Pepper spray item. Incapacitates nearby player
const VRR_ITEM_USETYPE_FLASHLIGHT = 39; // Flashlight item. Unusable for now, but plan to cast a custom light beam
const VRR_ITEM_USETYPE_AIRPLANETICKET = 40; // Airplane ticket. Allows a character to move to another server
const VRR_ITEM_USETYPE_TRAINTICKET = 41; // Train ticket. Allows a character to move to another server
const VRR_ITEM_USETYPE_VEHUPGRADE_PART = 42; // Vehicle update part item. Allows adding custom parts like spoilers, side skirts, roof scoops, etc
const VRR_ITEM_USETYPE_VEHTIRE = 43; // Vehicle tire item. Allows changing the tire/rim types
const VRR_ITEM_USETYPE_FUELCAN = 44; // Fuel can item. Allows refueling of a nearby vehicle anywhere
const VRR_ITEM_USETYPE_VEHCOLOUR = 45; // Vehicle colour item. Changes primary and secondary vehicle colours
const VRR_ITEM_USETYPE_VEHLIVERY = 46; // Vehicle livery/paintjob item. Applies decals and special paint jobs
const VRR_ITEM_USETYPE_VEHREPAIR = 47; // Vehicle repair item. Much longer use time
const VRR_ITEM_USETYPE_SMOKEDRUG = 48; // Smokable drug. Action output shows "Player_Name smokes some (drug)"
const VRR_ITEM_USETYPE_SNORTDRUG = 49; // Snortable drug. Action output shows "Player_Name snorts some (drug)"
const VRR_ITEM_USETYPE_PLANT = 50; // Plantable item. Pot plants, coke plants, etc
const VRR_ITEM_USETYPE_MEGAPHONE = 51; // Megaphone item. Allows shouting over greater distances. Also called a bullhorn
const VRR_ITEM_USETYPE_INJECTDRUG = 52; // Injectable drug. Action output shows "Player_Name injects some (drug)"
const VRR_ITEM_USETYPE_ALCOHOL = 53; // Alcohol. Applies an intoxication/drunkness effect
const VRR_ITEM_USETYPE_LOTTOTICKET = 54; // Lotto ticket. Allows a character to enter the lottery
// Item Drop Types
const VRR_ITEM_DROPTYPE_NONE = 0; // Can't be dropped
const VRR_ITEM_DROPTYPE_OBJECT = 1; // Drops as an object on the ground
const VRR_ITEM_DROPTYPE_PICKUP = 2; // Drops as a pickup
const VRR_ITEM_DROPTYPE_OBJECTLIGHT = 3; // Object that produces an area light effect (lamp, flashlight, etc)
const VRR_ITEM_DROPTYPE_DESTROY = 4; // Will destroy the item on drop (keys mostly but for any tiny object)
const VRR_ITEM_DROPTYPE_OBJECTSTACK = 5; // Stackable objects (crates and such). Will sit on top of closest other stackable
// Forensic Types
const VRR_FORENSICS_NONE = 0;
const VRR_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
const VRR_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit when somebody is shot
const VRR_FORENSICS_BODY = 3; // Body. A dead body lol
const VRR_FORENSICS_HAIR = 4; // Hair. Automatically applied to
const VRR_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
const VRR_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank
const VRR_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)
// Account Authentication Methods
const VRR_ACCT_AUTHMETHOD_NONE = 0; // None
const VRR_ACCT_AUTHMETHOD_EMAIL = 1; // Email
const VRR_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
const VRR_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
const VRR_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
const VRR_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
// Police Patrol Types
const VRR_PATROLTYPE_NONE = 0; // None
const VRR_PATROLTYPE_FOOT = 1; // Foot patrol. Officer takes a vehicle to get to their designated area and then walks a beat. More common in LC games
const VRR_PATROLTYPE_VEHICLE = 2; // Vehicle patrol. More common in VC/LS/SF/LV cities.
// Job Route States
const VRR_JOBROUTESTATE_NONE = 0; // None
const VRR_JOBROUTESTATE_INPROGRESS = 1; // Route is in progress. Player is in between stops but not at the last one.
const VRR_JOBROUTESTATE_LASTSTOP = 2; // Player is heading to the last stop on the route
const VRR_JOBROUTESTATE_PAUSED = 3; // Route is paused for some reason. For police, this could be player accepted callout and once finished, patrol route will resume
const VRR_JOBROUTESTATE_ATSTOP = 4; // For bus/trash stops that freeze player, this is the state when they're at one
// Item Occupied States
const VRR_ITEM_ACTION_NONE = 0; // None
const VRR_ITEM_ACTION_USE = 1; // Using item
const VRR_ITEM_ACTION_PICKUP = 2; // Picking up item
const VRR_ITEM_ACTION_DROP = 3; // Dropping item
const VRR_ITEM_ACTION_SWITCH = 4; // Switching item
const VRR_ITEM_ACTION_PUT = 5; // Putting item (into trunk, dash, crate, etc)
const VRR_ITEM_ACTION_TAKE = 6; // Taking item (from trunk, dash, crate, etc)
// Ped States
const VRR_PEDSTATE_NONE = 2; // None
const VRR_PEDSTATE_READY = 1; // Ready
const VRR_PEDSTATE_DRIVER = 2; // Driving a vehicle
const VRR_PEDSTATE_PASSENGER = 3; // In a vehicle as passenger
const VRR_PEDSTATE_DEAD = 4; // Dead
const VRR_PEDSTATE_ENTERINGPROPERTY = 5; // Entering a property
const VRR_PEDSTATE_EXITINGPROPERTY = 6; // Exiting a property
const VRR_PEDSTATE_ENTERINGVEHICLE = 7; // Entering a vehicle
const VRR_PEDSTATE_EXITINGVEHICLE = 8; // Exiting a vehicle
const VRR_PEDSTATE_BINDED = 9; // Binded by rope or handcuffs
const VRR_PEDSTATE_TAZED = 10; // Under incapacitating effect of tazer
const VRR_PEDSTATE_INTRUNK = 11; // In vehicle trunk
const VRR_PEDSTATE_INITEM = 12; // In item (crate, box, etc)
const VRR_PEDSTATE_HANDSUP = 13; // Has hands up (surrendering)
const VRR_PEDSTATE_SPAWNING = 14; // Spawning
// Two-Factor Authentication States
const VRR_2FA_STATE_NONE = 0; // None
const VRR_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
const VRR_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
const VRR_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
// Reset Password States
const VRR_RESETPASS_STATE_NONE = 0; // None
const VRR_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
const VRR_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
const VRR_RESETPASS_STATE_EMAILCONFIRM = 3; // Waiting on player to enter their email to confirm it's correct
// NPC Trigger Condition Match Types
const VRR_NPC_COND_MATCH_NONE = 0; // None (invalid)
const VRR_NPC_COND_MATCH_EQ = 1; // Must be equal to
const VRR_NPC_COND_MATCH_GT = 2; // Must be greater than
const VRR_NPC_COND_MATCH_LT = 3; // Must be less than
const VRR_NPC_COND_MATCH_GTEQ = 4; // Must be greater than or equal to
const VRR_NPC_COND_MATCH_LTEQ = 5; // Must be less than or equal to
const VRR_NPC_COND_MATCH_CONTAINS = 6; // Must contain string (case insensitive)
const VRR_NPC_COND_MATCH_CONTAINS_CASE = 7; // Must contain string (case sensitive)
const VRR_NPC_COND_MATCH_EXACT = 8; // Must match string exactly (case insensitive)
const VRR_NPC_COND_MATCH_EXACT_CASE = 9; // Must match string exactly (case insensitive)
// Business Types
const VRR_BIZ_TYPE_NONE = 0; // None (invalid)
const VRR_BIZ_TYPE_NORMAL = 1; // Normal business (sells items)
const VRR_BIZ_TYPE_BANK = 2; // Bank
const VRR_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc)
// Return-To types (for when a player is teleported)
const VRR_RETURNTO_TYPE_NONE = 0; // "Return to" data is invalid
const VRR_RETURNTO_TYPE_ADMINGET = 1; // "Return to" data is from admin teleporting
const VRR_RETURNTO_TYPE_SKINSELECT = 2; // "Return to" data is from skin select
// Card Game Types
const VRR_DECKCARD_GAME_NONE = 0; // None (invalid)
const VRR_DECKCARD_GAME_BLACKJACK = 1; // Blackjack
const VRR_DECKCARD_GAME_TEXASHOLDEM = 2; // Texas Hold-em
const VRR_DECKCARD_GAME_FIVECARDDRAW = 3; // Five Card Draw
const VRR_DECKCARD_GAME_FIVECARDSTUD = 4; // Five Card Stud
const VRR_DECKCARD_GAME_HIGHLOW = 5; // High-Low (Also known as War)
// Card Suits
const VRR_DECKCARD_SUIT_NONE = 0; // None (invalid)
const VRR_DECKCARD_SUIT_SPADE = 1; // Spades
const VRR_DECKCARD_SUIT_CLUB = 2; // Clubs
const VRR_DECKCARD_SUIT_HEART = 3; // Hearts
const VRR_DECKCARD_SUIT_DIAMOND = 4; // Diamonds
// GPS State Types
const VRR_GPS_TYPE_NONE = 0; // None (invalid)
const VRR_GPS_TYPE_BUSINESS = 1; // Business
const VRR_GPS_TYPE_POLICE = 2; // Police Station
const VRR_GPS_TYPE_HOSPITAL = 3; // Hospital
const VRR_GPS_TYPE_JOB = 4; // Job
const VRR_GPS_TYPE_GAMELOC = 5; // Game Location
// Discord Webhook Types
const VRR_DISCORD_WEBHOOK_NONE = 0;
const VRR_DISCORD_WEBHOOK_LOG = 1;
const VRR_DISCORD_WEBHOOK_ADMIN = 2;
// NPC Owner Types
const VRR_NPCOWNER_NONE = 0; // Not owned
const VRR_NPCOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
const VRR_NPCOWNER_JOB = 2; // Owned by a job
const VRR_NPCOWNER_CLAN = 3; // Owned by a clan
const VRR_NPCOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
const VRR_NPCOWNER_PUBLIC = 5; // Public NPC. Anybody can do stuff with it.
const VRR_NPCOWNER_BIZ = 6; // Owned by a business

View File

@@ -1,22 +1,20 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: core.js // FILE: core.js
// DESC: Provides core data structures, function, and operations // DESC: Provides core data structures, function, and operations
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
let scriptVersion = "1.2"; let scriptVersion = "1.1";
let serverStartTime = 0; let serverStartTime = 0;
let logLevel = LOG_INFO | LOG_DEBUG | LOG_VERBOSE; // LOG_ERROR|LOG_WARN; let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE; // LOG_ERROR|LOG_WARN;
let playerResourceReady = new Array(server.maxClients).fill(false); let playerResourceReady = new Array(server.maxClients).fill(false);
let playerResourceStarted = new Array(server.maxClients).fill(false); let playerResourceStarted = new Array(server.maxClients).fill(false);
let playerInitialized = new Array(server.maxClients).fill(false); let playerInitialized = new Array(server.maxClients).fill(false);
let playerGUI = new Array(server.maxClients).fill(false); let playerGUI = new Array(server.maxClients).fill(false);
let defaultNoAccountId = 479;
// =========================================================================== // ===========================================================================
@@ -30,19 +28,15 @@ let defaultNoAccountId = 479;
* @property {Array.<ItemData>} items * @property {Array.<ItemData>} items
* @property {Array.<ItemTypeData>} itemTypes * @property {Array.<ItemTypeData>} itemTypes
* @property {Array.<ClanData>} clans * @property {Array.<ClanData>} clans
* @property {Array.<TriggerData>} triggers * @property {Array} localeStrings
* @property {Array.<NPCData>} npcs * @property {Array.<NPCData>} npcs
* @property {Array.<RaceData>} races * @property {Array.<RaceData>} races
* @property {Array.<JobData>} jobs * @property {Array.<JobData>} jobs
* @property {Array.<GateData>} gates * @property {Array.<Gates>} gates
* @property {Array.<RadioStationData>} radioStations
* @property {Array} locales
* @property {Array} localeStrings
* @property {Array} groundItemCache * @property {Array} groundItemCache
* @property {Array} groundPlantCache * @property {Array} groundPlantCache
* @property {Array} purchasingVehicleCache * @property {Array} purchasingVehicleCache
* @property {Array} rentingVehicleCache * @property {Array} rentingVehicleCache
* @property {Array} atmLocationCache
*/ */
let serverData = { let serverData = {
vehicles: [], vehicles: [],
@@ -53,26 +47,26 @@ let serverData = {
items: [], items: [],
itemTypes: [], itemTypes: [],
clans: [], clans: [],
localeStrings: {},
cachedTranslations: [], cachedTranslations: [],
cachedTranslationFrom: [], cachedTranslationFrom: [],
triggers: [], //triggers: [],
npcs: [], npcs: [],
races: [], races: [],
jobs: [], jobs: [],
gates: [], gates: [],
radioStations: [],
localeStrings: {},
groundItemCache: [], groundItemCache: [],
groundPlantCache: [], groundPlantCache: [],
purchasingVehicleCache: [], purchasingVehicleCache: [],
rentingVehicleCache: [], rentingVehicleCache: [],
atmLocationCache: [],
}; };
// =========================================================================== // ===========================================================================
/** /**
* @return {ServerData} serverData *
* @return {ServerData}
*
*/ */
function getServerData() { function getServerData() {
return serverData; return serverData;

View File

@@ -1,23 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: crime.js
// DESC: Provides crime data structures, functions, and operations
// TYPE: Server (JavaScript)
// ===========================================================================
/**
* @class Representing a crime's data. Loaded and saved in the database
*/
class CrimeData {
constructor(suspectId, crimeType, reporterId = 0) {
this.crimeType = crimeType;
this.suspectId = suspectId;
this.reporterId = reporterId;
this.whenCommitted = 0;
this.whenReported = 0;
this.databaseId = 0;
}
};

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: database.js // FILE: database.js
// DESC: Provides database handling, functions and usage // DESC: Provides database handling, functions and usage
@@ -25,13 +24,13 @@ function createDatabaseInsertQuery(tableName, data) {
let fields = []; let fields = [];
let values = []; let values = [];
for (let i in data) { for(let i in data) {
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') { if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') {
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
fields.push(data[i][0]); fields.push(data[i][0]);
if (typeof data[i][1] == "string") { if(typeof data[i][1] == "string") {
if (data[i][1] == "{UNIXTIMESTAMP}") { if(data[i][1] == "{UNIXTIMESTAMP}") {
values.push("UNIX_TIMESTAMP()"); values.push("UNIX_TIMESTAMP()");
} else { } else {
values.push(`'${data[i][1]}'`); values.push(`'${data[i][1]}'`);
@@ -52,11 +51,11 @@ function createDatabaseInsertQuery(tableName, data) {
function createDatabaseUpdateQuery(tableName, data, whereClause) { function createDatabaseUpdateQuery(tableName, data, whereClause) {
let values = []; let values = [];
for (let i in data) { for(let i in data) {
if (data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') { if(data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') {
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
if (typeof data[i][1] == "string") { if(typeof data[i][1] == "string") {
if (data[i][1] == "{UNIXTIMESTAMP}") { if(data[i][1] == "{UNIXTIMESTAMP}") {
values.push(`${data[i][0]}=UNIX_TIMESTAMP()`); values.push(`${data[i][0]}=UNIX_TIMESTAMP()`);
} else { } else {
values.push(`${data[i][0]}='${data[i][1]}'`); values.push(`${data[i][0]}='${data[i][1]}'`);

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: developer.js // FILE: developer.js
// DESC: Provides developer operation, commands, functions and usage // DESC: Provides developer operation, commands, functions and usage
@@ -121,12 +120,12 @@ function pvd(params) {
// =========================================================================== // ===========================================================================
function addLogLevelCommand(command, params, client) { function addLogLevelCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
switch (toLowerCase(params)) { switch(toLowerCase(params)) {
case "debug": case "debug":
logLevel = logLevel | LOG_DEBUG; logLevel = logLevel | LOG_DEBUG;
break; break;
@@ -152,7 +151,9 @@ function addLogLevelCommand(command, params, client) {
} }
sendPlayerLogLevel(null, logLevel); sendPlayerLogLevel(null, logLevel);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`); messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
return true; return true;
} }
@@ -161,39 +162,40 @@ function addLogLevelCommand(command, params, client) {
function getLogLevelCommand(command, params, client) { function getLogLevelCommand(command, params, client) {
let logLevels = []; let logLevels = [];
if (hasBitFlag(logLevel, LOG_DEBUG)) { if(hasBitFlag(logLevel, LOG_DEBUG)) {
logLevels.push("debug"); logLevels.push("debug");
} }
if (hasBitFlag(logLevel, LOG_WARN)) { if(hasBitFlag(logLevel, LOG_WARN)) {
logLevels.push("warn"); logLevels.push("warn");
} }
if (hasBitFlag(logLevel, LOG_ERROR)) { if(hasBitFlag(logLevel, LOG_ERROR)) {
logLevels.push("error"); logLevels.push("error");
} }
if (hasBitFlag(logLevel, LOG_INFO)) { if(hasBitFlag(logLevel, LOG_INFO)) {
logLevels.push("info"); logLevels.push("info");
} }
if (hasBitFlag(logLevel, LOG_VERBOSE)) { if(hasBitFlag(logLevel, LOG_VERBOSE)) {
logLevels.push("verbose"); logLevels.push("verbose");
} }
messagePlayerAlert(client, `{MAINCOLOUR}Current log levels: {ALTCOLOUR}${toLowerCase(logLevels.join(", "))}`); messagePlayerAlert(`{MAINCOLOUR}Current log levels: {ALTCOLOUR}${toLowerCase(logLevels.join(", "))}`);
return true; return true;
} }
// =========================================================================== // ===========================================================================
function removeLogLevelCommand(command, params, client) { function removeLogLevelCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
switch (toLowerCase(params)) { switch(toLowerCase(params)) {
case "debug": case "debug":
logLevel = logLevel & ~LOG_DEBUG; logLevel = logLevel & ~LOG_DEBUG;
break; break;
@@ -219,26 +221,28 @@ function removeLogLevelCommand(command, params, client) {
} }
sendPlayerLogLevel(null, logLevel); sendPlayerLogLevel(null, logLevel);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`); messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
return true; return true;
} }
// =========================================================================== // ===========================================================================
function simulateCommandForPlayerCommand(command, params, client) { function simulateCommandForPlayerCommand(command, params, client) {
if (getCommand(command).requireLogin) { if(getCommand(command).requireLogin) {
if (!isPlayerLoggedIn(client)) { if(!isPlayerLoggedIn(client)) {
messagePlayerError(client, "You must be logged in to use this command!"); messagePlayerError(client, "You must be logged in to use this command!");
return false; return false;
} }
} }
if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) { if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messagePlayerError(client, "You do not have permission to use this command!"); messagePlayerError(client, "You do not have permission to use this command!");
return false; return false;
} }
if (areParamsEmpty(params) || !areThereEnoughParams(params, 2)) { if(areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -248,12 +252,12 @@ function simulateCommandForPlayerCommand(command, params, client) {
tempCommand.replace("/", ""); tempCommand.replace("/", "");
let tempParams = splitParams.slice(2).join(" "); let tempParams = splitParams.slice(2).join(" ");
if (!targetClient) { if(!targetClient) {
messagePlayerError(client, "Invalid player name or ID"); messagePlayerError(client, "Invalid player name or ID");
return false; return false;
} }
if (!getCommand(tempCommand)) { if(!getCommand(tempCommand)) {
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`); messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
return false; return false;
} }
@@ -266,19 +270,19 @@ function simulateCommandForPlayerCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function simulateCommandForAllPlayersCommand(command, params, client) { function simulateCommandForAllPlayersCommand(command, params, client) {
if (getCommand(command).requireLogin) { if(getCommand(command).requireLogin) {
if (!isPlayerLoggedIn(client)) { if(!isPlayerLoggedIn(client)) {
messagePlayerError(client, "You must be logged in to use this command!"); messagePlayerError(client, "You must be logged in to use this command!");
return false; return false;
} }
} }
if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) { if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messagePlayerError(client, "You do not have permission to use this command!"); messagePlayerError(client, "You do not have permission to use this command!");
return false; return false;
} }
if (areParamsEmpty(params) || !areThereEnoughParams(params, 2)) { if(areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -287,14 +291,14 @@ function simulateCommandForAllPlayersCommand(command, params, client) {
tempCommand.replace("/", ""); tempCommand.replace("/", "");
let tempParams = splitParams.slice(1).join(" "); let tempParams = splitParams.slice(1).join(" ");
if (!getCommand(tempCommand)) { if(!getCommand(tempCommand)) {
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`); messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
return false; return false;
} }
let clients = getClients(); let clients = getClients();
for (let i in clients) { for(let i in clients) {
if (!clients[i].console) { if(!clients[i].console) {
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, clients[i]); getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, clients[i]);
} }
} }
@@ -305,7 +309,7 @@ function simulateCommandForAllPlayersCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function executeServerCodeCommand(command, params, client) { function executeServerCodeCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -313,7 +317,7 @@ function executeServerCodeCommand(command, params, client) {
let returnValue = "Nothing"; let returnValue = "Nothing";
try { try {
returnValue = eval("(" + params + ")"); returnValue = eval("(" + params + ")");
} catch (error) { } catch(error) {
messagePlayerError(client, "The code could not be executed!"); messagePlayerError(client, "The code could not be executed!");
return false; return false;
} }
@@ -328,7 +332,7 @@ function executeServerCodeCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function executeClientCodeCommand(command, params, client) { function executeClientCodeCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -337,12 +341,12 @@ function executeClientCodeCommand(command, params, client) {
let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let targetCode = splitParams.slice(1).join(" "); let targetCode = splitParams.slice(1).join(" ");
if (!targetClient) { if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false; return false;
} }
if (targetCode == "") { if(targetCode == "") {
messagePlayerError(client, "You didn't enter any code!"); messagePlayerError(client, "You didn't enter any code!");
return false; return false;
} }
@@ -357,19 +361,19 @@ function executeClientCodeCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function setPlayerTesterStatusCommand(command, params, client) { function setPlayerTesterStatusCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let targetClient = getPlayerFromParams(params); let targetClient = getPlayerFromParams(params);
if (!targetClient) { if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false; return false;
} }
if (!hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"))) { if(!hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
getPlayerData(targetClient).accountData.flags.moderation = addBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester")); getPlayerData(targetClient).accountData.flags.moderation = addBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
} else { } else {
getPlayerData(targetClient).accountData.flags.moderation = removeBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester")); getPlayerData(targetClient).accountData.flags.moderation = removeBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
@@ -384,14 +388,14 @@ function setPlayerTesterStatusCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function testPromptGUICommand(command, params, client) { function testPromptGUICommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let targetClient = getPlayerFromParams(params); let targetClient = getPlayerFromParams(params);
if (!targetClient) { if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false; return false;
} }
@@ -403,14 +407,14 @@ function testPromptGUICommand(command, params, client) {
// =========================================================================== // ===========================================================================
function testInfoGUICommand(command, params, client) { function testInfoGUICommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let targetClient = getPlayerFromParams(params); let targetClient = getPlayerFromParams(params);
if (!targetClient) { if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false; return false;
} }
@@ -422,14 +426,14 @@ function testInfoGUICommand(command, params, client) {
// =========================================================================== // ===========================================================================
function testErrorGUICommand(command, params, client) { function testErrorGUICommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let targetClient = getPlayerFromParams(params); let targetClient = getPlayerFromParams(params);
if (!targetClient) { if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false; return false;
} }
@@ -452,8 +456,8 @@ function saveServerDataCommand(command, params, client) {
function testEmailCommand(command, params, client) { function testEmailCommand(command, params, client) {
try { try {
messagePlayerAlert(client, `Sending test email to ${params}`); messagePlayerAlert(client, `Sending test email to ${params}`);
sendEmail(params, "Player", "Test email", "Just testing the SMTP module for the server!"); sendEmail(params, "Player", "Test email", "Just testing the SMTP module for the server!");
} catch (error) { } catch(error) {
messagePlayerError(client, "The email could not be sent! Error: ${error}"); messagePlayerError(client, "The email could not be sent! Error: ${error}");
return false; return false;
} }
@@ -473,7 +477,7 @@ function restartGameModeCommand(command, params, client) {
function clientRunCodeFail(client, returnTo, error) { function clientRunCodeFail(client, returnTo, error) {
let returnClient = getClientFromIndex(returnTo); let returnClient = getClientFromIndex(returnTo);
if (!returnClient) { if(!returnClient) {
return false; return false;
} }
@@ -484,7 +488,7 @@ function clientRunCodeFail(client, returnTo, error) {
function clientRunCodeSuccess(client, returnTo, returnVal) { function clientRunCodeSuccess(client, returnTo, returnVal) {
let returnClient = getClientFromIndex(returnTo); let returnClient = getClientFromIndex(returnTo);
if (!returnClient) { if(!returnClient) {
return false; return false;
} }
@@ -496,25 +500,19 @@ function clientRunCodeSuccess(client, returnTo, returnVal) {
// =========================================================================== // ===========================================================================
function submitIdea(client, ideaText) { function submitIdea(client, ideaText) {
let position = toVector3(0.0, 0.0, 0.0); let position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
let heading = 0.0; let heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
let session = 0; let session = 0;
let databaseId = 0; let databaseId = 0;
if (client != null) { if(isConsole(client)) {
if (isConsole(client)) { databaseId = -1;
databaseId = -1;
} else {
databaseId = getPlayerData(client).accountData.databaseId;
position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
}
} else { } else {
databaseId = defaultNoAccountId; databaseId = getPlayerData(client).accountData.databaseId;
} }
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if(dbConnection) {
let safeIdeaMessage = escapeDatabaseString(dbConnection, ideaText); let safeIdeaMessage = escapeDatabaseString(dbConnection, ideaText);
queryDatabase(dbConnection, `INSERT INTO idea_main (idea_server, idea_script_ver, idea_who_added, idea_when_added, idea_message, idea_pos_x, idea_pos_y, idea_pos_z, idea_rot_z, idea_svr_start, idea_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeIdeaMessage}',${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`); queryDatabase(dbConnection, `INSERT INTO idea_main (idea_server, idea_script_ver, idea_who_added, idea_when_added, idea_message, idea_pos_x, idea_pos_y, idea_pos_z, idea_rot_z, idea_svr_start, idea_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeIdeaMessage}',${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
} }
@@ -523,25 +521,19 @@ function submitIdea(client, ideaText) {
// =========================================================================== // ===========================================================================
function submitBugReport(client, bugText) { function submitBugReport(client, bugText) {
let position = toVector3(0.0, 0.0, 0.0); let position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
let heading = 0.0; let heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
let session = 0; let session = 0;
let databaseId = 0; let databaseId = 0;
if (client != null) { if(isConsole(client)) {
if (isConsole(client)) { databaseId = -1;
databaseId = -1;
} else {
databaseId = getPlayerData(client).accountData.databaseId;
position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
}
} else { } else {
databaseId = defaultNoAccountId; databaseId = getPlayerData(client).accountData.databaseId;
} }
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if(dbConnection) {
let safeBugMessage = escapeDatabaseString(dbConnection, bugText); let safeBugMessage = escapeDatabaseString(dbConnection, bugText);
queryDatabase(dbConnection, `INSERT INTO bug_main (bug_server, bug_script_ver, bug_who_added, bug_when_added, bug_message, bug_pos_x, bug_pos_y, bug_pos_z, bug_rot_z, bug_svr_start, bug_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeBugMessage}', ${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`); queryDatabase(dbConnection, `INSERT INTO bug_main (bug_server, bug_script_ver, bug_who_added, bug_when_added, bug_message, bug_pos_x, bug_pos_y, bug_pos_z, bug_rot_z, bug_svr_start, bug_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeBugMessage}', ${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
} }
@@ -559,14 +551,14 @@ function migrateSubAccountsToPerServerData() {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
let dbQuery = false; let dbQuery = false;
let dbAssoc = false; let dbAssoc = false;
if (dbConnection) { if(dbConnection) {
dbQuery = queryDatabase(dbConnection, `SELECT * FROM sacct_main`); dbQuery = queryDatabase(dbConnection, `SELECT * FROM sacct_main`);
if (dbQuery) { if(dbQuery) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) { while(dbAssoc = fetchQueryAssoc(dbQuery)) {
createDefaultSubAccountServerData(dbAssoc["sacct_id"]); createDefaultSubAccountServerData(dbAssoc["sacct_id"]);
let dbQuery2 = queryDatabase(dbConnection, `UPDATE sacct_svr SET sacct_svr_skin = ${dbAssoc["sacct_skin"]}, sacct_svr_job = ${dbAssoc["sacct_job"]} WHERE sacct_svr_sacct=${dbAssoc["sacct_id"]} AND sacct_svr_server=${dbAssoc["sacct_server"]}`); let dbQuery2 = queryDatabase(dbConnection, `UPDATE sacct_svr SET sacct_svr_skin = ${dbAssoc["sacct_skin"]}, sacct_svr_job = ${dbAssoc["sacct_job"]} WHERE sacct_svr_sacct=${dbAssoc["sacct_id"]} AND sacct_svr_server=${dbAssoc["sacct_server"]}`);
if (dbQuery2) { if(dbQuery2) {
freeDatabaseQuery(dbQuery2); freeDatabaseQuery(dbQuery2);
} }
} }
@@ -581,10 +573,10 @@ function resetAllAccountsHotkeysToDefault() {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
let dbQuery = false; let dbQuery = false;
let dbAssoc = false; let dbAssoc = false;
if (dbConnection) { if(dbConnection) {
dbQuery = queryDatabase(dbConnection, `SELECT acct_id FROM acct_main`); dbQuery = queryDatabase(dbConnection, `SELECT acct_id FROM acct_main`);
if (dbQuery) { if(dbQuery) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) { while(dbAssoc = fetchQueryAssoc(dbQuery)) {
createDefaultKeybindsForAccount(dbAssoc["acct_id"]); createDefaultKeybindsForAccount(dbAssoc["acct_id"]);
} }
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
@@ -603,9 +595,9 @@ function togglePauseSavingToDatabaseCommand(command, params, client) {
function createAccountDataForNewServer(serverId) { function createAccountDataForNewServer(serverId) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
let dbQuery = false; let dbQuery = false;
if (dbConnection) { if(dbConnection) {
dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_main`); dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_main`);
if (dbQuery) { if(dbQuery) {
let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accountDatabaseId}, ${serverId})`; let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accountDatabaseId}, ${serverId})`;
quickDatabaseQuery(dbQueryString); quickDatabaseQuery(dbQueryString);
} }
@@ -615,7 +607,7 @@ function createAccountDataForNewServer(serverId) {
// =========================================================================== // ===========================================================================
function streamAudioURLToAllPlayersCommand(command, params, client) { function streamAudioURLToAllPlayersCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -629,7 +621,7 @@ function streamAudioURLToAllPlayersCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function streamAudioNameToAllPlayersCommand(command, params, client) { function streamAudioNameToAllPlayersCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
@@ -693,28 +685,28 @@ function showLocalePickerTestCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function executeDatabaseQueryCommand(command, params, client) { function executeDatabaseQueryCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
if (!targetClient) { if(!targetClient) {
messagePlayerError(client, "That player was not found!"); messagePlayerError(client, "That player was not found!");
return false; return false;
} }
if (targetCode == "") { if(targetCode == "") {
messagePlayerError(client, "You didn't enter any code!"); messagePlayerError(client, "You didn't enter any code!");
return false; return false;
} }
let results = quickDatabaseQueryWithResults(params); let success = quickDatabaseQuery(params);
if (results == false || results == null || results == undefined) { if(!success) {
messagePlayerAlert(client, `Database query failed to execute: {ALTCOLOUR}${query}`); messagePlayerAlert(client, `Database query failed to execute: {ALTCOLOUR}${query}`);
} else if (typeof results == "boolean") { } else if(typeof success != "boolean") {
messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`); messagePlayeSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
messagePlayerInfo(client, `Returns: ${getTrueFalseFromBool(results)}`); messagePlayerInfo(client, `Returns: ${success}`);
} else { } else {
messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`); messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
} }

View File

@@ -1,20 +1,12 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: discord.js // FILE: discord.js
// DESC: Provides discord bridging and connection functions and usage // DESC: Provides discord bridging and connection functions and usage
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// Discord Webhook Types
const AGRP_DISCORD_WEBHOOK_NONE = 0;
const AGRP_DISCORD_WEBHOOK_LOG = 1;
const AGRP_DISCORD_WEBHOOK_ADMIN = 2;
// ===========================================================================
function initDiscordScript() { function initDiscordScript() {
logToConsole(LOG_INFO, "[VRR.Discord]: Initializing discord script ..."); logToConsole(LOG_INFO, "[VRR.Discord]: Initializing discord script ...");
logToConsole(LOG_INFO, "[VRR.Discord]: Discord script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.Discord]: Discord script initialized successfully!");
@@ -110,8 +102,7 @@ function messageDiscordChatChannel(messageString) {
} }
messageString = removeColoursInMessage(messageString); messageString = removeColoursInMessage(messageString);
messageString = replaceProfanityInMessage(messageString); triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
} }
// =========================================================================== // ===========================================================================
@@ -130,8 +121,7 @@ function messageDiscordEventChannel(messageString) {
} }
messageString = removeColoursInMessage(messageString); messageString = removeColoursInMessage(messageString);
messageString = replaceProfanityInMessage(messageString); triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
} }
// =========================================================================== // ===========================================================================
@@ -150,35 +140,12 @@ function messageDiscordAdminChannel(messageString) {
} }
messageString = removeColoursInMessage(messageString); messageString = removeColoursInMessage(messageString);
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_ADMIN); triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_ADMIN);
} }
// =========================================================================== // ===========================================================================
function messageDiscordClanWebhook(clanIndex, requiredFlagValue, messageString) { function triggerDiscordWebHook(messageString, serverId = getServerId(), type = VRR_DISCORD_WEBHOOK_LOG) {
if (getServerConfig().devServer == true) {
return false;
}
if (!getGlobalConfig().discord.sendClan) {
return false;
}
if (!getServerConfig().discord.sendClan) {
return false;
}
if (!hasBitFlag(getClanData(clanIndex).discordWebhookFlags, requiredFlagValue)) {
return false;
}
messageString = removeColoursInMessage(messageString);
triggerClanDiscordWebHook(clanIndex, messageString);
}
// ===========================================================================
function triggerDiscordWebHook(messageString, serverId = getServerId(), type = AGRP_DISCORD_WEBHOOK_LOG) {
if (!getGlobalConfig().discord.webhook.enabled) { if (!getGlobalConfig().discord.webhook.enabled) {
return false; return false;
} }
@@ -201,31 +168,3 @@ function triggerDiscordWebHook(messageString, serverId = getServerId(), type = A
} }
// =========================================================================== // ===========================================================================
function triggerClanDiscordWebHook(clanIndex, messageString) {
if (!getGlobalConfig().discord.webhook.enabled) {
return false;
}
/*
let webhookURL = getClanData(clanIndex).discordWebhookURL;
let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL;
tempURL = tempURL.replace("{0}", encodeURI(messageString));
tempURL = tempURL.replace("{1}", serverId);
tempURL = tempURL.replace("{2}", type);
tempURL = tempURL.replace("{3}", getGlobalConfig().discord.webhook.pass);
httpGet(
tempURL,
"",
function (data) {
},
function (data) {
}
);
*/
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: economy.js // FILE: economy.js
// DESC: Provides economy/financial utils, functions and usage // DESC: Provides economy/financial utils, functions and usage
@@ -188,19 +187,19 @@ function repossessFirstAsset(client) {
// =========================================================================== // ===========================================================================
function getAllVehiclesOwnedByPlayer(client) { function getAllVehiclesOwnedByPlayer(client) {
return getServerData().vehicles.filter((v) => v.ownerType == AGRP_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId); return getServerData().vehicles.filter((v) => v.ownerType == VRR_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId);
} }
// =========================================================================== // ===========================================================================
function getAllBusinessesOwnedByPlayer(client) { function getAllBusinessesOwnedByPlayer(client) {
return getServerData().businesses.filter((b) => b.ownerType == AGRP_BIZ_OWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId); return getServerData().businesses.filter((b) => b.ownerType == VRR_BIZOWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId);
} }
// =========================================================================== // ===========================================================================
function getAllHousesOwnedByPlayer(client) { function getAllHousesOwnedByPlayer(client) {
return getServerData().houses.filter((h) => h.ownerType == AGRP_HOUSE_OWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId); return getServerData().houses.filter((h) => h.ownerType == VRR_HOUSEOWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: email.js // FILE: email.js
// DESC: Provides email handling, functions and usage // DESC: Provides email handling, functions and usage

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: event.js // FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events // DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
@@ -19,7 +18,11 @@ function initEventScript() {
function addAllEventHandlers() { function addAllEventHandlers() {
addEventHandler("onResourceStart", onResourceStart); addEventHandler("onResourceStart", onResourceStart);
addEventHandler("onResourceStop", onResourceStop); addEventHandler("onResourceStop", onResourceStop);
addEventHandler("onServerStop", onResourceStop);
addEventHandler("onProcess", onProcess); addEventHandler("onProcess", onProcess);
addEventHandler("onEntityProcess", onEntityProcess);
addEventHandler("onPlayerConnect", onPlayerConnect); addEventHandler("onPlayerConnect", onPlayerConnect);
addEventHandler("onPlayerJoin", onPlayerJoin); addEventHandler("onPlayerJoin", onPlayerJoin);
addEventHandler("onPlayerJoined", onPlayerJoined); addEventHandler("onPlayerJoined", onPlayerJoined);
@@ -27,12 +30,15 @@ function addAllEventHandlers() {
addEventHandler("onPlayerQuit", onPlayerQuit); addEventHandler("onPlayerQuit", onPlayerQuit);
addEventHandler("onElementStreamIn", onElementStreamIn); addEventHandler("onElementStreamIn", onElementStreamIn);
addEventHandler("onElementStreamOut", onElementStreamOut); addEventHandler("onElementStreamOut", onElementStreamOut);
addEventHandler("onPedSpawn", onPedSpawn); addEventHandler("onPedSpawn", onPedSpawn);
addEventHandler("onPedEnteredVehicleEx", onPedEnteredVehicle); addEventHandler("onPedEnterVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitedVehicleEx", onPedExitedVehicle); addEventHandler("onPedExitVehicle", onPedExitingVehicle);
addEventHandler("onPedEnteredSphereEx", onPedEnteredSphere);
addEventHandler("onPedExitedSphereEx", onPedExitedSphere); addEventHandler("onPedEnteringVehicle", onPedEnteringVehicle);
addEventHandler("OnPickupPickedUp", onPedPickupPickedUp); addEventHandler("onPedExitingVehicle", onPedExitingVehicle);
//addEventHandler("OnPlayerCommand", onPlayerCommand);
} }
// =========================================================================== // ===========================================================================
@@ -50,9 +56,9 @@ function onPlayerConnect(event, ipAddress, port) {
function onPlayerJoin(event, client) { function onPlayerJoin(event, client) {
logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`); logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`);
//if (isFadeCameraSupported()) { if (isFadeCameraSupported()) {
// fadeCamera(client, true, 1.0); fadeCamera(client, true, 1.0);
//} }
//if(isCustomCameraSupported()) { //if(isCustomCameraSupported()) {
// showConnectCameraToPlayer(client); // showConnectCameraToPlayer(client);
@@ -72,7 +78,7 @@ function onPlayerJoin(event, client) {
// =========================================================================== // ===========================================================================
function onPlayerJoined(event, client) { function onPlayerJoined(event, client) {
//initClient(client);
} }
// =========================================================================== // ===========================================================================
@@ -109,52 +115,31 @@ function onPlayerQuit(event, client, quitReasonId) {
} }
} }
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
getClients().forEach(forClient => {
let reasonText = getGroupedLocaleString(forClient, "DisconnectReasons", quitReasonId);
messagePlayerNormal(forClient, getLocaleString(forClient, "PlayerLeftServer", getPlayerName(client), reasonText));
});
//messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow")); //messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
//if (isPlayerFishing(client)) {
// stopFishing(client);
//}
if (isPlayerInPaintBall(client)) {
stopPaintBall(client);
}
if (isPlayerOnJobRoute(client)) {
stopJobRoute(client);
}
if (isPlayerWorking(client)) {
stopWorking(client);
}
if (isPlayerLoggedIn(client)) { if (isPlayerLoggedIn(client)) {
savePlayerToDatabase(client); savePlayerToDatabase(client);
resetClientStuff(client); resetClientStuff(client);
} getServerData().clients[getPlayerId(client)] = null;
if (getPlayerData(client).loginTimeout != null) {
clearTimeout(getPlayerData(client).loginTimeout);
} }
playerResourceReady[client.index] = false; playerResourceReady[client.index] = false;
playerResourceStarted[client.index] = false; playerResourceStarted[client.index] = false;
playerInitialized[client.index] = false; playerInitialized[client.index] = false;
playerGUIReady[client.index] = false; playerGUIReady[client.index] = false;
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
getClients().forEach(forClient => {
let reasonText = getGroupedLocaleString(forClient, "DisconnectReasons", quitReasonId);
messagePlayerNormal(forClient, getLocaleString(forClient, "PlayerLeftServer", getPlayerName(client), reasonText));
});
getServerData().clients[getPlayerId(client)] = null;
} }
// =========================================================================== // ===========================================================================
async function onPlayerChat(event, client, messageText) { async function onPlayerChat(event, client, messageText) {
event.preventDefault();
processPlayerChat(client, messageText); processPlayerChat(client, messageText);
event.preventDefault();
} }
// =========================================================================== // ===========================================================================
@@ -178,7 +163,7 @@ function onEntityProcess(event, entity) {
function onPedEnteringVehicle(event, ped, vehicle, seat) { function onPedEnteringVehicle(event, ped, vehicle, seat) {
if (ped.isType(ELEMENT_PLAYER)) { if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped); let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = AGRP_PEDSTATE_ENTERINGVEHICLE; getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
if (!getVehicleData(vehicle)) { if (!getVehicleData(vehicle)) {
return false; return false;
@@ -187,12 +172,12 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) {
if (getVehicleData(vehicle).locked) { if (getVehicleData(vehicle).locked) {
if (doesPlayerHaveVehicleKeys(client, vehicle)) { if (doesPlayerHaveVehicleKeys(client, vehicle)) {
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) { if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) {
messagePlayerTip(client, getLocaleString(client, "VehicleLockedCommandTip", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))}{MAINCOLOUR}`)); messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`);
} else { } else {
messagePlayerTip(client, getLocaleString(client, "VehicleLockedCommandTip", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}/lock{MAINCOLOUR}`)); messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
} }
} else { } else {
messagePlayerNormal(client, messagePlayerTip(client, getLocaleString(client, "VehicleLockedCantUnlock", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`))); messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
} }
//getPlayerData(client).enteringVehicle = null; //getPlayerData(client).enteringVehicle = null;
@@ -213,7 +198,7 @@ function onPedExitingVehicle(event, ped, vehicle) {
if (ped.isType(ELEMENT_PLAYER)) { if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped); let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = AGRP_PEDSTATE_EXITINGVEHICLE; getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE;
} }
if (!getVehicleData(vehicle).spawnLocked) { if (!getVehicleData(vehicle).spawnLocked) {
@@ -245,65 +230,169 @@ function onResourceStop(event, resource) {
if (resource == thisResource) { if (resource == thisResource) {
kickAllClients(); kickAllClients();
saveServerDataToDatabase(); saveServerDataToDatabase();
disconnectFromDatabase(persistentDatabaseConnection, true);
collectAllGarbage(); collectAllGarbage();
} }
} }
// =========================================================================== // ===========================================================================
function onPedEnteredSphere(event, ped, sphere) { function onPlayerEnteredSphere(client, sphere) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
// Handled client-side since server spheres aren't showing on GTAC atm (bug) }
//if (isPlayerOnJobRoute(client)) {
// if (sphere == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) { // ===========================================================================
// playerArrivedAtJobRouteLocation(client);
// } function onPlayerExitedSphere(client, sphere) {
//}
}
// ===========================================================================
async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
if (client == null) {
return false;
} }
}
// =========================================================================== let vehicle = null;
function onPedExitedSphere(event, ped, sphere) { if (getGame() == VRR_GAME_GTA_IV) {
//if (ped.isType(ELEMENT_PLAYER)) { vehicle = getVehicleFromIVNetworkId(clientVehicle);
// let client = getClientFromPlayerElement(ped); } else {
//} if (getPlayerPed(client) == null) {
} return false;
}
// ===========================================================================
await waitUntil(() => client != null && getPlayerPed(client) != null && getPlayerVehicle(client) != null);
function onPedPickupPickedUp(event, ped, pickup) {
if (ped.isType(ELEMENT_PLAYER)) { vehicle = getPlayerVehicle(client);
let client = getClientFromPlayerElement(ped); }
//if (isPlayerOnJobRoute(client)) { if (!getVehicleData(vehicle)) {
// if (pickup == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) { return false;
// playerArrivedAtJobRouteLocation(client); }
// }
//} logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
}
} getPlayerData(client).lastVehicle = vehicle;
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
// ===========================================================================
if (getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) {
function onPedWasted(event, ped, killerPed, weapon, pedPiece) { vehicle.engine = getVehicleData(vehicle).engine;
if (ped.isType(ELEMENT_PLAYER)) {
let killerClient = null; if (getVehicleData(vehicle).buyPrice > 0) {
if (killerPed != null && killerPed.type == ELEMENT_PLAYER) { messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
killerClient = getClientFromPlayerElement(killerPed); resetVehiclePosition(vehicle);
} else if (getVehicleData(vehicle).rentPrice > 0) {
if (getVehicleData(vehicle).rentedBy != client) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else {
messagePlayerAlert(client, `You are renting this ${getVehicleName(vehicle)} for {ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute. {MAINCOLOUR}Use {ALTCOLOUR}/stoprent {MAINCOLOUR}if you want to stop renting it.`);
}
} else {
let ownerName = "Nobody";
let ownerType = "None";
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
switch (getVehicleData(vehicle).ownerType) {
case VRR_VEHOWNER_CLAN:
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "clan";
break;
case VRR_VEHOWNER_JOB:
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "job";
break;
case VRR_VEHOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
ownerType = "player";
break;
case VRR_VEHOWNER_BIZ:
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
ownerType = "business";
break;
default:
break;
}
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`);
}
if (!getVehicleData(vehicle).engine) {
if (getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
if (doesPlayerHaveVehicleKeys(client, vehicle)) {
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
}
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
}
}
resetVehiclePosition(vehicle);
}
let currentSubAccount = getPlayerCurrentSubAccount(client);
if (isPlayerWorking(client)) {
if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if (getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
}
}
}
if (isPlayerWorking(client)) {
if (isPlayerOnJobRoute(client)) {
if (vehicle == getPlayerJobRouteVehicle(client)) {
stopReturnToJobVehicleCountdown(client);
}
}
}
}
if (getVehicleData(vehicle).streamingRadioStation != -1) {
if (getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) {
playRadioStreamForPlayer(client, getServerData().radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
} }
onPlayerWasted(getClientFromPlayerElement(ped), killerClient, weapon, pedPiece);
} }
} }
// =========================================================================== // ===========================================================================
function onPlayerDeath(client, killer, weapon, pedPiece) { function onPlayerExitedVehicle(client, vehicle) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
stopRadioStreamForPlayer(client);
if (!getVehicleData(vehicle)) {
return false;
}
if (isPlayerWorking(client)) {
if (isPlayerOnJobRoute(client)) {
if (vehicle == getPlayerJobRouteVehicle(client)) {
startReturnToJobVehicleCountdown(client);
}
}
}
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
}
// ===========================================================================
function onPlayerDeath(client, position) {
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`); logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`);
getPlayerData(client).pedState = AGRP_PEDSTATE_DEAD; getPlayerData(client).pedState = VRR_PEDSTATE_DEAD;
updatePlayerSpawnedState(client, false); updatePlayerSpawnedState(client, false);
setPlayerControlState(client, false); setPlayerControlState(client, false);
setTimeout(function () { setTimeout(function () {
@@ -311,72 +400,57 @@ function onPlayerDeath(client, killer, weapon, pedPiece) {
fadeCamera(client, false, 1.0); fadeCamera(client, false, 1.0);
} }
setTimeout(function () { setTimeout(function () {
if (isPlayerInPaintBall(client)) { if (getPlayerCurrentSubAccount(client).inJail) {
getPlayerData(killer).paintBallKills++; let closestJail = getClosestPoliceStation(getPlayerPosition(client));
getPlayerData(client).paintBallDeaths++; despawnPlayer(client);
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
if (getPlayerData(killer).paintBallDeaths >= getGlobalConfig().paintBallMaxKills) { if (isPlayerWorking(client)) {
let paintBallPlayers = getAllPlayersInBusiness(getPlayerData(client).paintBallBusiness); stopWorking(client);
let winner = paintBallPlayers[i];
for (let i in paintBallPlayers) {
if (getPlayerData(paintBallPlayers[i]).paintBallKills > getPlayerData(winner).paintBallKills) {
winner = paintBallPlayers[i];
}
}
for (let i in paintBallPlayers) {
showSmallGameMessage(paintBallPlayers[i], `${getLocaleString(paintBallPlayers[i], "PaintBallEnded")} ${getLocaleString(paintBallPlayers[i], "Winners", `${getCharacterFullName(winner)}`)}`);
stopPaintBall(paintBallPlayers[i]);
}
} else {
respawnPlayerForPaintBall(client);
} }
} else {
if (getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
despawnPlayer(client);
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
if (isPlayerWorking(client)) {
stopWorking(client);
}
if (getGame() == VRR_GAME_MAFIA_ONE) {
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestJail.position, closestJail.heading);
} else {
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
if (isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
resetPlayerBlip(client);
} else {
let closestHospital = getClosestHospital(getPlayerPosition(client));
despawnPlayer(client);
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
if (isPlayerWorking(client)) {
stopWorking(client);
}
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
if (isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
resetPlayerBlip(client);
} }
if (isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
resetPlayerBlip(client);
} else {
let closestHospital = getClosestHospital(getPlayerPosition(client));
despawnPlayer(client);
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
if (isPlayerWorking(client)) {
stopWorking(client);
}
if (getGame() == VRR_GAME_MAFIA_ONE) {
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestHospital.position, closestHospital.heading);
} else {
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
}
if (isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
resetPlayerBlip(client);
} }
}, 2000); }, 2000);
}, 1000); }, 1000);
/*
let queryData = [ let queryData = [
["log_death_server", getServerId()] ["log_death_server", getServerId()]
["log_death_who_died", getPlayerCurrentSubAccount(client).databaseId], ["log_death_who_died", getPlayerCurrentSubAccount(client).databaseId],
@@ -387,7 +461,6 @@ function onPlayerDeath(client, killer, weapon, pedPiece) {
]; ];
let queryString = createDatabaseInsertQuery("log_death", queryData); let queryString = createDatabaseInsertQuery("log_death", queryData);
addToQueryQueue(queryString); addToQueryQueue(queryString);
*/
} }
// =========================================================================== // ===========================================================================
@@ -414,7 +487,7 @@ async function onPlayerSpawn(client) {
await waitUntil(() => client != null && getPlayerPed(client) != null); await waitUntil(() => client != null && getPlayerPed(client) != null);
} }
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`); logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if (!getPlayerData(client)) { if (!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Spawn bug. Data invalid.`; getPlayerData(targetClient).customDisconnectReason = `Kicked - Spawn bug. Data invalid.`;
@@ -422,7 +495,7 @@ async function onPlayerSpawn(client) {
return false; return false;
} }
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`); logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if (!isPlayerLoggedIn(client)) { if (!isPlayerLoggedIn(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without logging in.`; getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without logging in.`;
@@ -430,7 +503,7 @@ async function onPlayerSpawn(client) {
return false; return false;
} }
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`); logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if (getPlayerData(client).currentSubAccount == -1) { if (getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without selecting a character.`; getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without selecting a character.`;
@@ -440,23 +513,26 @@ async function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
if (isGameFeatureSupported("pedScale")) { if (getGame() == VRR_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`); logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
setEntityData(getPlayerPed(client), "agrp.scale", getPlayerCurrentSubAccount(client).pedScale, true); setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
} }
//if (isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) { logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`); setEntityData(getPlayerPed(client), "vrr.scale", getPlayerCurrentSubAccount(client).pedScale, true);
// return false;
//}
if (isCustomCameraSupported() && getGame() != AGRP_GAME_GTA_IV && getGame() != AGRP_GAME_GTA_IV_EFLC) { if (isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] Restoring ${getPlayerDisplayForConsole(client)}'s camera`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
return false;
}
if (isCustomCameraSupported()) {
restorePlayerCamera(client); restorePlayerCamera(client);
} }
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
if (areServerElementsSupported()) { if (areServerElementsSupported()) {
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
getPlayerData(client).ped = getPlayerPed(client); getPlayerData(client).ped = getPlayerPed(client);
} }
@@ -465,19 +541,15 @@ async function onPlayerSpawn(client) {
//messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange")); //messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
//messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow")); //messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
// Tried this. Doesn't work for some reason. if (getGame() == VRR_GAME_MAFIA_ONE) {
// Mafia Connected needs fixed to set position on spawn. setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition);
//if (getGame() == AGRP_GAME_MAFIA_ONE) { setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading);
// setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition); setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
// setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading);
// setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
//}
if (isGameFeatureSupported("interior")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
} }
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`); logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension); setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
@@ -488,37 +560,30 @@ async function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`); logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health); setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
if (isGameFeatureSupported("pedArmour")) { logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`); setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`); logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job); sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
if (isGameFeatureSupported("rendering2D")) { logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`); setPlayer2DRendering(client, true, true, true, true, true, true);
setPlayer2DRendering(client, true, true, true, true, true, true);
}
if (isGameFeatureSupported("snow")) { logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`); if (isSnowSupported()) {
updatePlayerSnowState(client); updatePlayerSnowState(client);
} }
if (areServerElementsSupported() && isGameFeatureSupported("walkStyle")) { if (areServerElementsSupported() && getGame() == VRR_GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walking style for ${getPlayerDisplayForConsole(client)}`); logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
setEntityData(getPlayerPed(client), "agrp.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true); setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
}
if (isGameFeatureSupported("fightStyle")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player fighting style for ${getPlayerDisplayForConsole(client)}`);
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle); setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
} }
if (isGameFeatureSupported("rendering2D")) { logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`); if (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
updatePlayerShowLogoState(client, (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client))); updatePlayerShowLogoState(client, true);
} }
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`); logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
@@ -537,20 +602,20 @@ async function onPlayerSpawn(client) {
} }
//if(isGTAIV()) { //if(isGTAIV()) {
// setEntityData(getPlayerPed(client), "agrp.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true); // setEntityData(getPlayerPed(client), "vrr.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true); // setEntityData(getPlayerPed(client), "vrr.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true); // setEntityData(getPlayerPed(client), "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
//} //}
if (isGTAIV()) { if (isGTAIV()) {
@@ -558,7 +623,7 @@ async function onPlayerSpawn(client) {
} }
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`); logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
getPlayerData(client).pedState = AGRP_PEDSTATE_READY; getPlayerData(client).pedState = VRR_PEDSTATE_READY;
if (areServerElementsSupported()) { if (areServerElementsSupported()) {
syncPlayerProperties(client); syncPlayerProperties(client);
@@ -570,10 +635,11 @@ async function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`); logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
updatePlayerCash(client); updatePlayerCash(client);
if (isGameFeatureSupported("customNametag")) { logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`); updateAllPlayerNameTags();
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
} logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`);
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
if (!areServerElementsSupported()) { if (!areServerElementsSupported()) {
sendAllBusinessesToPlayer(client); sendAllBusinessesToPlayer(client);
@@ -588,45 +654,26 @@ async function onPlayerSpawn(client) {
getPlayerData(client).payDayTickStart = sdl.ticks; getPlayerData(client).payDayTickStart = sdl.ticks;
// Locales are handled via resource files now. No need to send anymore, but kept in case revert is needed.
//sendPlayerLocaleStrings(client); //sendPlayerLocaleStrings(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`); // Stop playing intro music and any other radio
updateAllPlayerNameTags(); stopRadioStreamForPlayer(client);
setPlayerWeaponDamageEvent(client, AGRP_WEAPON_DAMAGE_EVENT_NORMAL);
if (areServerElementsSupported()) {
if (getGlobalConfig().playerStreamInDistance == -1 || getGlobalConfig().playerStreamOutDistance == -1) {
getPlayerPed(client).netFlags.distanceStreaming = false;
} else {
setElementStreamInDistance(getPlayerPed(client), getServerConfig().playerStreamInDistance);
setElementStreamOutDistance(getPlayerPed(client), getServerConfig().playerStreamOutDistance);
}
resetPlayerBlip(client);
}
// Radio stuff must be last thing sent to client because it hangs the client for a second, which blocks processing of other incoming packets
// Start playing business/house radio if in one // Start playing business/house radio if in one
if (getPlayerCurrentSubAccount(client).interior != getGameConfig().mainWorldInterior[getGame()] || getPlayerCurrentSubAccount(client).dimension != getGameConfig().mainWorldDimension[getGame()]) { let businessId = getPlayerBusiness(client);
let businessId = getPlayerBusiness(client); let houseId = getPlayerHouse(client);
let houseId = getPlayerHouse(client); if (businessId != -1) {
if (businessId != -1) { if (getBusinessData(businessId).streamingRadioStation != -1) {
if (getBusinessData(businessId).streamingRadioStation != -1) { playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(businessId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(businessId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null); }
} } else if (houseId != -1) {
} else if (houseId != -1) { if (getHouseData(houseId).streamingRadioStation != -1) {
if (getHouseData(houseId).streamingRadioStation != -1) { playRadioStreamForPlayer(client, getRadioStationData(getHouseData(houseId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
playRadioStreamForPlayer(client, getRadioStationData(getHouseData(houseId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
}
} else {
stopRadioStreamForPlayer(client);
} }
} else {
stopRadioStreamForPlayer(client);
} }
resetPlayerBlip(client)
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`); messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
} }
@@ -639,168 +686,3 @@ function onPlayerCommand(event, client, command, params) {
} }
// =========================================================================== // ===========================================================================
function onPedExitedVehicle(event, ped, vehicle, seat) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
stopRadioStreamForPlayer(client);
if (!getVehicleData(vehicle)) {
return false;
}
if (isPlayerWorking(client)) {
if (isPlayerOnJobRoute(client)) {
if (vehicle == getPlayerJobRouteVehicle(client)) {
startReturnToJobVehicleCountdown(client);
}
}
}
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("agrp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
}
}
}
// ===========================================================================
function onPedEnteredVehicle(event, ped, vehicle, seat) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
if (getPlayerData(client) == false) {
return false;
}
if (getGame() == AGRP_GAME_GTA_IV) {
vehicle = getVehicleFromIVNetworkId(clientVehicle);
}
if (!getVehicleData(vehicle)) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("agrp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
getPlayerData(client).lastVehicle = vehicle;
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
if (getPlayerVehicleSeat(client) == AGRP_VEHSEAT_DRIVER) {
vehicle.engine = getVehicleData(vehicle).engine;
if (getVehicleData(vehicle).buyPrice > 0) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else if (getVehicleData(vehicle).rentPrice > 0) {
if (getVehicleData(vehicle).rentedBy != client) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else {
messagePlayerAlert(client, getLocaleString(client, "CurrentlyRentingThisVehicle", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}`, `{ALTCOLOUR}/stoprent{MAINCOLOUR}`));
}
} else {
let ownerName = "Nobody";
let ownerType = getLocaleString(client, "NotOwned");
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
switch (getVehicleData(vehicle).ownerType) {
case AGRP_VEHOWNER_CLAN:
ownerName = getClanData(getClanIndexFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = getLocaleString(client, "Clan");
break;
case AGRP_VEHOWNER_JOB:
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = getLocaleString(client, "Job");
break;
case AGRP_VEHOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
ownerType = getLocaleString(client, "Player");
break;
case AGRP_VEHOWNER_BIZ:
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
ownerType = getLocaleString(client, "Business");
break;
default:
break;
}
messagePlayerAlert(client, getLocaleString(client, "VehicleBelongsTo", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}${ownerName}{MAINCOLOUR}`, `{ALTCOLOUR}${ownerType}{MAINCOLOUR}`));
}
if (!getVehicleData(vehicle).engine) {
if (getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
if (doesPlayerHaveVehicleKeys(client, vehicle)) {
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
}
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
}
}
resetVehiclePosition(vehicle);
}
let currentSubAccount = getPlayerCurrentSubAccount(client);
if (isPlayerWorking(client)) {
if (getVehicleData(vehicle).ownerType == AGRP_VEHOWNER_JOB) {
if (getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
}
}
}
if (isPlayerWorking(client)) {
if (isPlayerOnJobRoute(client)) {
if (vehicle == getPlayerJobRouteVehicle(client)) {
stopReturnToJobVehicleCountdown(client);
}
}
}
}
let radioStationIndex = getVehicleData(vehicle).streamingRadioStationIndex;
if (radioStationIndex != -1) {
if (getPlayerData(client).streamingRadioStation != radioStationIndex) {
playRadioStreamForPlayer(client, getRadioStationData(radioStationIndex).url, true, getPlayerStreamingRadioVolume(client));
}
}
}
}
}
// ===========================================================================
function onPedEnteringVehicle(event, ped, vehicle, seat) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
}
}
}
// ===========================================================================
function onPedExitingVehicle(event, ped, vehicle, seat) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
onPlayerExitingVehicle(client, vehicle, seat);
}
}
}
// ===========================================================================

View File

@@ -1,209 +1,15 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: fishing.js // FILE: fishing.js
// DESC: Provides fishing functions and commands // DESC: Provides fishing functions and commands
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// Fishing Catch Types (Probably not going to be used, in favor of items and their use type)
const AGRP_FISHING_CATCH_TYPE_NONE = 0;
const AGRP_FISHING_CATCH_TYPE_FISH = 1;
const AGRP_FISHING_CATCH_TYPE_JUNK = 2;
// Fishing Line States
const AGRP_FISHING_LINE_STATE_NONE = 0;
const AGRP_FISHING_LINE_STATE_READY = 1;
const AGRP_FISHING_LINE_STATE_CASTING = 2;
const AGRP_FISHING_LINE_STATE_CASTED = 3;
const AGRP_FISHING_LINE_STATE_REELING = 4;
const AGRP_FISHING_LINE_STATE_HOOKED = 5;
// ===========================================================================
let fishingCollectables = [
// Fish
["Salmon", AGRP_FISHING_CATCH_TYPE_FISH],
["Tuna", AGRP_FISHING_CATCH_TYPE_FISH],
["Crab", AGRP_FISHING_CATCH_TYPE_FISH],
["Trout", AGRP_FISHING_CATCH_TYPE_FISH],
["Sea Bass", AGRP_FISHING_CATCH_TYPE_FISH],
["Shark", AGRP_FISHING_CATCH_TYPE_FISH],
["Turtle", AGRP_FISHING_CATCH_TYPE_FISH],
["Manta Ray", AGRP_FISHING_CATCH_TYPE_FISH],
["Cat Fish", AGRP_FISHING_CATCH_TYPE_FISH],
["Blue Marlin", AGRP_FISHING_CATCH_TYPE_FISH],
// Junk
["Rusty Can", AGRP_FISHING_CATCH_TYPE_JUNK],
["Old Pants", AGRP_FISHING_CATCH_TYPE_JUNK],
["Old Shoes", AGRP_FISHING_CATCH_TYPE_JUNK],
["Garbage", AGRP_FISHING_CATCH_TYPE_JUNK],
["Baby Diaper", AGRP_FISHING_CATCH_TYPE_JUNK],
["Old Tire", AGRP_FISHING_CATCH_TYPE_JUNK],
["Old Car Battery", AGRP_FISHING_CATCH_TYPE_JUNK],
["Horse Hoove", AGRP_FISHING_CATCH_TYPE_JUNK],
["Soggy Log", AGRP_FISHING_CATCH_TYPE_JUNK],
["Soggy Dildo", AGRP_FISHING_CATCH_TYPE_JUNK],
["Clump of Seaweed", AGRP_FISHING_CATCH_TYPE_JUNK],
];
// ===========================================================================
let fishingAnimations = {
[AGRP_GAME_GTA_III]: {
"fishingLineCasting": "bathit1",
"fishingLineReeling": "aimdown",
},
[AGRP_GAME_GTA_VC]: {
"fishingLineCasting": "frontpunch",
"fishingLineReeling": "aimdown",
},
[AGRP_GAME_GTA_SA]: {
"fishingLineCasting": "none",
"fishingLineReeling": "none",
}
};
// ===========================================================================
let fishingParticleEffects = {
[AGRP_GAME_GTA_III]: {
"fishingLineCast": [
"MediumSprayingWater",
0.2,
500
],
"fishingLineReel": [
"MediumSprayingWater",
0.2,
500
]
}
};
// ===========================================================================
function initFishingScript() { function initFishingScript() {
logToConsole(LOG_INFO, "[VRR.Fishing]: Initializing fishing script ..."); logToConsole(LOG_INFO, "[VRR.Fishing]: Initializing fishing script ...");
logToConsole(LOG_INFO, "[VRR.Fishing]: Fishing script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.Fishing]: Fishing script initialized successfully!");
} }
// =========================================================================== // ===========================================================================
function castFishingLineCommand(command, params, client) {
if (!isPlayerInFishingSpot(client)) {
messagePlayerError(client, getLocaleString(client, "CantFishHere"));
return false;
}
if (doesPlayerHaveItemOfUseTypeEquipped(client, AGRP_ITEM_USE_TYPE_FISHINGROD)) {
messagePlayerError(client, getLocaleString(client, "NeedFishingRod"));
return false;
}
if (doesPlayerHaveFishingLineCast(client)) {
messagePlayerError(client, getLocaleString(client, "FishingLineAlreadyCast"));
return false;
}
let maxStrength = getGlobalConfig().fishingCastMaxStrength;
let minStrength = getGlobalConfig().fishingCastMinStrength;
let keyDuration = getPlayerData(client).keyBindDuration;
let strength = Math.round((maxStrength - minStrength) * (keyDuration / getGlobalConfig().fishingLineCastDuration));
castPlayerFishingLine(client, strength);
let messageText = getLocaleString(client, "FishingCastCommandHelp");
if (doesPlayerHaveKeyBindForCommand(client, "fish")) {
messageText = getLocaleString(client, "FishingCastKeyPressHelp");
}
showSmallGameMessage(client, messageText);
}
// ===========================================================================
function resetFishingLineCommand(client) {
if (doesPlayerHaveFishingLineCast(client)) {
messagePlayerError(client, getLocaleString(client, "FishingLineNotCast"));
return false;
}
if (doesPlayerHaveItemOfUseTypeEquipped(client, AGRP_ITEM_USE_TYPE_FISHINGROD)) {
messagePlayerError(client, getLocaleString(client, "NeedFishingRod"));
return false;
}
if (!isPlayerInFishingSpot(client)) {
messagePlayerError(client, getLocaleString(client, "CantFishHere"));
return false;
}
makePedStopAnimation(getPlayerPed(client));
let messageText = getLocaleString(client, "FishingCastCommandHelp");
if (doesPlayerHaveKeyBindForCommand(client, "fish")) {
messageText = getLocaleString(client, "FishingCastKeyPressHelp");
}
showSmallGameMessage(client, messageText);
getPlayerData(client).fishingLineState = AGRP_FISHING_LINE_STATE_NONE;
getPlayerData(client).fishingLineCastStart = 0;
}
// ===========================================================================
function doesPlayerHaveFishingLineCast(client) {
return getPlayerData(client).fishingLineCastStart != 0;
}
// ===========================================================================
function castPlayerFishingLine(client, strength) {
let frontPosition = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), strength * 2);
makePlayerPlayAnimation(client, getAnimationFromParams(fishingAnimations[getGame()]["fishingLineCasting"]));
setTimeout(function () {
let particleEffectName = fishingParticleEffects[getGame()].fishingLineCast[1];
showParticleEffect(frontPosition, getGameConfig().particleEffects[getGame()][particleEffectName], fishingParticleEffects[getGame()].fishingLineCast[1], fishingParticleEffects[getGame()].fishingLineCast[2]);
getPlayerData(client).fishingLineCastPosition = frontPosition;
getPlayerData(client).fishingLineState = AGRP_FISHING_LINE_STATE_CASTED;
}, strength * 10);
}
// ===========================================================================
function isPlayerInFishingSpot(client) {
if (isPlayerOnBoat(client)) {
return true;
}
let closestFishingLocation = getClosestFishingLocation(getPlayerPosition(client));
if (closestFishingLocation != false) {
if (getDistance(getPlayerPosition(client), closestFishingLocation) < getGlobalConfig().fishingSpotDistance) {
return true;
}
}
return false;
}
// ===========================================================================
function isPlayerFishing(client) {
return (getPlayerData(client).fishingLineState != AGRP_FISHING_LINE_STATE_NONE);
}
// ===========================================================================
function isPlayerFishing(client) {
return (getPlayerData(client).fishingLineState != AGRP_FISHING_LINE_STATE_NONE);
}
// ===========================================================================

View File

@@ -1,21 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: forensics.js
// DESC: Provides forensics functions and commands (bullet casings, blood, etc)
// TYPE: Server (JavaScript)
// ===========================================================================
// Forensic Types
const AGRP_FORENSICS_NONE = 0;
const AGRP_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
const AGRP_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit and outfit worn when somebody is shot
const AGRP_FORENSICS_BODY = 3; // Body. A dead body lol
const AGRP_FORENSICS_HAIR = 4; // Hair.
const AGRP_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
const AGRP_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank and unfinished food items when eaten
const AGRP_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)
// ===========================================================================

View File

@@ -1,50 +1,12 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: gate.js // FILE: gate.js
// DESC: Provides gate functions and commands // DESC: Provides gate functions and commands
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// Gate Owner Types
const AGRP_GATEOWNER_NONE = 0; // Not owned
const AGRP_GATEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const AGRP_GATEOWNER_JOB = 2; // Owned by a job
const AGRP_GATEOWNER_CLAN = 3; // Owned by a clan
const AGRP_GATEOWNER_FACTION = 4; // Owned by a faction
const AGRP_GATEOWNER_PUBLIC = 5; // Public gate. Technically not owned. This probably won't be used.
const AGRP_GATEOWNER_BUSINESS = 6; // Owned by a business. Back lots, unloading areas, and other stuff like that
const AGRP_GATEOWNER_HOUSE = 7; // Owned by a house. Like for mansions with closed private areas.
// ===========================================================================
class GateData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.scriptName = "";
this.enabled = false;
this.position = toVector3(0.0, 0.0, 0.0);
this.locked = true;
this.ownerType = AGRP_GATEOWNER_NONE;
this.ownerId = 0;
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["gate_id"]);
this.name = toString(dbAssoc["gate_name"]);
this.scriptName = toString(dbAssoc["gate_script_name"]);
this.enabled = intToBool(toInteger(dbAssoc["gate_enabled"]));
this.position = toVector3(toFloat(dbAssoc["gate_pos_x"]), toFloat(dbAssoc["gate_pos_y"]), toFloat(dbAssoc["gate_pos_z"]));
this.ownerType = toInteger(dbAssoc["gate_owner_type"]);
this.ownerId = toInteger(dbAssoc["gate_owner_id"]);
}
}
}
// ===========================================================================
function initGateScript() { function initGateScript() {
logToConsole(LOG_INFO, `[VRR.Gate]: Initializing gate script ...`); logToConsole(LOG_INFO, `[VRR.Gate]: Initializing gate script ...`);
logToConsole(LOG_INFO, `[VRR.Gate]: Gate script initialized successfully!`); logToConsole(LOG_INFO, `[VRR.Gate]: Gate script initialized successfully!`);
@@ -55,66 +17,66 @@ function initGateScript() {
function doesPlayerHaveGateKeys(client, vehicle) { function doesPlayerHaveGateKeys(client, vehicle) {
let gateData = getGateData(vehicle); let gateData = getGateData(vehicle);
if (gateData.ownerType == AGRP_GATEOWNER_PUBLIC) { if(gateData.ownerType == VRR_GATEOWNER_PUBLIC) {
return true; return true;
} }
if (gateData.ownerType == AGRP_GATEOWNER_PLAYER) { if(gateData.ownerType == VRR_GATEOWNER_PLAYER) {
if (gateData.ownerId == getPlayerCurrentSubAccount(client).databaseId) { if(gateData.ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true; return true;
} }
} }
if (gateData.ownerType == AGRP_GATEOWNER_CLAN) { if(gateData.ownerType == VRR_GATEOWNER_CLAN) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) { if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
return true; return true;
} }
if (gateData.ownerId == getPlayerCurrentSubAccount(client).clan) { if(gateData.ownerId == getPlayerCurrentSubAccount(client).clan) {
if (gateData.clanRank <= getPlayerCurrentSubAccount(client).clanRank) { if(gateData.clanRank <= getPlayerCurrentSubAccount(client).clanRank) {
return true; return true;
} }
} }
} }
if (gateData.ownerType == AGRP_GATEOWNER_FACTION) { if(gateData.ownerType == VRR_GATEOWNER_FACTION) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageFactions"))) { if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageFactions"))) {
return true; return true;
} }
if (gateData.ownerId == getPlayerCurrentSubAccount(client).faction) { if(gateData.ownerId == getPlayerCurrentSubAccount(client).faction) {
if (gateData.factionRank <= getPlayerCurrentSubAccount(client).factionRank) { if(gateData.factionRank <= getPlayerCurrentSubAccount(client).factionRank) {
return true; return true;
} }
} }
} }
if (gateData.ownerType == AGRP_GATEOWNER_JOB) { if(gateData.ownerType == VRR_GATEOWNER_JOB) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) { if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
return true; return true;
} }
if (gateData.ownerId == getPlayerCurrentSubAccount(client).job) { if(gateData.ownerId == getPlayerCurrentSubAccount(client).job) {
return true; return true;
} }
} }
if (gateData.ownerType == AGRP_GATEOWNER_BUSINESS) { if(gateData.ownerType == VRR_GATEOWNER_BUSINESS) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) {
return true; return true;
} }
if (canPlayerManageBusiness(client, getBusinessIdFromDatabaseId(gateData.ownerId))) { if(canPlayerManageBusiness(client, getBusinessIdFromDatabaseId(gateData.ownerId))) {
return true; return true;
} }
} }
if (gateData.ownerType == AGRP_GATEOWNER_HOUSE) { if(gateData.ownerType == VRR_GATEOWNER_HOUSE) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
return true; return true;
} }
if (canPlayerManageHouse(client, getHouseIdFromDatabaseId(gateData.ownerId))) { if(canPlayerManageHouse(client, getHouseIdFromDatabaseId(gateData.ownerId))) {
return true; return true;
} }
} }
@@ -125,7 +87,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
// =========================================================================== // ===========================================================================
function getGateData(gateId) { function getGateData(gateId) {
if (typeof getServerData().gates[gateId] != "undefined") { if(typeof getServerData().gates[gateId] != "undefined") {
return getServerData().gates[gateId]; return getServerData().gates[gateId];
} }
@@ -136,8 +98,8 @@ function getGateData(gateId) {
function getClosestGate(position) { function getClosestGate(position) {
let closest = 0; let closest = 0;
for (let i in getServerData().gates[getGame()]) { for(let i in getServerData().gates[getGame()]) {
if (getDistance(getServerData().gates[i].position, position) < getDistance(getServerData().gates[closest].position, position)) { if(getDistance(getServerData().gates[i].position, position) < getDistance(getServerData().gates[closest].position, position)) {
closest = i; closest = i;
} }
} }
@@ -150,11 +112,11 @@ function getClosestGate(position) {
function triggerGateCommand(command, params, client) { function triggerGateCommand(command, params, client) {
let closestGate = getClosestGate(getPlayerPosition(client)); let closestGate = getClosestGate(getPlayerPosition(client));
if (!getGateData(closestGate)) { if(!getGateData(closestGate)) {
messagePlayerError(client, getLocaleString(client, "InvalidGate")); messagePlayerError(client, getLocaleString(client, "InvalidGate"));
} }
if (!doesPlayerHaveGateKeys(client, closestGate)) { if(!doesPlayerHaveGateKeys(client, closestGate)) {
messagePlayerError(client, getLocaleString(client, "NoGateAccess")); messagePlayerError(client, getLocaleString(client, "NoGateAccess"));
return false; return false;
} }
@@ -165,11 +127,11 @@ function triggerGateCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function saveAllGatesToDatabase() { function saveAllGatesToDatabase() {
if (getServerConfig().devServer) { if(getServerConfig().devServer) {
return false; return false;
} }
for (let i in getServerData().gates) { for(let i in getServerData().gates) {
saveGateToDatabase(i); saveGateToDatabase(i);
} }
} }
@@ -177,26 +139,26 @@ function saveAllGatesToDatabase() {
// =========================================================================== // ===========================================================================
function saveGateToDatabase(gateId) { function saveGateToDatabase(gateId) {
if (getGateData(gateId) == null) { if(getGateData(gateId) == null) {
// Invalid gate data // Invalid gate data
return false; return false;
} }
let tempGateData = getGateData(gateId); let tempGateData = getGateData(gateId);
if (tempGateData.databaseId == -1) { if(tempGateData.databaseId == -1) {
// Temp gate, no need to save // Temp gate, no need to save
return false; return false;
} }
if (!tempGateData.needsSaved) { if(!tempGateData.needsSaved) {
// Gate hasn't changed. No need to save. // Gate hasn't changed. No need to save.
return false; return false;
} }
logToConsole(LOG_VERBOSE, `[VRR.Gate]: Saving gate ${tempGateData.databaseId} to database ...`); logToConsole(LOG_VERBOSE, `[VRR.Gate]: Saving gate ${tempGateData.databaseId} to database ...`);
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if(dbConnection) {
let safeGateName = escapeDatabaseString(tempGateData.name); let safeGateName = escapeDatabaseString(tempGateData.name);
let safeGateScriptName = escapeDatabaseString(tempGateData.scriptName); let safeGateScriptName = escapeDatabaseString(tempGateData.scriptName);
@@ -213,7 +175,7 @@ function saveGateToDatabase(gateId) {
]; ];
let dbQuery = null; let dbQuery = null;
if (tempGateData.databaseId == 0) { if(tempGateData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("gate_main", data); let queryString = createDatabaseInsertQuery("gate_main", data);
dbQuery = queryDatabase(dbConnection, queryString); dbQuery = queryDatabase(dbConnection, queryString);
tempGateData.databaseId = getDatabaseInsertId(dbConnection); tempGateData.databaseId = getDatabaseInsertId(dbConnection);
@@ -242,11 +204,11 @@ function loadGatesFromDatabase() {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
let dbAssoc; let dbAssoc;
if (dbConnection) { if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM gate_main WHERE gate_server = ${getServerId()}`); let dbQuery = queryDatabase(dbConnection, `SELECT * FROM gate_main WHERE gate_server = ${getServerId()}`);
if (dbQuery) { if(dbQuery) {
if (dbQuery.numRows > 0) { if(dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) { while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempGateData = new GateData(dbAssoc); let tempGateData = new GateData(dbAssoc);
tempGates.push(tempGateData); tempGates.push(tempGateData);
logToConsole(LOG_DEBUG, `[VRR.Gate]: Gate '${tempGateData.name}' loaded from database successfully!`); logToConsole(LOG_DEBUG, `[VRR.Gate]: Gate '${tempGateData.name}' loaded from database successfully!`);

View File

@@ -1,149 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: gps.js
// DESC: Provides GPS functions and commands
// TYPE: Server (JavaScript)
// ===========================================================================
// GPS State Types
const AGRP_GPS_TYPE_NONE = 0; // None (invalid)
const AGRP_GPS_TYPE_BUSINESS = 1; // Business
const AGRP_GPS_TYPE_POLICE = 2; // Police Station
const AGRP_GPS_TYPE_HOSPITAL = 3; // Hospital
const AGRP_GPS_TYPE_JOB = 4; // Job
const AGRP_GPS_TYPE_GAMELOC = 5; // Game Location
// ===========================================================================
function gpsCommand(command, params, client) {
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessList")));
let locationType = AGRP_GPS_TYPE_NONE;
let useType = AGRP_ITEM_USE_TYPE_NONE;
let blipColour = "white";
switch (toLowerCase(params)) {
case "police":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_POLICE;
break;
case "hospital":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_HOSPITAL;
break;
case "job":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_JOB;
break;
case "skin":
case "skins":
case "clothes":
case "player":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_SKIN;
break;
case "gun":
case "guns":
case "weapon":
case "weapons":
case "wep":
case "weps":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_WEAPON;
break;
case "food":
case "eat":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_FOOD;
break;
case "drink":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_DRINK;
break;
case "alcohol":
case "booze":
case "bar":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_ALCOHOL;
break;
case "repair":
case "carrepair":
case "vehrepair":
case "spray":
case "fix":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_VEHREPAIR;
break;
case "vehiclecolour":
case "vehcolour":
case "carcolour":
case "colour":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_VEHCOLOUR;
break;
default: {
let itemTypeId = getItemTypeFromParams(params);
if (getItemTypeData(itemTypeId) != false) {
locationType = AGRP_GPS_TYPE_BUSINESS;
blipColour = "businessBlue";
useType = getItemTypeData(itemTypeId).useType;
} else {
let gameLocationId = getGameLocationFromParams(params);
if (gameLocationId != false) {
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
}
}
}
}
if (locationType == AGRP_GPS_TYPE_NONE) {
messagePlayerError(client, getLocaleString(client, "InvalidGPSLocation"));
return false;
}
if (locationType == AGRP_GPS_TYPE_BUSINESS) {
let businessId = getClosestBusinessWithBuyableItemOfUseType(useType);
if (!businessId) {
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
return false;
}
if (!getBusinessData(businessId)) {
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
return false;
}
hideAllBlipsForPlayerGPS(client);
blinkGenericGPSBlipForPlayer(client, getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getColourByType(blipColour), 10);
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
}
if (locationType == AGRP_GPS_TYPE_GAMELOC) {
hideAllBlipsForPlayerGPS(client);
blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10);
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
return true;
}
}
// ===========================================================================

View File

@@ -1,26 +1,12 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: gui.js // FILE: gui.js
// DESC: Provides GUI functions and usage // DESC: Provides GUI functions and usage
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// Prompts (used for client GUI prompt responses)
const AGRP_PROMPT_NONE = 0;
const AGRP_PROMPT_CREATEFIRSTCHAR = 1;
const AGRP_PROMPT_BIZORDER = 2;
const AGRP_PROMPT_GIVEVEHTOCLAN = 3;
const AGRP_PROMPT_GIVEBIZTOCLAN = 4;
const AGRP_PROMPT_GIVEHOUSETOCLAN = 5;
const AGRP_PROMPT_BUYBIZ = 6;
const AGRP_PROMPT_BUYHOUSE = 7;
const AGRP_PROMPT_RESETKEYBINDS = 8;
// ===========================================================================
function initGUIScript() { function initGUIScript() {
logToConsole(LOG_INFO, "[VRR.GUI]: Initializing GUI script ..."); logToConsole(LOG_INFO, "[VRR.GUI]: Initializing GUI script ...");
logToConsole(LOG_INFO, "[VRR.GUI]: GUI script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.GUI]: GUI script initialized successfully!");
@@ -29,21 +15,21 @@ function initGUIScript() {
// =========================================================================== // ===========================================================================
function playerPromptAnswerNo(client) { function playerPromptAnswerNo(client) {
if (getPlayerData(client).promptType == AGRP_PROMPT_NONE) { if (getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false; return false;
} }
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`); logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
switch (getPlayerData(client).promptType) { switch (getPlayerData(client).promptType) {
case AGRP_PROMPT_CREATEFIRSTCHAR: case VRR_PROMPT_CREATEFIRSTCHAR:
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`);
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters"); showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters");
getPlayerData(targetClient).customDisconnectReason = `Kicked - Didn't create a character`; getPlayerData(targetClient).customDisconnectReason = `Kicked - Didn't create a character`;
setTimeout(function () { disconnectPlayer(client); }, 5000); setTimeout(function () { disconnectPlayer(client); }, 5000);
break; break;
case AGRP_PROMPT_BIZORDER: case VRR_PROMPT_BIZORDER:
if (getPlayerData(client).businessOrderAmount > 0) { if (getPlayerData(client).businessOrderAmount > 0) {
if (canPlayerUseGUI(client)) { if (canPlayerUseGUI(client)) {
showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled"); showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled");
@@ -60,25 +46,25 @@ function playerPromptAnswerNo(client) {
break; break;
} }
getPlayerData(client).promptType = AGRP_PROMPT_NONE; getPlayerData(client).promptType = VRR_PROMPT_NONE;
} }
// =========================================================================== // ===========================================================================
function playerPromptAnswerYes(client) { function playerPromptAnswerYes(client) {
if (getPlayerData(client).promptType == AGRP_PROMPT_NONE) { if (getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false; return false;
} }
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`); logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
switch (getPlayerData(client).promptType) { switch (getPlayerData(client).promptType) {
case AGRP_PROMPT_CREATEFIRSTCHAR: { case VRR_PROMPT_CREATEFIRSTCHAR: {
showPlayerNewCharacterGUI(client); showPlayerNewCharacterGUI(client);
break; break;
} }
case AGRP_PROMPT_BIZORDER: { case VRR_PROMPT_BIZORDER: {
if (getPlayerData(client).businessOrderAmount > 0) { if (getPlayerData(client).businessOrderAmount > 0) {
if (getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) { if (getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`); logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`);
@@ -90,7 +76,7 @@ function playerPromptAnswerYes(client) {
} else { } else {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`); logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`);
showPlayerInfoGUI(client, `You ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} (${getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue)}) for ${getPlayerData(client).businessOrderCost}!`, "Business Order Successful"); showPlayerInfoGUI(client, `You ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} (${getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue)}) for ${getPlayerData(client).businessOrderCost}!`, "Business Order Successful");
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, AGRP_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount); createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount);
cacheBusinessItems(getPlayerData(client).businessOrderBusiness); cacheBusinessItems(getPlayerData(client).businessOrderBusiness);
getBusinessData(getPlayerData(client).businessOrderBusiness).till -= getPlayerData(client).businessOrderCost; getBusinessData(getPlayerData(client).businessOrderBusiness).till -= getPlayerData(client).businessOrderCost;
updateBusinessPickupLabelData(getPlayerData(client).businessOrderBusiness); updateBusinessPickupLabelData(getPlayerData(client).businessOrderBusiness);
@@ -105,7 +91,7 @@ function playerPromptAnswerYes(client) {
break; break;
} }
case AGRP_PROMPT_GIVEVEHTOCLAN: { case VRR_PROMPT_GIVEVEHTOCLAN: {
if (!isPlayerInAnyVehicle(client)) { if (!isPlayerInAnyVehicle(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicle")); messagePlayerError(client, getLocaleString(client, "MustBeInVehicle"));
return false; return false;
@@ -116,7 +102,7 @@ function playerPromptAnswerYes(client) {
return false; return false;
} }
if (getVehicleData(getPlayerVehicle(client)).ownerType != AGRP_VEHOWNER_PLAYER) { if (getVehicleData(getPlayerVehicle(client)).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle")); messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false; return false;
} }
@@ -126,21 +112,21 @@ function playerPromptAnswerYes(client) {
return false; return false;
} }
getVehicleData(getPlayerVehicle(client)).ownerType = AGRP_VEHOWNER_CLAN; getVehicleData(getPlayerVehicle(client)).ownerType = VRR_VEHOWNER_CLAN;
getVehicleData(getPlayerVehicle(client)).ownerId = getPlayerCurrentSubAccount(client).clan; getVehicleData(getPlayerVehicle(client)).ownerId = getPlayerCurrentSubAccount(client).clan;
messagePlayerSuccess(client, getLocaleString(client, "GaveVehicleToClan", getVehicleName(getPlayerVehicle(client)))); messagePlayerSuccess(client, getLocaleString(client, "GaveVehicleToClan", getVehicleName(getPlayerVehicle(client))));
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`); //messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
break; break;
} }
case AGRP_PROMPT_GIVEHOUSETOCLAN: { case VRR_PROMPT_GIVEHOUSETOCLAN: {
let houseId = getPlayerHouse(client); let houseId = getPlayerHouse(client);
if (!houseId) { if (!houseId) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse")); messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false; return false;
} }
if (getHouseData(houseId).ownerType != AGRP_VEHOWNER_PLAYER) { if (getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse")); messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false; return false;
} }
@@ -150,21 +136,21 @@ function playerPromptAnswerYes(client) {
return false; return false;
} }
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_CLAN; getHouseData(houseId).ownerType = VRR_HOUSEOWNER_CLAN;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).clan; getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).clan;
messagePlayerSuccess(client, getLocaleString(client, "GaveHouseToClan")); messagePlayerSuccess(client, getLocaleString(client, "GaveHouseToClan"));
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`); //messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
break; break;
} }
case AGRP_PROMPT_GIVEBIZTOCLAN: { case VRR_PROMPT_GIVEBIZTOCLAN: {
let businessId = getPlayerBusiness(client); let businessId = getPlayerBusiness(client);
if (!businessId) { if (!businessId) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
return false; return false;
} }
if (getBusinessData(businessId).ownerType != AGRP_VEHOWNER_PLAYER) { if (getBusinessData(businessId).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness")); messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
return false; return false;
} }
@@ -174,14 +160,14 @@ function playerPromptAnswerYes(client) {
return false; return false;
} }
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_CLAN; getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).clan; getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).clan;
messagePlayerSuccess(client, getLocaleString(client, "GaveBusinessToClan")); messagePlayerSuccess(client, getLocaleString(client, "GaveBusinessToClan"));
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`); //messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
break; break;
} }
case AGRP_PROMPT_BUYHOUSE: { case VRR_PROMPT_BUYHOUSE: {
let houseId = getPlayerHouse(client); let houseId = getPlayerHouse(client);
if (!houseId) { if (!houseId) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse")); messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
@@ -198,7 +184,7 @@ function playerPromptAnswerYes(client) {
return false; return false;
} }
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_PLAYER; getHouseData(houseId).ownerType = VRR_HOUSEOWNER_PLAYER;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).databaseId; getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getHouseData(houseId).buyPrice = 0; getHouseData(houseId).buyPrice = 0;
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
@@ -209,7 +195,7 @@ function playerPromptAnswerYes(client) {
break; break;
} }
case AGRP_PROMPT_BUYBIZ: { case VRR_PROMPT_BUYBIZ: {
let businessId = getPlayerBusiness(client); let businessId = getPlayerBusiness(client);
if (!businessId) { if (!businessId) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
@@ -226,7 +212,7 @@ function playerPromptAnswerYes(client) {
return false; return false;
} }
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_PLAYER; getBusinessData(businessId).ownerType = VRR_BIZOWNER_PLAYER;
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).databaseId; getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getBusinessData(businessId).buyPrice = 0; getBusinessData(businessId).buyPrice = 0;
getBusinessData(businessId).needsSaved = true; getBusinessData(businessId).needsSaved = true;
@@ -237,21 +223,13 @@ function playerPromptAnswerYes(client) {
break; break;
} }
case AGRP_PROMPT_RESETKEYBINDS: {
break;
}
case AGRP_PROMPT_COPYKEYBINDSTOSERVER: {
break;
}
default: { default: {
submitBugReport(client, `[AUTOMATED REPORT] Unknown prompt type: ${getPlayerData(client).promptType}`); submitBugReport(client, `[AUTOMATED REPORT] Unknown prompt type: ${getPlayerData(client).promptType}`);
break; break;
} }
} }
getPlayerData(client).promptType = AGRP_PROMPT_NONE; getPlayerData(client).promptType = VRR_PROMPT_NONE;
} }
// =========================================================================== // ===========================================================================
@@ -281,7 +259,7 @@ function playerToggledGUI(client) {
// =========================================================================== // ===========================================================================
function showPlayerTwoFactorAuthenticationGUI(client) { function showPlayerTwoFactorAuthenticationGUI(client) {
sendNetworkEventToPlayer("agrp.2fa", client); sendNetworkEventToPlayer("vrr.2fa", client);
} }
// =========================================================================== // ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: help.js // FILE: help.js
// DESC: Provides update info, help commands, and documentation // DESC: Provides update info, help commands, and documentation
@@ -49,12 +48,14 @@ let randomTips = [
// =========================================================================== // ===========================================================================
function helpCommand(command, params, client) { function helpCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
showMainHelpMessage(client); showMainHelpMessage(client);
return false; return false;
} }
switch (toLowerCase(getParam(params, " ", 1))) { let splitParams = params.split(" ");
switch(toLowerCase(getParam(params, " ", 1))) {
case "account": case "account":
showAccountHelpMessage(client); showAccountHelpMessage(client);
break; break;
@@ -194,8 +195,8 @@ function showMainHelpMessage(client) {
function showAccountHelpMessage(client) { function showAccountHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAccountHelp"))); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAccountHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 0, getServerName())); messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 1, `{ALTCOLOUR}/changepass{MAINCOLOUR}`, `{ALTCOLOUR}/resetpass{MAINCOLOUR}`)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 1, `{ALTCOLOUR}/changepass{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 2, `{ALTCOLOUR}/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert{MAINCOLOUR}`)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 2, `{ALTCOLOUR}/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert{MAINCOLOUR}`));
} }
@@ -243,7 +244,7 @@ function showChatHelpMessage(client) {
// =========================================================================== // ===========================================================================
function showRulesHelpMessage(client) { function showRulesHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderServerRules"))); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderServerRulesList")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 0)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 1)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 2)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 2));
@@ -327,7 +328,7 @@ function showRadioHelpMessage(client) {
function showWealthAndTaxHelpMessage(client) { function showWealthAndTaxHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWealthandTaxHelp"))); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWealthandTaxHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 0, `{ALTCOLOUR}${100 * getGlobalConfig().economy.incomeTaxRate}%{MAINCOLOUR}`)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 0, `{ALTCOLOUR}${100*getGlobalConfig().economy.incomeTaxRate}%{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 1)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 2, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle}{MAINCOLOUR}`, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerHouse}{MAINCOLOUR}`, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness}{MAINCOLOUR}`)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 2, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle}{MAINCOLOUR}`, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerHouse}{MAINCOLOUR}`, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness}{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 3, `{ALTCOLOUR}/wealth{MAINCOLOUR}`, `{ALTCOLOUR}/tax{MAINCOLOUR}`)); messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 3, `{ALTCOLOUR}/wealth{MAINCOLOUR}`, `{ALTCOLOUR}/tax{MAINCOLOUR}`));
@@ -336,7 +337,7 @@ function showWealthAndTaxHelpMessage(client) {
// =========================================================================== // ===========================================================================
function showCommandHelpMessage(client, commandName) { function showCommandHelpMessage(client, commandName) {
if (!commandName) { if(!commandName) {
messagePlayerSyntax(client, `${getCommandSyntaxText("help")}command <command name>`); messagePlayerSyntax(client, `${getCommandSyntaxText("help")}command <command name>`);
return false; return false;
} }
@@ -344,7 +345,7 @@ function showCommandHelpMessage(client, commandName) {
commandName = toLowerCase(commandName); commandName = toLowerCase(commandName);
commandName = commandName.trim(); commandName = commandName.trim();
if (commandName.slice(0, 1) == "/") { if(commandName.slice(0, 1) == "/") {
commandName = commandName.slice(1); commandName = commandName.slice(1);
} }
@@ -354,7 +355,7 @@ function showCommandHelpMessage(client, commandName) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName))); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName)));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.helpDescription}`); messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.helpDescription}`);
if (aliases.length > 0) { if(aliases.length > 0) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`); messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`);
} else { } else {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`); messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`);
@@ -393,7 +394,7 @@ function helpGetCarCommand(command, params, client) {
* @return {bool} Whether or not the command was successful * @return {bool} Whether or not the command was successful
* *
*/ */
function helpGetSkinCommand(command, params, client) { function helpGetSkinCommand(command, params, client) {
messagePlayerAlert(client, getLocaleString(client, "SkinCommandHelp", `{ALTCOLOUR}/info skin{MAINCOLOUR}`)); messagePlayerAlert(client, getLocaleString(client, "SkinCommandHelp", `{ALTCOLOUR}/info skin{MAINCOLOUR}`));
messagePlayerAlert(client, ``); messagePlayerAlert(client, ``);
} }

View File

@@ -1,167 +1,12 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: house.js // FILE: house.js
// DESC: Provides house commands, functions, and usage // DESC: Provides house commands, functions, and usage
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// House Location Types
const AGRP_HOUSE_LOC_NONE = 0; // None
const AGRP_HOUSE_LOC_GATE = 1; // Center of any moveable gate that belongs to the house
const AGRP_HOUSE_LOC_GARAGE = 2; // Location for garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
// ===========================================================================
// House Owner Types
const AGRP_HOUSE_OWNER_NONE = 0; // Not owned
const AGRP_HOUSE_OWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const AGRP_HOUSE_OWNER_JOB = 2; // Owned by a job
const AGRP_HOUSE_OWNER_CLAN = 3; // Owned by a clan
const AGRP_HOUSE_OWNER_FACTION = 4; // Owned by a faction
const AGRP_HOUSE_OWNER_PUBLIC = 5; // Is a public house. Technically not owned. This probably won't be used.
// ===========================================================================
/**
* @class Representing a house's data. Loaded and saved in the database
*/
class HouseData {
constructor(dbAssoc = false) {
this.databaseId = 0
this.description = "";
this.ownerType = AGRP_HOUSE_OWNER_NONE;
this.ownerId = 0;
this.buyPrice = 0;
this.rentPrice = 0;
this.renter = 0;
this.locked = false;
this.hasInterior = false;
this.index = -1;
this.needsSaved = false;
this.interiorLights = true;
this.itemCache = [];
this.locations = [];
//this.gameScripts = [];
this.entrancePosition = false;
this.entranceRotation = 0.0;
this.entranceInterior = 0;
this.entranceDimension = 0;
this.entrancePickupModel = -1;
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.exitPosition = false;
this.exitRotation = 0.0;
this.exitInterior = 0;
this.exitDimension = -1;
this.exitPickupModel = -1;
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.streamingRadioStation = 0;
this.streamingRadioStationIndex = -1;
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["house_id"]);
this.description = toString(dbAssoc["house_description"]);
this.ownerType = toInteger(dbAssoc["house_owner_type"]);
this.ownerId = toInteger(dbAssoc["house_owner_id"]);
this.buyPrice = toInteger(dbAssoc["house_buy_price"]);
this.rentPrice = toInteger(dbAssoc["house_rent_price"]);
this.renter = toInteger(dbAssoc["house_renter"]);
this.locked = intToBool(toInteger(dbAssoc["house_locked"]));
this.hasInterior = intToBool(toInteger(dbAssoc["house_has_interior"]));
this.interiorLights = intToBool(toInteger(dbAssoc["house_interior_lights"]));
this.entrancePosition = toVector3(toFloat(dbAssoc["house_entrance_pos_x"]), toFloat(dbAssoc["house_entrance_pos_y"]), toFloat(dbAssoc["house_entrance_pos_z"]));
this.entranceRotation = toFloat(dbAssoc["house_entrance_rot_z"]);
this.entranceInterior = toInteger(dbAssoc["house_entrance_int"]);
this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]);
this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"]));
this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]);
this.exitInterior = toInteger(dbAssoc["house_exit_int"]);
this.exitDimension = toInteger(dbAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]);
}
}
};
// ===========================================================================
/**
* @class Representing a houses's location data. Multiple can be used for a single house. Used for things like doors, garage entry/exit/vehspawn, gates, etc. Loaded and saved in the database
*/
class HouseLocationData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.type = 0;
this.house = 0;
this.enabled = false;
this.index = -1;
this.houseIndex = -1;
this.needsSaved = false;
this.position = toVector3(0.0, 0.0, 0.0);
this.interior = 0;
this.dimension = 0;
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["house_loc_id"]);
this.name = toString(dbAssoc["house_loc_name"]);
this.type = toInteger(dbAssoc["house_loc_type"]);
this.house = toInteger(dbAssoc["house_loc_house"]);
this.enabled = intToBool(toInteger(dbAssoc["house_loc_enabled"]));
this.index = -1;
this.position = toVector3(toFloat(dbAssoc["house_loc_pos_x"]), toFloat(dbAssoc["house_loc_pos_y"]), toFloat(dbAssoc["house_loc_pos_z"]));
this.interior = toInteger(dbAssoc["house_loc_int"]);
this.dimension = toInteger(dbAssoc["house_loc_vw"]);
}
};
//saveToDatabase = () => {
// saveHouseLocationToDatabase(this.houseIndex, this.index);
//}
};
// ===========================================================================
/**
* @class Representing a house's game scripts. Multiple can be used for a single house
*/
class HouseGameScriptData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.business = 0;
this.state = false;
this.index = -1;
this.houseIndex = -1;
this.needsSaved = false;
if (dbAssoc) {
this.databaseId = toInteger(dbAssoc["house_script_id"]);
this.name = toString(dbAssoc["house_script_name"]);
this.state = toInteger(dbAssoc["house_script_state"]);
this.business = toInteger(dbAssoc["house_script_biz"]);
}
}
};
// ===========================================================================
function initHouseScript() { function initHouseScript() {
logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ..."); logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ...");
logToConsole(LOG_INFO, "[VRR.House]: House script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.House]: House script initialized successfully!");
@@ -266,7 +111,7 @@ function setHouseDescriptionCommand(command, params, client) {
let oldDescription = getHouseData(houseId).description; let oldDescription = getHouseData(houseId).description;
getHouseData(houseId).description = newHouseDescription; getHouseData(houseId).description = newHouseDescription;
setEntityData(getHouseData(houseId).entrancePickup, "agrp.label.name", getHouseData(houseId).description, true); setEntityData(getHouseData(houseId).entrancePickup, "vrr.label.name", getHouseData(houseId).description, true);
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
@@ -299,7 +144,7 @@ function setHouseOwnerCommand(command, params, client) {
} }
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse")); messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false; return false;
} }
@@ -307,7 +152,7 @@ function setHouseOwnerCommand(command, params, client) {
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_PLAYER; getHouseData(houseId).ownerType = VRR_HOUSEOWNER_PLAYER;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(newHouseOwner).databaseId; getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(newHouseOwner).databaseId;
messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to {ALTCOLOUR}${newHouseOwner.name}`); messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to {ALTCOLOUR}${newHouseOwner.name}`);
} }
@@ -330,13 +175,13 @@ function removeHouseOwnerCommand(command, params, client) {
} }
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse")); messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false; return false;
} }
} }
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_NONE; getHouseData(houseId).ownerType = VRR_HOUSEOWNER_NONE;
getHouseData(houseId).ownerId = -1; getHouseData(houseId).ownerId = -1;
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
@@ -369,7 +214,7 @@ function setHouseClanCommand(command, params, client) {
return false; return false;
} }
if (getHouseData(houseId).ownerType != AGRP_VEHOWNER_PLAYER) { if (getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse")); messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false; return false;
} }
@@ -380,7 +225,7 @@ function setHouseClanCommand(command, params, client) {
} }
showPlayerPrompt(client, getLocaleString(client, "SetHouseClanConfirmMessage"), getLocaleString(client, "SetHouseClanConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); showPlayerPrompt(client, getLocaleString(client, "SetHouseClanConfirmMessage"), getLocaleString(client, "SetHouseClanConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_HOUSEGIVETOCLAN; getPlayerData(client).promptType = VRR_PROMPT_HOUSEGIVETOCLAN;
//messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`); //messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`);
} }
@@ -732,27 +577,6 @@ function removePlayerFromHouse(client) {
// =========================================================================== // ===========================================================================
/**
* Forces all players to exit a house
*
* @param {Number} houseId - The data index of the house to force all players inside to exit from
* @return {Boolean} Whether or not the players were forced to exit
*
*/
function removePlayersFromHouse(houseId) {
getClients().forEach(function (client) {
if (doesHouseHaveInterior(houseId)) {
if (getPlayerHouse(client) == houseId) {
exitHouse(client);
}
}
});
return true;
}
// ===========================================================================
/** /**
* This function creates a house * This function creates a house
* *
@@ -797,10 +621,6 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup
// =========================================================================== // ===========================================================================
function getHouseDataFromDatabaseId(databaseId) { function getHouseDataFromDatabaseId(databaseId) {
if (databaseId <= 0) {
return false;
}
let matchingHouses = getServerData().houses.filter(b => b.databaseId == databaseId) let matchingHouses = getServerData().houses.filter(b => b.databaseId == databaseId)
if (matchingHouses.length == 1) { if (matchingHouses.length == 1) {
return matchingHouses[0]; return matchingHouses[0];
@@ -867,18 +687,17 @@ function getPlayerHouse(client) {
// =========================================================================== // ===========================================================================
function saveAllHousesToDatabase() { function saveAllHousesToDatabase() {
logToConsole(LOG_DEBUG, `[VRR.House]: Saving all server houses to database ...`);
if (getServerConfig().devServer) { if (getServerConfig().devServer) {
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.House]: Aborting save all houses to database, dev server is enabled.`);
return false; return false;
} }
logToConsole(LOG_INFO, `[VRR.House]: Saving all server houses to database ...`);
for (let i in getServerData().houses) { for (let i in getServerData().houses) {
if (getServerData().houses[i].needsSaved) { if (getServerData().houses[i].needsSaved) {
saveHouseToDatabase(i); saveHouseToDatabase(i);
} }
} }
logToConsole(LOG_INFO, `[VRR.House]: Saved all server houses to database`); logToConsole(LOG_INFO, `[VRR.House]: Saving all server houses to database ...`);
} }
// =========================================================================== // ===========================================================================
@@ -890,7 +709,7 @@ function saveHouseToDatabase(houseId) {
return false; return false;
} }
logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house '${tempHouseData.description}' to database ...`); logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house '${tempHouseData.databaseId}' to database ...`);
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description); let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
@@ -910,7 +729,7 @@ function saveHouseToDatabase(houseId) {
["house_entrance_vw", tempHouseData.entranceDimension], ["house_entrance_vw", tempHouseData.entranceDimension],
["house_entrance_pickup", tempHouseData.entrancePickupModel], ["house_entrance_pickup", tempHouseData.entrancePickupModel],
["house_entrance_blip", tempHouseData.entranceBlipModel], ["house_entrance_blip", tempHouseData.entranceBlipModel],
//["house_entrance_cutscene", tempHouseData.entranceCutscene], ["house_entrance_cutscene", tempHouseData.entranceCutscene],
["house_exit_pos_x", tempHouseData.exitPosition.x], ["house_exit_pos_x", tempHouseData.exitPosition.x],
["house_exit_pos_y", tempHouseData.exitPosition.y], ["house_exit_pos_y", tempHouseData.exitPosition.y],
["house_exit_pos_z", tempHouseData.exitPosition.z], ["house_exit_pos_z", tempHouseData.exitPosition.z],
@@ -919,13 +738,12 @@ function saveHouseToDatabase(houseId) {
["house_exit_vw", tempHouseData.exitDimension], ["house_exit_vw", tempHouseData.exitDimension],
["house_exit_pickup", tempHouseData.exitPickupModel], ["house_exit_pickup", tempHouseData.exitPickupModel],
["house_exit_blip", tempHouseData.exitBlipModel], ["house_exit_blip", tempHouseData.exitBlipModel],
//["house_exit_cutscene", tempHouseData.exitCutscene], ["house_exit_cutscene", tempHouseData.exitCutscene],
["house_buy_price", tempHouseData.buyPrice], ["house_buy_price", tempHouseData.buyPrice],
["house_rent_price", tempHouseData.rentPrice], ["house_rent_price", tempHouseData.rentPrice],
["house_has_interior", boolToInt(tempHouseData.hasInterior)], ["house_has_interior", boolToInt(tempHouseData.hasInterior)],
["house_interior_lights", boolToInt(tempHouseData.interiorLights)], ["house_interior_lights", boolToInt(tempHouseData.interiorLights)],
["house_custom_interior", boolToInt(tempHouseData.customInterior)], ["house_custom_interior", boolToInt(tempHouseData.customInterior)],
["house_radio_station", boolToInt(tempHouseData.streamingRadioStation)],
]; ];
let dbQuery = null; let dbQuery = null;
@@ -958,9 +776,11 @@ function saveHouseLocationToDatabase(houseId, locationId) {
return false; return false;
} }
logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house location ${locationId} for house ${houseId} to database ...`); logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house location '${locationId}' for house '${getHouseData(houseId).databaseId}' to database ...`);
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, getHouseData(houseId).description);
let data = [ let data = [
["house_loc_house", getHouseData(houseId).databaseId], ["house_loc_house", getHouseData(houseId).databaseId],
["house_loc_type", tempHouseLocationData.type], ["house_loc_type", tempHouseLocationData.type],
@@ -999,7 +819,7 @@ function saveHouseLocationToDatabase(houseId, locationId) {
disconnectFromDatabase(dbConnection); disconnectFromDatabase(dbConnection);
return true; return true;
} }
logToConsole(LOG_VERBOSE, `[VRR.House]: Saved location ${locationId} for house ${houseId} to database`); logToConsole(LOG_VERBOSE, `[VRR.House]: Saved house '${tempHouseData.description}' to database!`);
return false; return false;
} }
@@ -1029,7 +849,7 @@ function createHouseEntrancePickup(houseId) {
return false; return false;
} }
if (!isGameFeatureSupported("pickup")) { if (!isGameFeatureSupported("pickups")) {
return false; return false;
} }
@@ -1086,7 +906,7 @@ function createHouseEntranceBlip(houseId) {
return false; return false;
} }
if (!isGameFeatureSupported("blip")) { if (!isGameFeatureSupported("blips")) {
return false; return false;
} }
@@ -1125,8 +945,8 @@ function createHouseEntranceBlip(houseId) {
setElementStreamOutDistance(entranceBlip, getGlobalConfig().houseBlipStreamOutDistance); setElementStreamOutDistance(entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
} }
setEntityData(entranceBlip, "agrp.owner.type", AGRP_BLIP_HOUSE_ENTRANCE, false); setEntityData(entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(entranceBlip, "agrp.owner.id", houseId, false); setEntityData(entranceBlip, "vrr.owner.id", houseId, false);
houseData.entranceBlip = entranceBlip; houseData.entranceBlip = entranceBlip;
} }
@@ -1143,7 +963,7 @@ function createHouseExitPickup(houseId) {
return false; return false;
} }
if (!isGameFeatureSupported("pickup")) { if (!isGameFeatureSupported("pickups")) {
return false; return false;
} }
@@ -1191,7 +1011,7 @@ function createHouseExitBlip(houseId) {
return false; return false;
} }
if (!isGameFeatureSupported("blip")) { if (!isGameFeatureSupported("blips")) {
return false; return false;
} }
@@ -1231,8 +1051,8 @@ function createHouseExitBlip(houseId) {
setElementStreamOutDistance(exitBlip, getGlobalConfig().houseBlipStreamOutDistance); setElementStreamOutDistance(exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
} }
setElementTransient(exitBlip, false); setElementTransient(exitBlip, false);
setEntityData(exitBlip, "agrp.owner.type", AGRP_BLIP_HOUSE_EXIT, false); setEntityData(exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(exitBlip, "agrp.owner.id", houseId, false); setEntityData(exitBlip, "vrr.owner.id", houseId, false);
getHouseData(houseId).exitBlip = exitBlip; getHouseData(houseId).exitBlip = exitBlip;
} }
} }
@@ -1241,22 +1061,22 @@ function createHouseExitBlip(houseId) {
function getHouseOwnerTypeText(ownerType) { function getHouseOwnerTypeText(ownerType) {
switch (ownerType) { switch (ownerType) {
case AGRP_HOUSE_OWNER_CLAN: case VRR_HOUSEOWNER_CLAN:
return "clan"; return "clan";
case AGRP_HOUSE_OWNER_PLAYER: case VRR_HOUSEOWNER_PLAYER:
return "player"; return "player";
case AGRP_HOUSE_OWNER_NONE: case VRR_HOUSEOWNER_NONE:
return "not owned"; return "not owned";
case AGRP_HOUSE_OWNER_PUBLIC: case VRR_HOUSEOWNER_PUBLIC:
return "not owned"; return "not owned";
case AGRP_HOUSE_OWNER_JOB: case VRR_HOUSEOWNER_JOB:
return "job"; return "job";
case AGRP_HOUSE_OWNER_BIZ: case VRR_HOUSEOWNER_BIZ:
return "business"; return "business";
default: default:
@@ -1291,28 +1111,28 @@ function getHouseInfoCommand(command, params, client) {
let ownerName = "Unknown"; let ownerName = "Unknown";
switch (getHouseData(houseId).ownerType) { switch (getHouseData(houseId).ownerType) {
case AGRP_HOUSE_OWNER_CLAN: case VRR_HOUSEOWNER_CLAN:
ownerName = getClanData(houseData).name; ownerName = getClanData(houseData).name;
break; break;
case AGRP_HOUSE_OWNER_PLAYER: case VRR_HOUSEOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(houseData.ownerId); let subAccountData = loadSubAccountFromId(houseData.ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`; ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`;
break; break;
case AGRP_HOUSE_OWNER_NONE: case VRR_HOUSEOWNER_NONE:
ownerName = "None"; ownerName = "None";
break; break;
case AGRP_HOUSE_OWNER_PUBLIC: case VRR_HOUSEOWNER_PUBLIC:
ownerName = "Public"; ownerName = "Public";
break; break;
case AGRP_HOUSE_OWNER_BIZ: case VRR_HOUSEOWNER_BIZ:
ownerName = getBusinessDataFromDatabaseId(houseData.ownerId).name; ownerName = getBusinessDataFromDatabaseId(houseData.ownerId).name;
break; break;
case AGRP_HOUSE_OWNER_JOB: case VRR_HOUSEOWNER_JOB:
ownerName = getJobData(houseData.ownerId).name; ownerName = getJobData(houseData.ownerId).name;
break; break;
} }
@@ -1448,7 +1268,7 @@ function buyHouseCommand(command, params, client) {
} }
showPlayerPrompt(client, getLocaleString(client, "BuyHouseConfirmMessage"), getLocaleString(client, "BuyHouseConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); showPlayerPrompt(client, getLocaleString(client, "BuyHouseConfirmMessage"), getLocaleString(client, "BuyHouseConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_HOUSEBUY; getPlayerData(client).promptType = VRR_PROMPT_HOUSEBUY;
} }
// =========================================================================== // ===========================================================================
@@ -1458,10 +1278,6 @@ function buyHouseCommand(command, params, client) {
* @return {HouseData} The house's data (class instance) * @return {HouseData} The house's data (class instance)
*/ */
function getHouseData(houseId) { function getHouseData(houseId) {
if (houseId == -1) {
return false;
}
if (typeof getServerData().houses[houseId] != "undefined") { if (typeof getServerData().houses[houseId] != "undefined") {
return getServerData().houses[houseId]; return getServerData().houses[houseId];
} }
@@ -1568,9 +1384,9 @@ function reloadAllHousesCommand(command, params, client) {
function exitHouse(client) { function exitHouse(client) {
let houseId = getPlayerHouse(client); let houseId = getPlayerHouse(client);
if (isPlayerSpawned(client)) { if (isPlayerSpawned(client)) {
setPlayerInterior(client, getServerData().houses[houseId].entranceInterior); setPlayerInterior(client, getServerData().house[houseId].entranceInterior);
setPlayerDimension(client, getServerData().houses[houseId].entranceDimension); setPlayerDimension(client, getServerData().house[houseId].entranceDimension);
setPlayerPosition(client, getServerData().houses[houseId].entrancePosition); setPlayerPosition(client, getServerData().house[houseId].entrancePosition);
} }
} }
@@ -1606,7 +1422,7 @@ function cacheHouseItems(houseId) {
getHouseData(houseId).itemCache = []; getHouseData(houseId).itemCache = [];
for (let i in getServerData().items) { for (let i in getServerData().items) {
if (getItemData(i).ownerType == AGRP_ITEM_OWNER_HOUSE && getItemData(i).ownerId == getHouseData(houseId).databaseId) { if (getItemData(i).ownerType == VRR_ITEM_OWNER_HOUSE && getItemData(i).ownerId == getHouseData(houseId).databaseId) {
getHouseData(houseId).itemCache.push(i); getHouseData(houseId).itemCache.push(i);
} }
} }
@@ -1635,7 +1451,7 @@ function getHouseIdFromDatabaseId(databaseId) {
//function clearPlayerHouseGameScripts(client, houseId) { //function clearPlayerHouseGameScripts(client, houseId) {
// for(let i in getHouseData(houseId).gameScripts) { // for(let i in getHouseData(houseId).gameScripts) {
// sendPlayerGameScriptState(client, AGRP_GAMESCRIPT_DENY); // sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY);
// } // }
//} //}
@@ -1657,11 +1473,11 @@ function canPlayerSetHouseInteriorLights(client, houseId) {
return true; return true;
} }
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true; return true;
} }
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) { if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
return true; return true;
} }
@@ -1677,11 +1493,11 @@ function canPlayerLockUnlockHouse(client, houseId) {
return true; return true;
} }
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true; return true;
} }
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) { if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
return true; return true;
} }
@@ -1731,13 +1547,13 @@ function canPlayerManageHouse(client, houseId) {
return true; return true;
} }
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER) { if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER) {
if (getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { if (getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true; return true;
} }
} }
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_CLAN) { if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN) {
if (getHouseData(houseId).ownerId == getPlayerClan(client)) { if (getHouseData(houseId).ownerId == getPlayerClan(client)) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
return true; return true;
@@ -1778,26 +1594,26 @@ function updateHousePickupLabelData(houseId) {
let houseData = getHouseData(houseId); let houseData = getHouseData(houseId);
if (houseData.entrancePickup != null) { if (houseData.entrancePickup != null) {
setEntityData(houseData.entrancePickup, "agrp.owner.type", AGRP_PICKUP_HOUSE_ENTRANCE, false); setEntityData(houseData.entrancePickup, "vrr.owner.type", VRR_PICKUP_HOUSE_ENTRANCE, false);
setEntityData(houseData.entrancePickup, "agrp.owner.id", houseId, false); setEntityData(houseData.entrancePickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.entrancePickup, "agrp.label.type", AGRP_LABEL_HOUSE, true); setEntityData(houseData.entrancePickup, "vrr.label.type", VRR_LABEL_HOUSE, true);
setEntityData(houseData.entrancePickup, "agrp.label.name", houseData.description, true); setEntityData(houseData.entrancePickup, "vrr.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "agrp.label.locked", houseData.locked, true); setEntityData(houseData.entrancePickup, "vrr.label.locked", houseData.locked, true);
if (houseData.buyPrice > 0) { if (houseData.buyPrice > 0) {
setEntityData(houseData.entrancePickup, "agrp.label.price", houseData.buyPrice, true); setEntityData(houseData.entrancePickup, "vrr.label.price", houseData.buyPrice, true);
setEntityData(houseData.entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_BUYHOUSE, true); setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUYHOUSE, true);
} else { } else {
if (houseData.rentPrice > 0) { if (houseData.rentPrice > 0) {
setEntityData(houseData.entrancePickup, "agrp.label.rentprice", houseData.rentPrice, true); setEntityData(houseData.entrancePickup, "vrr.label.rentprice", houseData.rentPrice, true);
setEntityData(houseData.entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_RENTHOUSE, true); setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_RENTHOUSE, true);
} }
} }
} }
if (houseData.exitPickup != null) { if (houseData.exitPickup != null) {
setEntityData(houseData.exitPickup, "agrp.owner.type", AGRP_PICKUP_HOUSE_EXIT, false); setEntityData(houseData.exitPickup, "vrr.owner.type", VRR_PICKUP_HOUSE_EXIT, false);
setEntityData(houseData.exitPickup, "agrp.owner.id", houseId, false); setEntityData(houseData.exitPickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.exitPickup, "agrp.label.type", AGRP_LABEL_EXIT, true); setEntityData(houseData.exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true);
} }
} }
@@ -1834,22 +1650,3 @@ function createHousePickups(houseId) {
} }
// =========================================================================== // ===========================================================================
/**
* Gets whether or not a client is in a business
*
* @param {Client} client - The client to check whether or not is in a business
* @return {Boolean} Whether or not the client is in a business
*
*/
function isPlayerInAnyHouse(client) {
for (let i in getServerData().houses) {
if (getServerData().houses[i].hasInterior && getServerData().houses[i].exitDimension == getPlayerDimension(client)) {
return i;
}
}
return false;
}
// ===========================================================================

View File

@@ -1,41 +0,0 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// ===========================================================================
// FILE: insurance.js
// DESC: Provides insurance commands, functions, and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// Insurance Account Owner Types
const AGRP_INS_ACCT_OWNER_NONE = 0; // None
const AGRP_INS_ACCT_OWNER_PLAYER = 1; // Player owns insurance company
const AGRP_INS_ACCT_OWNER_BIZ = 2; // Business owns insurance company
const AGRP_INS_ACCT_OWNER_CLAN = 3; // Clan owns insurance company
// ===========================================================================
// Insurance Account Entity Types
const AGRP_INS_ACCT_ENTITY_NONE = 0; // None
const AGRP_INS_ACCT_ENTITY_PLAYER_HEALTH = 1; // Health Insurance
const AGRP_INS_ACCT_ENTITY_PLAYER_LIFE = 2; // Life Insurance
const AGRP_INS_ACCT_ENTITY_VEH = 3; // Vehicle Insurance
const AGRP_INS_ACCT_ENTITY_BIZ = 4; // Business Insurance
const AGRP_INS_ACCT_ENTITY_HOUSE = 5; // House Insurance
// ===========================================================================
// Insurance Account History Types
const AGRP_INS_ACCT_HISTORY_NONE = 0; // None
const AGRP_INS_ACCT_HISTORY_PLAYER_MEDICAL = 1; // Medical insurance was used (player disease/injury)
const AGRP_INS_ACCT_HISTORY_PLAYER_DEATH = 2; // Life insurance was used (player death)
const AGRP_INS_ACCT_HISTORY_VEH_DAMAGE = 3; // Vehicle was damaged, but not destroyed
const AGRP_INS_ACCT_HISTORY_VEH_WRECKED = 4; // Vehicle was completely destroyed
const AGRP_INS_ACCT_HISTORY_VEH_THEFT = 5; // Vehicle was stolen
const AGRP_INS_ACCT_HISTORY_BIZ_DAMAGE = 6; // Business was damaged (broken items/window/door)
const AGRP_INS_ACCT_HISTORY_BIZ_THEFT = 7; // Business was stolen from
const AGRP_INS_ACCT_HISTORY_HOUSE_DAMAGE = 8; // House was damaged
const AGRP_INS_ACCT_HISTORY_HOUSE_THEFT = 9; // House was stolen from
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: drink.js // FILE: drink.js
// DESC: Provides features and usage for the drink item type // DESC: Provides features and usage for the drink item type

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: food.js // FILE: food.js
// DESC: Provides features and usage for the food item type // DESC: Provides features and usage for the food item type

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: handcuff.js // FILE: handcuff.js
// DESC: Provides features and usage for the handcuff item type // DESC: Provides features and usage for the handcuff item type
@@ -11,21 +10,27 @@
// =========================================================================== // ===========================================================================
function isPlayerHandCuffed(client) { function isPlayerHandCuffed(client) {
return (getPlayerData(client).pedState == AGRP_PEDSTATE_BINDED); return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
} }
// =========================================================================== // ===========================================================================
function handCuffPlayer(client) { function handCuffPlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_BINDED; getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false); setPlayerControlState(client, false);
} }
// =========================================================================== // ===========================================================================
function unHandCuffPlayer(client) { function unHandCuffPlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY; getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true); setPlayerControlState(client, true);
} }
// =========================================================================== // ===========================================================================
function isPlayerSurrendered(client) {
return true; //(getPlayerData(client).pedState == VRR_PEDSTATE_TAZED || getPlayerData(client).pedState == VRR_PEDSTATE_HANDSUP);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: phone.js // FILE: phone.js
// DESC: Provides features and usage for the phone item type // DESC: Provides features and usage for the phone item type
@@ -9,9 +8,9 @@
// =========================================================================== // ===========================================================================
function getItemWithPhoneNumber(phoneNumber) { function getItemWithPhoneNumber(phoneNumber) {
for (let i in getServerData().items) { for(let i in getServerData().items) {
if (getItemTypeData(getItemData(i).itemTypeIndex).useType == AGRP_ITEM_USE_TYPE_PHONE) { if(getItemTypeData(getItemData(i).itemTypeIndex).useType == VRR_ITEM_USETYPE_PHONE) {
if (getItemData(i).value == phoneNumber) { if(getItemData(i).value == phoneNumber) {
return i; return i;
} }
} }
@@ -31,15 +30,15 @@ function ringPhoneForNearbyPlayers(itemIndex) {
/* /*
if(isPhoneItemEnabled(itemIndex)) { if(isPhoneItemEnabled(itemIndex)) {
switch(getItemData(itemIndex).ownerType) { switch(getItemData(itemIndex).ownerType) {
case AGRP_ITEM_OWNER_GROUND: case VRR_ITEM_OWNER_GROUND:
playRingtoneForPlayersInRange(getItemData(itemIndex).position, getItemData(i).extra); playRingtoneForPlayersInRange(getItemData(itemIndex).position, getItemData(i).extra);
break; break;
case AGRP_ITEM_OWNER_VEHTRUNK: case VRR_ITEM_OWNER_VEHTRUNK:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra); playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break; break;
case AGRP_ITEM_OWNER_VEHDASH: case VRR_ITEM_OWNER_VEHDASH:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra); playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break; break;
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: handcuff.js // FILE: handcuff.js
// DESC: Provides features and usage for the handcuff item type // DESC: Provides features and usage for the handcuff item type
@@ -11,20 +10,20 @@
// =========================================================================== // ===========================================================================
function isPlayerTied(client) { function isPlayerTied(client) {
return (getPlayerData(client).pedState == AGRP_PEDSTATE_BINDED); return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
} }
// =========================================================================== // ===========================================================================
function ropeTiePlayer(client) { function ropeTiePlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_BINDED; getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false); setPlayerControlState(client, false);
} }
// =========================================================================== // ===========================================================================
function ropeUnTiePlayer(client) { function ropeUnTiePlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY; getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true); setPlayerControlState(client, true);
} }

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: tazer.js // FILE: tazer.js
// DESC: Provides features and usage for the tazer item type // DESC: Provides features and usage for the tazer item type
@@ -11,21 +10,21 @@
// =========================================================================== // ===========================================================================
function isPlayerTazed(client) { function isPlayerTazed(client) {
return (getPlayerData(client).pedState == AGRP_PEDSTATE_TAZED); return (getPlayerData(client).pedState == VRR_PEDSTATE_TAZED);
} }
// =========================================================================== // ===========================================================================
function tazePlayer(client) { function tazePlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_TAZED; getPlayerData(client).pedState = VRR_PEDSTATE_TAZED;
setPlayerControlState(client, false); setPlayerControlState(client, false);
let animationId = getAnimationFromParams("tazed"); let animationId = getAnimationFromParams("tazed");
if (animationId != false) { if(animationId != false) {
forcePlayerPlayAnimation(client, animationId); forcePlayerPlayAnimation(client, animationId);
} }
setTimeout(function () { setTimeout(function() {
unTazePlayer(client); unTazePlayer(client);
doActionToNearbyPlayers(client, `The tazer effect wears off`); doActionToNearbyPlayers(client, `The tazer effect wears off`);
}, getGlobalConfig().tazerEffectDuration); }, getGlobalConfig().tazerEffectDuration);
@@ -34,7 +33,7 @@ function tazePlayer(client) {
// =========================================================================== // ===========================================================================
function unTazePlayer(client) { function unTazePlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY; getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true); setPlayerControlState(client, true);
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo); setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: walkie-talkie.js // FILE: walkie-talkie.js
// DESC: Provides features and usage for the walkie-talkie item type // DESC: Provides features and usage for the walkie-talkie item type
@@ -9,11 +8,11 @@
// =========================================================================== // ===========================================================================
function getPlayerActiveWalkieTalkieFrequency(client) { function getPlayerActiveWalkieTalkieFrequency(client) {
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_WALKIETALKIE); let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, VRR_ITEM_USETYPE_WALKIETALKIE);
if (walkieTalkieSlot != -1) { if(walkieTalkieSlot != -1) {
if (getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot])) { if(getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot])) {
if (getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) { if(getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) {
return getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).value; return getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).value;
} }
} }
@@ -32,7 +31,7 @@ function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
// if(isPlayerSpawned(clients[i])) { // if(isPlayerSpawned(clients[i])) {
// if(!isSamePlayer(transmittingPlayer, clients[i])) { // if(!isSamePlayer(transmittingPlayer, clients[i])) {
// if(getPlayerActiveWalkieTalkieFrequency(clients[i]) == radioFrequency) { // if(getPlayerActiveWalkieTalkieFrequency(clients[i]) == radioFrequency) {
// if(getItemData(getPlayerData(clients[i]).hotBarItems[getPlayerFirstItemSlotByUseType(clients[i], AGRP_ITEM_USE_TYPE_WALKIETALKIE)]).enabled) { // if(getItemData(getPlayerData(clients[i]).hotBarItems[getPlayerFirstItemSlotByUseType(clients[i], VRR_ITEM_USETYPE_WALKIETALKIE)]).enabled) {
// walkieTalkieIncomingToNearbyPlayers(clients[i], messageText); // walkieTalkieIncomingToNearbyPlayers(clients[i], messageText);
// } // }
// } // }
@@ -41,10 +40,10 @@ function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
//} //}
let items = getServerData().items; let items = getServerData().items;
for (let i in items) { for(let i in items) {
if (items[i].enabled) { if(items[i].enabled) {
if (getItemTypeData(items[i].itemTypeIndex).useType == AGRP_ITEM_USE_TYPE_WALKIETALKIE) { if(getItemTypeData(items[i].itemTypeIndex).useType == VRR_ITEM_USETYPE_WALKIETALKIE) {
if (items[i].value == radioFrequency) { if(items[i].value == radioFrequency) {
walkieTalkieIncomingToNearbyPlayers(null, messageText, getItemPosition(i)); walkieTalkieIncomingToNearbyPlayers(null, messageText, getItemPosition(i));
} }
} }
@@ -56,7 +55,7 @@ function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
function walkieTalkieOutgoingToNearbyPlayers(client, messageText) { function walkieTalkieOutgoingToNearbyPlayers(client, messageText) {
let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().talkDistance); let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
for (let i in clients) { for(let i in clients) {
messagePlayerNormal(clients[i], `[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to radio): {MAINCOLOUR}${messageText}`); messagePlayerNormal(clients[i], `[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to radio): {MAINCOLOUR}${messageText}`);
} }
} }
@@ -65,12 +64,12 @@ function walkieTalkieOutgoingToNearbyPlayers(client, messageText) {
function walkieTalkieIncomingToNearbyPlayers(client, messageText, position = null) { function walkieTalkieIncomingToNearbyPlayers(client, messageText, position = null) {
let prefix = `{ALTCOLOUR}(Nearby radio)`; let prefix = `{ALTCOLOUR}(Nearby radio)`;
if (client != null) { if(client != null) {
prefix = `${getCharacterFullName(client)} {ALTCOLOUR}(from radio)`; prefix = `${getCharacterFullName(client)} {ALTCOLOUR}(from radio)`;
} }
let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().walkieTalkieSpeakerDistance); let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().walkieTalkieSpeakerDistance);
for (let i in clients) { for(let i in clients) {
messagePlayerNormal(clients[i], `[#CCCCCC]${prefix}: {MAINCOLOUR}${messageText}`); messagePlayerNormal(clients[i], `[#CCCCCC]${prefix}: {MAINCOLOUR}${messageText}`);
} }
} }
@@ -78,35 +77,35 @@ function walkieTalkieIncomingToNearbyPlayers(client, messageText, position = nul
// =========================================================================== // ===========================================================================
function setWalkieTalkieFrequencyCommand(command, params, client) { function setWalkieTalkieFrequencyCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
if (isNaN(params)) { if(isNaN(params)) {
messagePlayerError(client, `The frequency channel must be a number!`); messagePlayerError(client, `The frequency channel must be a number!`);
return false; return false;
} }
params = toInteger(params); params = toInteger(params);
if (params < 100 || params > 500) { if(params < 100 || params > 500) {
messagePlayerError(client, `The frequency channel must be between 100 and 500!`); messagePlayerError(client, `The frequency channel must be between 100 and 500!`);
return false; return false;
} }
if (!getPlayerActiveItem(client)) { if(!getPlayerActiveItem(client)) {
messagePlayerError(client, `You aren't holding a walkie talkie!`); messagePlayerError(client, `You aren't holding a walkie talkie!`);
return false; return false;
} }
if (!getItemData(getPlayerActiveItem(client))) { if(!getItemData(getPlayerActiveItem(client))) {
messagePlayerError(client, `You aren't holding a walkie talkie!`); messagePlayerError(client, `You aren't holding a walkie talkie!`);
return false; return false;
} }
if (getItemData(getPlayerActiveItem(client)).enabled) { if(getItemData(getPlayerActiveItem(client)).enabled) {
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "use")) { if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "use")) {
messagePlayerError(client, `Your walkie talkie is turned off. Press ${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use")).key)} to turn it on`); messagePlayerError(client, `Your walkie talkie is turned off. Press ${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use")).key)} to turn it on`);
} else { } else {
messagePlayerError(client, `Your walkie talkie is turned off. Type {ALTCOLOUR}/use {MAINCOLOUR}to turn it on`); messagePlayerError(client, `Your walkie talkie is turned off. Type {ALTCOLOUR}/use {MAINCOLOUR}to turn it on`);
@@ -114,20 +113,20 @@ function setWalkieTalkieFrequencyCommand(command, params, client) {
return false; return false;
} }
getItemData(getPlayerActiveItem(client)).value = params * 100; getItemData(getPlayerActiveItem(client)).value = params*100;
messagePlayerSuccess(client, getLocaleString(client, "FrequencyChannelChanged", `Walkie Talkie`, `${getPlayerData(client).activeHotBarSlot + 1}`, `${getItemValueDisplayForItem(getPlayerActiveItem(client))}`)); messagePlayerSuccess(client, `You set the frequency of you walkie talkie in slot ${getPlayerData(client).activeHotBarSlot} to ${getItemValueDisplayForItem(getPlayerActiveItem(client))}`)
} }
// =========================================================================== // ===========================================================================
function walkieTalkieChatCommand(command, params, client) { function walkieTalkieChatCommand(command, params, client) {
if (areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_WALKIETALKIE); let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, VRR_ITEM_USETYPE_WALKIETALKIE);
if (!getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) { if(!getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) {
messagePlayerError(client, "Please turn on a walkie talkie first!"); messagePlayerError(client, "Please turn on a walkie talkie first!");
return false; return false;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: bus.js // FILE: bus.js
// DESC: Provides bus driver job functions and usage // DESC: Provides bus driver job functions and usage

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: drug.js // FILE: drug.js
// DESC: Provides drug runner/dealer job functions and usage // DESC: Provides drug runner/dealer job functions and usage

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: fire.js // FILE: fire.js
// DESC: Provides firefighter job functions and usage // DESC: Provides firefighter job functions and usage

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: garbage.js // FILE: garbage.js
// DESC: Provides garbage collector job functions and usage // DESC: Provides garbage collector job functions and usage

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: medic.js // FILE: medic.js
// DESC: Provides paramedic job functions and usage // DESC: Provides paramedic job functions and usage

View File

@@ -1,7 +1,6 @@
// =========================================================================== // ===========================================================================
// Asshat Gaming Roleplay // Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/agrp_main // https://github.com/VortrexFTW/gtac_roleplay
// (c) 2022 Asshat Gaming
// =========================================================================== // ===========================================================================
// FILE: pizza-delivery.js // FILE: pizza-delivery.js
// DESC: Provides pizza delivery driver job functions and usage // DESC: Provides pizza delivery driver job functions and usage

Some files were not shown because too many files have changed in this diff Show More