Merge branch 'testing'

This commit is contained in:
Vortrex
2021-04-24 11:05:18 -05:00
115 changed files with 11337 additions and 6852 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.vs/
.git/
.git/
config/*

290
IDEAS.md
View File

@@ -1,12 +1,12 @@
Ideas for Asshat Gaming RP!
# Ideas
## For Asshat Gaming RP
==============================================================================================================
NOTICE: Most of these ideas are totally random and some might be unrealistic. Every time I thought of something, I just immediately threw it into this file. I never checked to see if I had already added it, so there may be duplicates or similar entries spread out and unorganized.
**NOTICE: Most of these ideas are totally random and some might be unrealistic. Every time I thought of something, I just immediately threw it into this file. I never checked to see if I had already added it, so there may be duplicates or similar entries spread out and unorganized.**
==============================================================================================================
* Businesses (some from GTA Online)
---
### Businesses (some from GTA Online)
* Nightclubs
* Executive Offices
* Warehouses
@@ -14,94 +14,95 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* Houses
* Garages
* Casinos
* 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?
---
* 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
* They come and go and aren't persistent.
* Police peds/traffic will pursue if player has 1+ stars and comes within range and line of sight.
* Named NPCs
---
### Named NPCs
* Persistent
* Move from place to place. Eat at restaurants, drive home, to work, get drunk at a bar, etc.
* Different personalities
* Relationship levels with each player and clan. If you piss them off, they won't do business with you.
* Firefighter Job
---
### Firefighter Job
* Vehicles catch on fire instead of blowing up.
* Random property fires can occur.
* Firetrucks can "spray" a fire, lowering the damage until it is extinguished (Aim detection).
* Streetsweeper Job
---
### Streetsweeper Job
* Instead of checkpoints, show actual messes on the road.
* Drive over the messes with the right vehicle to "clean" the mess.
* Only show messes if at least one player is on duty.
* Garbageman Job
---
### Garbageman Job
* Instead of checkpoints, have trashbag objects outside of properties or wherever.
* Allow the trashtruck drivers to "pickup" the trashbag, then "place" into the truck.
* If the truck is full, deliver the trashbags to the dump.
* Only show trashbags if at least one player is currently doing the job.
* Mailman Job
---
### Mailman Job
* Use a white solid van (Pony maybe) as a mail van.
* Load mail at the post office, and drive a specific route to "deliver" mail.
* Return the truck for payment.
* 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.
* Universal command to tow/release a vehicle ( /tow ).
* Attach to nearest vehicle.
* Item System
---
### Item System
* Several item types, including armour, skins, weapons, drugs, materials, and more.
* Items can be dropped and picked up.
* Items can be stored in a vehicle trunk or dash compartment.
* Items can be given, taken, or used.
* Payphones
---
### Payphones
* Make built in payphones usable (detect position, ring sound, etc)
* Payphones can be called, making them ring to nearby players.
* Multiple bed hospital.
---
### Multiple bed hospital.
* When one is taken, use the next one.
* 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)
* Several NPC's
---
### Several NPC's
* Paramedics/Doctors at hospitals,
* LC/VC/LS/SF/LV police dept desk clerk and dispatcher.
* Jail guard
* Interactive. Go up and talk to them for responses etc
* Use permissions/flag system for everything.
---
### Use permissions/flag system for everything.
* Admin abilities
* Moderation (muted/frozen/etc)
* LEO abilities
* Clan abilities
* Account Settings
* etc
* Interiors
---
### 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?)
* Stealable skins. When one is stolen, it is replaced by the thief's skin
* Black market for anything.
---
### Stealable skins.
* When one is stolen, it is replaced by the thief's skin
---
### Black market for anything.
* Smuggled drugs
* LEO items
* Weapons and weapon upgrades
* Illegal vehicle upgrades like NOS.
* Drug houses and weed farms.
---
### Drug houses and weed farms.
* Make weed only plantable in certain areas.
* Drug houses aren't limited to the type of house, as anybody can deal or use in any place.
* Size-based inventories.
---
### Size-based inventories.
* Items should have a size and inventories can only hold so much.
* Items inside of items. This could be (but not limited to):
* Briefcases
@@ -110,15 +111,15 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* Trashbags
* Boxes/crates
* Use the item sizes for storage capacity
* Weapons like DayZ.
---
### Weapons like DayZ.
* Multiple weapon types that issue different damages.
* Ammo clips that only fit a compatible weapon
* Different clip types hold different amounts of ammo in them (and specific ammo types)
* Hollow point and armor piercing round types
* Modifications. Flashlight, silencer, bigger clip, tracer, scope, etc.
* Crime scene investigations.
---
### Crime scene investigations.
* Blood
* Fingerprints
* Ballistics/bullets on ground, in objects, walls, etc.
@@ -129,8 +130,8 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* Can be cleaned up by anybody (including the murderer or suspects)
* Showering or swimming clears blood from body
* Rain washes away blood outside (if not under an object or bridge). Perhaps line of sight check with high up Z at same coord?
* Huge police interiors and garages.
---
### Police interiors and garages.
* Multiple interrogation rooms with blocked sound (chat is localized to that room)
* Multiple offices for ranking members
* Detective squad rooms with a CO office
@@ -138,15 +139,15 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* Crime scene lab
* Cell block area (or multiple cell blocks)
* Elevators that can take you to multiple levels of the building (and roof/garage).
* Custom MDC.
---
### Police Computer
* Arrest logs
* Past tickets
* Officer reports
* Investigation info
* APB list
* Admin panel.
---
### Admin panel.
* Reports
* Multiple actions for each
* Viewing info and past reports/actions on the reporter and the situation.
@@ -155,45 +156,54 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* Action
* Weapon/Kill/Death
* Others
* Log everything possible.
* Depending on type of injuries, have multiple results occur over time.
---
### Logging
* Log everything possible
---
### Injuries
* Depending on type of injuries, have multiple results occur over time.
* Gunshots lead to bleeding which could lead to passing out for loss of blood.
* Post-treatment effects are also possible including siezures from blunt force trauma.
* Custom actions to have different results. Interactive-ness.
---
### Interactive Actions
* Hotwiring a car could be successful or could also fail, depending on vehicle type and variance.
* The user has to go through each step in order to complete the task.
* Hotwiring could have things like splitting and joining wires to make the car start or the alarm stop.
* Include medical procedures in this idea. Surgeries, gunshot wounds, etc
* Require certain tools to perform different actions.
* Different vehicles have different wires to use to be successful.
* Limit weapons per person.
---
### Limit weapons per person.
* Have a visible large weapon if they have one (attached)
* Concealable smaller weapon.
* Officers usually have a utility belt. Allow it to hold equipment as well.
* Trunks can hold players/peds (not visibly) and items and is size based.
* Get "inside" the back of trucks/trailers and store items inside.
* Officers usually have a utility belt. Allow it to hold equipment as well.
---
###
---
### Vehicle Trunks
* Can hold tied up players/peds
* Can hold items
* Size/capacity depending on vehicle
---
### Vehicle Interiors
* Get "inside" the back of trucks/trailers and store items inside.
* Use an interior for this and allow dropped items (including crates and boxes and etc).
* Shouts and certain speech can be heard outside wherever the truck is at.
* Vehicle sink or explode while inside the back causes death and objects destroyed.
* Also for airplane interiors
* Multi space impound lot. When retrieving a car from impound, spawn it in the first empty space that isn't obstructed.
* Weapons obtain damage from use and time. If not cared for, they can have decreased damage from shots, or even break or malfunction
---
### Impound Lot
* Multi space impound lot. When retrieving a car from impound, spawn it in the first empty space that isn't obstructed.
---
### Weapon Wear and Tear
* Weapons obtain damage from use and time. If not cared for, they can have decreased damage from shots, or even break or malfunction
* Cleaning weapons improves reliability
* Weapons have identifying parts like barrel bores (for ballistics) and serial numbers. Serial numbers can be removed.
* GUI color schemes (https://vortrex.info/f/1/4eca24d1.png) with a settings page to switch them. Orange, red, blue, purple, etc.
* Police
---
### Weapon Identification
* Weapons have identifying parts like barrel bores (for ballistics) and serial numbers.
* Serial numbers can be removed.
---
### Police Behavior
* Stars
* 1 star for an initial misdemeanor. Traffic violation, pedestrian crime, etc. Police will pursue to fine/ticket.
* 2 stars for any subsequent crimes committed in police presence, after receiving one star and no action taken (if you don't pull over, run on foot, etc). Results in arrest.
@@ -203,8 +213,11 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* NPC police will chase you if you have 1+ stars. If you lose them with 2 or less stars, they go away unless you are sighted by another officer before cooldown.
* Any traffic violation that takes place within LOS and range of police will cause them to chase you until you pull over.
* Failure to pull over within a timely manner, or breaking another law before pulling over adds a second star. They won't fine you at this level, only arrest or worse.
* NPC Ideas
```
Player police officers can issue an APB for a player suspect. NPC police drive and walk around as normal in the game but if they spot the player suspect within a certain distance and line of sight, their position is sent to any player police officers via radio and shown as a blip on the radar. If the suspect evades the NPC police, the blip fades out at the last seen suspect location and eventually disappears, no longer available to player police officers. This means that the blip will continue to show other officers at the suspect's updated location until a) all police officers lose line of sight, b) suspect gets too far away or c) enters a house/business (losing line of sight with police unless they enter). All of these will cause the blip to show the suspects last known and seen location while the blip fades out and eventually disappears. Any officer that re-establishes line of sight within a certain distance will cause the suspect's blip to show again for all police. NPC police will NOT use the built-in wanted level system because this causes excessive spawning of police no matter where the suspect is generally completely unfair. Instead, scripting functions like ped.runTo, vehicle.setCarMission, vehicle.setCruiseSpeed, etc will be used to pursue the suspect. The logic in these functions is not perfect. The NPC officer can wreck the police car, get slowed down by traffic or stuck on something altogether, and the ped can be evaded by continously going around corners and such. All of this provides the ability for the suspect to have a chance of getting away. Changing skin/clothes or driving different/unknown vehicles reduces the NPC's line of sight and distance checking and thus reduces their chance of identifying them when near
```
---
### NPC Types
* Bodyguards
* Biker gang formation
* Convoy Line
@@ -220,46 +233,39 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* Mechanic
* Tweakers
* Bouncers
* Accents
---
### Accents
* Shown before message ... "[Japanese] John Smith says: hello"
* Pre-set accent choices
* 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.
* Player police officers can issue an APB for a player suspect. NPC police drive and walk around as normal in the game but if they spot the player suspect within a certain distance and line of sight, their position is sent to any player police officers via radio and shown as a blip on the radar. If the suspect evades the NPC police, the blip fades out at the last seen suspect location and eventually disappears, no longer available to player police officers. This means that the blip will continue to show other officers at the suspect's updated location until a) all police officers lose line of sight, b) suspect gets too far away or c) enters a house/business (losing line of sight with police unless they enter). All of these will cause the blip to show the suspects last known and seen location while the blip fades out and eventually disappears. Any officer that re-establishes line of sight within a certain distance will cause the suspect's blip to show again for all police. NPC police will NOT use the built-in wanted level system because this causes excessive spawning of police no matter where the suspect is generally completely unfair. Instead, scripting functions like ped.runTo, vehicle.setCarMission, vehicle.setCruiseSpeed, etc will be used to pursue the suspect. The logic in these functions is not perfect. The NPC officer can wreck the police car, get slowed down by traffic or stuck on something altogether, and the ped can be evaded by continously going around corners and such. All of this provides the ability for the suspect to have a chance of getting away. Changing skin/clothes or driving different/unknown vehicles reduces the NPC's line of sight and distance checking and thus reduces their chance of identifying them when near.
* Casinos
* Pebble companion app
* More GUI
* Basic layouts
* List
* Columned List (Grid?)
* Single Text Input Prompt
* Complex Layouts
* Info boxes for any type of server entity
* Admin functions for each one (ban, kick, delete, set owner, etc)
* Chat log
* Lists of submitted ideas and bug reports
* Web API
* REST-like URLs
* Type shortened to database table prefix style (/acct, /veh, etc)
* Companion app for my Pebble watch (Rebble)
---
### Casinos
* Will have to be custom-made and server sided
* Using server side will also allow casino gameplay in games where they don't exist
---
### Companion app
* Android/iOS
* Pebble watch (Uses phone companion app for connection)
* Whole thing streamlined
* Server select, then use GUI colours of server
* Connected players
* Links to account/character info
* Character Info leads to owned vehicles, houses, businesses, current clan, etc
* Character info leads to owned vehicles, houses, businesses, current clan, etc
* Clan info leads to owned businesses, houses, vehicles, etc
* Business, house, vehicle info has links back to owners info pages
* Alerts for reports, submitted bugs/ideas, hacker detection
* Notifications
* (Vehicle) For vehs with upgraded alarms, show when bumped or broken into
* (Business) For upgraded alarms, show when broken into
* (House) For upgraded alarms, show when broken into
* (Clan) House/Business/Vehicle bought/sold
* (Clan) Member joined/left
* (Clan) Point and turf war start/finish, add results
* (Admin) Reports
* (Admin) Hacker detection
* (Dev) Submitted bugs/ideas
* Silent mode to block incoming alerts
* Moderation action choices.
* Players
@@ -276,5 +282,69 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* Config options
* Shutdown, restart, gmx, etc
* Alert (probably pre-made messages, configurable in pebble app)
- Newspaper GUI
---
### More GUI
* Basic layouts
* List
* Columned List (Grid?)
* Single Text Input Prompt
* Complex Layouts
* Info boxes for any type of server entity
* Admin functions for each one (ban, kick, delete, set owner, etc)
* Chat log
* Lists of submitted ideas and bug reports
---
### Web API
* REST-like URLs
* Type shortened to database table prefix style (/acct, /veh, etc)
* Auth token header
---
### Newspaper GUI
---
### Tutorial Stuff
* Two sets of flags for each tutorial. One for "already finished" and "declined tutorial"
* Tutorials will be in their own dimension (tutorial dimension start + client index)
* Tutorials
* Business (Ask to take tutorial when purchasing one)
* House (Ask to take tutorial when purchasing/renting one)
* Job (One for each job. Ask to take tutorial when taking a job)
* Spawn job vehicle and put arrow on it to indicate as a job vehicle
* For route jobs, point camera at random route stop and show vehicle driving to it
* Show basic usage of each job's features through steps (i.e. for police: tazing, cuffing, detaining, arresting a player)
* Vehicle (ask to take tutorial when purchasing one. Show item in trunk/dash too)
* Set camera to look at DMV for registering vehicle
* Set camera to random pay and spray to modify/repair/recolour vehicle
* Clan (Ask to take tutorial when being set as owner of clan)
* Show rank management
* Show member management
* Show vehicle management
* Show business/house management
* Show turf wars
* Show point wars
---
### Inventory Display
* Player choice
* Minecraft-style hotbar
* GTA V style radial wheel
---
### Usable world furniture
* Key press to use
* ATMs
* Chairs, benches, beds, restaurant seats, etc
* Specific transition anims where possible, otherwise warp to locked anim (i.e. instant stand to sit)
* Available offsets
---
### Pointing
* Key to point sort of like FiveM has.
* Use a 3D primitive on the spot thats pointed to, if no anim available.
---
### 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.
---
### Real time display
Steam has the player's local time on it's overlay. Something like that. Toggleable in account settings of course.
---

View File

@@ -9,22 +9,6 @@ This is the roleplay resource for Asshat Gaming's GTAC servers
* testing - The next upcoming release. All feature/fix/change branches are merged into this one
* feature/fix/change - This is where the stuff you're currently working on goes into.
### Getting Started
* Download the GTAC server to your local PC. This will be your local test server.
* Unzip the server, and edit the server config (default is server.xml) to your liking.
* Add a CVAR to the server config called `devserver` and set it's value to "1" to use the dev server database.
* Run plink.exe to create an SSH tunnel.
* `plink.exe gtacrp.asshatgaming.com -P 40393 -l USERNAME -i PATHTOKEY -L 127.0.0.1:3307:127.0.0.1:3306`
* Replace USERNAME with your username
* Replace PATHTOKEY with the full file path to your private key
* Put the edited command into a batch file (.bat) to make it easier to use next time.
* Add a CVAR to the server config called `databaseport` and set it's value to 3307.
* Clone this git repository into a subdirectory within the server's resources folder.
* Add the subdirectory's folder name to the resources section of the server config.
* Start the server to make sure it works and connects.
* Make a branch based on `testing` for every new feature/fix/change and prefix it with one of those (i.e. `feature-something`)
* Test the feature, and if it works, merge the branch for it into testing branch
### Scripting Style
* Always use camelCase, even for event names.
* Use a util function where possible. Keep raw logic in command/event/network handlers to a minimum.

24
TODO.md
View File

@@ -1,19 +1,16 @@
* Ice cream job
* VC: -862.39, -578.35, 11.10
------------------------------------------------------
* Change structure of item types to include only **one** set of items
* Use a new table for game-specific data (model, obj pos/rot/scale, etc)
------------------------------------------------------
* Cut down on engine/lights/lock messages.
* Account settings to toggle tips
* Get coords for more bus routes.
* Add more jobs
------------------------------------------------------
For grand opening:
- Get remaining interiors set up for the businesses/houses in Vice City
- Add command help option. Pick sub option:
- Put as optional arg in command handler func like the LU script
- Or put in commandData class (probably this one)
- Add police officer commands logic
- Tutorial
- Pick up item (grab bottle of beer off ground)
- Equip item (switch to bottle of beer item)
@@ -24,3 +21,16 @@ For grand opening:
- Take second beer from crate
- Store second beer in trunk
------------------------------------------------------
* Look into using TLS instead of SSL for SMTP email usage.
------------------------------------------------------
* Item management commands
* Item Types
* Create
* Set base price
* Set model
* Set drop position offset
* Set drop rotation offset
------------------------------------------------------
------------------------------------------------------
* Change pizza delivery job to pick a random house door instead of pre-established places on the street.

8
asshat-rp.code-workspace Normal file
View File

@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

8
config/database.json Normal file
View File

@@ -0,0 +1,8 @@
{
"host": "",
"user": "",
"pass": "",
"name": "",
"port": 3306,
"usePersistentConnection": true
}

19
config/email.json Normal file
View File

@@ -0,0 +1,19 @@
{
"smtp": {
"host":"",
"port":"",
"username":"",
"password":"",
"from":"",
"fromName":"",
"useTLS":"true"
},
"bodyContent": {
"confirmEmail": "Welcome to Asshat Gaming Roleplay for GTA Connected!\nPlease confirm your email by using the command /verifyemail in-game.\n\nYour verification code is: {VERIFICATIONCODE}",
"emailConfirmed": "Your email has been confirmed on Asshat Gaming Roleplay for GTA Connected!\nYou may now use this email to reset your password, require two-factor authentication on login, receive offline notifications, and more!",
"twoFactorAuthentication": "Please enter the following code to continue on Asshat Gaming's roleplay server for {GAMENAME}: {2FACODE}",
"accountAuthSuccessAlert": "You or someone else has successfully logged in to your account on the Asshat Gaming roleplay server for {GAMENAME}.\nIP Address: {IPADDRESS}\nLocation: {LOCATION}\nTimestamp: {TIMESTAMP}",
"accountAuthFailAlert": "You or someone else has failed to login to your account on the Asshat Gaming roleplay server for {GAMENAME}.\nIP Address: {IPADDRESS}\nLocation: {LOCATION}\nTimestamp: {TIMESTAMP}",
"offlineMessageAlert": "You have received a private message on the Asshat Gaming roleplay server for {GAMENAME}. You are receiving this notification because you enabled message notifications via email when you're not connected to the server.\nFrom: {FROMNAME}\nTimestamp: {TIMESTAMP}\nMessage: {MESSAGE}"
}
}

119
config/keybind.json Normal file
View File

@@ -0,0 +1,119 @@
{
"config": {
"shortHoldDuration": 500,
"longHoldDuration": 1500,
"coolDownBetweenUse": 500
},
"defaultKeyBinds": [
{
"keyName": "k",
"commandString": "engine",
"keyState": 1
},
{
"keyName": "l",
"commandString": "lights",
"keyState": 1
},
{
"keyName": "j",
"commandString": "lock",
"keyState": 1
},
{
"keyName": "f",
"commandString": "enter",
"keyState": 1
},
{
"keyName": "g",
"commandString": "passenger",
"keyState": 1
},
{
"keyName": "f",
"commandString": "passenger",
"keyState": 3
},
{
"keyName": "m",
"commandString": "cursor",
"keyState": 1
},
{
"keyName": "o",
"commandString": "drop",
"keyState": 1
},
{
"keyName": "p",
"commandString": "pickup",
"keyState": 1
},
{
"keyName": "u",
"commandString": "use",
"keyState": 1
},
{
"keyName": "i",
"commandString": "inv",
"keyState": 1
},
{
"keyName": "0",
"commandString": "i 0",
"keyState": 1
},
{
"keyName": "1",
"commandString": "i 1",
"keyState": 1
},
{
"keyName": "2",
"commandString": "i 2",
"keyState": 1
},
{
"keyName": "3",
"commandString": "i 3",
"keyState": 1
},
{
"keyName": "4",
"commandString": "i 4",
"keyState": 1
},
{
"keyName": "5",
"commandString": "i 5",
"keyState": 1
},
{
"keyName": "6",
"commandString": "i 6",
"keyState": 1
},
{
"keyName": "7",
"commandString": "i 7",
"keyState": 1
},
{
"keyName": "8",
"commandString": "i 8",
"keyState": 1
},
{
"keyName": "9",
"commandString": "i 9",
"keyState": 1
},
{
"keyName": "e",
"commandString": "action primary",
"keyState": 3
}
]
}

27
config/roleplay.json Normal file
View File

@@ -0,0 +1,27 @@
{
"accents": [
"English",
"French",
"Russian",
"Scottish",
"Irish",
"Spanish",
"Southern American",
"Italian",
"Australian",
"Jamaican",
"Israeli",
"Dutch",
"Brazilian",
"Portuguese",
"German",
"Canadian",
"Chinese",
"Japanese",
"Turkish",
"Korean",
"Estonian",
"Sicilian",
"Indian"
]
}

152
meta.xml
View File

@@ -4,14 +4,11 @@
<!-- Shared -->
<script src="scripts/shared/native.js" type="server" language="javascript" />
<script src="scripts/shared/native.js" type="client" language="javascript" />
<script src="scripts/shared/game-data.js" type="server" language="javascript" />
<script src="scripts/shared/game-data.js" type="client" language="javascript" />
<script src="scripts/shared/const.js" type="server" language="javascript" />
<script src="scripts/shared/const.js" type="client" language="javascript" />
<!-- Server -->
<script src="scripts/server/class.js" type="server" language="javascript" />
<script src="scripts/server/account.js" type="server" language="javascript" />
<script src="scripts/server/ammunation.js" type="server" language="javascript" />
<script src="scripts/server/anticheat.js" type="server" language="javascript" />
@@ -26,7 +23,10 @@
<script src="scripts/server/database.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/economy.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/fishing.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/house.js" type="server" language="javascript" />
@@ -37,17 +37,20 @@
<script src="scripts/server/messaging.js" type="server" language="javascript" />
<script src="scripts/server/misc.js" type="server" language="javascript" />
<script src="scripts/server/native.js" type="server" language="javascript" />
<script src="scripts/server/npc.js" type="server" language="javascript" />
<script src="scripts/server/moderation.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/subaccount.js" type="server" language="javascript" />
<script src="scripts/server/timers.js" type="server" language="javascript" />
<script src="scripts/server/translate.js" type="server" language="javascript" />
<script src="scripts/server/trigger.js" type="server" language="javascript" />
<script src="scripts/server/utilities.js" type="server" language="javascript" />
<script src="scripts/server/vehicle.js" type="server" language="javascript" />
<script src="scripts/server/config.js" type="server" language="javascript" />
<script src="scripts/server/core.js" type="server" language="javascript" />
<script src="scripts/server/command.js" type="server" language="javascript" />
<script src="scripts/server/gamedata.js" type="server" language="javascript" />
<script src="scripts/server/business/bakery.js" type="server" language="javascript" />
<script src="scripts/server/business/bar.js" type="server" language="javascript" />
@@ -74,14 +77,17 @@
<script src="scripts/server/item/drink.js" type="server" language="javascript" />
<script src="scripts/server/item/walkie-talkie.js" type="server" language="javascript" />
<script src="scripts/server/item/phone.js" type="server" language="javascript" />
<script src="scripts/server/item/handcuff.js" type="server" language="javascript" />
<script src="scripts/server/item/rope.js" type="server" language="javascript" />
<script src="scripts/server/item/tazer.js" type="server" language="javascript" />
<script src="scripts/server/startup.js" type="server" language="javascript" />
<!-- Client -->
<!-- Extra Files -->
<file type="client" src="files/images/main-logo.png" />
<file type="client" src="files/fonts/roboto-regular.ttf" />
<file type="client" src="files/fonts/pricedown.ttf" />
<file type="client" src="files/images/skins/none.png" />
<!-- Client Scripts -->
<script src="scripts/client/gui.js" type="client" language="javascript" />
<script src="scripts/client/main.js" type="client" language="javascript" />
<script src="scripts/client/nametag.js" type="client" language="javascript" />
@@ -90,125 +96,19 @@
<script src="scripts/client/keybind.js" type="client" language="javascript" />
<script src="scripts/client/chatbox.js" type="client" language="javascript" />
<script src="scripts/client/label.js" type="client" language="javascript" />
<script src="scripts/client/mouse-camera.js" type="client" language="javascript" />
<script src="scripts/client/skin-select.js" type="client" language="javascript" />
<script src="scripts/client/server.js" type="client" language="javascript" />
<script src="scripts/client/job.js" type="client" language="javascript" />
<script src="scripts/client/event.js" type="client" language="javascript" />
<script src="scripts/client/item.js" type="client" language="javascript" />
<script src="scripts/client/utilities.js" type="client" language="javascript" />
<script src="scripts/client/messaging.js" type="client" language="javascript" />
<script src="scripts/client/logo.js" type="client" language="javascript" />
<script src="scripts/client/afk.js" type="client" language="javascript" />
<file type="client" src="files/images/skins/none.png" />
<!--
<file type="client" src="files/images/skins/gta3/Skin000.png" />
<file type="client" src="files/images/skins/gta3/Skin001.png" />
<file type="client" src="files/images/skins/gta3/Skin002.png" />
<file type="client" src="files/images/skins/gta3/Skin003.png" />
<file type="client" src="files/images/skins/gta3/Skin004.png" />
<file type="client" src="files/images/skins/gta3/Skin005.png" />
<file type="client" src="files/images/skins/gta3/Skin006.png" />
<file type="client" src="files/images/skins/gta3/Skin007.png" />
<file type="client" src="files/images/skins/gta3/Skin008.png" />
<file type="client" src="files/images/skins/gta3/Skin009.png" />
<file type="client" src="files/images/skins/gta3/Skin010.png" />
<file type="client" src="files/images/skins/gta3/Skin011.png" />
<file type="client" src="files/images/skins/gta3/Skin012.png" />
<file type="client" src="files/images/skins/gta3/Skin013.png" />
<file type="client" src="files/images/skins/gta3/Skin014.png" />
<file type="client" src="files/images/skins/gta3/Skin015.png" />
<file type="client" src="files/images/skins/gta3/Skin016.png" />
<file type="client" src="files/images/skins/gta3/Skin017.png" />
<file type="client" src="files/images/skins/gta3/Skin018.png" />
<file type="client" src="files/images/skins/gta3/Skin020.png" />
<file type="client" src="files/images/skins/gta3/Skin021.png" />
<file type="client" src="files/images/skins/gta3/Skin022.png" />
<file type="client" src="files/images/skins/gta3/Skin023.png" />
<file type="client" src="files/images/skins/gta3/Skin024.png" />
<file type="client" src="files/images/skins/gta3/Skin025.png" />
<file type="client" src="files/images/skins/gta3/Skin030.png" />
<file type="client" src="files/images/skins/gta3/Skin031.png" />
<file type="client" src="files/images/skins/gta3/Skin032.png" />
<file type="client" src="files/images/skins/gta3/Skin033.png" />
<file type="client" src="files/images/skins/gta3/Skin034.png" />
<file type="client" src="files/images/skins/gta3/Skin035.png" />
<file type="client" src="files/images/skins/gta3/Skin036.png" />
<file type="client" src="files/images/skins/gta3/Skin037.png" />
<file type="client" src="files/images/skins/gta3/Skin038.png" />
<file type="client" src="files/images/skins/gta3/Skin039.png" />
<file type="client" src="files/images/skins/gta3/Skin040.png" />
<file type="client" src="files/images/skins/gta3/Skin041.png" />
<file type="client" src="files/images/skins/gta3/Skin042.png" />
<file type="client" src="files/images/skins/gta3/Skin043.png" />
<file type="client" src="files/images/skins/gta3/Skin044.png" />
<file type="client" src="files/images/skins/gta3/Skin045.png" />
<file type="client" src="files/images/skins/gta3/Skin046.png" />
<file type="client" src="files/images/skins/gta3/Skin047.png" />
<file type="client" src="files/images/skins/gta3/Skin048.png" />
<file type="client" src="files/images/skins/gta3/Skin049.png" />
<file type="client" src="files/images/skins/gta3/Skin050.png" />
<file type="client" src="files/images/skins/gta3/Skin051.png" />
<file type="client" src="files/images/skins/gta3/Skin052.png" />
<file type="client" src="files/images/skins/gta3/Skin053.png" />
<file type="client" src="files/images/skins/gta3/Skin054.png" />
<file type="client" src="files/images/skins/gta3/Skin055.png" />
<file type="client" src="files/images/skins/gta3/Skin056.png" />
<file type="client" src="files/images/skins/gta3/Skin057.png" />
<file type="client" src="files/images/skins/gta3/Skin058.png" />
<file type="client" src="files/images/skins/gta3/Skin059.png" />
<file type="client" src="files/images/skins/gta3/Skin060.png" />
<file type="client" src="files/images/skins/gta3/Skin061.png" />
<file type="client" src="files/images/skins/gta3/Skin062.png" />
<file type="client" src="files/images/skins/gta3/Skin063.png" />
<file type="client" src="files/images/skins/gta3/Skin064.png" />
<file type="client" src="files/images/skins/gta3/Skin065.png" />
<file type="client" src="files/images/skins/gta3/Skin066.png" />
<file type="client" src="files/images/skins/gta3/Skin067.png" />
<file type="client" src="files/images/skins/gta3/Skin068.png" />
<file type="client" src="files/images/skins/gta3/Skin069.png" />
<file type="client" src="files/images/skins/gta3/Skin070.png" />
<file type="client" src="files/images/skins/gta3/Skin071.png" />
<file type="client" src="files/images/skins/gta3/Skin072.png" />
<file type="client" src="files/images/skins/gta3/Skin073.png" />
<file type="client" src="files/images/skins/gta3/Skin074.png" />
<file type="client" src="files/images/skins/gta3/Skin075.png" />
<file type="client" src="files/images/skins/gta3/Skin076.png" />
<file type="client" src="files/images/skins/gta3/Skin077.png" />
<file type="client" src="files/images/skins/gta3/Skin078.png" />
<file type="client" src="files/images/skins/gta3/Skin080.png" />
<file type="client" src="files/images/skins/gta3/Skin081.png" />
<file type="client" src="files/images/skins/gta3/Skin082.png" />
<file type="client" src="files/images/skins/gta3/Skin083.png" />
<file type="client" src="files/images/skins/gta3/Skin084.png" />
<file type="client" src="files/images/skins/gta3/Skin085.png" />
<file type="client" src="files/images/skins/gta3/Skin086.png" />
<file type="client" src="files/images/skins/gta3/Skin087.png" />
<file type="client" src="files/images/skins/gta3/Skin088.png" />
<file type="client" src="files/images/skins/gta3/Skin089.png" />
<file type="client" src="files/images/skins/gta3/Skin090.png" />
<file type="client" src="files/images/skins/gta3/Skin091.png" />
<file type="client" src="files/images/skins/gta3/Skin092.png" />
<file type="client" src="files/images/skins/gta3/Skin093.png" />
<file type="client" src="files/images/skins/gta3/Skin094.png" />
<file type="client" src="files/images/skins/gta3/Skin095.png" />
<file type="client" src="files/images/skins/gta3/Skin096.png" />
<file type="client" src="files/images/skins/gta3/Skin097.png" />
<file type="client" src="files/images/skins/gta3/Skin098.png" />
<file type="client" src="files/images/skins/gta3/Skin099.png" />
<file type="client" src="files/images/skins/gta3/Skin100.png" />
<file type="client" src="files/images/skins/gta3/Skin101.png" />
<file type="client" src="files/images/skins/gta3/Skin102.png" />
<file type="client" src="files/images/skins/gta3/Skin103.png" />
<file type="client" src="files/images/skins/gta3/Skin104.png" />
<file type="client" src="files/images/skins/gta3/Skin105.png" />
<file type="client" src="files/images/skins/gta3/Skin106.png" />
<file type="client" src="files/images/skins/gta3/Skin107.png" />
<file type="client" src="files/images/skins/gta3/Skin108.png" />
<file type="client" src="files/images/skins/gta3/Skin109.png" />
<file type="client" src="files/images/skins/gta3/Skin110.png" />
<file type="client" src="files/images/skins/gta3/Skin111.png" />
<file type="client" src="files/images/skins/gta3/Skin112.png" />
<file type="client" src="files/images/skins/gta3/Skin113.png" />
<file type="client" src="files/images/skins/gta3/Skin114.png" />
<file type="client" src="files/images/skins/gta3/Skin115.png" />
<file type="client" src="files/images/skins/gta3/Skin116.png" />
<file type="client" src="files/images/skins/gta3/Skin118.png" />
<file type="client" src="files/images/skins/gta3/Skin120.png" />
<file type="client" src="files/images/skins/gta3/Skin121.png" />
-->
<!-- Startup -->
<script src="scripts/server/startup.js" type="server" language="javascript" />
<script src="scripts/client/startup.js" type="client" language="javascript" />
<!-- MexUI -->
<file type="client" src="third-party/mexui/Images/down-arrow.png" />
@@ -273,4 +173,4 @@
<script language="javascript" type="client" src="third-party/mexui/Core/Control/WeekDay.js" />
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Year.js" />
<script language="javascript" type="client" src="third-party/mexui/Core/Init.js" />
</meta>
</meta>

View File

@@ -1,35 +1,40 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: afk.js
// DESC: Provides AFK detection
// TYPE: Client (JavaScript)
// ===========================================================================
// -------------------------------------------------------------------------
function initAFKScript() {
logToConsole(LOG_DEBUG, "[Asshat.AFK]: Initializing AFK script ...");
logToConsole(LOG_DEBUG, "[Asshat.AFK]: AFK script initialized!");
}
addEventHandler("OnLostFocus", function(event) {
triggerNetworkEvent("ag.afk", true);
if(localPlayer != null) {
localPlayer.collisionsEnabled = false;
gta.setCiviliansEnabled(false);
gta.setTrafficEnabled(false);
}
});
// ===========================================================================
// -------------------------------------------------------------------------
function processLostFocusAFK(event) {
sendServerNewAFKStatus(true);
//if(localPlayer != null) {
// localPlayer.collisionsEnabled = false;
// gta.setCiviliansEnabled(false);
// gta.setTrafficEnabled(false);
//}
}
addEventHandler("OnFocus", function(event) {
triggerNetworkEvent("ag.afk", false);
if(localPlayer != null) {
localPlayer.collisionsEnabled = true;
if(gta.game != GAME_GTA_SA) {
gta.setCiviliansEnabled(true);
}
gta.setTrafficEnabled(true);
}
});
// ===========================================================================
// -------------------------------------------------------------------------
function processFocusAFK(event) {
sendServerNewAFKStatus(false);
//if(localPlayer != null) {
// localPlayer.collisionsEnabled = true;
// if(gta.game != GAME_GTA_SA) {
// gta.setCiviliansEnabled(true);
// }
// gta.setTrafficEnabled(true);
//}
}
// ===========================================================================

View File

@@ -1,39 +1,65 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// 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;
bindKey(SDLK_PAGEUP, KEYSTATE_DOWN, chatBoxScrollUp);
bindKey(SDLK_PAGEDOWN, KEYSTATE_DOWN, chatBoxScrollDown);
// ===========================================================================
// ---------------------------------------------------------------------------
function initChatBoxScript() {
logToConsole(LOG_DEBUG, "[Asshat.ChatBox]: Initializing chatbox script ...");
bindChatBoxKeys();
logToConsole(LOG_DEBUG, "[Asshat.ChatBox]: Chatbox script initialized!");
}
addNetworkHandler("ag.m", function(messageString, colour) {
// ===========================================================================
function bindChatBoxKeys() {
bindKey(SDLK_PAGEUP, KEYSTATE_DOWN, chatBoxScrollUp);
bindKey(SDLK_PAGEDOWN, KEYSTATE_DOWN, chatBoxScrollDown);
}
// ===========================================================================
function unBindChatBoxKeys() {
unbindKey(SDLK_PAGEUP);
unbindKey(SDLK_PAGEDOWN);
}
// ===========================================================================
function receiveChatBoxMessageFromServer(messageString, colour) {
message(messageString, colour);
addToChatBoxHistory(messageString, colour);
bottomMessageIndex = chatBoxHistory.length-1;
});
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setChatScrollLines(amount) {
scrollAmount = amount;
}
// ===========================================================================
function addToChatBoxHistory(messageString, colour) {
chatBoxHistory.push([messageString, colour]);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function chatBoxScrollUp() {
if(bottomMessageIndex > maxChatBoxLines) {
@@ -42,7 +68,7 @@ function chatBoxScrollUp() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function chatBoxScrollDown() {
if(bottomMessageIndex < chatBoxHistory.length-1) {
@@ -51,7 +77,7 @@ function chatBoxScrollDown() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clearChatBox() {
for(let i = 0 ; i <= maxChatBoxLines ; i++) {
@@ -59,7 +85,7 @@ function clearChatBox() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updateChatBox() {
clearChatBox();
@@ -72,4 +98,4 @@ function updateChatBox() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================

237
scripts/client/event.js Normal file
View File

@@ -0,0 +1,237 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
// TYPE: Client (JavaScript)
// ===========================================================================
function initEventScript() {
logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ...");
addCustomEvents();
addAllEventHandlers();
logToConsole(LOG_DEBUG, "[Asshat.Event]: Event script initialized!");
}
// ===========================================================================
function addCustomEvents() {
addEvent("OnLocalPlayerEnterSphere", 1);
addEvent("OnLocalPlayerExitSphere", 1);
addEvent("OnLocalPlayerEnteredVehicle", 1);
addEvent("OnLocalPlayerExitedVehicle", 1);
addEvent("OnLocalPlayerSwitchWeapon", 2);
}
// ===========================================================================
function addAllEventHandlers() {
bindEventHandler("OnResourceStart", thisResource, onResourceStart);
bindEventHandler("OnResourceReady", thisResource, onResourceReady);
bindEventHandler("OnResourceStop", thisResource, onResourceStop);
addEventHandler("OnProcess", onProcess);
addEventHandler("OnKeyUp", onKeyUp);
addEventHandler("OnDrawnHUD", onDrawnHUD);
addEventHandler("OnPedWasted", onPedWasted);
addEventHandler("OnElementStreamIn", onElementStreamIn);
addEventHandler("OnLocalPlayerEnteredVehicle", onLocalPlayerEnteredVehicle);
addEventHandler("OnLocalPlayerExitedVehicle", onLocalPlayerExitedVehicle);
addEventHandler("OnLocalPlayerEnterSphere", onLocalPlayerEnterSphere);
addEventHandler("OnLocalPlayerExitSphere", onLocalPlayerExitSphere);
addEventHandler("OnLocalPlayerSwitchWeapon", onLocalPlayerSwitchWeapon);
addEventHandler("OnPedInflictDamage", onPedInflictDamage);
addEventHandler("OnLostFocus", onLostFocus);
addEventHandler("OnFocus", onFocus);
addEventHandler("OnCameraProcess", onCameraProcess);
}
// ===========================================================================
function onResourceStart(event, resource) {
sendResourceStartedSignalToServer();
//closeAllGarages();
if(getGame() == GAME_GTA_SA) {
gta.setDefaultInteriors(false);
}
garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60);
}
// ===========================================================================
function onResourceStop(event, resource) {
sendResourceStoppedSignalToServer();
}
// ===========================================================================
function onResourceReady(event, resource) {
sendResourceReadySignalToServer();
//closeAllGarages();
}
// ===========================================================================
function onProcess(event, deltaTime) {
if(gta.game != GAME_GTA_IV) {
gta.clearMessages();
}
if(localPlayer == null) {
return false;
}
if(!isSpawned) {
return false;
}
processSync();
destroyAutoCreatedPickups();
processLocalPlayerControlState();
clearLocalPlayerWantedLevel();
processLocalPlayerVehicleControlState();
processLocalPlayerSphereEntryExitHandling();
processLocalPlayerVehicleEntryExitHandling();
processJobRouteSphere();
forceLocalPlayerEquippedWeaponItem();
processWantedLevelReset();
}
// ===========================================================================
function onKeyUp(event, keyCode, scanCode, keyModifiers) {
processSkinSelectKeyPress(keyCode);
}
// ===========================================================================
function onDrawnHUD(event) {
if(!renderHUD) {
return false;
}
if(localPlayer == null) {
return false;
}
//if(gta.game == GAME_GTA_VC) {
// return false;
//}
processSmallGameMessageRendering();
processScoreBoardRendering();
processLabelRendering();
processLogoRendering();
processItemActionRendering();
processSkinSelectRendering();
processNameTagRendering();
}
// ===========================================================================
function onPedWasted(event, wastedPed, killerPed, weapon, pedPiece) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Ped ${wastedPed.name} died`);
wastedPed.clearWeapons();
}
// ===========================================================================
function onElementStreamIn(event, element) {
syncElementProperties(element);
}
// ===========================================================================
function onLocalPlayerExitedVehicle(event, vehicle, seat) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Local player exited vehicle`);
triggerNetworkEvent("ag.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
if(inVehicleSeat) {
parkedVehiclePosition = false;
parkedVehicleHeading = false;
}
}
// ===========================================================================
function onLocalPlayerEnteredVehicle(event, vehicle, seat) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Local player entered vehicle`);
triggerNetworkEvent("ag.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
if(inVehicleSeat == 0) {
if(inVehicle.owner != -1) {
inVehicle.engine = false;
if(!inVehicle.engine) {
parkedVehiclePosition = inVehicle.position;
parkedVehicleHeading = inVehicle.heading;
}
}
}
}
// ===========================================================================
function onPedInflictDamage(event, damagedEntity, damagerEntity, weaponId, healthLoss, pedPiece) {
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`;
logToConsole(LOG_DEBUG, `[Asshat.Event] ${damagerEntityString} damaged ${damagedEntityString}'s '${pedPiece} with weapon ${weaponId}`);
if(!isNull(damagedEntity) && !isNull(damagerEntity)) {
if(damagedEntity.isType(ELEMENT_PLAYER)) {
if(damagedEntity == localPlayer) {
if(!weaponDamageEnabled[damagerEntity.name]) {
event.preventDefault();
triggerNetworkEvent("ag.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss);
}
}
}
}
}
// ===========================================================================
function onLocalPlayerEnterSphere(event, sphere) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Local player entered sphere`);
if(sphere == jobRouteStopSphere) {
enteredJobRouteSphere();
}
}
// ===========================================================================
function onLocalPlayerExitSphere(event, sphere) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Local player exited sphere`);
}
// ===========================================================================
function onLostFocus(event) {
processLostFocusAFK();
}
// ===========================================================================
function onFocus(event) {
processFocusAFK();
}
// ===========================================================================
function onLocalPlayerSwitchWeapon(oldWeapon, newWeapon) {
}
// ===========================================================================
function onCameraProcess(event) {
}
// ===========================================================================

File diff suppressed because it is too large Load Diff

63
scripts/client/item.js Normal file
View File

@@ -0,0 +1,63 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: item.js
// DESC: Provides item action and hotbar functions
// TYPE: Client (JavaScript)
// ===========================================================================
let itemActionDelayDuration = 0;
let itemActionDelayStart = 0;
let itemActionDelayEnabled = false;
let itemActionDelayPosition = toVector2(gta.width/2-100, gta.height-10);
let itemActionDelaySize = toVector2(200, 5);
// ===========================================================================
function initItemScript() {
logToConsole(LOG_DEBUG, "[Asshat.Item]: Initializing item script ...");
logToConsole(LOG_DEBUG, "[Asshat.Item]: Item script initialized!");
}
// ===========================================================================
function processItemActionRendering() {
if(renderItemActionDelay) {
if(itemActionDelayEnabled) {
let finishTime = itemActionDelayStart+itemActionDelayDuration;
if(sdl.ticks >= finishTime) {
itemActionDelayEnabled = false;
itemActionDelayDuration = 0;
itemActionDelayStart = 0;
tellServerItemActionDelayComplete();
} else {
let currentTick = sdl.ticks-itemActionDelayStart;
let progressPercent = Math.ceil(currentTick*100/itemActionDelayDuration);
let width = Math.ceil(getPercentage(itemActionDelaySize.x, progressPercent));
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), itemActionDelayPosition.y-(itemActionDelaySize.y/2)-2], [width, itemActionDelaySize.y], COLOUR_LIME, COLOUR_LIME, COLOUR_LIME, COLOUR_LIME);
}
}
}
}
// ===========================================================================
function updatePlayerHotBar(activeSlot, itemsArray) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Updating hotbar`);
}
// ===========================================================================
function showItemActionDelay(duration) {
itemActionDelayDuration = duration;
itemActionDelayStart = sdl.ticks;
itemActionDelayEnabled = true;
logToConsole(LOG_DEBUG, `Item action delay started. Duration: ${itemActionDelayDuration}, Start: ${itemActionDelayStart}, Rendering Enabled: ${renderItemActionDelay}`);
}
// ===========================================================================

76
scripts/client/job.js Normal file
View File

@@ -0,0 +1,76 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: job.js
// DESC: Provides job functions and usage
// TYPE: Client (JavaScript)
// ===========================================================================
let localPlayerJobType = 0;
let localPlayerWorking = false;
let jobRouteStopBlip = null;
let jobRouteStopSphere = null;
// ===========================================================================
function initJobScript() {
logToConsole(LOG_DEBUG, "[Asshat.Job]: Initializing job script ...");
logToConsole(LOG_DEBUG, "[Asshat.Job]: Job script initialized!");
}
// ===========================================================================
function setLocalPlayerJobType(tempJobType) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Set local player job type to ${tempJobType}`);
localPlayerJobType = tempJobType;
}
// ===========================================================================
function setLocalPlayerWorkingState(tempWorking) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Setting working state to ${tempWorking}`);
localPlayerWorking = tempWorking;
}
// ===========================================================================
function showJobRouteStop() {
logToConsole(LOG_DEBUG, `[Asshat.Job] Showing route stop`);
if(gta.game == GAME_GTA_SA) {
jobRouteStopSphere = gta.createPickup(1318, position, 1);
} else {
jobRouteStopSphere = gta.createSphere(position, 3);
jobRouteStopSphere.colour = colour;
}
jobRouteStopBlip = gta.createBlip(position, 0, 2, colour);
}
// ===========================================================================
function showJobRouteStop(position, colour) {
logToConsole(LOG_DEBUG, `[Asshat.Job] Showing route stop`);
if(gta.game == GAME_GTA_SA) {
jobRouteStopSphere = gta.createPickup(1318, position, 1);
} else {
jobRouteStopSphere = gta.createSphere(position, 3);
jobRouteStopSphere.colour = colour;
}
jobRouteStopBlip = gta.createBlip(position, 0, 2, colour);
}
// ===========================================================================
function enteredJobRouteSphere() {
logToConsole(LOG_DEBUG, `[Asshat.Job] Entered job route sphere`);
tellServerPlayerArrivedAtJobRouteStop();
destroyElement(jobRouteStopSphere);
destroyElement(jobRouteStopBlip);
jobRouteStopSphere = null;
jobRouteStopBlip = null;
}
// ===========================================================================

View File

@@ -1,8 +1,8 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: keybind.js
// DESC: Provides keybind features
// TYPE: Client (JavaScript)
@@ -10,29 +10,44 @@
let lastKeyBindUse = 0;
let keyBindDelayTime = 500;
let keyBindShortHoldDuration = 500;
let keyBindLongHoldDuration = 1500;
// -------------------------------------------------------------------------
// ===========================================================================
function initKeyBindScript() {
logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Initializing key bind script ...");
logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Key bind script initialized!");
}
// ===========================================================================
function bindAccountKey(key, keyState) {
logToConsole(LOG_DEBUG, `[Asshat.KeyBind]: Binded key ${sdl.getKeyName(key)} (${key})`);
bindKey(toInteger(key), keyState, function(event) {
if(hasKeyBindDelayElapsed()) {
lastKeyBindUse = sdl.ticks;
triggerNetworkEvent("ag.useKeyBind", key);
if(canLocalPlayerUseKeyBinds()) {
logToConsole(LOG_DEBUG, `[Asshat.KeyBind]: Using keybind for key ${sdl.getKeyName(key)} (${key})`);
lastKeyBindUse = sdl.ticks;
tellServerPlayerUsedKeyBind(key);
} else {
logToConsole(LOG_ERROR, `[Asshat.KeyBind]: Failed to use keybind for key ${sdl.getKeyName(key)} (${key}) - Not allowed to use keybinds!`);
}
} else {
logToConsole(LOG_ERROR, `[Asshat.KeyBind]: Failed to use keybind for key ${sdl.getKeyName(key)} (${key}) - Not enough time has passed since last keybind use!`);
}
});
return false;
}
addNetworkHandler("ag.addKeyBind", bindAccountKey);
// -------------------------------------------------------------------------
// ===========================================================================
function unBindAccountKey(key) {
logToConsole(LOG_DEBUG, `[Asshat.KeyBind]: Unbinded key ${sdl.getKeyName(key)} (${key})`);
unbindKey(key);
return true;
}
addNetworkHandler("ag.delKeyBind", unBindAccountKey);
// -------------------------------------------------------------------------
// ===========================================================================
function hasKeyBindDelayElapsed() {
if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) {
@@ -42,4 +57,10 @@ function hasKeyBindDelayElapsed() {
return false;
}
// -------------------------------------------------------------------------
// ===========================================================================
function canLocalPlayerUseKeyBinds() {
return true; //(!usingSkinSelector && isSpawned && !itemActionDelayEnabled);
}
// ===========================================================================

View File

@@ -1,8 +1,8 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: labels.js
// DESC: Provides functionality for world labels (3D labels)
// TYPE: Client (JavaScript)
@@ -25,19 +25,49 @@ let unlockedColour = toColour(50, 205, 50, 255);
let lockedColour = toColour(205, 92, 92, 255);
let jobHelpColour = toColour(234, 198, 126, 255);
// -------------------------------------------------------------------------
let renderLabelDistance = 7.5;
bindEventHandler("onResourceReady", thisResource, function(event, resource) {
propertyLabelNameFont = lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
propertyLabelLockedFont = lucasFont.createDefaultFont(12.0, "Roboto", "Light");
let propertyLabelLockedOffset = 16;
let propertyLabelNameOffset = 18;
jobNameLabelFont = lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
jobHelpLabelFont = lucasFont.createDefaultFont(10.0, "Roboto", "Light");
});
// ===========================================================================
// -------------------------------------------------------------------------
function initLabelScript() {
logToConsole(LOG_DEBUG, "[Asshat.Label]: Initializing label script ...");
propertyLabelNameFont = initLabelPropertyNameFont();
propertyLabelLockedFont = initLabelPropertyLockedFont();
jobNameLabelFont = initLabelJobNameFont();
jobHelpLabelFont = initLabelJobHelpFont();
logToConsole(LOG_DEBUG, "[Asshat.Label]: Label script initialized!");
}
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) {
// ===========================================================================
function initLabelPropertyNameFont() {
return lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
}
// ===========================================================================
function initLabelPropertyLockedFont() {
return lucasFont.createDefaultFont(12.0, "Roboto", "Light");
}
// ===========================================================================
function initLabelJobNameFont() {
return lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
}
// ===========================================================================
function initLabelJobHelpFont() {
return lucasFont.createDefaultFont(10.0, "Roboto", "Light");
}
// ===========================================================================
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, shouldShowBuyInfo) {
if(localPlayer == null) {
return false;
}
@@ -54,24 +84,35 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price)
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition);
if(screenPosition.x < 0 || screenPosition.x > gta.width) {
return false;
}
let text = "";
if(price > 0) {
text = `For sale: $${price}`;
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(0, 150, 0, 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 -= 18;
screenPosition.y -= propertyLabelLockedOffset;
}
text = (locked) ? "LOCKED" : "UNLOCKED";
if(isBusiness) {
text = (locked) ? "CLOSED" : "OPEN";
if(!locked && shouldShowBuyInfo) {
if(getDistance(localPlayer.position, position) <= renderLabelDistance-2) {
let size = propertyLabelLockedFont.measure(`Use /buy to purchase items`, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(`Use /buy to purchase items`, [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;
}
}
}
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);
screenPosition.y -= 22;
screenPosition.y -= propertyLabelNameOffset;
text = name || " ";
size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
@@ -97,6 +138,10 @@ function renderPropertyExitLabel(position) {
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition);
if(screenPosition.x < 0 || screenPosition.x > gta.width) {
return false;
}
let text = "EXIT";
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);
@@ -121,6 +166,10 @@ function renderJobLabel(name, position, jobType) {
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition);
if(screenPosition.x < 0 || screenPosition.x > gta.width) {
return false;
}
let text = "";
if(jobType == localPlayerJobType) {
if(localPlayerWorking) {
@@ -149,32 +198,39 @@ function renderJobLabel(name, position, jobType) {
// -------------------------------------------------------------------------
function processLabelRendering() {
if(localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP);
for(let i in pickups) {
if(pickups[i].getData("ag.label.type") != null) {
if(getDistance(localPlayer.position, pickups[i].position) <= 7.5) {
let price = 0;
if(pickups[i].getData("ag.label.price") != null) {
price = pickups[i].getData("ag.label.price");
}
if(renderLabels && gta.game != GAME_GTA_IV) {
if(localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP);
for(let i in pickups) {
if(pickups[i].getData("ag.label.type") != null) {
if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
let price = 0;
let shouldShowBuyHelp = false;
if(pickups[i].getData("ag.label.price") != null) {
price = pickups[i].getData("ag.label.price");
}
switch(pickups[i].getData("ag.label.type")) {
case AG_LABEL_BUSINESS:
renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), true, price);
break;
if(pickups[i].getData("ag.label.buyhelp") != null) {
shouldShowBuyHelp = pickups[i].getData("ag.label.buyhelp");
}
case AG_LABEL_HOUSE:
renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), false, price);
break;
switch(pickups[i].getData("ag.label.type")) {
case AG_LABEL_BUSINESS:
renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), true, price, shouldShowBuyHelp);
break;
case AG_LABEL_JOB:
renderJobLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.jobType"));
break;
case AG_LABEL_HOUSE:
renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), false, price);
break;
case AG_LABEL_EXIT:
renderPropertyExitLabel(pickups[i].position);
break;
case AG_LABEL_JOB:
renderJobLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.jobType"));
break;
case AG_LABEL_EXIT:
renderPropertyExitLabel(pickups[i].position);
break;
}
}
}
}

53
scripts/client/logo.js Normal file
View File

@@ -0,0 +1,53 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: logo.js
// DESC: Provides logo rendering functions
// TYPE: Client (JavaScript)
// ===========================================================================
let logoImage = null;
let logoPos = toVector2(gta.width-132, gta.height-132);
let logoSize = toVector2(128, 128);
// ===========================================================================
function initLogoScript() {
logToConsole(LOG_DEBUG, "[Asshat.Logo]: Initializing logo script ...");
logoImage = loadLogoImage();
logToConsole(LOG_DEBUG, "[Asshat.Logo]: Logo script initialized!");
}
// ===========================================================================
function loadLogoImage() {
let logoStream = openFile(mainLogoPath);
let tempLogoImage = null;
if(logoStream != null) {
tempLogoImage = drawing.loadPNG(logoStream);
logoStream.close();
}
return tempLogoImage;
}
// ===========================================================================
function processLogoRendering() {
if(renderLogo) {
if(logoImage != null) {
graphics.drawRectangle(logoImage, logoPos, logoSize);
}
}
}
// ===========================================================================
function setServerLogoRenderState(state) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Server logo ${(state) ? "enabled" : "disabled"}`);
renderLogo = state;
}
// ===========================================================================

View File

@@ -1,40 +1,19 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: main.js
// DESC: Main client script (will be reorganized into individual files later)
// TYPE: Client (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
let bigMessageFont = null;
let logoImage = null;
let logoPos = toVector2(gta.width-132, gta.height-132);
let logoSize = toVector2(128, 128);
let jobRouteStopBlip = null;
let jobRouteStopSphere = null;
let smallGameMessageFont = null;
let smallGameMessageText = "";
let smallGameMessageColour = COLOUR_WHITE;
let smallGameMessageTimer = null;
let inSphere = false;
let inVehicle = false;
let inVehicleSeat = false;
let isWalking = false;
let isSpawned = false;
let localPlayerJobType = 0;
let localPlayerWorking = false;
let mouseCameraEnabled = false;
let garbageCollectorInterval = null;
let parkedVehiclePosition = false;
@@ -44,7 +23,7 @@ let renderHUD = true;
let renderLabels = true;
let renderLogo = true;
let renderSmallGameMessage = true;
let renderScoreboard = true;
let renderScoreBoard = true;
let renderHotBar = true;
let renderItemActionDelay = true;
@@ -57,729 +36,11 @@ let forceWeapon = 0;
let forceWeaponAmmo = 0;
let forceWeaponClipAmmo = 0;
let itemActionDelayDuration = 0;
let itemActionDelayStart = 0;
let itemActionDelayEnabled = false;
let itemActionDelayPosition = toVector2(gta.width/2, gta.height-100);
let itemActionDelaySize = toVector2(100, 10);
let drunkEffectAmount = 0;
let drunkEffectDurationTimer = null;
// ---------------------------------------------------------------------------
let controlsEnabled = true;
addEvent("OnLocalPlayerEnterSphere", 1);
addEvent("OnLocalPlayerExitSphere", 1);
addEvent("OnLocalPlayerEnteredVehicle", 1);
addEvent("OnLocalPlayerExitedVehicle", 1);
addEvent("OnLocalPlayerSwitchWeapon", 2);
let streamingRadio = null;
// ---------------------------------------------------------------------------
bindEventHandler("onResourceReady", thisResource, function(event, resource) {
if(resource == thisResource) {
let fontStream = openFile("files/fonts/pricedown.ttf");
if(fontStream != null) {
bigMessageFont = lucasFont.createFont(fontStream, 28.0);
smallGameMessageFont = lucasFont.createFont(fontStream, 20.0);
fontStream.close();
}
let logoStream = openFile(mainLogoPath);
if(logoStream != null) {
logoImage = drawing.loadPNG(logoStream);
logoStream.close();
}
}
triggerNetworkEvent("ag.clientReady");
openAllGarages();
});
// ---------------------------------------------------------------------------
bindEventHandler("onResourceStart", thisResource, function(event, resource) {
if(gta.game == GAME_GTA_SA) {
gta.setDefaultInteriors(false);
gta.setCiviliansEnabled(false);
}
garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60);
addNetworkHandler("ag.passenger", enterVehicleAsPassenger);
triggerNetworkEvent("ag.clientStarted");
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.connectCamera", function(cameraPosition, cameraLookat) {
gta.fadeCamera(true);
gta.setCameraLookAt(cameraPosition, cameraLookat, true);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.restoreCamera", function() {
logToConsole(LOG_DEBUG, `[Asshat.Main] Camera restored`);
gta.restoreCamera(true);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.clearPeds", function() {
logToConsole(LOG_DEBUG, `[Asshat.Main] Clearing all self-owned peds ...`);
clearSelfOwnedPeds();
logToConsole(LOG_DEBUG, `[Asshat.Main] All self-owned peds cleared`);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.logo", function(state) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Server logo ${(state) ? "enabled" : "disabled"}`);
renderLogo = state;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.ambience", function(state) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`);
gta.setTrafficEnabled(state);
gta.setGenerateCarsAroundCamera(state);
if(gta.game != GAME_GTA_SA) {
gta.setCiviliansEnabled(state);
}
clearSelfOwnedPeds();
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.runCode", function(code, returnTo) {
let returnValue = "Nothing";
try {
returnValue = eval("(" + code + ")");
} catch(error) {
triggerNetworkEvent("ag.runCodeFail", returnTo, code);
return false;
}
triggerNetworkEvent("ag.runCodeSuccess", returnTo, code, returnValue);
});
// -------------------------------------------------------------------------
function enterVehicleAsPassenger() {
if(localPlayer.vehicle == null) {
let tempVehicle = getClosestVehicle(localPlayer.position);
if(tempVehicle != null) {
localPlayer.enterVehicle(tempVehicle, false);
}
}
}
// -------------------------------------------------------------------------
function getClosestVehicle(pos) {
return getVehicles().reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
}
// -------------------------------------------------------------------------
addNetworkHandler("ag.clearWeapons", function() {
logToConsole(LOG_DEBUG, `[Asshat.Main] Clearing weapons`);
localPlayer.clearWeapons();
forceWeapon = 0;
forceWeaponAmmo = 0;
forceWeaponClipAmmo = 0;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.giveWeapon", function(weaponId, ammo, active) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Giving weapon ${weaponId} with ${ammo} ammo`);
localPlayer.giveWeapon(weaponId, ammo, active);
forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(weaponId));
forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(weaponId));
forceWeapon = weaponId;
});
// ---------------------------------------------------------------------------
addEventHandler("OnElementStreamIn", function(event, element) {
switch(element.type) {
case ELEMENT_VEHICLE:
syncVehicleProperties(element);
break;
case ELEMENT_CIVILIAN:
syncCivilianProperties(element);
break;
case ELEMENT_PLAYER:
syncPlayerProperties(element);
break;
case ELEMENT_OBJECT:
//syncObjectProperties(element);
break;
default:
break;
}
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.blips", function(blipData) {
for(let i in blipData) {
allServerBlips.push(blipData[i]);
}
});
// ---------------------------------------------------------------------------
function showIslandBlips() {
for(let i in allServerBlips) {
let position = toVector3(allServerBlips[i][1], allServerBlips[i][2], allServerBlips[i][3]);
if(getIslandFromPosition(position) == getIslandFromPosition(localPlayer.position)) {
let tempBlip = createBlip(position, allServerBlips[i][0], allServerBlips[i][4], allServerBlips[i][5]);
currentServerBlips.push(tempBlip);
}
}
}
// ---------------------------------------------------------------------------
function getIslandFromPosition(position) {
switch(gta.game) {
case GAME_GTA_III:
if(position.x > 616) {
return 1;
} else if(position.x < -283) {
return 3;
}
return 2;
default:
return 0;
}
}
// ---------------------------------------------------------------------------
addEventHandler("onPedSpawn", function(event, ped) {
// Nasty workaround since localPlayer is null as the player spawns (reported as client bug #194)
setTimeout(initLocalPlayer, 500, ped);
});
// ---------------------------------------------------------------------------
function attemptToShowBlipsOnSpawn(ped) {
if(ped == localPlayer) {
showIslandBlips();
}
}
// ---------------------------------------------------------------------------
addNetworkHandler("ag.skin", function(skin) {
localPlayer.skin = skin;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.pedSkin", function(ped, skin) {
ped.skin = skin;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.position", function(position) {
localPlayer.position = position;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.heading", function(heading) {
localPlayer.heading = heading;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.interior", function(interior) {
localPlayer.interior = interior;
gta.cameraInterior = interior;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.dimension", function(dimension) {
localPlayer.dimension = dimension;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.removeFromVehicle", function() {
localPlayer.removeFromVehicle();
});
// ---------------------------------------------------------------------------
function initLocalPlayer(player) {
addEventHandler("onProcess", processEvent);
}
// ---------------------------------------------------------------------------
function processEvent(event, deltaTime) {
gta.clearMessages();
if(localPlayer != null) {
localPlayer.wantedLevel = 0;
let position = localPlayer.position;
if(localPlayer.vehicle) {
position = localPlayer.vehicle.position;
}
if(inVehicle && localPlayer.vehicle != null) {
if(!localPlayer.vehicle.engine) {
localPlayer.vehicle.velocity = toVector3(0.0, 0.0, 0.0);
localPlayer.vehicle.turnVelocity = toVector3(0.0, 0.0, 0.0);
if(parkedVehiclePosition) {
localPlayer.vehicle.position = parkedVehiclePosition;
localPlayer.vehicle.heading = parkedVehicleHeading;
}
} else {
if(parkedVehiclePosition) {
parkedVehiclePosition = false;
parkedVehicleHeading = false;
}
}
}
getElementsByType(ELEMENT_PICKUP).forEach(function(pickup) {
if(pickup.isOwner) {
destroyElement(pickup);
}
});
getElementsByType(ELEMENT_MARKER).forEach(function(sphere) {
if(position.distance(sphere.position) <= sphere.radius) {
if(!inSphere) {
inSphere = sphere;
triggerEvent("OnLocalPlayerEnterSphere", null, sphere);
//triggerNetworkEvent("ag.onPlayerEnterSphere", sphere);
}
} else {
if(inSphere) {
inSphere = false;
triggerEvent("OnLocalPlayerExitSphere", null, sphere);
//triggerNetworkEvent("ag.onPlayerExitSphere", sphere);
}
}
});
if(gta.game == GAME_GTA_SA) {
if(jobRouteStopSphere != null) {
if(position.distance(jobRouteStopSphere.position) <= 2.0) {
enteredJobRouteSphere();
}
}
}
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;
}
}
if(forceWeapon != 0) {
if(localPlayer.weapon != forceWeapon) {
localPlayer.weapon = forceWeapon;
localPlayer.setWeaponClipAmmunition(getWeaponSlot(forceWeapon), forceWeaponClipAmmo);
localPlayer.setWeaponAmmunition(getWeaponSlot(forceWeapon), forceWeaponAmmo);
} else {
forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(forceWeapon));
forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(forceWeapon));
}
} else {
if(localPlayer.weapon > 0) {
localPlayer.clearWeapons();
}
}
}
}
// ---------------------------------------------------------------------------
addEventHandler("OnDrawnHUD", function (event) {
if(!renderHUD) {
return false;
}
if(localPlayer == null) {
return false;
}
if(renderSmallGameMessage) {
if(smallGameMessageFont != null) {
if(smallGameMessageFont != "") {
smallGameMessageFont.render(smallGameMessageText, [0, gta.height-50], gta.width, 0.5, 0.0, smallGameMessageFont.size, smallGameMessageColour, true, true, false, true);
}
}
}
if(renderLogo) {
if(logoImage != null) {
drawing.drawRectangle(logoImage, logoPos, logoSize);
}
}
if(renderScoreboard) {
if(isKeyDown(SDLK_TAB)) {
processScoreboardRendering();
}
}
if(renderLabels) {
processLabelRendering();
}
if(renderItemActionDelay) {
//logToConsole(LOG_DEBUG, `Item action delay render enabled`);
if(itemActionDelayEnabled) {
//logToConsole(LOG_DEBUG, `Item action delay enabled`);
let finishTime = itemActionDelayStart+itemActionDelayDuration;
if(sdl.ticks >= finishTime) {
logToConsole(LOG_DEBUG, `Item action delay finish time reached`);
itemActionDelayEnabled = false;
itemActionDelayDuration = 0;
itemActionDelayStart = 0;
triggerNetworkEvent("ag.itemActionDelayComplete");
} else {
let progressWidth = itemActionDelaySize.x-Math.ceil((finishTime-sdl.ticks)/100);
logToConsole(LOG_DEBUG, `Item action delay in progress - ${Math.ceil((finishTime-sdl.ticks)/100)} - ${progressWidth}/${itemActionDelaySize.x}`);
drawing.drawRectangle(null, [itemActionDelayPosition.x-(itemActionDelaySize.x/2), itemActionDelayPosition.y-(itemActionDelaySize.y/2)], [progressWidth, itemActionDelaySize.y], COLOUR_LIME, COLOUR_LIME, COLOUR_LIME, COLOUR_LIME);
}
}
}
});
// ---------------------------------------------------------------------------
function openAllGarages() {
switch(gta.game) {
case GAME_GTA_III:
for(let i=0;i<=26;i++) {
openGarage(i);
}
break;
case GAME_GTA_VC:
for(let i=0;i<=32;i++) {
openGarage(i);
}
break;
case GAME_GTA_SA:
for(let i=0;i<=44;i++) {
openGarage(i);
}
break;
default:
break;
}
}
// ---------------------------------------------------------------------------
function closeAllGarages() {
switch(gta.game) {
case GAME_GTA_III:
for(let i=0;i<=26;i++) {
closeGarage(i);
}
break;
case GAME_GTA_VC:
for(let i=0;i<=32;i++) {
closeGarage(i);
}
break;
case GAME_GTA_SA:
for(let i=0;i<=44;i++) {
closeGarage(i);
}
break;
default:
break;
}
}
// ---------------------------------------------------------------------------
addNetworkHandler("ag.freeze", function(state) {
gui.showCursor(state, !state);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.control", function(controlState, cursorState = false) {
gui.showCursor(cursorState, controlState);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.cursortoggle", function() {
gui.showCursor(!gui.cursorEnabled, false);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.fadeCamera", function(state, time) {
gta.fadeCamera(state, time);
});
// ---------------------------------------------------------------------------
addEventHandler("OnPedWasted", function(event, wastedPed, killerPed, weapon, pedPiece) {
wastedPed.clearWeapons();
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.showBusStop", function(position, colour) {
if(gta.game == GAME_GTA_SA) {
jobRouteStopSphere = gta.createPickup(1318, position, 1);
} else {
jobRouteStopSphere = gta.createSphere(position, 3);
jobRouteStopSphere.colour = colour;
}
jobRouteStopBlip = gta.createBlip(position, 0, 2, colour);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.snow", function(fallingSnow, groundSnow) {
if(!isNull(snowing)) {
snowing = fallingSnow;
forceSnowing(groundSnow);
}
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.money", function(amount) {
localPlayer.money = amount;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.removeWorldObject", function(model, position, range) {
logToConsole(LOG_DEBUG, `Removing world object ${model} at X: ${position.x}, Y: ${position.x}, Z: ${position.x} with range of ${range}`);
gta.removeWorldObject(model, position, range);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.excludeGroundSnow", function(model) {
logToConsole(LOG_DEBUG, `Disabling ground snow for object model ${model}`);
groundSnow.excludeModel(model);
});
// ---------------------------------------------------------------------------
addEventHandler("OnLocalPlayerEnterSphere", function(event, sphere) {
if(sphere == jobRouteStopSphere) {
enteredJobRouteSphere();
}
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.smallGameMessage", function(text, colour, duration) {
if(smallGameMessageText != "") {
clearTimeout(smallGameMessageTimer);
}
smallGameMessageColour = colour;
smallGameMessageText = text;
smallGameMessageTimer = setTimeout(function() {
smallGameMessageText = "";
smallGameMessageColour = COLOUR_WHITE;
smallGameMessageTimer = null;
}, duration);
});
// ---------------------------------------------------------------------------
function enteredJobRouteSphere() {
triggerNetworkEvent("ag.arrivedAtBusStop");
destroyElement(jobRouteStopSphere);
destroyElement(jobRouteStopBlip);
jobRouteStopSphere = null;
jobRouteStopBlip = null;
}
// ---------------------------------------------------------------------------
addNetworkHandler("ag.jobType", function(tempJobType) {
logToConsole(LOG_INFO, `[Asshat.Main] Set local player job type to ${tempJobType}`);
localPlayerJobType = tempJobType;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.working", function(tempWorking) {
localPlayerWorking = tempWorking;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.spawned", function(client, state) {
isSpawned = state;
syncPlayerProperties(localPlayer);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.weaponDamageEvent", function(clientName, eventType) {
logToConsole(LOG_INFO, `[Asshat.Main] Set ${clientName} damage event type to ${eventType}`);
weaponDamageEvent[clientName] = eventType;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.weaponDamageEnabled", function(clientName, state) {
logToConsole(LOG_INFO, `[Asshat.Main] ${(state)?"Enabled":"Disabled"} damage from ${clientName}`);
weaponDamageEnabled[clientName] = state;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.mouseCamera", function(state) {
logToConsole(LOG_INFO, `[Asshat.Main] ${(state)?"Enabled":"Disabled"} mouse camera`);
mouseCameraEnabled = !mouseCameraEnabled;
SetStandardControlsEnabled(!mouseCameraEnabled);
});
// ---------------------------------------------------------------------------
function clearSelfOwnedPeds() {
logToConsole(LOG_DEBUG, `Clearing self-owned peds`);
getElementsByType(ELEMENT_CIVILIAN).forEach(function(ped) {
if(ped.isOwner) {
destroyElement(ped);
}
});
}
// ---------------------------------------------------------------------------
addNetworkHandler("ag.set2DRendering", function(hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState) {
renderHUD = hudState;
setHUDEnabled(hudState);
renderLabels = labelState;
renderSmallGameMessage = smallGameMessageState;
renderScoreboard = scoreboardState;
renderHotBar = hotBarState;
renderItemActionDelay = itemActionDelayState;
});
// ---------------------------------------------------------------------------
function getLocalPlayerVehicleSeat() {
for(let i = 0 ; i <= 4 ; i++) {
if(localPlayer.vehicle.getOccupant(i) == localPlayer) {
return i;
}
}
}
// ---------------------------------------------------------------------------
addEventHandler("OnPedInflictDamage", function(event, damagedPed, damagerEntity, weaponId, healthLoss, pedPiece) {
if(damagedPed == localPlayer) {
if(!weaponDamageEnabled[damagerEntity.name]) {
event.preventDefault();
triggerNetworkEvent(player, "ag.weaponDamage", damagerEntity, weaponId, pedPiece);
}
}
});
// ---------------------------------------------------------------------------
addEventHandler("OnLocalPlayerExitedVehicle", function(event, vehicle, seat) {
triggerNetworkEvent("ag.onPlayerExitVehicle");
if(inVehicleSeat) {
parkedVehiclePosition = false;
parkedVehicleHeading = false;
}
});
// ---------------------------------------------------------------------------
addEventHandler("OnLocalPlayerEnteredVehicle", function(event, vehicle, seat) {
triggerNetworkEvent("ag.onPlayerEnterVehicle");
if(inVehicleSeat == 0) {
if(inVehicle.owner != -1) {
inVehicle.engine = false;
if(!inVehicle.engine) {
parkedVehiclePosition = inVehicle.position;
parkedVehicleHeading = inVehicle.heading;
}
}
}
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.showItemActionDelay", function(duration) {
itemActionDelayDuration = duration;
itemActionDelayStart = sdl.ticks;
itemActionDelayEnabled = true;
logToConsole(LOG_DEBUG, `Item action delay event called. Duration: ${itemActionDelayDuration}, Start: ${itemActionDelayStart}, Render: ${renderItemActionDelay}`);
});
// ---------------------------------------------------------------------------
function getWeaponSlot(weaponId) {
return getGameData().weaponSlots[gta.game][weaponId];
}
// ---------------------------------------------------------------------------
addNetworkHandler("ag.drunkEffect", function(amount, duration) {
drunkEffectAmount = 0;
drunkEffectDurationTimer = setInterval(function() {
drunkEffectAmount = drunkEffectAmount;
if(drunkEffectAmount > 0) {
gta.SET_MOTION_BLUR(drunkEffectAmount);
} else {
clearInterval(drunkEffectDurationTimer);
drunkEffectDurationTimer = null;
}
}, 1000);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.clearPedState", function() {
localPlayer.clearObjective();
});
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -0,0 +1,80 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: messaging.js
// DESC: Provides messaging/textdraw functions and usage
// TYPE: Client (JavaScript)
// ===========================================================================
let smallGameMessageFont = null;
let smallGameMessageText = "";
let smallGameMessageColour = COLOUR_WHITE;
let smallGameMessageTimer = null;
// ===========================================================================
function initMessagingScript() {
logToConsole(LOG_DEBUG, "[Asshat.Messaging]: Initializing messaging script ...");
smallGameMessageFont = loadSmallGameMessageFont();
logToConsole(LOG_DEBUG, "[Asshat.Messaging]: Messaging script initialized!");
}
// ===========================================================================
function loadSmallGameMessageFont() {
let tempSmallGameMessageFont = null;
let fontStream = openFile("files/fonts/pricedown.ttf");
if(fontStream != null) {
tempSmallGameMessageFont = lucasFont.createFont(fontStream, 20.0);
fontStream.close();
}
return tempSmallGameMessageFont;
}
// ===========================================================================
function loadBigGameMessageFont() {
let tempBigGameMessageFont = null;
let fontStream = openFile("files/fonts/pricedown.ttf");
if(fontStream != null) {
tempBigGameMessageFont = lucasFont.createFont(fontStream, 28.0);
fontStream.close();
}
return tempBigGameMessageFont;
}
// ===========================================================================
function processSmallGameMessageRendering() {
if(renderSmallGameMessage) {
if(smallGameMessageFont != null) {
if(smallGameMessageFont != "") {
smallGameMessageFont.render(smallGameMessageText, [0, gta.height-50], gta.width, 0.5, 0.0, smallGameMessageFont.size, smallGameMessageColour, true, true, false, true);
}
}
}
}
// ===========================================================================
function showSmallGameMessage(text, colour, duration) {
logToConsole(LOG_DEBUG, `[Asshat.Messaging] Showing small game message '${text}' for ${duration}ms`);
if(smallGameMessageText != "") {
clearTimeout(smallGameMessageTimer);
}
smallGameMessageColour = colour;
smallGameMessageText = text;
smallGameMessageTimer = setTimeout(function() {
smallGameMessageText = "";
smallGameMessageColour = COLOUR_WHITE;
smallGameMessageTimer = null;
}, duration);
}
// ===========================================================================

View File

@@ -1,725 +0,0 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: mouse-camera.js
// DESC: Provides a freelook camera similar to SA for III and VC
// TYPE: Client (JavaScript)
// ===========================================================================
// CREDITS TO LUCASC190 FOR MAKING THE MOUSE CAMERA
// WALKING CODE ADDED BY VORTREX
function SetStandardControlsEnabled(bEnabled)
{
if (gta.standardControls === undefined)
{
console.warn("gta.standardControls not implemented");
return;
}
gta.standardControls = bEnabled;
}
function GetCurrentPlayerIndex()
{
return 0;
}
function GetPlayerPed(uiIndex)
{
if (uiIndex >= 1)
throw new Error("player index out of range");
return localPlayer;
}
function GetPedVehicle(pPed)
{
return pPed.vehicle;
}
let ENTITYTYPE_BUILDING = 1;
let ENTITYTYPE_VEHICLE = 2;
let ENTITYTYPE_PED = 3;
let ENTITYTYPE_OBJECT = 4;
let ENTITYTYPE_DUMMY = 5;
function GetEntityType(Entity)
{
if (Entity.isType(ELEMENT_BUILDING))
return ENTITYTYPE_BUILDING;
if (Entity.isType(ELEMENT_VEHICLE))
return ENTITYTYPE_VEHICLE;
if (Entity.isType(ELEMENT_PED))
return ENTITYTYPE_PED;
if (Entity.isType(ELEMENT_OBJECT))
return ENTITYTYPE_OBJECT;
//if (Entity.isType(ELEMENT_DUMMY))
// return ENTITYTYPE_DUMMY;
return undefined;
}
function GetPlaceableMatrix(pPlaceable)
{
if (pPlaceable == GetCamera())
return gta.cameraMatrix;
return pPlaceable.matrix;
}
function GetEntityModel(pEntity)
{
return pEntity;
}
function GetModelBoundingSphere(usModel)
{
return [usModel.boundingRadius, usModel.boundingCentre.x, usModel.boundingCentre.y, usModel.boundingCentre.z];
}
function GetMouseSpeed()
{
if (gui.cursorEnabled)
return [0,0];
let MouseSpeed = gta.getMouseSpeed();
return [MouseSpeed.x,-MouseSpeed.y];
}
function GetMouseSensitivity()
{
if (gta.getMouseSensitivity === undefined)
{
//console.error("gta.getMouseSensitivity not implemented");
return [0.0025,0.003];
}
let MouseSensitivity = gta.getMouseSensitivity();
return [MouseSensitivity.x,MouseSensitivity.y];
}
let GetCamera;
{
const Camera = Symbol();
GetCamera = function()
{
return Camera;
}
}
function AreEntityCollisionsEnabled(pEntity)
{
return pEntity.collisionsEnabled;
}
function SetEntityCollisionsEnabled(pEntity, bCollisionsEnabled)
{
pEntity.collisionsEnabled = bCollisionsEnabled;
}
function ProcessLineOfSight(vecStartX, vecStartY, vecStartZ, vecEndX, vecEndY, vecEndZ, bCheckBuildings, bCheckVehicles, bCheckPeds, bCheckObjects, bCheckDummies, bCheckSeeThroughStuff, bIgnoreSomeObjectsForCamera)
{
if (gta.processLineOfSight === undefined)
{
console.warn("gta.processLineOfSight not implemented");
return [null];
}
let Result = gta.processLineOfSight([vecStartX, vecStartY, vecStartZ], [vecEndX, vecEndY, vecEndZ], bCheckBuildings, bCheckVehicles, bCheckPeds, bCheckObjects, bCheckDummies, bCheckSeeThroughStuff, bIgnoreSomeObjectsForCamera);
if (Result == null)
return [null];
return [Result.position.x, Result.position.y ,Result.position.z, Result.normal.x, Result.normal.y ,Result.normal.z, Result.entity];
}
function SetPlaceableMatrix(pPlaceable, mat)
{
if (pPlaceable == GetCamera())
{
gta.setCameraMatrix(mat);
return;
}
pPlaceable.matrix = mat;
}
const UpdateCamera = gta.updateCamera;
let GetTickCount;
{
let FrameCount = 0;
setInterval(() =>
{
++FrameCount;
}, 0);
let GTAFrameCount = 0;
addEventHandler("OnProcess", (event, deltaTime) =>
{
++GTAFrameCount;
});
GetTickCount = function(bGTA, bFrames)
{
if (bFrames)
return bGTA ? GTAFrameCount : FrameCount;
else
return bGTA ? gta.tickCount : sdl.ticks;
}
}
function easingSinusoidalInOut(t,b,c,d)//TODO: Move this to MathUtil.js
{
return -c/2 * (Math.cos((Math.PI)*t/d) - 1) + b;
}
//TODO: extract
function applyMultiplierTimeStep(m,t)//TODO: Move this to MathUtil.js
{
return Math.max(Math.min(1.0-(1.0-m)*(t),1),0);
}
//TODO: getOffset
//TODO: round
//TODO: getNumberBetween
//TODO: split
//TODO: isWhiteSpaceCharacter
//TODO: isControlCharacter
//TODO: alert
//TODO: confirm
const identityMatrix = new Matrix4x4();
if (identityMatrix.setIdentity === undefined)
{
identityMatrix.m11 = 1;
identityMatrix.m12 = 0;
identityMatrix.m13 = 0;
identityMatrix.m14 = 0;
identityMatrix.m21 = 0;
identityMatrix.m22 = 1;
identityMatrix.m23 = 0;
identityMatrix.m24 = 0;
identityMatrix.m31 = 0;
identityMatrix.m32 = 0;
identityMatrix.m33 = 1;
identityMatrix.m34 = 0;
identityMatrix.m41 = 0;
identityMatrix.m42 = 0;
identityMatrix.m43 = 0;
identityMatrix.m44 = 1;
}
const cameraIdentityMatrix = new Matrix4x4();
cameraIdentityMatrix.m11 = -1;
cameraIdentityMatrix.m12 = 0;
cameraIdentityMatrix.m13 = 0;
cameraIdentityMatrix.m14 = 0;
cameraIdentityMatrix.m21 = 0;
cameraIdentityMatrix.m22 = 1;
cameraIdentityMatrix.m23 = 0;
cameraIdentityMatrix.m24 = 0;
cameraIdentityMatrix.m31 = 0;
cameraIdentityMatrix.m32 = 0;
cameraIdentityMatrix.m33 = 1;
cameraIdentityMatrix.m34 = 0;
cameraIdentityMatrix.m41 = 0;
cameraIdentityMatrix.m42 = 0;
cameraIdentityMatrix.m43 = 0;
cameraIdentityMatrix.m44 = 1;
function createMultipliedMatrix()
{
let matrix = new Matrix4x4();
matrix.setMultiply.apply(matrix, arguments);
return matrix;
}
function createXRotationMatrix(x)
{
let matrix = new Matrix4x4();
matrix.setRotateX(x);
return matrix;
}
function createYRotationMatrix(x)
{
let matrix = new Matrix4x4();
matrix.setRotateY(x);
return matrix;
}
function createZRotationMatrix(z)
{
let matrix = new Matrix4x4();
matrix.setRotateZ(z);
return matrix;
}
function createTranslationMatrix(x,y,z)
{
let matrix = new Matrix4x4();
matrix.setTranslate([x,y,z]);
return matrix;
}
//TODO: createScaleMatrix
function getDotProduct(x,y,z,x2,y2,z2)
{
return x*x2 + y*y2 + z*z2;
}
function getCrossProduct(x,y,z,x2,y2,z2)
{
return [y*z2-z*y2, z*x2-x*z2, x*y2-y*x2];
}
function getLength(x,y,z)
{
return Math.sqrt(getDotProduct(x,y,z,x,y,z));
}
function normalise(x,y,z)
{
let length = getLength(x,y,z);
if (length == 0)
throw new Error("an attempt was made to normalise a three dimensional vector with a length of zero");
return [x/length, y/length, z/length];
}
function createLookAtLHMatrix(eyeX, eyeY, eyeZ, atX, atY, atZ, upX,upY,upZ)
{
let matrix = new Matrix4x4();
let [lookX, lookY, lookZ] = normalise(atX-eyeX,atY-eyeY,atZ-eyeZ);
let [rightX, rightY, rightZ] = normalise.apply(null,getCrossProduct(upX,upY,upZ,lookX, lookY, lookZ));
[upX,upY,upZ] = getCrossProduct(lookX, lookY, lookZ,rightX, rightY, rightZ);
matrix.m11 = rightX;
matrix.m12 = rightY;
matrix.m13 = rightZ;
matrix.m14 = 0;
matrix.m21 = lookX;
matrix.m22 = lookY;
matrix.m23 = lookZ;
matrix.m24 = 0;
matrix.m31 = upX;
matrix.m32 = upY;
matrix.m33 = upZ;
matrix.m34 = 0;
matrix.m41 = eyeX;
matrix.m42 = eyeY;
matrix.m43 = eyeZ;
matrix.m44 = 1;
matrix.m41 = eyeX;
matrix.m42 = eyeY;
matrix.m43 = eyeZ;
matrix.m44 = 1;
return matrix;
}
function getDifferenceBetweenAngles(current,target)
{
let f = (((target-current)+Math.PI)/(Math.PI*2));
return ((f-Math.floor(f))*(Math.PI*2))-Math.PI;
}
let easeCamera = false;
let easeStartTicks;
let easeDuration;
let easeStartPosX, easeStartPosY, easeStartPosZ;
let easeStartLookX, easeStartLookY, easeStartLookZ;
let easeStartUpX, easeStartUpY, easeStartUpZ;
function getCameraPositionInfo(matrix)
{
return [matrix.m41, matrix.m42, matrix.m43, matrix.m21, matrix.m22, matrix.m23, matrix.m31, matrix.m32, matrix.m33];
}
function startCameraEase()
{
easeCamera = true;
easeStartTicks = GetTickCount(true,false);
easeDuration = 1000;
let matrix = GetPlaceableMatrix(GetCamera());
[easeStartPosX, easeStartPosY, easeStartPosZ, easeStartLookX, easeStartLookY, easeStartLookZ, easeStartUpX, easeStartUpY, easeStartUpZ] = getCameraPositionInfo(matrix);
}
function applyCameraEase(matrix)
{
if (!easeCamera)
return matrix;
let ease = (GetTickCount(true,false)-easeStartTicks)/easeDuration;
if (ease < 1)
{
ease = easingSinusoidalInOut(ease,0,1,1);
let [newPosX, newPosY, newPosZ, newLookX, newLookY, newLookZ, newUpX, newUpY, newUpZ] = getCameraPositionInfo(matrix);
let easePosX = easeStartPosX+(newPosX-easeStartPosX)*ease;
let easePosY = easeStartPosY+(newPosY-easeStartPosY)*ease;
let easePosZ = easeStartPosZ+(newPosZ-easeStartPosZ)*ease;
let easeLookX = easeStartLookX+(newLookX-easeStartLookX)*ease;
let easeLookY = easeStartLookY+(newLookY-easeStartLookY)*ease;
let easeLookZ = easeStartLookZ+(newLookZ-easeStartLookZ)*ease;
let easeUpX = easeStartUpX+(newUpX-easeStartUpX)*ease;
let easeUpY = easeStartUpY+(newUpY-easeStartUpY)*ease;
let easeUpZ = easeStartUpZ+(newUpZ-easeStartUpZ)*ease;
return createLookAtLHMatrix(easePosX,easePosY,easePosZ,easePosX+easeLookX,easePosY+easeLookY,easePosZ+easeLookZ,easeUpX,easeUpY,easeUpZ);
}
return matrix;
}
function isCameraEasing()
{
return easeCamera && GetTickCount(true,false) < (easeStartTicks+easeDuration);
}
let oldCameraTarget = null;
let OldPosition = null;//2019 Lucas was here!
let cameraRotZ;
let cameraRotY;
function getCameraTarget()
{
let playerPed = GetPlayerPed(GetCurrentPlayerIndex());
let vehicle = GetPedVehicle(playerPed);
if (vehicle != null)
return vehicle;
if (playerPed != null)
{
//if (playerPed.health <= 1)//Breaks because of fade//2019 Lucas was here!
// return null;
return playerPed;
}
return null;
}
function isRelativeToTarget(target)
{
if (GetEntityType(target) == ENTITYTYPE_PED)
return false;
return false
}
function isClipped(target)
{
if (GetEntityType(target) == ENTITYTYPE_PED)
return true;
return true;
}
//2019 Lucas was here!
function ShouldReturnToRestRotation(Target)
{
if (GetEntityType(Target) == ENTITYTYPE_PED)
return false;
return true;
}
function getCameraRestRotation(target)
{
let targetMatrix = GetPlaceableMatrix(target);
let rotZ;
if (isRelativeToTarget(target))
rotZ = 0;
else
rotZ = -Math.atan2(targetMatrix.m21,targetMatrix.m22);
let rotY = -0.2;
return [rotZ, rotY];
}
function resetCameraRotation()
{
[cameraRotZ, cameraRotY] = getCameraRestRotation(getCameraTarget());
}
//2019 Lucas was here!
let DeltaTime = 0;
addEventHandler("OnProcess", (event, deltaTime) =>
{
DeltaTime = deltaTime;
if(!localPlayer) {
return false;
}
if(gta.game >= GAME_GTA_SA) {
// We don't need this for GTA SA+
return false;
}
/*
if(localPlayer.vehicle == null) {
let newAngle = 0.0;
let moveKeyHeld = false;
if(isKeyDown(SDLK_w)) {
newAngle = Math.PI;
moveKeyHeld = true;
if(isKeyDown(SDLK_a)) {
newAngle = newAngle+Math.PI/4;
} else if(isKeyDown(SDLK_d)) {
newAngle = newAngle-Math.PI/4;
}
} else if(isKeyDown(SDLK_s)) {
newAngle = Math.PI*2;
moveKeyHeld = true;
if(isKeyDown(SDLK_a)) {
newAngle = newAngle-Math.PI/4;
} else if(isKeyDown(SDLK_d)) {
newAngle = newAngle+Math.PI/4;
}
} else if(isKeyDown(SDLK_a)) {
newAngle = -Math.PI/2;
moveKeyHeld = true;
} else if(isKeyDown(SDLK_d)) {
newAngle = Math.PI/2;
moveKeyHeld = true;
}
if(moveKeyHeld && !gui.cursorEnabled) {
localPlayer.heading = cameraAngle + newAngle;
}
if(sdl.getModState()&KMOD_ALT && !gui.cursorEnabled) {
if(moveKeyHeld) {
let position = getPosInFrontOfPos(localPlayer.position, localPlayer.heading, 1.0);
localPlayer.walkTo(vec3ToVec2(position));
isWalking = true;
triggerNetworkEvent("ag.walk", true);
} else {
isWalking = false;
triggerNetworkEvent("ag.walk", false);
}
} else {
isWalking = false;
triggerNetworkEvent("ag.walk", false);
}
}
*/
});
let IdleTime = 0;//2019 Lucas was here!
function processReturnToRestRotation()
{
//resetCameraRotation();//2019 Lucas was here!
//2019 Lucas was here!
let Target = getCameraTarget();
if (!ShouldReturnToRestRotation(Target))
return;
IdleTime += DeltaTime;
if (IdleTime > 1.5)
{
let Velocity = Target.velocity;
let Matrix = Target.matrix;
let Speed = getDotProduct(Velocity.x,Velocity.y,Velocity.z,Matrix.getElement(1*4+0),Matrix.getElement(1*4+1),Matrix.getElement(1*4+2));
let AbsSpeed = Math.abs(Speed);
let Multiplier = Math.min(AbsSpeed/0.75, 1);
if (Multiplier != 0)
{
let [TargetCameraRotZ2, TargetCameraRotY2] = getCameraRestRotation(Target);
if (Speed < 0)
TargetCameraRotZ2 += Math.PI;
let TimeStep = gta.timeStep/50*60;
cameraRotZ += getDifferenceBetweenAngles(cameraRotZ,TargetCameraRotZ2)*applyMultiplierTimeStep(1/20,TimeStep)*Multiplier;
cameraRotY += getDifferenceBetweenAngles(cameraRotY,TargetCameraRotY2)*applyMultiplierTimeStep(1/20,TimeStep)*Multiplier;
}
}
}
function cancelReturnToRestRotation()
{
IdleTime = 0;//2019 Lucas was here!
}
let distance;
let zIncrease;
function getCameraOffsetInfo(target)
{
if (GetEntityType(target) == ENTITYTYPE_PED)
{
let distance = 4;
let zIncrease = 0.8;
let offsetX = 0;
let offsetY = 0;
let offsetZ = 0;
return [distance, zIncrease, offsetX, offsetY, offsetZ];
}
let model = GetEntityModel(target);
let [radius] = GetModelBoundingSphere(model);
let minDistance;
let maxDistance;
let minZIncrease;
let maxZIncrease;
let minRadius;
let maxRadius;
let offsetX;
let offsetY;
let offsetZ;
if (radius <= 3.0535011291504)
{
minDistance = 4;
maxDistance = 8;
minZIncrease = 0.5;
maxZIncrease = 1;
minRadius = 2;
maxRadius = 3.0535011291504;
}
else
{
minDistance = 8;
maxDistance = 16;
minZIncrease = 1;
maxZIncrease = 2;
minRadius = 3.05350112915042;
maxRadius = 6.3955960273743;
}
offsetX = 0;
offsetY = 0;
offsetZ = 0;
distance = minDistance+(radius-minRadius)/(maxRadius-minRadius)*(maxDistance-minDistance);
zIncrease = minZIncrease+(radius-minRadius)/(maxRadius-minRadius)*(maxZIncrease-minZIncrease);
return [distance, zIncrease, offsetX, offsetY, offsetZ];
}
function update()
{
let target = getCameraTarget();
if (target != null)
{
if (oldCameraTarget != target)
{
//if (oldCameraTarget != null)//2019 Lucas was here!
let Position = target.position;
if (OldPosition == null || getLength(Position.x-OldPosition.x,Position.y-OldPosition.y,Position.z-OldPosition.z) < 10)
startCameraEase()
resetCameraRotation()
}
let [mouseSpeedX, mouseSpeedY] = GetMouseSpeed();
let [mouseSensitivityX, mouseSensitivityY] = GetMouseSensitivity();
mouseSpeedX = mouseSpeedX*mouseSensitivityX*2;
mouseSpeedY = mouseSpeedY*mouseSensitivityY*2;
if (mouseSpeedX == 0 && mouseSpeedY == 0)
{
processReturnToRestRotation();
}
else
{
cameraRotZ = cameraRotZ-mouseSpeedX;
cameraRotY = cameraRotY-mouseSpeedY;
cancelReturnToRestRotation();
}
cameraRotY = Math.max(cameraRotY,-Math.PI/2+0.01);
if (GetEntityType(target) != ENTITYTYPE_PED)
cameraRotY = Math.min(cameraRotY,Math.PI/8.5);//2019 Lucas was here!
else
cameraRotY = Math.min(cameraRotY,Math.PI/4);
let camera = GetCamera();
let targetMatrix = GetPlaceableMatrix(target);
let [distance, zIncrease, offsetX, offsetY, offsetZ] = getCameraOffsetInfo(target);
let offsetTranslationMatrix = createTranslationMatrix(offsetX, offsetY, offsetZ);
targetMatrix = createMultipliedMatrix(offsetTranslationMatrix,targetMatrix);
let targetPosX, targetPosY, targetPosZ;
if (isRelativeToTarget(target))
[targetPosX, targetPosY, targetPosZ] = [0,0,0];
else
[targetPosX, targetPosY, targetPosZ] = [targetMatrix.m41,targetMatrix.m42,targetMatrix.m43];
let distanceTranslationMatrix = createTranslationMatrix(0,-distance,0);
targetPosZ = targetPosZ+zIncrease;
let targetTranslationMatrix = createTranslationMatrix(targetPosX, targetPosY, targetPosZ);
let offsetRotationX = createXRotationMatrix(cameraRotY);
let offsetRotationZ = createZRotationMatrix(cameraRotZ);
let cameraMatrix = createMultipliedMatrix(cameraIdentityMatrix,distanceTranslationMatrix,offsetRotationX,offsetRotationZ,targetTranslationMatrix);
if (isRelativeToTarget(target))
{
cameraMatrix = createMultipliedMatrix(cameraMatrix,targetMatrix);
targetTranslationMatrix = createMultipliedMatrix(targetTranslationMatrix,targetMatrix);
}
if (isClipped(target))
{
let startX = targetTranslationMatrix.m41;
let startY = targetTranslationMatrix.m42;
let startZ = targetTranslationMatrix.m43;
let endX = cameraMatrix.m41;
let endY = cameraMatrix.m42;
let endZ = cameraMatrix.m43;
let checkBuildings = true;
let checkVehicles = true;
let checkPeds = true;
let checkObjects = true;
let checkDummies = false;
let checkSeeThroughStuff = false;
let ignoreSomeObjectsForCamera = true;
let collisionsEnabled = AreEntityCollisionsEnabled(target);
if (collisionsEnabled)
SetEntityCollisionsEnabled(target,false);
let [positionX,positionY,positionZ,normalX,normalY,normalZ,targetEntity] = ProcessLineOfSight(startX,startY,startZ,endX,endY,endZ,checkBuildings,checkVehicles,checkPeds,checkObjects,checkDummies,checkSeeThroughStuff,ignoreSomeObjectsForCamera);
if (collisionsEnabled)
SetEntityCollisionsEnabled(target,true);
if (positionX != null)
{
//2019 Lucas was here!
let Distance = 0.3;
positionX += normalX*Distance;
positionY += normalY*Distance;
positionZ += normalZ*Distance;
cameraMatrix.m41 = positionX;
cameraMatrix.m42 = positionY;
cameraMatrix.m43 = positionZ;
}
}
if (isCameraEasing())
cameraMatrix = applyCameraEase(cameraMatrix);
SetPlaceableMatrix(camera,cameraMatrix);
UpdateCamera(camera);
}
oldCameraTarget = target;
OldPosition = (target != null) ? target.position : null;//2019 Lucas was here!
return target != null;
}
addEventHandler("OnCameraProcess", (event) =>
{
if(mouseCameraEnabled) {
update();
event.preventDefault();
}
});
function getPosInFrontOfPos(pos, angle, distance) {
let x = (pos.x+((Math.cos(angle+(Math.PI/2)))*distance));
let y = (pos.y+((Math.sin(angle+(Math.PI/2)))*distance));
let z = pos.z;
return new Vec3(x,y,z);
}
function vec3ToVec2(pos) {
return new Vec2(pos[0], pos[1]);
}
/*
addEventHandler("OnEntityProcess", function(event, entity) {
if(entity.type == ELEMENT_PLAYER) {
if(entity != localPlayer) {
let isPlayerWalking = entity.getData("ag.walk");
if(isPlayerWalking == true) {
let position = getPosInFrontOfPos(entity.position, entity.heading, 1.0);
entity.walkTo(position);
}
}
}
});
function getHeadingFromPosToPos(pos1, pos2) {
let x = pos2.x-pos1.x;
let y = pos2.y-pos1.y;
let rad = Math.atan2(y, x);
let deg = radToDeg(rad);
deg -= 90;
deg = deg % 360;
return degToRad(deg);
}
*/

View File

@@ -1,8 +1,8 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: nametags.js
// DESC: Provides nametag rendering
// TYPE: Client (JavaScript)
@@ -20,31 +20,52 @@ let playerColours = {};
let playerPaused = {};
let playerPing = {};
// -------------------------------------------------------------------------
// ===========================================================================
addEventHandler("OnResourceReady", function(event, resource) {
if (resource == thisResource) {
nametagFont = lucasFont.createDefaultFont(12.0, "Roboto", "Light");
afkStatusFont = lucasFont.createDefaultFont(18.0, "Roboto", "Light");
}
});
function initNameTagScript() {
logToConsole(LOG_DEBUG, "[Asshat.NameTag]: Initializing nametag script ...");
nametagFont = loadNameTagFont();
afkStatusFont = loadPausedStatusFont();
logToConsole(LOG_DEBUG, "[Asshat.NameTag]: Nametag script initialized!");
}
// -------------------------------------------------------------------------
// ===========================================================================
addNetworkHandler("ag.nametag", function(clientName, characterName, colour, paused, ping) {
function loadNameTagFont() {
return lucasFont.createDefaultFont(12.0, "Roboto", "Light");
}
// ===========================================================================
function loadPausedStatusFont() {
return lucasFont.createDefaultFont(18.0, "Roboto", "Light");
}
// ===========================================================================
function updatePlayerNameTag(clientName, characterName, colour, paused, ping) {
playerNames[clientName] = characterName;
playerColours[clientName] = colour;
playerPaused[clientName] = paused;
playerPing[clientName] = ping;
});
// -------------------------------------------------------------------------
if(gta.game == GAME_GTA_IV) {
let client = getPlayerFromParams(clientName);
if(client != false) {
if(client.player != null) {
client.player.setNametag(characterName, colour);
}
}
}
}
addNetworkHandler("ag.ping", function(clientName, ping) {
// ===========================================================================
function updatePlayerPing(clientName, ping) {
playerPing[clientName] = ping;
});
}
// -------------------------------------------------------------------------
// ===========================================================================
function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk, skin) {
if(nametagFont == null) {
@@ -75,9 +96,9 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
let hx = x-width/2;
let hy = y-10/2;
let colourB = toColour(0, 0, 0, Math.floor(255.0*alpha)); // Background colour (black)
drawing.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB);
let colour = toColour(Math.floor(255.0*alpha), Math.floor(255.0-(health*255.0)), Math.floor(health*255.0), 0); // Health bar colour (varies, depending on health)
drawing.drawRectangle(null, [hx+2, hy+2], [(width-4)*health, 10-6], colour, colour, colour, colour);
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)
graphics.drawRectangle(null, [hx+2, hy+2], [(width-4)*health, 10-6], colour, colour, colour, colour);
}
// Armour Bar
@@ -88,9 +109,9 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
let hx = x-width/2;
let hy = y-10/2;
let colourB = toColour(255, 0, 0, 0); // Background colour (black)
drawing.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)
drawing.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;
@@ -113,7 +134,7 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function updateNametags(element) {
if(localPlayer != null) {
@@ -166,7 +187,7 @@ function updateNametags(element) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function getClientFromPlayer(player) {
getClients().forEach(function(client) {
@@ -176,9 +197,9 @@ function getClientFromPlayer(player) {
});
}
// -------------------------------------------------------------------------
// ===========================================================================
addEventHandler("OnDrawnHUD", function(event) {
function processNameTagRendering(event) {
if(gta.game >= GAME_GTA_IV) {
return false;
}
@@ -188,12 +209,12 @@ addEventHandler("OnDrawnHUD", function(event) {
updateNametags(player);
}
});
});
}
// -------------------------------------------------------------------------
// ===========================================================================
function createColour(alpha, red, green, blue) {
return alpha << 24 | red << 16 | green << 8 | blue;
}
// -------------------------------------------------------------------------
// ===========================================================================

View File

@@ -1,8 +1,8 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: scoreboard.js
// DESC: Provides scoreboard features and rendering
// TYPE: Client (JavaScript)
@@ -15,67 +15,85 @@ let pausedColour = COLOUR_RED;
let scoreboardKey = SDLK_TAB;
// -------------------------------------------------------------------------
// ===========================================================================
bindEventHandler("OnResourceReady", thisResource, function(event, resource) {
scoreBoardTitleFont = lucasFont.createDefaultFont(22.0, "Roboto", "Regular");
scoreBoardListFont = lucasFont.createDefaultFont(12.0, "Roboto", "Light");
});
function initScoreBoardScript() {
logToConsole(LOG_DEBUG, "[Asshat.ScoreBoard]: Initializing scoreboard script ...");
scoreBoardTitleFont = initScoreBoardTitleFont();
scoreBoardListFont = initScoreBoardListFont();
logToConsole(LOG_DEBUG, "[Asshat.ScoreBoard]: Scoreboard script initialized!");
}
// -------------------------------------------------------------------------
// ===========================================================================
function processScoreboardRendering() {
if(scoreBoardListFont != null && scoreBoardTitleFont != null) {
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);
scoreBoardTitleFont.render("PLAYERS", [game.width/2, scoreboardStart-50], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
function initScoreBoardTitleFont() {
return lucasFont.createDefaultFont(22.0, "Roboto", "Regular");
}
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);
// ===========================================================================
let clients = getClients();
for(let i in clients) {
if(!clients[i].console) {
let name = clients[i].name;
let colour = COLOUR_WHITE;
let paused = false;
let ping = "-1";
function initScoreBoardListFont() {
return lucasFont.createDefaultFont(12.0, "Roboto", "Light");
}
if(typeof playerNames[clients[i].name] != "undefined") {
name = playerNames[clients[i].name];
}
// ===========================================================================
if(typeof playerPaused[clients[i].name] != "undefined") {
paused = playerPaused[clients[i].name];
}
function processScoreBoardRendering() {
if(renderScoreBoard) {
if(isKeyDown(SDLK_TAB)) {
if(scoreBoardListFont != null && scoreBoardTitleFont != null) {
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);
scoreBoardTitleFont.render("PLAYERS", [game.width/2, scoreboardStart-50], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
if(typeof playerColours[clients[i].name] != "undefined") {
colour = playerColours[clients[i].name];
}
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);
if(typeof playerPing[clients[i].name] != "undefined") {
ping = toString(playerPing[clients[i].name]);
}
let clients = getClients();
for(let i in clients) {
if(!clients[i].console) {
let name = clients[i].name;
let colour = COLOUR_WHITE;
let paused = false;
let ping = "-1";
// Player ID
let text = String(clients[i].index);
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);
if(typeof playerNames[clients[i].name] != "undefined") {
name = playerNames[clients[i].name];
}
// Player Name
text = name;
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);
if(typeof playerPaused[clients[i].name] != "undefined") {
paused = playerPaused[clients[i].name];
}
// Ping
text = ping;
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);
if(typeof playerColours[clients[i].name] != "undefined") {
colour = playerColours[clients[i].name];
}
// PAUSED Status (depends on resource "afk")
if(paused == true) {
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);
if(typeof playerPing[clients[i].name] != "undefined") {
ping = toString(playerPing[clients[i].name]);
}
// Player ID
let text = String(clients[i].index);
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);
// Player Name
text = name;
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);
// Ping
text = ping;
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);
// PAUSED Status (depends on resource "afk")
if(paused == true) {
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);
}
}
}
}
}

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

@@ -0,0 +1,245 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: server.js
// DESC: Provides server communication and cross-endpoint operations
// TYPE: Client (JavaScript)
// ===========================================================================
function initServerScript() {
logToConsole(LOG_DEBUG, "[Asshat.Server]: Initializing server script ...");
addAllNetworkHandlers();
logToConsole(LOG_DEBUG, "[Asshat.Server]: Server script initialized!");
}
// ===========================================================================
function addAllNetworkHandlers() {
logToConsole(LOG_DEBUG, "[Asshat.Server]: Adding network handlers ...");
addNetworkHandler("ag.smallGameMessage", showSmallGameMessage);
addNetworkHandler("ag.working", setLocalPlayerWorkingState);
addNetworkHandler("ag.jobType", setLocalPlayerJobType);
addNetworkHandler("ag.passenger", enterVehicleAsPassenger);
addNetworkHandler("ag.freeze", setLocalPlayerFrozenState);
addNetworkHandler("ag.control", setLocalPlayerControlState);
addNetworkHandler("ag.fadeCamera", fadeLocalCamera);
addNetworkHandler("ag.removeFromVehicle", removeLocalPlayerFromVehicle);
addNetworkHandler("ag.clearPeds", clearLocalPlayerOwnedPeds);
addNetworkHandler("ag.restoreCamera", restoreLocalCamera);
addNetworkHandler("ag.cameraLookAt", setLocalCameraLookAt);
addNetworkHandler("ag.logo", setServerLogoRenderState);
addNetworkHandler("ag.ambience", setCityAmbienceState);
addNetworkHandler("ag.runCode", runClientCode);
addNetworkHandler("ag.clearWeapons", clearLocalPlayerWeapons);
addNetworkHandler("ag.giveWeapon", giveLocalPlayerWeapon);
addNetworkHandler("ag.position", setLocalPlayerPosition);
addNetworkHandler("ag.heading", setLocalPlayerHeading);
addNetworkHandler("ag.interior", setLocalPlayerInterior);
addNetworkHandler("ag.showJobRouteStop", showJobRouteStop);
addNetworkHandler("ag.snow", setSnowState);
addNetworkHandler("ag.health", setLocalPlayerHealth);
addNetworkHandler("ag.skinSelect", toggleSkinSelect);
addNetworkHandler("ag.hotbar", updatePlayerHotBar);
addNetworkHandler("ag.pedSpeech", playPedSpeech);
addNetworkHandler("ag.clearPedState", clearLocalPedState);
addNetworkHandler("ag.drunkEffect", setLocalPlayerDrunkEffect);
addNetworkHandler("ag.showItemActionDelay", showItemActionDelay);
addNetworkHandler("ag.set2DRendering", setPlayer2DRendering);
addNetworkHandler("ag.mouseCursor", setMouseCursorState);
addNetworkHandler("ag.mouseCamera", setMouseCameraState);
addNetworkHandler("ag.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
addNetworkHandler("ag.weaponDamageEvent", setPlayerWeaponDamageEvent);
addNetworkHandler("ag.spawned", onServerSpawnedPlayer);
addNetworkHandler("ag.money", setLocalPlayerCash);
addNetworkHandler("ag.excludeGroundSnow", excludeModelFromGroundSnow);
addNetworkHandler("ag.removeWorldObject", removeWorldObject);
addNetworkHandler("ag.delKeyBind", unBindAccountKey);
addNetworkHandler("ag.addKeyBind", bindAccountKey);
addNetworkHandler("ag.nametag", updatePlayerNameTag);
addNetworkHandler("ag.ping", updatePlayerPing);
addNetworkHandler("ag.m", receiveChatBoxMessageFromServer);
addNetworkHandler("ag.chatScrollLines", setChatScrollLines);
addNetworkHandler("ag.radioStream", playStreamingRadio);
addNetworkHandler("ag.radioVolume", setStreamingRadioVolume);
addNetworkHandler("ag.veh.lights", toggleVehicleLights);
addNetworkHandler("ag.veh.engine", toggleVehicleEngine);
addNetworkHandler("ag.veh.sync", syncVehicleProperties);
addNetworkHandler("ag.civ.sync", syncCivilianProperties);
addNetworkHandler("ag.plr.sync", syncPlayerProperties);
addNetworkHandler("ag.obj.sync", syncObjectProperties);
addNetworkHandler("ag.veh.repair", repairVehicle);
}
// ===========================================================================
function sendResourceReadySignalToServer() {
triggerNetworkEvent("ag.clientReady");
}
// ===========================================================================
function sendResourceStartedSignalToServer() {
triggerNetworkEvent("ag.clientStarted");
}
// ===========================================================================
function sendResourceStoppedSignalToServer() {
triggerNetworkEvent("ag.clientStopped");
}
// ===========================================================================
function setPlayer2DRendering(hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`);
renderHUD = hudState;
setHUDEnabled(hudState);
renderLabels = labelState;
renderSmallGameMessage = smallGameMessageState;
renderScoreBoard = scoreboardState;
renderHotBar = hotBarState;
renderItemActionDelay = itemActionDelayState;
}
// ===========================================================================
function onServerSpawnedPlayer(state) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Setting spawned state to ${state}`);
isSpawned = state;
if(state) {
if(gta.game == GAME_GTA_III) {
gta.SET_PLAYER_NEVER_GETS_TIRED(gta.GET_PLAYER_ID(), 0);
gta.setGameStat(STAT_PROGRESSMADE, 9999);
gta.setGameStat(STAT_TOTALPROGRESSINGAME, 9999);
}
if(gta.game == GAME_GTA_VC) {
gta.SET_PLAYER_NEVER_GETS_TIRED(gta.GET_PLAYER_ID(), 0);
gta.setGameStat(STAT_PROGRESSMADE, 9999);
gta.setGameStat(STAT_TOTALPROGRESSINGAME, 9999);
gta.REQUEST_ANIMATION("bikev");
gta.REQUEST_ANIMATION("bikeh");
gta.REQUEST_ANIMATION("biked");
gta.REQUEST_ANIMATION("knife");
gta.REQUEST_ANIMATION("python");
gta.REQUEST_ANIMATION("shotgun");
gta.REQUEST_ANIMATION("buddy");
gta.REQUEST_ANIMATION("tec");
gta.REQUEST_ANIMATION("uzi");
gta.REQUEST_ANIMATION("rifle");
gta.REQUEST_ANIMATION("m60");
gta.REQUEST_ANIMATION("sniper");
gta.REQUEST_ANIMATION("grenade");
gta.REQUEST_ANIMATION("flame");
gta.REQUEST_ANIMATION("medic");
gta.REQUEST_ANIMATION("sunbathe");
gta.REQUEST_ANIMATION("playidles");
gta.REQUEST_ANIMATION("riot");
gta.REQUEST_ANIMATION("strip");
gta.REQUEST_ANIMATION("lance");
gta.REQUEST_ANIMATION("skate");
}
if(gta.game == GAME_GTA_SA) {
gta.setGameStat(STAT_WEAPONTYPE_PISTOL_SKILL, 400);
gta.setGameStat(STAT_WEAPONTYPE_PISTOL_SILENCED_SKILL, 400);
gta.setGameStat(STAT_WEAPONTYPE_DESERT_EAGLE_SKILL, 400);
gta.setGameStat(STAT_WEAPONTYPE_SHOTGUN_SKILL, 400);
gta.setGameStat(STAT_WEAPONTYPE_SAWNOFF_SHOTGUN_SKILL, 1);
gta.setGameStat(STAT_WEAPONTYPE_SPAS12_SHOTGUN_SKILL, 400);
gta.setGameStat(STAT_WEAPONTYPE_MICRO_UZI_SKILL, 400);
gta.setGameStat(STAT_WEAPONTYPE_MP5_SKILL, 400);
gta.setGameStat(STAT_WEAPONTYPE_AK47_SKILL, 400);
gta.setGameStat(STAT_WEAPONTYPE_M4_SKILL, 400);
gta.setGameStat(STAT_DRIVING_SKILL, 9999);
gta.setGameStat(STAT_FAT, 0);
gta.setGameStat(STAT_ENERGY, 9999);
gta.setGameStat(STAT_CYCLE_SKILL, 9999);
gta.setGameStat(STAT_BIKE_SKILL, 9999);
gta.setGameStat(STAT_GAMBLING, 9999);
gta.setGameStat(STAT_PROGRESS_MADE, 9999);
gta.setGameStat(STAT_RESPECT, 0);
gta.setGameStat(STAT_RESPECT_TOTAL, 0);
gta.setGameStat(STAT_SEX_APPEAL, 0);
gta.setGameStat(STAT_STAMINA, 9999);
gta.setGameStat(STAT_TOTAL_PROGRESS, 100);
gta.setGameStat(STAT_UNDERWATER_STAMINA, 9999);
gta.setGameStat(STAT_BODY_MUSCLE, 0);
}
}
}
// ===========================================================================
function tellServerPlayerUsedKeyBind(key) {
triggerNetworkEvent("ag.useKeyBind", key);
}
// ===========================================================================
function tellServerPlayerArrivedAtJobRouteStop() {
triggerNetworkEvent("ag.arrivedAtJobRouteStop");
}
// ===========================================================================
function tellServerItemActionDelayComplete() {
triggerNetworkEvent("ag.itemActionDelayComplete");
}
// ===========================================================================
function sendServerClientInfo() {
triggerNetworkEvent("ag.clientInfo", `${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_PATCH}.${CLIENT_VERSION_BUILD}`, gta.width, gta.height);
}
// ===========================================================================
function sendServerNewAFKStatus(state) {
triggerNetworkEvent("ag.afk", state);
}
// ===========================================================================
function playStreamingRadio(url, loop) {
//gta.forceRadioChannel(-1);
if(url == "") {
if(streamingRadio != null) {
streamingRadio.stop();
}
return true;
}
if(streamingRadio != null) {
streamingRadio.stop();
}
streamingRadio = audio.createSoundFromURL(url, loop);
streamingRadio.volume = 0.5;
streamingRadio.play();
}
// ===========================================================================
function setStreamingRadioVolume(volume) {
if(streamingRadio != null) {
streamingRadio.volume = volume;
}
}
// ===========================================================================

View File

@@ -0,0 +1,140 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: skin-select.js
// DESC: Provides skin-selector functions and usage
// TYPE: Client (JavaScript)
// ===========================================================================
let skinSelectMessageFontTop = null;
let skinSelectMessageFontBottom = null;
let skinSelectMessageTextTop = "Skin Name";
let skinSelectMessageTextBottom = "Choose a skin using LEFT and RIGHT arrows. Use ENTER to finish or BACKSPACE to cancel.";
let skinSelectMessageColourTop = COLOUR_YELLOW;
let skinSelectMessageColourBottom = COLOUR_WHITE;
let usingSkinSelector = false;
let usingNewCharacterSkinSelector = false;
let skinSelectorIndex = 0;
let skinSelectPosition = null;
let skinSelectHeading = null;
let newCharacterSkinSelectPedPosition = [
[],
[139.54, -903.00, 26.16],
[-379.16, -535.27, 17.28],
[2495.03, -1685.66, 13.51],
[904.27, -498.00, 14.522],
];
let newCharacterSkinSelectPedHeading = [
[],
[15.0],
[0.0],
[0.01],
[3.127],
];
// ===========================================================================
function initSkinSelectScript() {
logToConsole(LOG_DEBUG, "[Asshat.SkinSelect]: Initializing skin selector script ...");
skinSelectMessageFontTop = loadSkinSelectMessageFontTop();
skinSelectMessageFontBottom = loadSkinSelectMessageFontBottom();
logToConsole(LOG_DEBUG, "[Asshat.SkinSelect]: Skin selector script initialized!");
}
// ===========================================================================
function loadSkinSelectMessageFontTop() {
return lucasFont.createDefaultFont(20.0, "Roboto");
}
// ===========================================================================
function loadSkinSelectMessageFontBottom() {
return lucasFont.createDefaultFont(12.0, "Roboto", "Light");
}
// ===========================================================================
function processSkinSelectKeyPress(keyCode) {
if(usingSkinSelector) {
if(keyCode == SDLK_RIGHT) {
if(allowedSkins[gta.game].length-1 == skinSelectorIndex) {
skinSelectorIndex = 0;
} else {
skinSelectorIndex++;
}
localPlayer.skin = allowedSkins[gta.game][skinSelectorIndex][0];
skinSelectMessageTextTop = allowedSkins[gta.game][skinSelectorIndex][1];
} else if(keyCode == SDLK_LEFT) {
if(skinSelectorIndex <= 0) {
skinSelectorIndex = allowedSkins[gta.game].length-1;
} else {
skinSelectorIndex--;
}
localPlayer.skin = allowedSkins[gta.game][skinSelectorIndex][0];
skinSelectMessageTextTop = allowedSkins[gta.game][skinSelectorIndex][1];
} else if(keyCode == SDLK_RETURN) {
triggerNetworkEvent("ag.skinSelected", skinSelectorIndex);
} else if(keyCode == SDLK_BACKSPACE) {
triggerNetworkEvent("ag.skinSelected", -1);
}
}
}
// ===========================================================================
function processSkinSelectRendering() {
if(usingSkinSelector) {
if(skinSelectMessageFontTop != null && skinSelectMessageFontBottom != null) {
if(gta.game != GAME_GTA_VC) {
skinSelectMessageFontTop.render(skinSelectMessageTextTop, [0, gta.height-100], gta.width, 0.5, 0.0, skinSelectMessageFontTop.size, skinSelectMessageColourTop, true, true, false, true);
skinSelectMessageFontBottom.render(skinSelectMessageTextBottom, [0, gta.height-65], gta.width, 0.5, 0.0, skinSelectMessageFontBottom.size, skinSelectMessageColourBottom, true, true, false, true);
}
}
localPlayer.position = skinSelectPosition;
localPlayer.heading = skinSelectHeading;
if(gta.game == GAME_GTA_III || gta.game == GAME_GTA_VC) {
localPlayer.clearObjective();
}
}
}
// ===========================================================================
function toggleSkinSelect(state) {
if(state) {
skinSelectorIndex = getAllowedSkinIndexBySkinId(localPlayer.skin);
if(localPlayer.skin != allowedSkins[gta.game][skinSelectorIndex][0]) {
localPlayer.skin = allowedSkins[gta.game][skinSelectorIndex][0];
}
usingSkinSelector = true;
let tempPosition = localPlayer.position;
tempPosition.z += 0.5;
let frontCameraPosition = getPosInFrontOfPos(tempPosition, localPlayer.heading, 3);
gta.setCameraLookAt(frontCameraPosition, localPlayer.position, true);
gui.showCursor(true, false);
localPlayer.invincible = true;
localPlayer.setProofs(true, true, true, true, true);
localPlayer.collisionsEnabled = false;
skinSelectPosition = localPlayer.position;
skinSelectHeading = localPlayer.heading;
} else {
usingSkinSelector = false;
//gta.restoreCamera(true);
gui.showCursor(false, true);
if(localPlayer) {
localPlayer.invincible = false;
localPlayer.setProofs(false, false, false, false, false);
localPlayer.collisionsEnabled = true;
}
}
}
// ===========================================================================

30
scripts/client/startup.js Normal file
View File

@@ -0,0 +1,30 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: startup.js
// DESC: Provides startup/shutdown procedures
// TYPE: Client (JavaScript)
// ===========================================================================
function initClientScripts() {
initGUIScript();
initNameTagScript();
initScoreBoardScript();
initMessagingScript();
initServerScript();
initLogoScript();
initLabelScript();
initChatBoxScript();
initAFKScript();
initKeyBindScript();
initEventScript();
initSkinSelectScript();
}
// ===========================================================================
initClientScripts();
// ===========================================================================

View File

@@ -1,65 +1,87 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: sync.js
// DESC: Provides some elements and data sync
// TYPE: Client (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
// ===========================================================================
addEventHandler("onProcess", function(event, deltaTime) {
if(localPlayer != null && isSpawned) {
if(localPlayer.health <= 1) {
function processSync(event, deltaTime) {
if(localPlayer != null) {
if(gta.game == GAME_GTA_IV) {
triggerNetworkEvent("ag.player.position", localPlayer.position);
triggerNetworkEvent("ag.player.heading", localPlayer.heading);
}
if(localPlayer.health <= 0) {
logToConsole(LOG_DEBUG, `Local player died`);
localPlayer.clearWeapons();
triggerNetworkEvent("ag.player.death", localPlayer.position);
triggerNetworkEvent("ag.playerDeath", localPlayer.position);
}
}
});
}
// ---------------------------------------------------------------------------
// ===========================================================================
addNetworkHandler("ag.veh.engine", function(vehicle, state) {
function toggleVehicleEngine(vehicle, state) {
vehicle.engine = state;
});
}
// ---------------------------------------------------------------------------
// ===========================================================================
addNetworkHandler("ag.veh.lights", function(vehicle, state) {
vehicle.lights = state;
});
function toggleVehicleLights(vehicle, state) {
getElementFromId(vehicle).lights = state;
}
// ---------------------------------------------------------------------------
// ===========================================================================
addNetworkHandler("ag.veh.repair", function(syncId) {
function repairVehicle(syncId) {
getVehicleFromSyncId(syncId).fix();
});
}
// ---------------------------------------------------------------------------
// ===========================================================================
function syncVehicleProperties(vehicle) {
//if(doesEntityDataExist(vehicle, "ag.lights")) {
// let lights = getEntityData(vehicle, "ag.lights");
// if(lights != vehicle.lights) {
// vehicle.lights = lights;
// }
//}
if(vehicle != null) {
syncVehicleProperties(vehicle);
}
}
//if(doesEntityDataExist(vehicle, "ag.engine")) {
// let engine = getEntityData(vehicle, "ag.engine");
// if(engine != vehicle.engine) {
// vehicle.engine = engine;
// }
//}
// ===========================================================================
//if(doesEntityDataExist(vehicle, "ag.siren")) {
// let siren = getEntityData(vehicle, "ag.siren");
// if(siren != vehicle.siren) {
// vehicle.siren = siren;
// }
//}
function syncCivilianProperties(civilian) {
if(civilian != null) {
syncCivilianProperties(civilian);
}
}
// ===========================================================================
function syncPlayerProperties(player) {
if(player != null) {
syncPlayerProperties(player);
}
}
// ===========================================================================
function syncObjectProperties(object) {
if(object != null) {
syncObjectProperties(object);
}
}
// ===========================================================================
function syncVehicleProperties(vehicle) {
if(doesEntityDataExist(vehicle, "ag.lights")) {
let lightStatus = getEntityData(vehicle, "ag.lights");
vehicle.lights = lightStatus;
}
if(doesEntityDataExist(vehicle, "ag.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "ag.panelStatus");
@@ -82,64 +104,269 @@ function syncVehicleProperties(vehicle) {
}
}
if(doesEntityDataExist(vehicle, "ag.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "ag.suspensionHeight");
vehicle.setSuspensionHeight(suspensionHeight);
}
}
addNetworkHandler("ag.veh.sync", function(event, vehicle) {
syncVehicleProperties(vehicle);
});
//if(doesEntityDataExist(vehicle, "ag.suspensionHeight")) {
// let suspensionHeight = getEntityData(vehicle, "ag.suspensionHeight");
// vehicle.setSuspensionHeight(suspensionHeight);
//}
// ---------------------------------------------------------------------------
if(getGame() == GAME_GTA_SA) {
if(doesEntityDataExist(vehicle, "ag.upgrades")) {
let upgrades = getEntityData(vehicle, "ag.upgrades");
for(let i in upgrades) {
vehicle.addUpgrade(upgrades[i]);
}
}
}
if(getGame() == GAME_GTA_SA || getGame() == GAME_GTA_IV) {
if(doesEntityDataExist(vehicle, "ag.livery")) {
let livery = getEntityData(vehicle, "ag.livery");
if(getGame() == GAME_GTA_SA) {
vehicle.setPaintJob(livery);
} else if(getGame() == GAME_GTA_IV) {
vehicle.livery = livery;
}
}
}
//gta.REMOVE_UPSIDEDOWN_CAR_CHECK(gta.GET_VEHICLE_ID(vehicle));
}
// ===========================================================================
function syncCivilianProperties(civilian) {
if(doesEntityDataExist(civilian, "ag.scale")) {
let scaleFactor = getEntityData(civilian, "ag.scale");
let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = civilian.position;
civilian.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
civilian.position = tempPosition;
if(getGame() == GAME_GTA_III) {
if(doesEntityDataExist(civilian, "ag.scale")) {
let scaleFactor = getEntityData(civilian, "ag.scale");
let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = civilian.position;
civilian.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
civilian.position = tempPosition;
}
}
if(getGame() == GAME_GTA_SA) {
if(doesEntityDataExist(civilian, "ag.fightStyle")) {
let fightStyle = getEntityData(civilian, "ag.fightStyle");
civilian.setFightStyle(fightStyle[0], fightStyle[1]);
}
}
if(getGame() == GAME_GTA_III) {
if(doesEntityDataExist(civilian, "ag.walkStyle")) {
let walkStyle = getEntityData(civilian, "ag.walkStyle");
civilian.walkStyle = walkStyle;
}
}
if(getGame() == GAME_GTA_IV) {
if(doesEntityDataExist(civilian, "ag.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "ag.bodyPropHair");
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "ag.bodyPropHead");
civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "ag.bodyPropEyes");
civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "ag.bodyPropLeftHand");
civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "ag.bodyPropRightHand");
civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "ag.bodyPropLeftWrist");
civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "ag.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "ag.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "ag.bodyPropHip");
civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "ag.bodyPropLeftFoot");
civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if(doesEntityDataExist(civilian, "ag.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "ag.bodyPropRightFoot");
civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
}
addNetworkHandler("ag.civ.sync", function(event, civilian) {
//syncCivilianProperties(civilian);
});
// ---------------------------------------------------------------------------
// ===========================================================================
function syncPlayerProperties(player) {
if(doesEntityDataExist(player, "ag.scale")) {
let scaleFactor = getEntityData(player, "ag.scale");
let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = player.position;
player.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
player.position = tempPosition;
if(getGame() == GAME_GTA_III) {
if(doesEntityDataExist(player, "ag.scale")) {
let scaleFactor = getEntityData(player, "ag.scale");
let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = player.position;
player.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
player.position = tempPosition;
}
}
if(getGame() == GAME_GTA_SA) {
if(doesEntityDataExist(player, "ag.fightStyle")) {
let fightStyle = getEntityData(player, "ag.fightStyle");
player.fightStyle = fightStyle;
}
}
//if(getGame() == GAME_GTA_SA) {
// if(doesEntityDataExist(player, "ag.walkStyle")) {
// let walkStyle = getEntityData(player, "ag.walkStyle");
// player.walkStyle = walkStyle;
// }
//}
if(getGame() == GAME_GTA_IV) {
if(doesEntityDataExist(player, "ag.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "ag.bodyPartHair");
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
}
if(doesEntityDataExist(player, "ag.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "ag.bodyPartHead");
player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]);
}
if(doesEntityDataExist(player, "ag.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "ag.bodyPartUpper");
player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]);
}
if(doesEntityDataExist(player, "ag.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "ag.bodyPartLower");
player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]);
}
}
if(getGame() == GAME_GTA_IV) {
if(doesEntityDataExist(player, "ag.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "ag.bodyPropHair");
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "ag.bodyPropHead");
player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "ag.bodyPropEyes");
player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "ag.bodyPropLeftHand");
player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "ag.bodyPropRightHand");
player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "ag.bodyPropLeftWrist");
player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "ag.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "ag.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "ag.bodyPropHip");
player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "ag.bodyPropLeftFoot");
player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if(doesEntityDataExist(player, "ag.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "ag.bodyPropRightFoot");
player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
}
addNetworkHandler("ag.player.sync", function(event, player) {
syncPlayerProperties(player);
});
// ---------------------------------------------------------------------------
// ===========================================================================
function syncObjectProperties(object) {
if(doesEntityDataExist(object, "ag.scale")) {
let scaleFactor = getEntityData(object, "ag.scale");
let tempMatrix = object.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = object.position;
object.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
object.position = tempPosition;
if(getGame() == GAME_GTA_III) {
if(doesEntityDataExist(object, "ag.scale")) {
let scaleFactor = getEntityData(object, "ag.scale");
let tempMatrix = object.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = object.position;
object.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
object.position = tempPosition;
}
}
}
addNetworkHandler("ag.obj.sync", function(event, object) {
//syncObjectProperties(object);
});
// ---------------------------------------------------------------------------
// ===========================================================================
function syncElementProperties(element) {
switch(element.type) {
case ELEMENT_VEHICLE:
syncVehicleProperties(element);
break;
case ELEMENT_CIVILIAN:
syncCivilianProperties(element);
break;
case ELEMENT_PLAYER:
syncPlayerProperties(element);
break;
case ELEMENT_OBJECT:
syncObjectProperties(element);
break;
default:
break;
}
}
// ===========================================================================

629
scripts/client/utilities.js Normal file
View File

@@ -0,0 +1,629 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: utilities.js
// DESC: Provides util functions and arrays with data
// TYPE: Client (JavaScript)
// ===========================================================================
let weaponSlots = [
false,
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
],
[
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
3,
3,
4,
4,
4,
5,
5,
5,
5,
6,
6,
8,
8,
7,
7,
7,
7,
9,
-1,
9,
],
[
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
8,
8,
8,
-1,
-1,
-1,
2,
2,
2,
3,
3,
3,
4,
4,
5,
5,
4,
6,
6,
7,
7,
7,
7,
8,
12,
9,
9,
9,
9,
9,
11,
9,
9,
9,
],
];
function openAllGarages() {
switch(gta.game) {
case GAME_GTA_III:
for(let i=0;i<=26;i++) {
openGarage(i);
//gta.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case GAME_GTA_VC:
for(let i=0;i<=32;i++) {
openGarage(i);
//gta.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case GAME_GTA_SA:
for(let i=0;i<=44;i++) {
openGarage(i);
}
break;
default:
break;
}
}
// ===========================================================================
function closeAllGarages() {
switch(gta.game) {
case GAME_GTA_III:
for(let i=0;i<=26;i++) {
closeGarage(i);
//gta.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case GAME_GTA_VC:
for(let i=0;i<=32;i++) {
closeGarage(i);
//gta.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case GAME_GTA_SA:
for(let i=0;i<=44;i++) {
closeGarage(i);
}
break;
default:
break;
}
}
// ===========================================================================
function setLocalPlayerFrozenState(state) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Setting frozen state to ${state}`);
gui.showCursor(state, !state);
}
// ===========================================================================
function setLocalPlayerControlState(controlState, cursorState = false) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`);
controlsEnabled = controlState;
localPlayer.invincible = true;
localPlayer.collisionsEnabled = controlState;
localPlayer.invincible = false;
}
// ===========================================================================
function fadeLocalCamera(state, time) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Fading camera ${(state)?"in":"out"} for ${time} seconds`);
gta.fadeCamera(state, time);
}
// ===========================================================================
function removeLocalPlayerFromVehicle() {
localPlayer.removeFromVehicle();
}
// ===========================================================================
function restoreLocalCamera() {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Camera restored`);
gta.restoreCamera(true);
};
// ===========================================================================
function clearLocalPlayerOwnedPeds() {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Clearing all self-owned peds ...`);
clearSelfOwnedPeds();
logToConsole(LOG_DEBUG, `[Asshat.Utilities] All self-owned peds cleared`);
};
// ===========================================================================
function setLocalCameraLookAt(cameraPosition, cameraLookAt) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Set camera to look at [${cameraLookAt.x}, ${cameraLookAt.y}, ${cameraLookAt.z}] from [${cameraPosition.x}, ${cameraPosition.y}, ${cameraPosition.z}]`);
gta.setCameraLookAt(cameraPosition, cameraLookAt, true);
}
// ===========================================================================
function setCityAmbienceState(state) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`);
gta.setTrafficEnabled(state);
gta.setGenerateCarsAroundCamera(state);
if(gta.game != GAME_GTA_SA) {
gta.setCiviliansEnabled(state);
}
clearSelfOwnedPeds();
}
// ===========================================================================
function runClientCode(code, returnTo) {
let returnValue = "Nothing";
try {
returnValue = eval("(" + code + ")");
} catch(error) {
triggerNetworkEvent("ag.runCodeFail", returnTo, code);
return false;
}
triggerNetworkEvent("ag.runCodeSuccess", returnTo, code, returnValue);
}
// ===========================================================================
function enterVehicleAsPassenger() {
if(localPlayer.vehicle == null) {
let tempVehicle = getClosestVehicle(localPlayer.position);
if(tempVehicle != null) {
localPlayer.enterVehicle(tempVehicle, false);
}
}
}
// ===========================================================================
function giveLocalPlayerWeapon(weaponId, ammo, active) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Giving weapon ${weaponId} with ${ammo} ammo`);
localPlayer.giveWeapon(weaponId, ammo, active);
forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(weaponId));
forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(weaponId));
forceWeapon = weaponId;
}
// ===========================================================================
function giveLocalPlayerWeapon(weaponId, ammo, active) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Giving weapon ${weaponId} with ${ammo} ammo`);
localPlayer.giveWeapon(weaponId, ammo, active);
forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(weaponId));
forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(weaponId));
forceWeapon = weaponId;
}
// ===========================================================================
function clearLocalPlayerWeapons() {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Clearing weapons`);
localPlayer.clearWeapons();
forceWeapon = 0;
forceWeaponAmmo = 0;
forceWeaponClipAmmo = 0;
}
// ===========================================================================
function getClosestVehicle(pos) {
return getVehicles().reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
}
// ===========================================================================
function setLocalPlayerPosition(position) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Setting position to ${position.x}, ${position.y}, ${position.z}`);
localPlayer.velocity = toVector3(0.0, 0.0, 0.0);
localPlayer.position = position;
}
// ===========================================================================
function setLocalPlayerHeading(heading) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Setting heading to ${heading}`);
localPlayer.heading = heading;
}
// ===========================================================================
function setLocalPlayerInterior(interior) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Setting interior to ${interior}`);
localPlayer.interior = interior;
gta.cameraInterior = interior;
}
// ===========================================================================
function setSnowState(fallingSnow, groundSnow) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Setting falling snow to ${fallingSnow} and ground snow to ${groundSnow}`);
if(!isNull(snowing)) {
snowing = fallingSnow;
forceSnowing(groundSnow);
}
}
// ===========================================================================
function setLocalPlayerHealth(health) {
localPlayer.health = health;
}
// ===========================================================================
function isSnowEnabled() {
return (typeof snowing != "undefined");
}
// ===========================================================================
function playPedSpeech(pedName, speechId) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Making ${pedName}'s ped talk (${speechId})`);
gta.SET_CHAR_SAY(int, int);
}
// ===========================================================================
function clearLocalPedState() {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Clearing local ped state`);
localPlayer.clearObjective();
}
// ===========================================================================
function getWeaponSlot(weaponId) {
return weaponSlots[gta.game][weaponId];
}
// ===========================================================================
function setLocalPlayerDrunkEffect(amount, duration) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Drunk effect set to ${amount} for ${duration}ms`);
drunkEffectAmount = 0;
drunkEffectDurationTimer = setInterval(function() {
drunkEffectAmount = drunkEffectAmount;
if(drunkEffectAmount > 0) {
gta.SET_MOTION_BLUR(drunkEffectAmount);
} else {
clearInterval(drunkEffectDurationTimer);
drunkEffectDurationTimer = null;
}
}, 1000);
}
// ===========================================================================
function getLocalPlayerVehicleSeat() {
for(let i = 0 ; i <= 4 ; i++) {
if(localPlayer.vehicle.getOccupant(i) == localPlayer) {
return i;
}
}
}
// ===========================================================================
function clearSelfOwnedPeds() {
logToConsole(LOG_DEBUG, `Clearing self-owned peds`);
getElementsByType(ELEMENT_CIVILIAN).forEach(function(ped) {
if(ped.isOwner) {
destroyElement(ped);
}
});
}
// ===========================================================================
function setMouseCameraState(state) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] ${(state)?"Enabled":"Disabled"} mouse camera`);
mouseCameraEnabled = !mouseCameraEnabled;
SetStandardControlsEnabled(!mouseCameraEnabled);
}
// ===========================================================================
function setMouseCursorState(state) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] ${(state)?"Enabled":"Disabled"} mouse cursor`);
gui.showCursor(state, !state);
}
// ===========================================================================
function setPlayerWeaponDamageEvent(clientName, eventType) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Set ${clientName} damage event type to ${eventType}`);
weaponDamageEvent[clientName] = eventType;
}
// ===========================================================================
function setPlayerWeaponDamageEnabled(clientName, state) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] ${(state)?"Enabled":"Disabled"} damage from ${clientName}`);
weaponDamageEnabled[clientName] = state;
}
// ===========================================================================
function setLocalPlayerCash(amount) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Setting local player money`);
localPlayer.money = amount;
}
// ===========================================================================
function removeWorldObject(model, position, range) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Removing world object ${model} at X: ${position.x}, Y: ${position.x}, Z: ${position.x} with range of ${range}`);
gta.removeWorldObject(model, position, range);
}
// ===========================================================================
function excludeModelFromGroundSnow(model) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Disabling ground snow for object model ${model}`);
groundSnow.excludeModel(model);
}
// ===========================================================================
function destroyAutoCreatedPickups() {
getElementsByType(ELEMENT_PICKUP).forEach(function(pickup) {
if(pickup.isOwner) {
destroyElement(pickup);
}
});
}
// ===========================================================================
function processLocalPlayerControlState() {
if(localPlayer == null) {
return false;
}
if(isSpawned) {
return false;
}
if(!controlsEnabled) {
clearLocalPedState();
}
}
// ===========================================================================
function clearLocalPlayerWantedLevel() {
if(localPlayer == null) {
return false;
}
if(isSpawned) {
return false;
}
localPlayer.wantedLevel = 0;
}
// ===========================================================================
function processLocalPlayerVehicleControlState() {
let position = getLocalPlayerPosition();
if(inVehicle && localPlayer.vehicle != null) {
if(!localPlayer.vehicle.engine) {
localPlayer.vehicle.velocity = toVector3(0.0, 0.0, 0.0);
localPlayer.vehicle.turnVelocity = toVector3(0.0, 0.0, 0.0);
if(parkedVehiclePosition) {
localPlayer.vehicle.position = parkedVehiclePosition;
localPlayer.vehicle.heading = parkedVehicleHeading;
}
} else {
if(parkedVehiclePosition) {
parkedVehiclePosition = false;
parkedVehicleHeading = false;
}
}
}
}
// ===========================================================================
function processLocalPlayerSphereEntryExitHandling() {
let position = getLocalPlayerPosition();
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(gta.game == GAME_GTA_SA) {
let position = getLocalPlayerPosition();
if(jobRouteStopSphere != null) {
if(getDistance(position, jobRouteStopSphere.position) <= 2.0) {
enteredJobRouteSphere();
}
}
}
}
// ===========================================================================
function forceLocalPlayerEquippedWeaponItem() {
if(forceWeapon != 0) {
if(localPlayer.weapon != forceWeapon) {
localPlayer.weapon = forceWeapon;
localPlayer.setWeaponClipAmmunition(getWeaponSlot(forceWeapon), forceWeaponClipAmmo);
localPlayer.setWeaponAmmunition(getWeaponSlot(forceWeapon), forceWeaponAmmo);
} else {
forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(forceWeapon));
forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(forceWeapon));
}
} else {
if(localPlayer.weapon > 0) {
localPlayer.clearWeapons();
}
}
}
// ===========================================================================
function getLocalPlayerPosition() {
let position = localPlayer.position;
if(localPlayer.vehicle) {
position = localPlayer.vehicle.position;
}
return position;
}
// ===========================================================================
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(vehicleArg) {
// Soon this will also be used to get the IV vehicle via it's ID
return vehicleArg;
}
// ===========================================================================
function getPosInFrontOfPos(pos, angle, distance) {
let x = (pos.x+((Math.cos(angle+(Math.PI/2)))*distance));
let y = (pos.y+((Math.sin(angle+(Math.PI/2)))*distance));
let z = pos.z;
return toVector3(x, y, z);
}
// ===========================================================================
function getAllowedSkinIndexBySkinId(skinId) {
for(let i in allowedSkins[gta.game]) {
if(skinId == allowedSkins[gta.game][i][0]) {
return i;
}
}
return -1;
}
// ===========================================================================
function processWantedLevelReset() {
localPlayer.wantedLevel = 0;
}
// ===========================================================================

12
scripts/jsconfig.json Normal file
View File

@@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"moduleResolution": "classic"
},
"include": [
"server/*",
"client/*",
"third-party/*"
]
}

View File

@@ -2,41 +2,14 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: accent.js
// DESC: Provides accent functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
let accents = [
"English",
"French",
"Russian",
"Scottish",
"Irish",
"Spanish",
"Southern American",
"Italian",
"Australian",
"Jamaican",
"Israeli",
"Dutch",
"Brazilian",
"Portuguese",
"German",
"Canadian",
"Chinese",
"Japanese",
"Turkish",
"Korean",
"Estonian",
"Sicilian",
];
// ---------------------------------------------------------------------------
function getPlayerAccentText(client) {
return getPlayerCurrentSubAccount(client).accent;
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: account.js
// DESC: Provides account functions and usage
// TYPE: Server (JavaScript)
@@ -13,7 +13,7 @@ function initAccountScript() {
logToConsole(LOG_DEBUG, "[Asshat.Account]: Account script initialized!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loginCommand(command, params, client) {
if(!isPlayerRegistered(client)) {
@@ -30,7 +30,7 @@ function loginCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function autoLoginByIPCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("autoLoginIP");
@@ -45,7 +45,7 @@ function autoLoginByIPCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function autoSelectLastCharacterCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("autoSelectLastCharacter");
@@ -60,7 +60,7 @@ function autoSelectLastCharacterCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function toggleAccountGUICommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("noGUI");
@@ -97,7 +97,7 @@ function toggleAccountGUICommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function toggleAccountServerLogoCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("noServerLogo");
@@ -119,38 +119,40 @@ function toggleAccountServerLogoCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
// UNFINISHED!
// TO-DO: Make GUI, add command to generate code to add to auth app and command to input code returned by auth app
function toggleAccountTwoFactorAuthCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("twoStepAuth");
if(getPlayerData(client).emailAddress != "") {
if(getPlayerData(client).accountData.emailAddress != "") {
messagePlayerError(client, "You need to add your email to your account to use two-factor authentication.");
messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/setemail [#FFFFFF]to add your email.");
return false;
}
if(!isValidEmailAddress(getPlayerData(client).emailAddress)) {
messagePlayerError(client, "The email you previously added is not valid.");
messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/setemail [#FFFFFF]to add a valid email.");
if(isAccountEmailVerified(getPlayerData(client).accountData)) {
messagePlayerError(client, "You need to verify your email to your account to use two-factor authentication.");
messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/verifyemail [#FFFFFF]to verify your email.");
return false;
}
if(!doesPlayerHaveTwoFactorAuthEnabled(client)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue;
messagePlayerSuccess(client, `[#FFFFFF]Use this code to add your account into your authenticator app: [#AAAAAA]${addtoAuthenticatorCode}`);
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, `[#FFFFFF]You have turned ${getBoolRedGreenInlineColour(false)}ON [#FFFFFF] two factor authentication![#AAAAAA]${addtoAuthenticatorCode}`);
messagePlayerAlert(client, "You will be required to enter a code sent to your email every time you log on.");
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication ON for their account`);
} else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue;
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, `You have turned ${getBoolRedGreenInlineColour(false)}OFF [#FFFFFF]two-factor authentication for login.`);
messagePlayerAlert(client, "You won't be required to enter a code sent to your email every time you log on anymore.");
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication OFF for their account`);
}
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function registerCommand(command, params, client) {
if(isPlayerRegistered(client)) {
@@ -169,7 +171,7 @@ function registerCommand(command, params, client) {
//messagePlayerAlert(client, "To play on the server, you will need to make a character.");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function changePasswordCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -196,12 +198,34 @@ function changePasswordCommand(command, params, client) {
messagePlayerSuccess(client, "Your password has been changed!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setAccountChatScrollLinesCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if(isNaN(params)) {
messagePlayerError(client, "The line amount must be a number!");
return false;
}
if(toInteger(params) < 1 || toInteger(params) > 6) {
messagePlayerError(client, "The line amount must be between 1 and 6!");
return false;
}
let lines = Math.ceil(toInteger(params));
getPlayerData(client).accountData.chatScrollLines = lines;
sendPlayerChatScrollLines(client, lines);
messagePlayerSuccess(client, `Your chatbox will now scroll ${toInteger(lines)} lines at a time!`);
}
// ===========================================================================
function setAccountEmailCommand(command, params, client) {
messagePlayerError(client, `This command is not yet finished and will be available soon!`);
return false;
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -215,12 +239,61 @@ function setAccountEmailCommand(command, params, client) {
return false;
}
// TO-DO: Command (like /verifyemail or use this one for second step too) to input verification code sent to email.
//getPlayerData(client).accountData.emailAddress = emailAddress;
messagePlayerSuccess(client, "Your password has been changed!");
//if(.emailAddress != "") {
// messagePlayerError(client, `Your email is already set!`);
// return false;
//}
if(getPlayerData(client).accountData.emailAddress != "" && isAccountEmailVerified(getPlayerData(client).accountData)) {
messagePlayerError(client, `You already set your email and verified it!`);
return false;
}
setAccountEmail(getPlayerData(client).accountData, emailAddress);
let emailVerificationCode = generateEmailVerificationCode();
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
messagePlayerSuccess(client, `Your email has been set!`);
messagePlayerAlert(client, `Please verify your email to enable extra account security and recovery features.`);
messagePlayerAlert(client, `A verification code and instructions have been sent to your email.`);
saveAccountToDatabase(getPlayerData(client).accountData);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function verifyAccountEmailCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let verificationCode = splitParams[0];
if(isAccountEmailVerified(getPlayerData(client).accountData)) {
messagePlayerError(client, `You already verified your email!`);
return false;
}
if(module.hashing.sha512(verificationCode) != getPlayerData(client).accountData.emailVerificationCode) {
messagePlayerError(client, `Invalid email verification code! A new one has been created and sent to your email.`);
let emailVerificationCode = generateEmailVerificationCode();
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
return false;
}
getPlayerData(client).accountData.flags.moderation = addBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("emailVerified"));
getPlayerData(client).accountData.emailVerificationCode = "";
messagePlayerSuccess(client, `Your email has been verified!`);
messagePlayerAlert(client, `You can now use your email for password resets, two-factor authentication, alerts, and more!`);
saveAccountToDatabase(getPlayerData(client).accountData);
}
// ===========================================================================
function setAccountDiscordCommand(command, params, client) {
messagePlayerError(client, `This command is not yet finished and will be available soon!`);
@@ -239,12 +312,12 @@ function setAccountDiscordCommand(command, params, client) {
return false;
}
// TO-DO: Command (like /verifyemail or use this one for second step too) to input verification code sent to email.
// TO-DO: Command (like /verifydiscord or use this one for second step too) to input verification code sent to email.
//getPlayerData(client).accountData.emailAddress = emailAddress;
//messagePlayerSuccess(client, "Your discord account has been attached to your game account!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerLoggedIn(client) {
if(isConsole(client)) {
@@ -258,7 +331,7 @@ function isPlayerLoggedIn(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerRegistered(client) {
if(isConsole(client)) {
@@ -274,14 +347,14 @@ function isPlayerRegistered(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPasswordMeetRequirements(password) {
// Will be added soon
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isAccountPasswordCorrect(accountData, password) {
if(accountData.password == password) {
@@ -291,13 +364,13 @@ function isAccountPasswordCorrect(accountData, password) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAccountFromName(accountName, fullLoad = false) {
let dbConnection = connectToDatabase();
if(dbConnection) {
accountName = escapeDatabaseString(dbConnection, accountName);
let dbQueryString = `SELECT *, INET_NTOA(acct_ip) AS ipstring FROM acct_main WHERE acct_name = '${accountName}' LIMIT 1;`;
let dbQueryString = `SELECT acct_main.*, acct_svr.*, INET_NTOA(acct_ip) AS ipstring 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_name = '${accountName}' LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
if(dbQuery.numRows > 0) {
@@ -319,7 +392,7 @@ function loadAccountFromName(accountName, fullLoad = false) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAccountFromId(accountId, fullLoad = false) {
let dbConnection = connectToDatabase();
@@ -345,7 +418,7 @@ function loadAccountFromId(accountId, fullLoad = false) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getAccountHashingFunction() {
switch(toLowerCase(getGlobalConfig().accountPasswordHash)) {
@@ -384,7 +457,7 @@ function getAccountHashingFunction() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isNameRegistered(name) {
let accountData = loadAccountFromName(name, true);
@@ -395,7 +468,7 @@ function isNameRegistered(name) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function hashAccountPassword(name, password) {
let hashFunction = getAccountHashingFunction();
@@ -403,18 +476,20 @@ function hashAccountPassword(name, password) {
return hashFunction(saltedInfo);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saltAccountInfo(name, password) {
return "ag.gaming." + toString(accountSaltHash) + "." + toString(name) + "." + toString(password);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loginSuccess(client) {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} successfully logged in.`);
getPlayerData(client).loggedIn = true;
updateConnectionLogOnAuth(client, getPlayerData(client).accountData.databaseId);
if(doesPlayerHaveStaffPermission(client, "developer") || doesPlayerHaveStaffPermission(client, "manageServer")) {
logToConsole(LOG_WARN, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`);
client.administrator = true;
@@ -423,7 +498,7 @@ function loginSuccess(client) {
if(getPlayerData(client).subAccounts.length == 0) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
showPlayerPromptGUI(client, "You have no characters. Would you like to make one?", "No characters");
setEntityData(client, "ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
getPlayerData(client).promptType = AG_PROMPT_CREATEFIRSTCHAR;
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else {
messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`);
@@ -436,34 +511,74 @@ function loginSuccess(client) {
getPlayerData(client).accountData.ipAddress = client.ip;
sendRemovedWorldObjectsToPlayer(client);
sendAccountKeyBindsToClient(client);
sendPlayerChatScrollLines(client, getPlayerData(client).accountData.chatScrollLines);
messagePlayerNormal(null, `👋 ${client.name} has joined the server`, getColourByName("softYellow"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveAccountToDatabase(accountData) {
let dbConnection = connectToDatabase();
if(dbConnection) {
//logToConsole(LOG_VERBOSE, `Escaping account data for ${getPlayerDisplayForConsole(client)}`);
let safePassword = escapeDatabaseString(dbConnection, accountData.password);
//logToConsole(LOG_VERBOSE, `${getPlayerDisplayForConsole(accountData.name)}'s password escaped successfully`);
let safeStaffTitle = escapeDatabaseString(dbConnection, accountData.staffTitle);
//logToConsole(LOG_VERBOSE, `${getPlayerDisplayForConsole(client)}'s staff title escaped successfully`);
let safeEmailAddress = escapeDatabaseString(dbConnection, accountData.emailAddress);
//let safeIRCAccount = dbConnection.escapetoString(accountData.ircAccount);
//logToConsole(LOG_VERBOSE, `${getPlayerDisplayForConsole(client)}'s email address escaped successfully`);
let dbQueryString =
`UPDATE acct_main SET
acct_email='${safeEmailAddress}',
acct_pass='${safePassword}',
acct_discord=${accountData.discordAccount},
acct_ip=INET_ATON('${accountData.ipAddress}'),
acct_code_verifyemail='${accountData.emailVerificationCode}'
WHERE acct_id=${accountData.databaseId}`;
/*
acct_settings=${accountData.settings},
acct_staff_title='${safeStaffTitle}',
acct_staff_flags=${accountData.flags.admin},
acct_mod_flags=${accountData.flags.moderation},
*/
//dbQueryString = dbQueryString.trim();
dbQueryString = dbQueryString.replace(/(?:\r\n|\r|\n|\t)/g, "");
let dbQueryString = `UPDATE acct_main SET acct_pass='${safePassword}', acct_settings=${accountData.settings}, acct_staff_flags=${accountData.flags.admin}, acct_staff_title='${safeStaffTitle}', acct_mod_flags=${toString(accountData.flags.moderation)}, acct_discord=${toString(accountData.discordAccount)}, acct_email='${safeEmailAddress}', acct_ip=INET_ATON('${accountData.ipAddress}') WHERE acct_id=${accountData.databaseId}`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
//freeDatabaseQuery(dbQuery);
freeDatabaseQuery(dbQuery);
dbQuery = null;
dbQueryString =
`UPDATE acct_svr SET
acct_svr_acct='${accountData.databaseId}',
acct_svr_settings=${accountData.flags.settings},
acct_svr_staff_title='${safeStaffTitle}',
acct_svr_staff_flags=${accountData.flags.admin},
acct_svr_mod_flags=${accountData.flags.moderation},
acct_svr_chat_scroll_lines=${accountData.chatScrollLines}
WHERE acct_svr_acct=${accountData.databaseId} AND acct_svr_svr = ${getServerId()}`;
//dbQueryString = dbQueryString.trim();
dbQueryString = dbQueryString.replace(/(?:\r\n|\r|\n|\t)/g, "");
dbQuery = queryDatabase(dbConnection, dbQueryString);
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveAccountKeyBindsDatabase(keyBindData) {
let dbConnection = connectToDatabase();
if(dbConnection) {
//logToConsole(LOG_VERBOSE, `Escaping account keybinds data for ${getPlayerDisplayForConsole(client)}`);
let safeCommandString = escapeDatabaseString(dbConnection, keyBindData.commandString);
//logToConsole(LOG_VERBOSE, `${getPlayerDisplayForConsole(client)}'s keybind command string escaped successfully`);
if(keyBindData.databaseId == 0) {
let dbQueryString = `INSERT INTO acct_hotkey (acct_hotkey_cmdstr, acct_hotkey_key, acct_hotkey_down, acct_hotkey_enabled) VALUES ('${safeCommandString}', ${keyBindData.key}, ${boolToInt(keyBindData.keyState)}, ${boolToInt(keyBindData.enabled)}, ${keyBindData.account}`;
keyBindData.databaseId = getDatabaseInsertId(dbConnection);
@@ -479,12 +594,13 @@ function saveAccountKeyBindsDatabase(keyBindData) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveAccountStaffNotesDatabase(staffNoteData) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeNoteContent = escapeDatabaseString(dbConnection, staffNoteData.note);
//logToConsole(LOG_VERBOSE, `${getPlayerDisplayForConsole(client)}'s staff note string escaped successfully`);
if(staffNoteData.databaseId == 0) {
let dbQueryString = `INSERT INTO acct_note (acct_note_message, acct_note_who_added, acct_note_when_added, acct_note_server, acct_note_acct) VALUES ('${safeNoteContent}', ${staffNoteData.whoAdded}, UNIX_TIMESTAMP(), ${getServerId()}, ${staffNoteData.account}`;
staffNoteData.databaseId = getDatabaseInsertId(dbConnection);
@@ -496,7 +612,7 @@ function saveAccountStaffNotesDatabase(staffNoteData) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
/*
function saveAccountContactsDatabase(accountContactData) {
@@ -519,7 +635,7 @@ function saveAccountContactsDatabase(accountContactData) {
}
*/
// ---------------------------------------------------------------------------
// ===========================================================================
function createAccount(name, password, email = "") {
let dbConnection = connectToDatabase();
@@ -529,10 +645,11 @@ function createAccount(name, password, email = "") {
let safeName = escapeDatabaseString(dbConnection, name);
let safeEmail = escapeDatabaseString(dbConnection, email);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}')`);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email, acct_when_registered) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}', UNIX_TIMESTAMP())`);
if(getDatabaseInsertId(dbConnection) > 0) {
let accountData = loadAccountFromId(getDatabaseInsertId(dbConnection), true);
createDefaultKeybindsForAccount(accountData.databaseId);
createDefaultAccountServerData(accountData.databaseId);
return accountData;
}
}
@@ -540,10 +657,13 @@ function createAccount(name, password, email = "") {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function checkLogin(client, password) {
getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining-1;
if(getPlayerData(client).loginAttemptsRemaining <= 0) {
client.disconnect();
}
if(isPlayerLoggedIn(client)) {
logToConsole(LOG_WARN, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`);
@@ -599,7 +719,7 @@ function checkLogin(client, password) {
loginSuccess(client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function checkRegistration(client, password, confirmPassword = "", emailAddress = "") {
logToConsole(LOG_DEBUG, "[Asshat.Account]: Checking registration for " + toString(client.name));
@@ -685,24 +805,29 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
getPlayerData(client).loggedIn = true;
messagePlayerSuccess(client, "Your account has been created!");
messagePlayerAlert(client, "Don't forget to verify your email! A verification code has been sent to you");
messagePlayerAlert(client, "To play on the server, you will need to make a character.");
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationSuccessGUI(client);
showPlayerPromptGUI(client, "You have no characters. Would you like to make one?", "No Characters");
setEntityData(client, "ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
getPlayerData(client).promptType = AG_PROMPT_CREATEFIRSTCHAR;
let emailVerificationCode = generateEmailVerificationCode();
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
} else {
messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`);
}
};
// ---------------------------------------------------------------------------
// ===========================================================================
function isValidEmailAddress(emailAddress) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveAllClientsToDatabase() {
logToConsole(LOG_DEBUG, "[Asshat.Account]: Saving all clients to database ...");
@@ -712,7 +837,7 @@ function saveAllClientsToDatabase() {
logToConsole(LOG_DEBUG, "[Asshat.Account]: All clients saved to database successfully!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function savePlayerToDatabase(client) {
if(getPlayerData(client) == null) {
@@ -727,22 +852,29 @@ function savePlayerToDatabase(client) {
saveAccountToDatabase(getPlayerData(client).accountData);
if(getPlayerData(client).currentSubAccount != -1) {
let subAccountData = getPlayerCurrentSubAccount(client);
//let subAccountData = getPlayerCurrentSubAccount(client);
if(client.player != null) {
subAccountData.spawnPosition = getPlayerPosition(client);
subAccountData.spawnHeading = getPlayerHeading(client);
subAccountData.interior = getPlayerInterior(client);
subAccountData.dimension = getPlayerDimension(client);
if(getPlayerData(client).returnToPosition != null) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition;
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading;
getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior;
getPlayerCurrentSubAccount(client).dimension = getPlayerData(client).returnToDimension;
} else {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client);
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client);
getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client);
getPlayerCurrentSubAccount(client).dimension = getPlayerDimension(client);
}
}
saveSubAccountToDatabase(subAccountData);
saveSubAccountToDatabase(getPlayerCurrentSubAccount(client));
}
logToConsole(LOG_DEBUG, `[Asshat.Account]: Saved client ${getPlayerDisplayForConsole(client)} to database successfully!`);
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function initClient(client) {
if(isConsole(client)) {
@@ -753,6 +885,7 @@ function initClient(client) {
sendPlayerGUIInit(client);
showConnectCameraToPlayer(client);
//playRadioStreamForPlayer(client, getServerConfig().introMusicURL, true);
messageClient(`Please wait ...`, client, getColourByName("softGreen"));
setTimeout(function() {
@@ -794,23 +927,45 @@ function initClient(client) {
}, 2500);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveConnectionToDatabase(client) {
let dbQueryString = `INSERT INTO conn_main (conn_when_connect, conn_server, conn_script_version, conn_game_version, conn_client_version) VALUES (UNIX_TIMESTAMP(), ${getServerConfig().databaseId}, '${scriptVersion}', '${client.gameVersion}', '0.0.0')`;
return quickDatabaseQuery(dbQueryString);
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeName = escapeDatabaseString(dbConnection, client.name);
let dbQueryString = `INSERT INTO conn_main (conn_when_connect, conn_server, conn_script_version, conn_game_version, conn_client_version, conn_name, conn_ip) VALUES (UNIX_TIMESTAMP(), ${getServerConfig().databaseId}, '${scriptVersion}', '${client.gameVersion}', '0.0.0', '${safeName}', INET_ATON('${client.ip}'))`;
let query = queryDatabase(dbConnection, dbQueryString);
setEntityData(client, "ag.connection", getDatabaseInsertId(dbConnection));
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createDefaultKeybindsForAccount(accountDatabaseId) {
for(let i in getGlobalConfig().defaultKeybinds) {
let dbQueryString = `INSERT INTO acct_hotkey (acct_hotkey_acct, acct_hotkey_key, acct_hotkey_cmdstr, acct_hotkey_when_added, acct_hotkey_down) VALUES (${accountDatabaseId}, ${getGlobalConfig().defaultKeybinds[i].key}, '${getGlobalConfig().defaultKeybinds[i].commandString}', UNIX_TIMESTAMP(), ${boolToInt(getGlobalConfig().defaultKeybinds[i].keyState)})`;
logToConsole(LOG_DEBUG, `[Asshat.Account]: Creating default keybinds for account ${accountDatabaseId} ...`);
for(let j = 1 ; j <= 4 ; j++) {
logToConsole(LOG_DEBUG, `[Asshat.Account]: Creating default keybinds for account ${accountDatabaseId} on server ${j} ...`);
for(let i in getGlobalConfig().keyBind.defaultKeyBinds) {
logToConsole(LOG_DEBUG, `[Asshat.Account]: Creating default keybind ${i} for account ${accountDatabaseId} on server ${j} with key ${sdl.getKeyFromName(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName.toLowerCase())} ...`);
let dbQueryString = `INSERT INTO acct_hotkey (acct_hotkey_acct, acct_hotkey_server, acct_hotkey_key, acct_hotkey_cmdstr, acct_hotkey_when_added, acct_hotkey_down) VALUES (${accountDatabaseId}, ${j}, ${sdl.getKeyFromName(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName.toLowerCase())}, '${getGlobalConfig().keyBind.defaultKeyBinds[i].commandString}', UNIX_TIMESTAMP(), ${getGlobalConfig().keyBind.defaultKeyBinds[i].keyState})`;
quickDatabaseQuery(dbQueryString);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Created default keybind ${i} for account ${accountDatabaseId} on server ${j} with key ${sdl.getKeyFromName(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName.toLowerCase())}!`);
}
logToConsole(LOG_DEBUG, `[Asshat.Account]: Create default keybinds for account ${accountDatabaseId} on server ${j}!`);
}
logToConsole(LOG_DEBUG, `[Asshat.Account]: Created default keybinds for account ${accountDatabaseId} successfully!`);
}
// ===========================================================================
function createDefaultAccountServerData(accountDatabaseId) {
for(let i = 1 ; i <= 4 ; i++) {
let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accountDatabaseId}, ${i})`;
quickDatabaseQuery(dbQueryString);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAccountKeybindsFromDatabase(accountDatabaseID) {
logToConsole(LOG_DEBUG, `[Asshat.Account]: Loading account keybinds for account ${accountDatabaseID} from database ...`);
@@ -821,7 +976,7 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) {
let dbAssoc;
if(dbConnection) {
dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID}`);
dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID} AND acct_hotkey_server = ${getServerId()}`);
if(dbQuery) {
if(dbQuery.numRows > 0) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
@@ -839,7 +994,7 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) {
return tempAccountKeybinds;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
logToConsole(LOG_DEBUG, `[Asshat.Account]: Loading account staff notes for account ${accountDatabaseID} from database ...`);
@@ -868,7 +1023,7 @@ function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
return tempAccountStaffNotes;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAccountContactsFromDatabase(accountDatabaseID) {
logToConsole(LOG_DEBUG, `[Asshat.Account]: Loading account contacts for account ${accountDatabaseID} from database ...`);
@@ -897,7 +1052,7 @@ function loadAccountContactsFromDatabase(accountDatabaseID) {
return tempAccountContacts;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAccountMessagesFromDatabase(accountDatabaseID) {
logToConsole(LOG_DEBUG, `[Asshat.Account]: Loading account messages for account ${accountDatabaseID} from database ...`);
@@ -926,7 +1081,7 @@ function loadAccountMessagesFromDatabase(accountDatabaseID) {
return tempAccountMessages;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isAccountAutoIPLoginEnabled(accountData) {
let accountSettings = accountData.settings;
@@ -934,7 +1089,7 @@ function isAccountAutoIPLoginEnabled(accountData) {
return hasBitFlag(accountSettings, flagValue);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveGUIEnabled(client) {
if(hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("noGUI"))) {
@@ -944,7 +1099,7 @@ function doesPlayerHaveGUIEnabled(client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveLogoEnabled(client) {
if(hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("noServerLogo"))) {
@@ -954,7 +1109,7 @@ function doesPlayerHaveLogoEnabled(client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveAutoLoginByIPEnabled(client) {
if(hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("autoLoginIP"))) {
@@ -964,20 +1119,73 @@ function doesPlayerHaveAutoLoginByIPEnabled(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveAutoSelectLastCharacterEnabled(client) {
if(hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("autoSelectLastCharacter"))) {
return true;
}
return true;
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerStaffTitle(client) {
return getPlayerData(client).accountData.staffTitle;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isAccountEmailVerified(accountData) {
return hasBitFlag(accountData.flags.moderation, getModerationFlagValue("emailVerified"));
}
// ===========================================================================
function isAccountTwoFactorAuthenticationVerified(accountData) {
return hasBitFlag(accountData.flags.moderation, getModerationFlagValue("twoFactorAuthVerified"));
}
// ===========================================================================
function setAccountEmail(accountData, emailAddress) {
accountData.emailAddress = emailAddress;
}
// ===========================================================================
function setAccountEmailVerificationCode(accountData, emailVerificationCode) {
accountData.emailVerificationCode = module.hashing.sha512(emailVerificationCode);
}
// ===========================================================================
function generateEmailVerificationCode() {
return generateRandomString(10);
}
// ===========================================================================
function sendEmailVerificationEmail(client, emailVerificationCode) {
let emailBodyText = getEmailConfig().bodyContent.confirmEmail;
emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", emailVerificationCode);
sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on Asshat Gaming RP`, emailBodyText);
}
// ===========================================================================
function verifyAccountEmail(accountData, verificationCode) {
let emailVerificationCode = generateRandomString(10);
let emailBodyText = getEmailConfig().bodyContent.confirmEmail;
emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", emailVerificationCode);
sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on Asshat Gaming RP`, emailBodyText);
getPlayerData(client).accountData.emailAddress = emailAddress;
getPlayerData(client).accountData.emailVerificationCode = module.hashing.sha512(emailVerificationCode);
}
// ===========================================================================

View File

@@ -1,9 +0,0 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: ammunation.js
// DESC: Provides ammunation functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: anticheat.js
// DESC: Provides anticheat functions and usage
// TYPE: Server (JavaScript)
@@ -14,7 +14,7 @@ function initAntiCheatScript() {
getServerData().antiCheat.blackListedGameScripts = loadAntiCheatGameScriptBlackListFromDatabase();
logToConsole(LOG_DEBUG, "[Asshat.AntiCheat]: Anticheat script initialized!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAntiCheatGameScriptWhiteListFromDatabase() {
logToConsole(LOG_DEBUG, `[Asshat.AntiCheat] Loading whitelisted game scripts ...`);
@@ -38,7 +38,7 @@ function loadAntiCheatGameScriptWhiteListFromDatabase() {
return tempWhiteListedGameScripts;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAntiCheatGameScriptBlackListFromDatabase() {
logToConsole(LOG_DEBUG, `[Asshat.AntiCheat] Loading blacklisted game scripts ...`);
@@ -62,4 +62,17 @@ function loadAntiCheatGameScriptBlackListFromDatabase() {
return tempBlackListedGameScripts;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clearPlayerStateToEnterExitProperty(client) {
if(getPlayerData(client).pedState != AG_PEDSTATE_READY) {
if(getPlayerData(client).pedState == AG_PEDSTATE_ENTERINGVEHICLE) {
sendPlayerClearPedState(client);
getPlayerData(client).pedState = AG_PEDSTATE_READY;
} else {
return false;
}
}
}
// ===========================================================================

View File

@@ -2,28 +2,20 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: bans.js
// DESC: Provides ban functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
const banType = {
none: 0,
account: 1,
subAccount: 3,
ipAddress: 4,
uid: 5,
};
// ---------------------------------------------------------------------------
// ===========================================================================
function initBanScript() {
logToConsole(LOG_DEBUG, "[Asshat.Ban]: Initializing ban script ...");
logToConsole(LOG_DEBUG, "[Asshat.Ban]: Ban script initialized!");
logToConsole(LOG_INFO, "[Asshat.Ban]: Initializing ban script ...");
logToConsole(LOG_INFO, "[Asshat.Ban]: Ban script initialized!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function accountBanCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -37,12 +29,18 @@ function accountBanCommand(command, params, client) {
return false;
}
messageAdminAction(`${getPlayerData(targetClient).accountData.name} has been banned from the server (account ban).`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, "");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(splitParams[0]);
let reason = splitParams.slice(1).join(" ");
logToConsole(LOG_WARN, `[Asshat.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
messageAdminAction(`${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) has been account banned.`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function subAccountBanCommand(command, params, client, fromDiscord) {
if(areParamsEmpty(params)) {
@@ -60,12 +58,14 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
let targetClient = getPlayerFromParams(splitParams[0]);
let reason = splitParams.slice(1).join(" ");
messageAdminAction(`${getPlayerData(targetClient).currentSubAccountData.name} has been banned from the server (character ban).`);
logToConsole(LOG_WARN, `[Asshat.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
messageAdminAction(`${getPlayerData(targetClient).currentSubAccountData.name} has been character banned.`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function ipBanCommand(command, params, client, fromDiscord) {
if(areParamsEmpty(params)) {
@@ -83,13 +83,13 @@ function ipBanCommand(command, params, client, fromDiscord) {
let targetClient = getPlayerFromParams(splitParams[0]);
let reason = splitParams.slice(1).join(" ");
messageAdminAction(`${targetClient.name} has been banned from the server (IP ban).`);
messageAdminAction(`${targetClient.name} has been IP banned.`);
banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip);
targetClient.disconnect();
}
// ---------------------------------------------------------------------------
// ===========================================================================
function subNetBanCommand(command, params, client, fromDiscord) {
if(areParamsEmpty(params)) {
@@ -112,7 +112,7 @@ function subNetBanCommand(command, params, client, fromDiscord) {
banSubNet(targetClient.ip, getSubNet(targetClient.ip, octetAmount), getPlayerData(client).accountData.databaseId, reason);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function banAccount(accountId, adminAccountId, reason) {
let dbConnection = connectToDatabase();
@@ -127,7 +127,7 @@ function banAccount(accountId, adminAccountId, reason) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function banSubAccount(subAccountId, adminAccountId, reason) {
let dbConnection = connectToDatabase();
@@ -142,7 +142,7 @@ function banSubAccount(subAccountId, adminAccountId, reason) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function banIPAddress(ipAddress, adminAccountId, reason) {
let dbConnection = connectToDatabase();
@@ -157,7 +157,7 @@ function banIPAddress(ipAddress, adminAccountId, reason) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
let dbConnection = connectToDatabase();
@@ -172,7 +172,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function unbanAccount(accountId, adminAccountId) {
let dbConnection = connectToDatabase();
@@ -186,7 +186,7 @@ function unbanAccount(accountId, adminAccountId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function unbanSubAccount(subAccountId, adminAccountId) {
let dbConnection = connectToDatabase();
@@ -200,7 +200,7 @@ function unbanSubAccount(subAccountId, adminAccountId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function unbanIPAddress(ipAddress, adminAccountId) {
let dbConnection = connectToDatabase();
@@ -214,7 +214,7 @@ function unbanIPAddress(ipAddress, adminAccountId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
let dbConnection = connectToDatabase();
@@ -228,7 +228,7 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isAccountBanned(accountId) {
let bans = getServerData().bans;
@@ -243,7 +243,7 @@ function isAccountBanned(accountId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isSubAccountBanned(subAccountId) {
let bans = getServerData().bans;
@@ -258,7 +258,7 @@ function isSubAccountBanned(subAccountId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isIpAddressBanned(ipAddress) {
let bans = getServerData().bans;
@@ -273,5 +273,5 @@ function isIpAddressBanned(ipAddress) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,13 +2,13 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: bitflags.js
// DESC: Provides bitwise operations, functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
// ===========================================================================
let serverBitFlags = {
staffFlags: {},
@@ -17,9 +17,10 @@ let serverBitFlags = {
clanFlags: {},
accountSettingsFlags: {},
subAccountSettingsFlags: {},
accountFlags: {},
};
// ---------------------------------------------------------------------------
// ===========================================================================
let serverBitFlagKeys = {
staffFlagKeys: [
@@ -34,6 +35,7 @@ let serverBitFlagKeys = {
"manageJobs",
"manageItems",
"manageWorld",
"manageAntiCheat",
"developer",
],
moderationFlagKeys: [
@@ -44,13 +46,24 @@ let serverBitFlagKeys = {
"gunBanned",
"jobBanned",
"ammuBanned",
"noSkinCustomization",
"desyncWeapons",
"hackerWorld",
"adminJailed",
"exemptFromAntiCheat",
"exemptFromBans",
"forceTutorial",
"characterNameNeedsStaffApproval",
"emailVerified",
"twoFactorAuthVerified",
],
factionFlagKeys: [
"none",
"police",
"medical",
"fire",
"government"
"government",
"generic",
],
clanFlagKeys: [
"none",
@@ -83,6 +96,7 @@ let serverBitFlagKeys = {
"manageVehicles",
"manageHouses",
"manageBusinesses",
"manageNPCs",
"owner",
],
accountSettingsFlagKeys: [
@@ -95,13 +109,109 @@ let serverBitFlagKeys = {
"autoLoginIP",
"noServerLogo",
"autoSelectLastCharacter",
"showRealTimeClock",
"useGUIForItems",
"useRadialWheelItems", // If this is disabled, use MMORPG-style hotbar IF useGUIForItems is enabled
"disableKeyBinds",
"showTimedRandomTips",
"showActionTips",
],
npcTriggerTypeKeys: [
"farProximity", // Comes within a far distance of NPC
"mediumProximity", // Comes within a medium distance of NPC
"nearProximity", // Comes within a close distance of NPC
"enterLineOfSight", // Enters the NPC's line of sight
"exitLineOfSight", // Leaves the NPC's line of sight
"pedCollision", // Bumps into ped on foot
"vehicleCollision", // Bumps into ped with a vehicle
"shootGun", // Shoots a gun (target isn't a factor, it's just about only shooting a gun in general)
"swingMelee", // Swings a melee weapon (target doesnt matter, it's just about only swinging a melee weapon in general)
"hotwireVehicleStart", // Begin attempt to hotwire a vehicle
"hotwireVehicleFail", // Failed to hotwire a vehicle
"hotwireVehicleSucceed", // Succeeded at hotwiring a vehicle
"vehicleAlarmStart", // Vehicle alarm goes off
"vehicleAlarmStop", // Vehicle alarm shuts off (disabled, battery dead, damaged, or just turned off legitly)
"sirenStart", // Any vehicle with a siren that gets activated
"sirenStop", // Any vehicle with a siren that gets deactivated
"vehicleEnter", // Enters any vehicle
"vehicleExit", // Exits any vehicle
"propertyEnter", // Enters any interior
"propertyExit", // Exits any interior
"attackedByMelee", // Any element is attacked by melee weapon
"attackedByGun", // Any element is attacked by gun
"attackedByFist", // Any element is attacked by fist
],
npcTriggerConditionTypeKeys: [
"isInLineOfSight",
"isFarProximity",
"isMediumProximity",
"isNearProximity",
"isEnemyClan",
"isAllyClan",
"isSameClan",
"isNotInClan",
"isLawEnforcement",
"isFirefighter",
"isParamedic",
"isCriminal",
"hasWantedLevel",
"isSelfVehicle",
"isPlayerVehicle",
"isOtherVehicle",
"isClanVehicle",
"isEmergencyVehicle",
"isPoliceVehicle",
"isDriver",
"isInFrontSeat",
"isInSeatId",
"vehicleLocked",
"vehicleHotwired",
"isPistol",
"isShotgun",
"isAutomatic",
"isRifle",
"isAssaultRifle",
"isSniper",
"isRPG",
"isFlameThrower",
"isTalking",
"isShouting",
"isWhispering",
],
npcTriggerResponseTypeKeys: [
"shout",
"talk",
"whisper",
"switchWeapon",
"shootWeapon",
"aimWeapon",
"fleeSprint",
"fleeWalk",
"fleeRun",
"attackMelee",
"attackFist",
"walkToward",
"runToward",
"sprintToward",
"crouch",
"phoneCall",
"walkieTalkieMessage",
"switchRadioStation",
"toggleSiren",
"fleeTo",
"driveTo",
"enterVehicle",
"exitVehicle",
"pullOutOfVehicle",
"enterProperty",
"searchArea",
],
subAccountSettingsFlagKeys: [],
}
// ---------------------------------------------------------------------------
// ===========================================================================
function initBitFlagScript() {
logToConsole(LOG_INFO, "[Asshat.BitFlag]: Initializing bit flag script ...");
serverBitFlags.staffFlags = createBitFlagTable(serverBitFlagKeys.staffFlagKeys);
serverBitFlags.moderationFlags = createBitFlagTable(serverBitFlagKeys.moderationFlagKeys);
serverBitFlags.accountSettingsFlags = createBitFlagTable(serverBitFlagKeys.accountSettingsFlagKeys);
@@ -109,16 +219,14 @@ function initBitFlagScript() {
serverBitFlags.clanFlags = createBitFlagTable(serverBitFlagKeys.clanFlagKeys);
serverBitFlags.clanPermissionFlags = createBitFlagTable(serverBitFlagKeys.clanPermissionFlagKeys);
serverBitFlags.factionFlags = createBitFlagTable(serverBitFlagKeys.factionFlagKeys);
serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys);
serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys);
serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys);
logToConsole(LOG_INFO, "[Asshat.BitFlag]: Bit flag script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addBitFlagCommandHandlers() {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createBitFlagTable(keyNames) {
let bitVal = 0;
@@ -134,7 +242,7 @@ function createBitFlagTable(keyNames) {
return bitTable;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function hasBitFlag(allFlags, checkForFlag) {
if(allFlags == 0) {
@@ -148,7 +256,7 @@ function hasBitFlag(allFlags, checkForFlag) {
return (allFlags & checkForFlag);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveStaffPermission(client, requiredFlags) {
if(isConsole(client)) {
@@ -176,7 +284,7 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveClanPermission(client, requiredFlags) {
if(isConsole(client)) {
@@ -206,7 +314,7 @@ function doesPlayerHaveClanPermission(client, requiredFlags) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getStaffFlagValue(flagName) {
if(flagName == "all") {
@@ -220,7 +328,7 @@ function getStaffFlagValue(flagName) {
return serverBitFlags.staffFlags[flagName];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getClanFlagValue(flagName) {
if(flagName == "all") {
@@ -234,7 +342,7 @@ function getClanFlagValue(flagName) {
return getServerBitFlags().clanFlags[flagName];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getAccountSettingsFlagValue(flagName) {
if(flagName == "all") {
@@ -248,21 +356,21 @@ function getAccountSettingsFlagValue(flagName) {
return serverBitFlags.accountSettingsFlags[flagName];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getAccountFlagsFlagValue(flagName) {
function getModerationFlagValue(flagName) {
if(flagName == "all") {
return -1;
}
if(typeof serverBitFlags.accountFlags[flagName] === "undefined") {
if(typeof serverBitFlags.moderationFlags[flagName] === "undefined") {
return false;
}
return serverBitFlags.accountFlags[flagName];
return serverBitFlags.moderationFlags[flagName];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function givePlayerStaffFlag(client, flagName) {
if(!getStaffFlagValue(flagName)) {
@@ -273,7 +381,7 @@ function givePlayerStaffFlag(client, flagName) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function takePlayerStaffFlag(client, flagName) {
if(!getStaffFlagValue(flagName)) {
@@ -284,19 +392,19 @@ function takePlayerStaffFlag(client, flagName) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addBitFlag(allFlags, flagValue) {
return allFlags | flagValue;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removeBitFlag(allFlags, flagValue) {
return allFlags & ~flagValue;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function takePlayerStaffFlag(client, flagName) {
if(!getStaffFlagValue(flagName)) {
@@ -307,23 +415,39 @@ function takePlayerStaffFlag(client, flagName) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clearPlayerStaffFlags(client) {
getPlayerData(client).accountData.flags.admin = getStaffFlagValue("none");
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getServerBitFlags() {
return serverBitFlags;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getServerBitFlagKeys() {
return serverBitFlagKeys;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createBitwiseTable(tableKeys) {
let bitVal = 0;
let bitTable = {};
let incVal = 1;
for(let i in tableKeys) {
let key = tableKeys[i];
bitTable[key] = bitVal;
bitVal = 1 << incVal;
incVal++;
}
return bitTable;
}
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: bakery.js
// DESC: Provides bakery business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: bar.js
// DESC: Provides bar/pub business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: burger.js
// DESC: Provides burger joint (McDonalds?) business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: clothing.js
// DESC: Provides clothing (skin) business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: club.js
// DESC: Provides club/nightclub business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: fuel.js
// DESC: Provides fuel/petrol business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: mechanic.js
// DESC: Provides mechanic/vehicle repair business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: pizza.js
// DESC: Provides pizza restaurant business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: restaurant.js
// DESC: Provides generic restaurant business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: vehicle.js
// DESC: Provides vehicle dealership business functions and usage
// TYPE: Business (JavaScript)

View File

@@ -2,8 +2,9 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: weapon.js
// DESC: Provides weapon (ammu) business functions and usage
// DESC: Provides weapon (ammunations & illegal gunshops) business usage
// TYPE: Business (JavaScript)
// ===========================================================================
// ===========================================================================

View File

@@ -2,19 +2,19 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: chat.js
// DESC: Provides chat functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initChatScript() {
logToConsole(LOG_DEBUG, "[Asshat.Chat]: Initializing chat script ...");
logToConsole(LOG_DEBUG, "[Asshat.Chat]: Chat script initialized successfully!");
logToConsole(LOG_INFO, "[Asshat.Chat]: Initializing chat script ...");
logToConsole(LOG_INFO, "[Asshat.Chat]: Chat script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function meActionCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -26,9 +26,14 @@ function meActionCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doActionCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -38,9 +43,14 @@ function doActionCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function shoutCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -50,9 +60,14 @@ function shoutCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function talkCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -62,9 +77,14 @@ function talkCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function whisperCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -74,9 +94,14 @@ function whisperCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function adminChatCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -85,9 +110,14 @@ function adminChatCommand(command, params, client) {
messageAdmins(`[#FFFF00][Admin Chat] [#AAAAAA]${client.name} [#CCCCCC](${getPlayerStaffTitle(client)})[#FFFFFF]: ${params}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clanChatCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -96,18 +126,18 @@ function clanChatCommand(command, params, client) {
clanChat(client, params);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function talkToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
for(let i in clients) {
//if(clients[i] != client) {
messagePlayerTalk(getClientFromPlayerElement(clients[i]), client, messageText);
messagePlayerTalk(clients[i], client, messageText);
//}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function phoneOutgoingToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
@@ -116,7 +146,7 @@ function phoneOutgoingToNearbyPlayers(client, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function phoneIncomingToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().radioSpeakerDistance);
@@ -125,59 +155,59 @@ function phoneIncomingToNearbyPlayers(client, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function whisperToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(client.player.position, getGlobalConfig().talkDistance);
let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
for(let i in clients) {
//if(clients[i] != client) {
messagePlayerWhisper(getClientFromPlayerElement(clients[i]), client, messageText);
messagePlayerWhisper(clients[i], client, messageText);
//}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function shoutToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(client.player.position, getGlobalConfig().shoutDistance);
let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().shoutDistance);
for(let i in clients) {
//if(clients[i].index != client.index) {
messagePlayerShout(getClientFromPlayerElement(clients[i]), client, messageText);
messagePlayerShout(clients[i], client, messageText);
//}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doActionToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(client.player.position, getGlobalConfig().doActionDistance);
let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().doActionDistance);
for(let i in clients) {
//if(clients[i].index != client.index) {
messagePlayerDoAction(getClientFromPlayerElement(clients[i]), client, messageText);
messagePlayerDoAction(clients[i], client, messageText);
//}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function meActionToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(client.player.position, getGlobalConfig().meActionDistance);
let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().meActionDistance);
for(let i in clients) {
//if(clients[i].index != client.index) {
messagePlayerMeAction(getClientFromPlayerElement(clients[i]), client, messageText);
messagePlayerMeAction(clients[i], client, messageText);
//}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clanChat(client, messageText) {
let clients = getClients();
for(let i in clients) {
if(getPlayerCurrentSubAccount(client).clan != getPlayerCurrentSubAccount(clients[i]).clan) {
messageClientClanChat(getClientFromPlayerElement(clients[i]), client, messageText);
messageClientClanChat(clients[i], client, messageText);
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,24 +2,24 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: clan.js
// DESC: Provides clan functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initClanScript() {
logToConsole(LOG_DEBUG, "[Asshat.Clan]: Initializing clans script ...");
logToConsole(LOG_INFO, "[Asshat.Clan]: Initializing clans script ...");
getServerData().clans = loadClansFromDatabase();
setAllClanDataIndexes();
logToConsole(LOG_DEBUG, "[Asshat.Clan]: Clan script initialized successfully!");
logToConsole(LOG_INFO, "[Asshat.Clan]: Clan script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadClansFromDatabase() {
logToConsole(LOG_DEBUG, "[Asshat.Clan]: Loading clans from database ...");
logToConsole(LOG_INFO, "[Asshat.Clan]: Loading clans from database ...");
let tempClans = [];
let dbConnection = connectToDatabase();
@@ -30,11 +30,11 @@ function loadClansFromDatabase() {
if(dbQuery) {
if(dbQuery.numRows > 0) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempClanData = getClasses().clanData(dbAssoc);
let tempClanData = new serverClasses.clanData(dbAssoc);
tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId);
tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId);
tempClans.push(tempClanData);
logToConsole(LOG_DEBUG, `[Asshat.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
logToConsole(LOG_VERBOSE, `[Asshat.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -42,11 +42,95 @@ function loadClansFromDatabase() {
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_DEBUG, `[Asshat.Clan]: ${tempClans.length} clans loaded from database successfully!`);
logToConsole(LOG_INFO, `[Asshat.Clan]: ${tempClans.length} clans loaded from database successfully!`);
return tempClans;
}
// -------------------------------------------------------------------------
// ===========================================================================
function loadClanMembersFromDatabase() {
logToConsole(LOG_INFO, "[Asshat.Clan]: Loading clans from database ...");
let tempClans = [];
let dbConnection = connectToDatabase();
let dbAssoc;
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`);
if(dbQuery) {
if(dbQuery.numRows > 0) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempClanData = new serverClasses.clanData(dbAssoc);
tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId);
tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId);
tempClans.push(tempClanData);
logToConsole(LOG_VERBOSE, `[Asshat.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_INFO, `[Asshat.Clan]: ${tempClans.length} clans loaded from database successfully!`);
return tempClans;
}
// ===========================================================================
function loadClanRanksFromDatabase(clanDatabaseId) {
logToConsole(LOG_INFO, `[Asshat.Clan]: Loading ranks for clan ${clanDatabaseId} from database ...`);
let dbConnection = connectToDatabase();
let dbAssoc;
let tempClanRanks = [];
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_rank WHERE clan_rank_clan = ${clanDatabaseId}`);
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery)
let tempClanRankData = new serverClasses.clanRankData(dbAssoc);
tempClanRanks.push(tempClanRankData);
logToConsole(LOG_VERBOSE, `[Asshat.Clan]: Clan rank '${tempClanRankData.name}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_INFO, `[Asshat.Clan]: Loaded ranks for clan ${clanDatabaseId} from database successfully!`);
return tempClanRanks;
}
// ===========================================================================
function loadClanMembersFromDatabase(clanDatabaseId) {
logToConsole(LOG_INFO, `[Asshat.Clan]: Loading members for clan ${clanDatabaseId} from database ...`);
let dbConnection = connectToDatabase();
let dbAssoc;
let tempClanMembers = [];
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_member WHERE clan_member_clan = ${clanDatabaseId}`);
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery)
let tempClanMemberData = new serverClasses.clanMemberData(dbAssoc);
tempClanMembers.push(tempClanMemberData);
logToConsole(LOG_VERBOSE, `[Asshat.Clan]: Clan member '${tempClanMemberData.subAccount}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_INFO, `[Asshat.Clan]: Loaded members for clan ${clanDatabaseId} from database successfully!`);
return tempClanMembers;
}
// ===========================================================================
function createClanCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -64,7 +148,7 @@ function createClanCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]created clan[#FF9900]${params}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function deleteClanCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -83,7 +167,7 @@ function deleteClanCommand(command, params, client) {
deleteClan(clanId);
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanOwnerCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("owner"))) {
@@ -116,7 +200,7 @@ function setClanOwnerCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set clan[#FF9900]${getClanData(clanId).name} [#FFFFFF]owner to [#AAAAAA]${getCharacterFullName(targetClient)}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanTagCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("clanTag"))) {
@@ -141,7 +225,7 @@ function setClanTagCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set clan[#FF9900]${getClanData(clanId).index} [#FFFFFF]tag to [#AAAAAA]${params}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanNameCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("clanName"))) {
@@ -166,7 +250,7 @@ function setClanNameCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set clan[#FF9900]${getClanData(clanId).index} [#FFFFFF]name to [#AAAAAA]${params}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanMemberTagCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberTag"))) {
@@ -199,7 +283,7 @@ function setClanMemberTagCommand(command, params, client) {
messagePlayerAlert(client, `[#AAAAAA]${getCharacterFullName(targetClient)} [#FFFFFF]set your clan tag to [#AAAAAA]${tag}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanRankTagCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankTag"))) {
@@ -229,7 +313,7 @@ function setClanRankTagCommand(command, params, client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function addClanMemberFlagCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberFlags"))) {
@@ -266,7 +350,7 @@ function addClanMemberFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to [#AAAAAA]${getCharacterFullName(client)}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function removeClanMemberFlagCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberFlags"))) {
@@ -303,7 +387,7 @@ function removeClanMemberFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from [#AAAAAA]${getCharacterFullName(client)}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function addClanRankFlagCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankFlags"))) {
@@ -341,7 +425,7 @@ function addClanRankFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function removeClanRankFlagCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankFlags"))) {
@@ -379,7 +463,7 @@ function removeClanRankFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanMemberTitleCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberTitle"))) {
@@ -411,7 +495,7 @@ function setClanMemberTitleCommand(command, params, client) {
messagePlayerSuccess(client, `You changed the name of [#AAAAAA]${getCharacterFullName(client)} [#FFFFFF]from [#AAAAAA]${oldMemberTitle} [#FFFFFF]to [#AAAAAA]${params}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanRankTitleCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankTitle"))) {
@@ -443,7 +527,7 @@ function setClanRankTitleCommand(command, params, client) {
messagePlayerSuccess(client, `You changed the name of rank ${rankId} from [#AAAAAA]${oldRankName} [#FFFFFF]to [#AAAAAA]${params}`);
}
// -------------------------------------------------------------------------
// ===========================================================================
function createClan(name) {
let dbConnection = connectToDatabase();
@@ -451,19 +535,18 @@ function createClan(name) {
if(dbConnection) {
escapedName = escapeDatabaseString(dbConnection, escapedName)
let dbQuery = queryDatabase(dbConnection, `INSERT INTO clan_main (clan_server, clan_name) VALUES (${getServerId()}, '${escapedName}')`);
disconnectFromDatabase(dbConnection);
queryDatabase(dbConnection, `INSERT INTO clan_main (clan_server, clan_name) VALUES (${getServerId()}, '${escapedName}')`);
let tempClan = new serverClasses.clanData();
tempClan.databaseId = getDatabaseInsertId(dbConnection);
tempClan.name = name;
getServerData().clans.push(tempClan);
let tempClanData = loadClanFromDatabaseById(getDatabaseInsertId(dbConnection));
if(tempClanData != false) {
let tempClan = serverClasses.clanData(tempClanData);
getServerData().clans.push(tempClan);
}
setAllClanDataIndexes();
}
return true;
}
// -------------------------------------------------------------------------
// ===========================================================================
function deleteClan(clanId) {
saveClansToDatabase();
@@ -481,7 +564,7 @@ function deleteClan(clanId) {
return false;
}
// -------------------------------------------------------------------------
// ===========================================================================
function getClanData(clanId) {
let clans = getServerData().clans;
@@ -494,7 +577,7 @@ function getClanData(clanId) {
return false;
}
// -------------------------------------------------------------------------
// ===========================================================================
function doesClanNameExist(name) {
let clans = getServerData().clans;
@@ -507,7 +590,7 @@ function doesClanNameExist(name) {
return false;
}
// -------------------------------------------------------------------------
// ===========================================================================
function doesClanIdExist(clanId) {
let clans = getServerData().clans;
@@ -520,13 +603,13 @@ function doesClanIdExist(clanId) {
return false;
}
// -------------------------------------------------------------------------
// ===========================================================================
function reloadAllClans() {
getServerData().clans = loadClansFromDatabase();
}
// -------------------------------------------------------------------------
// ===========================================================================
function saveClansToDatabase() {
let clans = getServerData().clans;
@@ -535,12 +618,13 @@ function saveClansToDatabase() {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function saveClanToDatabase(clanData) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQueryString = `UPDATE clan_main SET clan_name = '${escapeDatabaseString(dbConnection, clanData.name)}', clan_owner = ${clanData.ownerId}`;
let safeClanName = escapeDatabaseString(dbConnection, clanData.name);
let dbQueryString = `UPDATE clan_main SET clan_name = '${safeClanName}', clan_owner = ${clanData.ownerId} WHERE clan_id = ${clanData.databaseId}`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
@@ -550,55 +634,55 @@ function saveClanToDatabase(clanData) {
return false;
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanTag(clanId, tag) {
getClanData(clanId).tag = tag;
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanOwner(clanId, ownerId) {
getClanData(clanId).ownerId = ownerId;
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanMemberTag(memberId, tag) {
// finish this later, need to query db
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanMemberFlags(memberId, flags) {
// finish this later, need to query db
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanMemberTitle(memberId, title) {
// finish this later, need to query db
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanRankTag(clanId, rankId, tag) {
getClanRankData(clanId, rankId).tag = tag;
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanRankFlags(clanId, rankId, flags) {
getClanRankData(clanId, rankId).flags = flags;
}
// -------------------------------------------------------------------------
// ===========================================================================
function setClanRankTitle(clanId, rankId, title) {
getClanRankData(clanId, rankId).title = title;
}
// -------------------------------------------------------------------------
// ===========================================================================
function saveAllClansToDatabase() {
for(let i in getServerData().clans) {
@@ -606,7 +690,7 @@ function saveAllClansToDatabase() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setAllClanDataIndexes() {
for(let i in getServerData().clans) {
@@ -624,7 +708,7 @@ function setAllClanDataIndexes() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function arePlayersInSameClan(client1, client2) {
if(getPlayerClan(client1) == getPlayerClan(client2)) {
@@ -634,4 +718,4 @@ function arePlayersInSameClan(client1, client2) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,20 +2,23 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: class.js
// DESC: Provides classes
// TYPE: Server (JavaScript)
// ===========================================================================
let serverClasses = initClassTable();
let serverClasses = {};
// ---------------------------------------------------------------------------
// ===========================================================================
function initClassScript() {
logToConsole(LOG_INFO, "[Asshat.Class]: Initializing class script ...");
serverClasses = initClassTable();
logToConsole(LOG_INFO, "[Asshat.Class]: Class script initialized successfully!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function initClassTable() {
let tempClasses = {
@@ -36,6 +39,14 @@ function initClassTable() {
this.connectCameraPosition = false;
this.connectCameraLookAt = false;
this.characterSelectCameraPosition = false;
this.characterSelectCameraLookAt = false;
this.characterSelectPedPosition = false;
this.characterSelectPedHeading = false;
this.characterSelectInterior = false;
this.characterSelectDimension = false;
this.hour = 0;
this.minute = 0
this.weather = 0
@@ -44,10 +55,13 @@ function initClassTable() {
this.useGUI = true;
this.guiColour = [200, 200, 200];
this.showLogo = true;
this.inflationMultiplier = 1;
this.antiCheat = {
enabled: false,
checkGameScripts: false,
gameScriptWhiteListEnabled: false,
gameScriptBlackListEnabled: false,
gameScriptWhiteList: [],
gameScriptBlackList: [],
};
@@ -55,6 +69,13 @@ function initClassTable() {
this.discordBotToken = "";
this.discordEnabled = false;
this.createJobPickups = false;
this.createBusinessPickups = false;
this.createHousePickups = false;
this.createJobBlips = false;
this.createBusinessBlips = false;
this.createHouseBlips = false;
if(dbAssoc) {
this.databaseId = dbAssoc["svr_id"];
this.name = dbAssoc["svr_name"];
@@ -69,8 +90,17 @@ function initClassTable() {
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.characterSelectCameraPosition = toVector3(dbAssoc["svr_charselect_cam_pos_x"], dbAssoc["svr_charselect_cam_pos_y"], dbAssoc["svr_charselect_cam_pos_z"]);
this.characterSelectCameraLookAt = toVector3(dbAssoc["svr_charselect_cam_lookat_x"], dbAssoc["svr_charselect_cam_lookat_y"], dbAssoc["svr_charselect_cam_lookat_z"]);
this.characterSelectPedPosition = toVector3(dbAssoc["svr_charselect_ped_pos_x"], dbAssoc["svr_charselect_ped_pos_y"], dbAssoc["svr_charselect_ped_pos_z"]);
this.characterSelectPedHeading = toFloat(dbAssoc["svr_charselect_ped_rot_z"]);
this.characterSelectInterior = toInteger(dbAssoc["svr_charselect_int"]);
this.characterSelectDimension = toInteger(dbAssoc["svr_charselect_int"]);
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(dbAssoc["svr_start_snow_falling"]);
this.groundSnow = intToBool(dbAssoc["svr_start_snow_ground"]);
@@ -82,12 +112,23 @@ function initClassTable() {
this.antiCheat = {
enabled: intToBool(dbAssoc["svr_ac_enabled"]),
checkGameScripts: intToBool(dbAssoc["svr_ac_check_scripts"]),
gameScriptBlackListEnabled: intToBool(dbAssoc["svr_ac_script_bl"]),
gameScriptWhiteListEnabled: intToBool(dbAssoc["svr_ac_script_wl"]),
gameScriptWhiteList: [],
gameScriptBlackList: [],
};
this.discordBotToken = "";
this.discordEnabled = false;
this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]);
this.discordEnabled = intToBool(dbAssoc["svr_discord_bot_enabled"]);
this.createJobPickups = intToBool(dbAssoc["svr_job_pickups"]);
this.createBusinessPickups = intToBool(dbAssoc["svr_biz_pickups"]);
this.createHousePickups = intToBool(dbAssoc["svr_house_pickups"]);
this.createJobBlips = intToBool(dbAssoc["svr_job_blips"]);
this.createBusinessBlips = intToBool(dbAssoc["svr_biz_blips"]);
this.createHouseBlips = intToBool(dbAssoc["svr_house_blips"]);
this.introMusicURL = dbAssoc["svr_intro_music"];
}
}
},
@@ -103,13 +144,10 @@ function initClassTable() {
this.clientVersion = "0.0.0";
this.loginAttemptsRemaining = 3;
this.busRoute = null;
this.busRouteStop = null;
this.busRouteIsland = null;
this.garbageRoute = null;
this.garbageRouteStop = null;
this.garbageRouteIsland = null;
this.jobRoute = false;
this.jobRouteStop = false;
this.jobRouteIsland = false;
this.jobRouteVehicle = false;
this.spawned = false;
@@ -123,7 +161,6 @@ function initClassTable() {
this.switchingCharacter = false;
this.tutorialState = AG_TUTORIAL_STATE_NONE;
this.tutorialStep = -1;
this.tutorialItem = null;
this.tutorialVehicle = null;
@@ -134,6 +171,7 @@ function initClassTable() {
this.jobLockerCache = new Array(9).fill(-1);
this.jobEquipmentCache = [];
this.jobUniform = 0;
this.itemActionState = AG_ITEM_ACTION_NONE;
this.itemActionItem = -1;
@@ -141,6 +179,33 @@ function initClassTable() {
this.alcoholLevel = 0;
this.pedState = AG_PEDSTATE_NONE;
this.promptType = AG_PROMPT_NONE;
this.businessOrderAmount = 0;
this.businessOrderBusiness = -1;
this.businessOrderItem = -1;
this.businessOrderValue = -1;
this.syncPosition = null;
this.syncHeading = null;
this.twoFactorAuthenticationState = AG_2FA_STATE_NONE;
this.twoFactorAuthenticationCode = 0;
this.payDayAmount = 0;
this.payDayTickStart = 0;
this.creatingCharacter = false;
this.creatingCharacterSkin = -1;
this.streamingRadioStation = -1;
this.streamingRadioVolume = 25;
this.returnToPosition = null;
this.returnToHeading = null;
this.returnToInterior = null;
this.returnToDimension = null;
}
},
accountData: class {
@@ -166,7 +231,11 @@ function initClassTable() {
this.keyBinds = [];
this.contacts = [];
this.subAccounts = [];
this.loggedIn = false;
this.emailVerificationCode = "";
this.twoFactorAuthVerificationCode = "";
this.chatScrollLines = 1;
if(dbAssoc) {
this.databaseId = dbAssoc["acct_id"];
@@ -174,15 +243,16 @@ function initClassTable() {
this.password = dbAssoc["acct_pass"];
this.registerDate = dbAssoc["acct_when_made"];
this.flags = {
moderation: dbAssoc["acct_mod_flags"],
settings: dbAssoc["acct_settings"],
admin: dbAssoc["acct_staff_flags"],
moderation: dbAssoc["acct_svr_mod_flags"],
settings: dbAssoc["acct_svr_settings"],
admin: dbAssoc["acct_svr_staff_flags"],
};
this.staffTitle = dbAssoc["acct_staff_title"];
this.ircAccount = dbAssoc["acct_irc"] || "None";
this.staffTitle = dbAssoc["acct_svr_staff_title"];
this.ircAccount = dbAssoc["acct_irc"];
this.discordAccount = dbAssoc["acct_discord"];
this.settings = dbAssoc["acct_settings"];
this.settings = dbAssoc["acct_svr_settings"];
this.emailAddress = dbAssoc["acct_email"];
this.whenRegistered = dbAssoc["acct_when_registered"];
this.ipAddress = dbAssoc["ipstring"];
this.notes = [];
@@ -190,7 +260,10 @@ function initClassTable() {
this.keyBinds = [];
this.contacts = [];
this.subAccounts = [];
this.loggedIn = false;
this.emailVerificationCode = dbAssoc["acct_code_verifyemail"];
this.twoFactorAuthVerificationCode = dbAssoc["acct_code_2fa"];
this.chatScrollLines = dbAssoc["acct_svr_chat_scroll_lines"];
}
}
},
@@ -268,11 +341,10 @@ function initClassTable() {
this.server = 0;
this.firstName = "John";
this.lastName = "Doe";
this.middleName = "Q";
this.account = 0;
this.skin = 0;
this.cash = 0;
this.placeOfOrigin = "";
this.dateOfBirth = "";
this.spawnPosition = toVector3(0.0, 0.0, 0.0);
this.spawnHeading = 0.0;
this.lastLogin = 0;
@@ -289,28 +361,79 @@ function initClassTable() {
this.interior = 0;
this.dimension = 0;
this.pedScale = toVector3(1.0, 1.0, 1.0);
this.walkStyle = 0;
this.fightStyle = 0;
this.health = 100;
this.armour = 100;
this.inHouse = 0;
this.inBusiness = 0;
this.bodyParts = {
hair: [0,0],
head: [0,0],
upper: [0,0],
lower: [0,0],
};
this.bodyProps = {
hair: [0,0],
eyes: [0,0],
head: [0,0],
leftHand: [0,0],
rightHand: [0,0],
leftWrist: [0,0],
rightWrist: [0,0],
hip: [0,0],
leftFoot: [0,0],
rightFoot: [0,0],
};
if(dbAssoc) {
this.databaseId = dbAssoc["sacct_id"];
this.server = dbAssoc["sacct_server"];
this.server = toInteger(dbAssoc["sacct_server"]);
this.firstName = dbAssoc["sacct_name_first"];
this.lastName = dbAssoc["sacct_name_last"];
this.account = dbAssoc["sacct_acct"];
this.skin = dbAssoc["sacct_skin"];
this.cash = dbAssoc["sacct_cash"];
this.placeOfOrigin = dbAssoc["sacct_origin"];
this.dateOfBirth = dbAssoc["sacct_when_born"];
this.spawnPosition = toVector3(dbAssoc["sacct_pos_x"], dbAssoc["sacct_pos_y"], dbAssoc["sacct_pos_z"]);
this.middleName = dbAssoc["sacct_name_middle"] || "";
this.account = toInteger(dbAssoc["sacct_acct"]);
this.skin = toInteger(dbAssoc["sacct_svr_skin"]);
this.cash = toInteger(dbAssoc["sacct_cash"]);
this.spawnPosition = toVector3(toFloat(dbAssoc["sacct_pos_x"]), toFloat(dbAssoc["sacct_pos_y"]), toFloat(dbAssoc["sacct_pos_z"]));
this.spawnHeading = toFloat(dbAssoc["sacct_angle"]);
this.lastLogin = toInteger(dbAssoc["sacct_last_login"]);
this.clan = toInteger(dbAssoc["sacct_clan"]);
this.clanFlags = toInteger(dbAssoc["sacct_clan_flags"]);
this.clanRank = toInteger(dbAssoc["sacct_clan_rank"]);
this.clanTitle = toInteger(dbAssoc["sacct_clan_title"]);
this.job = dbAssoc["sacct_job"];
this.interior = dbAssoc["sacct_int"];
this.dimension = dbAssoc["sacct_vw"];
this.pedScale = toVector3(dbAssoc["sacct_scale_x"], dbAssoc["sacct_scale_y"], dbAssoc["sacct_scale_z"]);
this.lastLogin = toInteger(dbAssoc["sacct_when_lastlogin"]);
this.clan = toInteger(dbAssoc["sacct_svr_clan"]);
this.clanFlags = toInteger(dbAssoc["sacct_svr_clan_flags"]);
this.clanRank = toInteger(dbAssoc["sacct_svr_clan_rank"]);
this.clanTitle = toInteger(dbAssoc["sacct_svr_clan_title"]);
this.job = toInteger(dbAssoc["sacct_svr_job"]);
this.interior = toInteger(dbAssoc["sacct_int"]);
this.dimension = toInteger(dbAssoc["sacct_vw"]);
this.pedScale = toVector3(toFloat(dbAssoc["sacct_svr_scale_x"]), toFloat(dbAssoc["sacct_svr_scale_y"]), toFloat(dbAssoc["sacct_svr_scale_z"]));
this.walkStyle = toInteger(dbAssoc["sacct_svr_walkstyle"]);
this.fightStyle = toInteger(dbAssoc["sacct_svr_fightstyle"]);
this.health = toInteger(dbAssoc["sacct_health"]);
this.armour = toInteger(dbAssoc["sacct_armour"]);
this.inHouse = toInteger(dbAssoc["sacct_inhouse"]);
this.inBusiness = toInteger(dbAssoc["sacct_inbusiness"]);
this.bodyParts = {
hair: [toInteger(dbAssoc["sacct_svr_hd_part_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_hair_texture"]) || 0],
head: [toInteger(dbAssoc["sacct_svr_hd_part_head_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_head_texture"]) || 0],
upper: [toInteger(dbAssoc["sacct_svr_hd_part_upper_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_upper_texture"]) || 0],
lower: [toInteger(dbAssoc["sacct_svr_hd_part_lower_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_lower_texture"]) || 0],
};
this.bodyProps = {
hair: [toInteger(dbAssoc["sacct_svr_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_hair_texture"]) || 0],
eyes: [toInteger(dbAssoc["sacct_svr_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_eyes_texture"]) || 0],
head: [toInteger(dbAssoc["sacct_svr_hd_prop_head_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_head_texture"]) || 0],
leftHand: [toInteger(dbAssoc["sacct_svr_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_lefthand_texture"]) || 0],
rightHand: [toInteger(dbAssoc["sacct_svr_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_righthand_texture"]) || 0],
leftWrist: [toInteger(dbAssoc["sacct_svr_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_leftwrist_texture"]) || 0],
rightWrist: [toInteger(dbAssoc["sacct_svr_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_rightwrist_texture"]) || 0],
hip: [toInteger(dbAssoc["sacct_svr_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_hip_texture"]) || 0],
leftFoot: [toInteger(dbAssoc["sacct_svr_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_leftfoot_texture"]) || 0],
rightFoot: [toInteger(dbAssoc["sacct_svr_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_rightfoot_texture"]) || 0],
};
}
}
},
@@ -325,7 +448,8 @@ function initClassTable() {
this.hasInterior = false;
this.index = -1;
this.needsSaved = false;
this.itemCache = [];
this.floorItemCache = [];
this.storageItemCache = [];
this.entrancePosition = false;
this.entranceRotation = 0.0;
@@ -411,6 +535,8 @@ function initClassTable() {
this.ownerType = AG_HOUSEOWNER_NONE;
this.ownerId = 0;
this.buyPrice = 0;
this.rentPrice = 0;
this.renter = 0;
this.locked = false;
this.hasInterior = false;
this.index = -1;
@@ -441,6 +567,8 @@ function initClassTable() {
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"]));
@@ -464,7 +592,7 @@ function initClassTable() {
constructor(dbAssoc) {
this.databaseId = 0;
this.name = "";
this.owner = 0;
this.ownerId = 0;
this.tag = "";
this.enabled = false;
this.index = -1;
@@ -573,6 +701,22 @@ function initClassTable() {
this.colour3 = (vehicle) ? vehicle.colour3 : 1;
this.colour4 = (vehicle) ? vehicle.colour4 : 1;
this.extras = [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
];
// Vehicle Attributes
this.locked = false;
this.engine = false;
@@ -595,7 +739,7 @@ function initClassTable() {
this.ownerType = toInteger(dbAssoc["veh_owner_type"]);
this.ownerId = toInteger(dbAssoc["veh_owner_id"]);
this.buyPrice = toInteger(dbAssoc["veh_buy_price"]);
this.rentPrice = toInteger(dbAssoc["veh_buy_price"]);
this.rentPrice = toInteger(dbAssoc["veh_rent_price"]);
// Position and Rotation
this.spawnPosition = toVector3(dbAssoc["veh_pos_x"], dbAssoc["veh_pos_y"], dbAssoc["veh_pos_z"]);
@@ -616,6 +760,23 @@ function initClassTable() {
this.colour3 = toInteger(dbAssoc["veh_col3"]);
this.colour4 = toInteger(dbAssoc["veh_col4"]);
// Extras (components on SA, extras on IV+)
this.extras = [
toInteger(dbAssoc["veh_extra1"]),
toInteger(dbAssoc["veh_extra2"]),
toInteger(dbAssoc["veh_extra3"]),
toInteger(dbAssoc["veh_extra4"]),
toInteger(dbAssoc["veh_extra5"]),
toInteger(dbAssoc["veh_extra6"]),
toInteger(dbAssoc["veh_extra7"]),
toInteger(dbAssoc["veh_extra8"]),
toInteger(dbAssoc["veh_extra9"]),
toInteger(dbAssoc["veh_extra10"]),
toInteger(dbAssoc["veh_extra11"]),
toInteger(dbAssoc["veh_extra12"]),
toInteger(dbAssoc["veh_extra13"]),
];
// Vehicle Attributes
this.locked = intToBool(toInteger(dbAssoc["veh_locked"]));
this.engine = intToBool(toInteger(dbAssoc["veh_engine"]));
@@ -629,7 +790,12 @@ function initClassTable() {
this.insuranceAccount = toInteger(0);
this.fuel = toInteger(0);
this.flags = toInteger(0);
this.needsSaved = false;
this.whoAdded = toInteger(dbAssoc["veh_who_added"]);
this.whenAdded = toInteger(dbAssoc["veh_when_added"]);
}
this.streamingRadioStation = -1;
}
},
commandData: class {
@@ -660,8 +826,8 @@ function initClassTable() {
this.crimeType = crimeType;
this.suspectId = suspectId;
this.reporterId = reporterId;
this.whenCommitted = new Date().getTime();
this.whenReported = new Date().getTime();
this.whenCommitted = 0;
this.whenReported = 0;
this.databaseId = 0;
}
},
@@ -694,8 +860,8 @@ function initClassTable() {
this.blipModel = dbAssoc["job_blip"];
this.pickupModel = dbAssoc["job_pickup"];
this.colour = toColour(dbAssoc["job_colour_r"], dbAssoc["job_colour_g"], dbAssoc["job_colour_b"], 255);
this.whiteListEnabled = dbAssoc["job_whitelist"];
this.blackListEnabled = dbAssoc["job_blacklist"];
this.whiteListEnabled = dbAssoc["job_wl"];
this.blackListEnabled = dbAssoc["job_bl"];
this.walkieTalkieFrequency = dbAssoc["job_walkietalkiefreq"];
this.equipment = [];
@@ -832,7 +998,7 @@ function initClassTable() {
}
},
keyBindData: class {
constructor(dbAssoc = false, key = 0, commandString = "") {
constructor(dbAssoc = false, key = 0, commandString = "", keyState = AG_KEYSTATE_UP) {
this.databaseId = 0;
this.key = key;
this.account = 0;
@@ -895,12 +1061,34 @@ function initClassTable() {
this.range = range;
}
},
excludedGroundSnowModel: class {
constructor(model) {
this.model = model;
}
},
interiorTemplateData: class {
constructor(exitPosition, exitInterior) {
this.exitPosition = exitPosition;
this.exitInterior = exitInterior;
}
},
radioStationData: class {
constructor(dbAssoc) {
this.databaseId = 0;
this.name = "";
this.url = "";
this.genre = "";
this.codec = "";
if(dbAssoc) {
this.databaseId = dbAssoc["radio_id"];
this.name = dbAssoc["radio_name"];
this.url = dbAssoc["radio_url"];
this.genre = dbAssoc["radio_genre"];
this.codec = dbAssoc["radio_codec"];
}
}
},
itemData: class {
constructor(dbAssoc = false) {
this.databaseId = 0;
@@ -919,6 +1107,7 @@ function initClassTable() {
this.amount = 0;
this.value = 0;
this.enabled = false;
this.extra = false;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["item_id"]);
@@ -946,6 +1135,7 @@ function initClassTable() {
this.useType = AG_ITEM_USETYPE_NONE;
this.useId = 0;
this.useValue = 0;
this.maxValue = 0;
this.dropType = AG_ITEM_DROPTYPE_NONE;
this.useId = 0;
this.dropPosition = toVector3(0.0, 0.0, 0.0);
@@ -953,6 +1143,10 @@ function initClassTable() {
this.dropScale = toVector3(0.0, 0.0, 0.0);
this.dropModel = 0;
this.orderPrice = 0;
this.orderValue = 0;
this.demandMultiplier = 1;
this.supplyMultiplier = 1;
this.riskMultiplier = 1;
this.needsSaved = false;
this.switchDelay = 0;
this.pickupDelay = 0;
@@ -974,10 +1168,12 @@ function initClassTable() {
this.dropModel = toInteger(dbAssoc["item_type_drop_model"]);
this.useId = toInteger(dbAssoc["item_type_use_id"]);
this.useValue = toInteger(dbAssoc["item_type_use_value"]);
this.maxValue = toInteger(dbAssoc["item_type_max_value"]);
this.orderPrice = toInteger(dbAssoc["item_type_order_price"]);
this.orderValue = toInteger(dbAssoc["item_type_order_value"]);
this.demandMultiplier = toFloat(dbAssoc["item_type_demand_multiplier"]);
this.supplyMultiplier = toFloat(dbAssoc["item_type_supply_multiplier"]);
this.orderPrice = toInteger(dbAssoc["item_type_order_price"]);
this.riskMultiplier = toFloat(dbAssoc["item_type_risk_multiplier"]);
this.size = toInteger(dbAssoc["item_type_size"]);
this.capacity = toInteger(dbAssoc["item_type_capacity"]);
this.useDelay = toInteger(dbAssoc["item_type_delay_use"]);
@@ -989,22 +1185,166 @@ function initClassTable() {
this.dropDelay = toInteger(dbAssoc["item_type_delay_drop"]);
}
}
},
npcData: class {
constructor(dbAssoc) {
this.databaseId = 0;
this.server = 0;
this.firstName = "John";
this.lastName = "Doe";
this.middleName = "Q";
this.skin = 0;
this.cash = 0;
this.spawnPosition = toVector3(0.0, 0.0, 0.0);
this.spawnHeading = 0.0;
this.clan = 0;
this.isWorking = false;
this.jobUniform = this.skin;
this.lastJobVehicle = null;
this.job = 0;
this.weapons = [];
this.interior = 0;
this.dimension = 0;
this.pedScale = toVector3(1.0, 1.0, 1.0);
this.walkStyle = 0;
this.fightStyle = 0;
this.health = 100;
this.armour = 100;
this.currentAction = AG_NPCACTION_NONE;
this.triggers = [];
this.bodyParts = {
hair: [0,0],
head: [0,0],
upper: [0,0],
lower: [0,0],
};
this.bodyProps = {
hair: [0,0],
eyes: [0,0],
head: [0,0],
leftHand: [0,0],
rightHand: [0,0],
leftWrist: [0,0],
rightWrist: [0,0],
hip: [0,0],
leftFoot: [0,0],
rightFoot: [0,0],
};
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_id"]);
this.server = toInteger(dbAssoc["npc_server"]);
this.firstName = dbAssoc["npc_name_first"];
this.lastName = dbAssoc["npc_name_last"];
this.middleName = dbAssoc["npc_name_middle"] || "";
this.skin = toInteger(dbAssoc["npc_skin"]);
this.cash = toInteger(dbAssoc["npc_cash"]);
this.spawnPosition = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"]));
this.spawnHeading = toFloat(dbAssoc["npc_angle"]);
this.lastLogin = toInteger(dbAssoc["npc_when_lastlogin"]);
this.clan = toInteger(dbAssoc["npc_clan"]);
this.clanFlags = toInteger(dbAssoc["npc_clan_flags"]);
this.clanRank = toInteger(dbAssoc["npc_clan_rank"]);
this.clanTitle = toInteger(dbAssoc["npc_clan_title"]);
this.job = toInteger(dbAssoc["npc_job"]);
this.interior = toInteger(dbAssoc["npc_int"]);
this.dimension = toInteger(dbAssoc["npc_vw"]);
this.pedScale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"]));
this.walkStyle = toInteger(dbAssoc["npc_walkstyle"]);
this.fightStyle = toInteger(dbAssoc["npc_fightstyle"]);
this.health = toInteger(dbAssoc["npc_health"]);
this.armour = toInteger(dbAssoc["npc_armour"]);
this.bodyParts = {
hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0],
head: [toInteger(dbAssoc["npc_hd_part_head_model"]) || 0, toInteger(dbAssoc["npc_hd_part_head_texture"]) || 0],
upper: [toInteger(dbAssoc["npc_hd_part_upper_model"]) || 0, toInteger(dbAssoc["npc_hd_part_upper_texture"]) || 0],
lower: [toInteger(dbAssoc["npc_hd_part_lower_model"]) || 0, toInteger(dbAssoc["npc_hd_part_lower_texture"]) || 0],
};
this.bodyProps = {
hair: [toInteger(dbAssoc["npc_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hair_texture"]) || 0],
eyes: [toInteger(dbAssoc["npc_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_eyes_texture"]) || 0],
head: [toInteger(dbAssoc["npc_hd_prop_head_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_head_texture"]) || 0],
leftHand: [toInteger(dbAssoc["npc_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_lefthand_texture"]) || 0],
rightHand: [toInteger(dbAssoc["npc_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_righthand_texture"]) || 0],
leftWrist: [toInteger(dbAssoc["npc_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftwrist_texture"]) || 0],
rightWrist: [toInteger(dbAssoc["npc_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightwrist_texture"]) || 0],
hip: [toInteger(dbAssoc["npc_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hip_texture"]) || 0],
leftFoot: [toInteger(dbAssoc["npc_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftfoot_texture"]) || 0],
rightFoot: [toInteger(dbAssoc["npc_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightfoot_texture"]) || 0],
};
}
}
},
npcTriggerData: class {
constructor(dbAssoc) {
this.databaseId = 0;
this.npcId = 0;
this.index = 0;
this.npc = 0;
this.triggerType = 0;
this.conditions = [];
this.responses = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_trig_id"]);
this.npc = toInteger(dbAssoc["npc_trig_npc"]);
this.triggerType = toInteger(dbAssoc["npc_trig_type"]);
}
}
},
npcTriggerConditionData: class {
constructor(dbAssoc) {
this.databaseId = 0;
this.triggerId = 0;
this.index = 0;
this.conditionType = 0;
this.conditionValue = false;
this.matchType = false;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_trig_cond_id"]);
this.npc = toInteger(dbAssoc["npc_trig_cond_trig"]);
this.conditionType = toInteger(dbAssoc["npc_trig_cond_type"]);
this.conditionValue = toInteger(dbAssoc["npc_trig_cond_val"]);
this.matchType = toInteger(dbAssoc["npc_trig_cond_val"]);
}
}
},
npcTriggerResponseData: class {
constructor(dbAssoc) {
this.databaseId = 0;
this.triggerId = 0;
this.index = 0;
this.responseType = 0;
this.responseValue = false;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_trig_resp_id"]);
this.npc = toInteger(dbAssoc["npc_trig_resp_trig"]);
this.responseType = toInteger(dbAssoc["npc_trig_resp_type"]);
this.responseValue = toInteger(dbAssoc["npc_trig_resp_val"]);
}
}
}
}
return tempClasses;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getClasses() {
return serverClasses;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getClass(className) {
return serverClasses[className];
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: client.js
// DESC: Provides client communication and cross-endpoint operations
// TYPE: Server (JavaScript)
@@ -11,10 +11,10 @@
function initClientScript() {
logToConsole(LOG_DEBUG, "[Asshat.Client]: Initializing client script ...");
addAllNetworkHandlers();
logToConsole(LOG_DEBUG, "[Asshat.Clan]: Initializing client script ...");
logToConsole(LOG_DEBUG, "[Asshat.Client]: Client script initialized!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addAllNetworkHandlers() {
logToConsole(LOG_DEBUG, "[Asshat.Client]: Adding network handlers ...");
@@ -43,6 +43,7 @@ function addAllNetworkHandlers() {
addNetworkHandler("ag.clientReady", playerClientReady);
addNetworkHandler("ag.guiReady", playerGUIReady);
addNetworkHandler("ag.clientStarted", playerClientStarted);
addNetworkHandler("ag.clientStopped", playerClientStopped);
// Account
addNetworkHandler("ag.checkLogin", checkLogin);
@@ -62,30 +63,40 @@ function addAllNetworkHandlers() {
addNetworkHandler("ag.itemActionDelayComplete", playerItemActionDelayComplete);
addNetworkHandler("ag.weaponDamage", playerDamagedByPlayer);
addNetworkHandler("ag.player.position", updatePositionInPlayerData);
addNetworkHandler("ag.player.heading", updateHeadingInPlayerData);
addNetworkHandler("ag.skinSelected", playerFinishedSkinSelection);
addNetworkHandler("ag.clientInfo", updateConnectionLogOnClientInfoReceive);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updatePlayerNameTag(client) {
//logToConsole(LOG_DEBUG, `[Asshat.Client] Sending ${getPlayerDisplayForConsole(client)}'s updated nametag to all players`);
triggerNetworkEvent("ag.nametag", null, client.name, getPlayerNameForNameTag(client), getPlayerColour(client), false, client.ping);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updateAllPlayerNameTags() {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending updated nametags to all players`);
let clients = getClients();
for(let i in clients) {
updatePlayerNameTag(clients[i]);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updatePlayerPing(client) {
//logToConsole(LOG_DEBUG, `[Asshat.Client] Sending ${getPlayerDisplayForConsole(client)}'s ping to all players`);
triggerNetworkEvent("ag.ping", null, client.name, client.ping);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerClientReady(client) {
setEntityData(client, "ag.isReady", true, false);
@@ -95,14 +106,14 @@ function playerClientReady(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerGUIReady(client) {
setEntityData(client, "ag.guiReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerClientStarted(client) {
setEntityData(client, "ag.isStarted", true, false);
@@ -112,80 +123,93 @@ function playerClientStarted(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerClientStopped(client) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources have stopped (possibly error?). Kicking them from the server ...`);
client.disconnect();
}
// ===========================================================================
function showGameMessage(client, text, colour, duration) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing game message to ${getPlayerDisplayForConsole(client)} (${text}) for ${duration} milliseconds`);
triggerNetworkEvent("ag.smallGameMessage", client, text, colour, duration);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function enableCityAmbienceForPlayer(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Setting ${getPlayerDisplayForConsole(client)}'s city ambience to ${toUpperCase(getOnOffFromBool(false))}`);
triggerNetworkEvent("ag.ambience", client, true);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function disableCityAmbienceForPlayer(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Setting ${getPlayerDisplayForConsole(client)}'s city ambience to ${toUpperCase(getOnOffFromBool(false))}`);
triggerNetworkEvent("ag.ambience", client, false);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clearPlayerOwnedPeds(client) {
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Clearing peds owned by ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[Asshat.Client] Clearing peds owned by ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.clearPeds", client);
}
// ---------------------------------------------------------------------------
function updatePlayerJobType(client) {
triggerNetworkEvent("ag.jobType", client, getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client).job));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updatePlayerSpawnedState(client, state) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Setting ${getPlayerDisplayForConsole(client)}'s spawned state ${toUpperCase(getOnOffFromBool(state))}`);
getPlayerData(client).spawned = true;
triggerNetworkEvent("ag.spawned", client, state);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerControlState(client, state) {
triggerNetworkEvent("ag.control", client, state);
logToConsole(LOG_DEBUG, `[Asshat.Client] Setting ${getPlayerDisplayForConsole(client)}'s control state ${toUpperCase(getOnOffFromBool(state))}`);
triggerNetworkEvent("ag.control", client, state, !state);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updatePlayerShowLogoState(client, state) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Setting ${getPlayerDisplayForConsole(client)}'s logo state ${toUpperCase(getOnOffFromBool(state))}`);
triggerNetworkEvent("ag.logo", client, state);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function restorePlayerCamera(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Restoring ${getPlayerDisplayForConsole(client)}'s camera`);
triggerNetworkEvent("ag.restoreCamera", client);
}
// -------------------------------------------------------------------------
// ===========================================================================
function setPlayer2DRendering(client, hudState = false, labelState = false, smallGameMessageState = false, scoreboardState = false, hotBarState = false, itemActionDelayState = false) {
triggerNetworkEvent("ag.set2DRendering", client, hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function syncPlayerProperties(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending signal to sync ${getPlayerDisplayForConsole(client)}'s player ped properties`);
triggerNetworkEvent("ag.player.sync", null, client.player);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updatePlayerSnowState(client) {
triggerNetworkEvent("ag.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow);
if(doesGameHaveSnow(getServerGame())) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`);
triggerNetworkEvent("ag.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendExcludedModelsForGroundSnowToPlayer(client) {
if(getGameConfig().excludedGroundSnowModels[getServerGame()].length > 0) {
@@ -196,290 +220,672 @@ function sendExcludedModelsForGroundSnowToPlayer(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendRemovedWorldObjectsToPlayer(client) {
if(getGameConfig().removedWorldObjects[getServerGame()].length > 0) {
for(let i in getGameConfig().removedWorldObjects[getServerGame()]) {
logToConsole(LOG_DEBUG, `[Asshat.Misc] Sending removed world object ${i} (${getGameConfig().removedWorldObjects[getServerGame()][i].model}) to ${client.name}`);
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending removed world object ${i} (${getGameConfig().removedWorldObjects[getServerGame()][i].model}) to ${client.name}`);
triggerNetworkEvent("ag.removeWorldObject", client, getGameConfig().removedWorldObjects[getServerGame()][i].model, getGameConfig().removedWorldObjects[getServerGame()][i].position, getGameConfig().removedWorldObjects[getServerGame()][i].range);
}
}
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updatePlayerHotBar(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending updated hotbar data to ${getPlayerDisplayForConsole(client)}`);
let tempHotBarItems = [];
for(let i in getPlayerData(client).hotBarItems) {
let itemImage = "";
let itemValue = 0;
let itemExists = false;
if(getPlayerData(client).hotBarItems[i] != -1) {
let itemData = getItemData(getPlayerData(client).hotBarItems[i]);
let itemTypeData = getItemTypeData(itemData.itemTypeIndex);
itemExists = true;
itemImage = itemTypeData.hotbarImage;
itemValue = itemData.value;
if(getItemData(getPlayerData(client).hotBarItems[i])) {
let itemData = getItemData(getPlayerData(client).hotBarItems[i]);
let itemTypeData = getItemTypeData(itemData.itemTypeIndex);
itemExists = true;
itemImage = itemTypeData.hotbarImage;
itemValue = itemData.value;
}
}
tempHotBarItems.push([i, itemExists, itemImage, itemValue]);
}
triggerNetworkEvent("ag.hotbar", client, getPlayerData(client).activeHotBarSlot, tempHotBarItems);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerWeaponDamageEnabled(client, state) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending weapon damage state for ${getPlayerDisplayForConsole(client)} to all players`);
triggerNetworkEvent("ag.weaponDamageEnabled", null, client.name, state);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerWeaponDamageEvent(client, eventType) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending weapon damage event (${eventType}) for ${getPlayerDisplayForConsole(client)} to all players`);
triggerNetworkEvent("ag.weaponDamageEvent", null, client.name, eventType);
getPlayerData(client).weaponDamageEvent = eventType;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendJobRouteStopToPlayer(client, position, colour) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending job route stop data to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.showJobRouteStop", client, position, colour);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerLoginSuccessGUI(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending login success GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.loginSuccess", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerLoginFailedGUI(client, errorMessage) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending login failed GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.loginFailed", client, errorMessage);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerRegistrationSuccessGUI(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending registration success GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.registrationSuccess", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerRegistrationFailedGUI(client, errorMessage) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending registration failed GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.registrationFailed", client, errorMessage);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerGUIColours(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending GUI colours to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.guiColour", client, getServerConfig().guiColour[0], getServerConfig().guiColour[1], getServerConfig().guiColour[2]);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerGUIInit(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending GUI init signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.guiInit", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerLoginGUI(client, errorMessage = "") {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending show login GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.showLogin", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerRegistrationGUI(client, errorMessage = "") {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending show registration GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.showRegistration", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerNewCharacterGUI(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending show new character GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.showNewCharacter", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerCharacterSelectGUI(client, firstName, lastName, placeOfOrigin, dateOfBirth, skin) {
triggerNetworkEvent("ag.showCharacterSelect", client, firstName, lastName, placeOfOrigin, dateOfBirth, skin);
function showPlayerCharacterSelectGUI(client, firstName, lastName, cash, clan, lastPlayed, skin) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending character select GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.showCharacterSelect", client, firstName, lastName, cash, clan, lastPlayed, skin);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function updatePlayerCharacterSelectGUI(client, firstName, lastName, placeOfOrigin, dateOfBirth, skin) {
triggerNetworkEvent("ag.showCharacterSelect", client, firstName, lastName, placeOfOrigin, dateOfBirth, skin);
function updatePlayerCharacterSelectGUI(client, firstName, lastName, cash, clan, lastPlayed, skin) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending update character select GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.switchCharacterSelect", client, firstName, lastName, cash, clan, lastPlayed, skin);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerCharacterSelectSuccessGUI(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending character select success GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.characterSelectSuccess", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerCharacterSelectFailedGUI(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending character select failed GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.characterSelectFailed", client);
}
// ===========================================================================
function showPlayerPromptGUI(client, promptMessage, promptTitle) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending show prompt GUI signal to ${getPlayerDisplayForConsole(client)} (Title: ${promptTitle}, Message: ${promptMessage})`);
triggerNetworkEvent("ag.showPrompt", client, promptMessage, promptTitle);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerInfoGUI(client, infoMessage, infoTitle) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending show info GUI signal to ${getPlayerDisplayForConsole(client)} (Title: ${infoTitle}, Message: ${infoMessage})`);
triggerNetworkEvent("ag.showInfo", client, infoMessage, infoTitle);
}
// ===========================================================================
function showPlayerErrorGUI(client, errorMessage, errorTitle) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending show error GUI signal to ${getPlayerDisplayForConsole(client)} (Title: ${errorTitle}, Message: ${errorMessage})`);
triggerNetworkEvent("ag.showInfo", client, errorMessage, errorTitle);
}
// ===========================================================================
function sendRunCodeToClient(client, code, returnTo) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending runcode to ${getPlayerDisplayForConsole(client)} (returnTo: ${getPlayerDisplayForConsole(getClientFromIndex(returnTo))}, Code: ${code})`);
triggerNetworkEvent("ag.runCode", client, code, returnTo);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerWorkingState(client, state) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending working state (${toUpperCase(getYesNoFromBool(state))}) to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.working", client, state);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerJobType(client, jobType) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending job type (${jobType}) to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.jobType", client, jobType);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerStopJobRoute(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending signal to abort job route to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.stopJobRoute", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerMouseCameraToggle(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending signal to toggle mouse camera ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.mouseCamera", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerMouseCursorToggle(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending signal to toggle mouse cursor ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.mouseCursor", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendAddAccountKeyBindToClient(client, key, keyState) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending added keybind to ${getPlayerDisplayForConsole(client)} (Key: ${sdl.getKeyName(key)}, State: ${(keyState) ? "down" : "up"})`);
triggerNetworkEvent("ag.addKeyBind", client, toInteger(key), (keyState) ? KEYSTATE_DOWN : KEYSTATE_UP);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendRemoveAccountKeyBindToClient(client, key, keyState) {
function sendRemoveAccountKeyBindToClient(client, key) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending deleted keybind to ${getPlayerDisplayForConsole(client)} (Key: ${sdl.getKeyName(key)})`);
triggerNetworkEvent("ag.delKeyBind", client, toInteger(key));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerSetPosition(client, position) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending set position signal to ${getPlayerDisplayForConsole(client)} (Position: ${position.x}, ${position.y}, ${position.z})`);
triggerNetworkEvent("ag.position", client, position);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerSetHeading(client, heading) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending set heading signal to ${getPlayerDisplayForConsole(client)} (Heading: ${heading})`);
triggerNetworkEvent("ag.heading", client, heading);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerSetInterior(client, interior) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending set interior signal to ${getPlayerDisplayForConsole(client)} (Interior: ${interior})`);
triggerNetworkEvent("ag.interior", client, interior);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerFrozenState(client, state) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending set frozen signal to ${getPlayerDisplayForConsole(client)} (State: ${toUpperCase(getYesNoFromBool(state))})`);
triggerNetworkEvent("ag.frozen", client, state);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function givePlayerWeapon(client, weaponId, ammo, active) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
triggerNetworkEvent("ag.giveWeapon", client, weaponId, ammo, active);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clearPlayerWeapons(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to clear weapons`);
triggerNetworkEvent("ag.clearWeapons", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerNewCharacterFailedGUI(client, errorMessage) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending new character failed GUI signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.newCharacterFailed", client, errorMessage);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerRemoveFromVehicle(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Sending remove from vehicle signal to ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.removeFromVehicle", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendChatBoxMessageToPlayer(client, message, colour) {
triggerNetworkEvent("ag.m", client, message, colour)
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerItemTakeDelay(client, itemId) {
triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(itemId).itemTypeIndex).takeDelay);
if(getItemData(itemId)) {
let delay = getItemTypeData(getItemData(itemId).itemTypeIndex).pickupDelay;
if(delay > 0) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item TAKE delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`);
triggerNetworkEvent("ag.showItemActionDelay", client, delay);
} else {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item TAKE delay to ${getPlayerDisplayForConsole(client)} (instant)`);
playerTakeItem(client, itemId);
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerItemUseDelay(client, itemSlot) {
triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).useDelay);
if(getItemData(getPlayerData(client).hotBarItems[itemSlot])) {
let delay = getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).useDelay;
if(delay > 0) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item USE delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`);
triggerNetworkEvent("ag.showItemActionDelay", client, delay);
} else {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item USE delay to ${getPlayerDisplayForConsole(client)} (instant)`);
playerUseItem(client, itemSlot);
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerItemDropDelay(client, itemSlot) {
triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).dropDelay);
if(getItemData(getPlayerData(client).hotBarItems[itemSlot])) {
let delay = getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).dropDelay;
if(delay > 0) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item DROP delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`);
triggerNetworkEvent("ag.showItemActionDelay", client, delay);
} else {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item DROP delay to ${getPlayerDisplayForConsole(client)} (instant)`);
playerDropItem(client, itemSlot);
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerItemPickupDelay(client, itemId) {
triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(itemId).itemTypeIndex).pickupDelay);
if(getItemData(itemId)) {
let delay = getItemTypeData(getItemData(itemId).itemTypeIndex).pickupDelay;
if(delay > 0) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item PICKUP delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`);
triggerNetworkEvent("ag.showItemActionDelay", client, delay);
} else {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item PICKUP delay to ${getPlayerDisplayForConsole(client)} (instant)`);
playerPickupItem(client, itemId);
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerItemPutDelay(client, itemSlot) {
triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).putDelay);
if(getItemData(getPlayerData(client).hotBarItems[itemSlot])) {
let delay = getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).putDelay;
if(delay > 0) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item PUT delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`);
triggerNetworkEvent("ag.showItemActionDelay", client, delay);
} else {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item PUT delay to ${getPlayerDisplayForConsole(client)} (instant)`);
playerPutItem(client, itemSlot);
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showPlayerItemSwitchDelay(client, itemSlot) {
if(itemSlot != -1) {
if(getPlayerData(client).hotBarItems[itemSlot] != -1) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item switch delay to ${getPlayerDisplayForConsole(client)} (${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).switchDelay} milliseconds)`);
triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).switchDelay);
} else {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item switch delay to ${getPlayerDisplayForConsole(client)} (instant)`);
playerSwitchItem(client, itemSlot);
}
} else {
logToConsole(LOG_DEBUG, `[Asshat.Client] Showing item switch delay to ${getPlayerDisplayForConsole(client)} (instant)`);
playerSwitchItem(client, itemSlot);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerDrunkEffect(client, amount, duration) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Setting drunk effect for ${getPlayerDisplayForConsole(client)} to ${amount} for ${duration} milliseconds`);
triggerNetworkEvent("ag.drunkEffect", client, amount, duration);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendPlayerClearPedState(client) {
logToConsole(LOG_DEBUG, `[Asshat.Client] Clearing ped state for ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.clearPedState", client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerDamagedByPlayer(client, damagerEntityName, weaponId, pedPiece, healthLoss) {
let damagerEntity = getPlayerFromParams(damagerEntityName);
if(isNull(damagerEntity)) {
logToConsole(LOG_DEBUG, `[Asshat.Client] ${getPlayerDisplayForConsole(client)}'s damager entity from ID is null`);
return false;
}
logToConsole(LOG_DEBUG, `[Asshat.Client] ${getPlayerDisplayForConsole(client)} was damaged by ${damagerEntity}`);
if(isNull(damagerEntity)) {
logToConsole(LOG_DEBUG, `[Asshat.Client] ${getPlayerDisplayForConsole(client)}'s damager client is INVALID`);
return false;
}
if(!getPlayerData(damagerEntity) || !getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Client] ${getPlayerDisplayForConsole(client)}'s damager's client data is INVALID`);
return false;
}
logToConsole(LOG_DEBUG, `[Asshat.Client] ${getPlayerDisplayForConsole(client)}'s damager is ${getPlayerDisplayForConsole(damagerEntity)}`);
switch(getPlayerData(damagerEntity).weaponDamageEvent) {
case AG_WEAPON_DAMAGE_EVENT_TAZER:
logToConsole(LOG_DEBUG, `[Asshat.Client] ${getPlayerDisplayForConsole(client)}'s damager ${getPlayerDisplayForConsole(damagerEntity)} is using a tazer`);
if(!isPlayerTazed(client) && !isPlayerHandCuffed(client) && !isPlayerInAnyVehicle(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Client] ${getPlayerDisplayForConsole(client)} was not previously tazed, binded, or in a vehicle. Taze successful`);
meActionToNearbyPlayers(damagerEntity, `electrifies ${getCharacterFullName(client)} with their tazer`);
tazePlayer(client);
}
break;
default:
break;
}
}
// ===========================================================================
function setPlayerCameraLookAt(client, cameraPosition, lookAtPosition) {
triggerNetworkEvent("ag.cameraLookAt", client, cameraPosition, lookAtPosition);
}
// ===========================================================================
function setTimeMinuteDuration(client, minuteDuration) {
triggerNetworkEvent("ag.minuteDuration", client, minuteDuration);
}
// ===========================================================================
function updatePositionInPlayerData(client, position) {
getPlayerData(client).syncPosition = position;
}
// ===========================================================================
function updateHeadingInPlayerData(client, heading) {
getPlayerData(client).syncHeading = heading;
}
// ===========================================================================
function forcePlayerIntoSkinSelect(client) {
if(getGameConfig().skinChangePosition[getServerGame()].length != 0) {
getPlayerData(client).returnToPosition = getPlayerPosition(client);
getPlayerData(client).returnToHeading = getPlayerHeading(client);
getPlayerData(client).returnToInterior = getPlayerInterior(client);
getPlayerData(client).returnToDimension = getPlayerDimension(client);
setPlayerPosition(client, getGameConfig().skinChangePosition[getServerGame()][0]);
setPlayerHeading(client, getGameConfig().skinChangePosition[getServerGame()][1]);
setPlayerInterior(client, getGameConfig().skinChangePosition[getServerGame()][2]);
setPlayerDimension(client, client.index+100);
}
triggerNetworkEvent("ag.skinSelect", client, true);
}
// ===========================================================================
function playerSkinItemSelectComplete(client, skinId) {
getPlayerCurrentSubAccount(client).skin = skinId;
}
// ===========================================================================
function updatePlayerCash(client) {
triggerNetworkEvent("ag.money", client, getPlayerCurrentSubAccount(client).cash);
}
// ===========================================================================
function sendAllPoliceStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].policeStation != -1) {
let tempBlips = [];
for(let i in getServerData().policeStations[getServerGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].policeStation,
getServerData().policeStations[getServerGame()][i].position.x,
getServerData().policeStations[getServerGame()][i].position.y,
getServerData().policeStations[getServerGame()][i].position.z,
3,
getColourByName("policeBlue"),
]);
}
triggerNetworkEvent("ag.blips", client, tempBlips);
}
}
// ===========================================================================
function sendAllFireStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].fireStation != -1) {
let tempBlips = [];
for(let i in getServerData().fireStations[getServerGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].fireStation,
getServerData().fireStations[getServerGame()][i].position.x,
getServerData().fireStations[getServerGame()][i].position.y,
getServerData().fireStations[getServerGame()][i].position.z,
3,
getColourByName("firefighterRed"),
]);
}
triggerNetworkEvent("ag.blips", client, tempBlips);
}
}
// ===========================================================================
function sendAllHospitalBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].hospital != -1) {
let tempBlips = [];
for(let i in getServerData().hospitals[getServerGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].hospital,
getServerData().hospitals[getServerGame()][i].position.x,
getServerData().hospitals[getServerGame()][i].position.y,
getServerData().hospitals[getServerGame()][i].position.z,
3,
getColourByName("medicPink"),
]);
}
triggerNetworkEvent("ag.blips", client, tempBlips);
}
}
// ===========================================================================
function sendAllAmmunationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].ammunation != -1) {
let tempBlips = [];
for(let i in getServerData().ammunations[getServerGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].ammunation,
getServerData().ammunations[getServerGame()][i].position.x,
getServerData().ammunations[getServerGame()][i].position.y,
getServerData().ammunations[getServerGame()][i].position.z,
3,
0
]);
}
triggerNetworkEvent("ag.blips", client, tempBlips);
}
}
// ===========================================================================
function sendAllPayAndSprayBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].payAndSpray != -1) {
let tempBlips = [];
for(let i in getServerData().payAndSprays[getServerGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].payAndSpray,
getServerData().payAndSprays[getServerGame()][i].position.x,
getServerData().payAndSprays[getServerGame()][i].position.y,
getServerData().payAndSprays[getServerGame()][i].position.z,
3,
0
]);
}
triggerNetworkEvent("ag.blips", client, tempBlips);
}
}
// ===========================================================================
function sendAllFuelStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].fuelStation != -1) {
let tempBlips = [];
for(let i in getServerData().fuelStations[getServerGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].fuelStation,
getServerData().fuelStations[getServerGame()][i].position.x,
getServerData().fuelStations[getServerGame()][i].position.y,
getServerData().fuelStations[getServerGame()][i].position.z,
3,
getColourByName("burntOrange"),
]);
}
triggerNetworkEvent("ag.blips", client, tempBlips);
}
}
// ===========================================================================
function sendPlayerSetHealth(client, health) {
triggerNetworkEvent("ag.health", client, health);
}
// ===========================================================================
function sendPlayerSetArmour(client, armour) {
triggerNetworkEvent("ag.armour", client, armour);
}
// ===========================================================================
function playerFinishedSkinSelection(client, allowedSkinIndex) {
if(allowedSkinIndex == -1) {
return false;
} else {
getPlayerCurrentSubAccount(client).skin = allowedSkins[getServerGame()][allowedSkinIndex][0];
if(isPlayerWorking(client)) {
messagePlayerAlert(client, "Your new skin has been saved but won't be shown until you stop working.");
setPlayerSkin(client, getJobData(getPlayerCurrentSubAccount(client).job).uniforms[getPlayerData(client).jobUniform].skinId);
}
deleteItem(getPlayerData(client).itemActionItem);
restorePlayerCamera(client);
cachePlayerHotBarItems(client);
setPlayerSkin(client, allowedSkins[getServerGame()][allowedSkinIndex][0]);
setPlayerPosition(client, getPlayerData(client).returnToPosition);
setPlayerHeading(client, getPlayerData(client).returnToHeading);
setPlayerInterior(client, getPlayerData(client).returnToInterior);
setPlayerDimension(client, getPlayerData(client).returnToDimension);
getPlayerData(client).returnToPosition = null;
getPlayerData(client).returnToHeading = null;
getPlayerData(client).returnToInterior = null;
getPlayerData(client).returnToDimension = null;
meActionToNearbyPlayers(client, `changes their skin to ${allowedSkins[getServerGame()][allowedSkinIndex][1]}`);
}
triggerNetworkEvent("ag.skinSelect", client, false);
}
// ===========================================================================
function sendPlayerChatScrollLines(client, amount) {
triggerNetworkEvent("ag.chatScrollLines", client, amount);
}
// ===========================================================================
function playRadioStreamForPlayer(client, streamURL) {
triggerNetworkEvent("ag.radioStream", client, streamURL);
}
// ===========================================================================
function setPlayerStreamingRadioVolume(client, volumeLevel) {
triggerNetworkEvent("ag.radioVolume", client, volumeLevel);
}
// ===========================================================================
function setVehicleLightsState(vehicle, state) {
triggerNetworkEvent("ag.veh.lights", null, vehicle.id, state);
}
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: colour.js
// DESC: Provides colours, functions and usage
// TYPE: Server (JavaScript)
@@ -30,17 +30,18 @@ let serverColours = {
royalBlue: toColour(0, 0, 255, 255),
teal: toColour(0, 255, 255, 255),
orange: toColour(255, 128, 0, 255),
softRed: toColour(205, 92, 92, 255),
softRed: toColour(205, 60, 60, 255),
softGreen: toColour(50, 205, 50, 255),
lightPurple: toColour(150, 0, 150, 255),
lightGrey: toColour(200, 200, 200, 255),
mediumGrey: toColour(150, 150, 150, 255),
darkGrey: toColour(64, 64, 64, 255),
policeBlue: toColour(70, 130, 180, 255),
policeBlue: toColour(50, 80, 200, 255),
medicPink: toColour(219, 112, 147, 255),
firefighterRed: toColour(205, 92, 92, 255),
busDriverGreen: toColour(50, 205, 50, 255),
taxiDriverYellow: toColour(240, 230, 140, 255),
firefighterRed: toColour(205, 60, 60, 255),
busDriverGreen: toColour(50, 160, 50, 255),
taxiDriverYellow: toColour(240, 230, 100, 255),
deliveryPurple: toColour(177, 156, 217, 255),
civilianWhite: toColour(200, 200, 200, 255),
burntYellow: toColour(210, 210, 0, 255),
burntOrange: toColour(210, 120, 0, 255),
@@ -49,28 +50,28 @@ let serverColours = {
businessBlue: toColour(0, 153, 255, 255),
houseGreen: toColour(17, 204, 17, 255),
clanOrange: toColour(255, 153, 0, 255),
}
},
};
// -------------------------------------------------------------------------
// ===========================================================================
function getServerColours() {
return serverColours;
}
// -------------------------------------------------------------------------
// ===========================================================================
function getColourByType(typeName) {
return getServerColours().byType[typeName];
}
// -------------------------------------------------------------------------
// ===========================================================================
function getColourByName(colourName) {
return getServerColours().byName[colourName];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerColour(client) {
if(getPlayerData(client) != false) {
@@ -86,10 +87,49 @@ function getPlayerColour(client) {
return getColourByName("civilianWhite");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getBoolRedGreenInlineColour(boolVal) {
return (!boolVal) ? "[#AA2222]" : "[#22AA22]";
return (!boolVal) ? "[#cd3c3c]" : "[#32cd32]";
}
// ---------------------------------------------------------------------------
// ===========================================================================
function hexToRgb(h) {
return [
'0x'+h[1]+h[2]|0,
'0x'+h[3]+h[4]|0,
'0x'+h[5]+h[6]|0
];
}
// ===========================================================================
function rgbToHex(r, g, b) {
return "#"+((1<<24)+(r<<16)+(g<<8)+ b).toString(16).slice(1);
}
// ===========================================================================
function getClientChatColour(client) {
let tempJob = getPlayerCurrentSubAccount(client).job;
if(tempJob != -1) {
if(getPlayerData(client).isWorking) {
return getJobData(tempJob).jobColour;
}
}
return getColourByName("white");
}
// ===========================================================================
function getRandomRGB() {
return toColour.apply(null, [
getRandom(0, 255),
getRandom(0, 255),
getRandom(0, 255),
255
]);
}
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: command.js
// DESC: Provides command data, functions and usage
// TYPE: Server (JavaScript)
@@ -10,6 +10,8 @@
let serverCommands = [];
// ===========================================================================
let builtInCommands = [
"refresh",
"restart",
@@ -23,16 +25,16 @@ let builtInCommands = [
"dumpdoc",
];
// ---------------------------------------------------------------------------
// ===========================================================================
function initCommandScript() {
logToConsole(LOG_DEBUG, "[Asshat.Command]: Initializing commands script ...");
logToConsole(LOG_INFO, "[Asshat.Command]: Initializing commands script ...");
serverCommands = loadCommands();
addAllCommandHandlers();
logToConsole(LOG_DEBUG, "[Asshat.Command]: Initialized commands script!");
//addAllCommandHandlers();
logToConsole(LOG_INFO, "[Asshat.Command]: Initialized commands script!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadCommands() {
return {
@@ -44,10 +46,21 @@ function loadCommands() {
commandData("autolastchar", autoSelectLastCharacterCommand, "", getStaffFlagValue("none"), true, false, "Toggle whether to automatically spawn with the last character you played as"),
commandData("gui", toggleAccountGUICommand, "", getStaffFlagValue("none"), false, false, "Toggle whether to use GUI. If GUI is disabled on the server, it won't show even if you have GUI enabled."),
commandData("2fa", toggleAccountTwoFactorAuthCommand, "", getStaffFlagValue("none"), true, false, "Set up and use two-factor authentication."),
commandData("setemail", setAccountEmailCommand, "<email address>", getStaffFlagValue("none"), true, false, "Sets your email. To reset your password, you must have a valid email set to your account."),
commandData("setemail", setAccountEmailCommand, "<email address>", getStaffFlagValue("none"), true, false, "Sets your email. To reset your password, you must have a valid email set and verified."),
commandData("verifyemail", verifyAccountEmailCommand, "<verification code>", getStaffFlagValue("none"), true, false, "Confirms/verifies your email."),
commandData("setdiscord", setAccountDiscordCommand, "<Name#0000 - discord name and id>", getStaffFlagValue("none"), true, false, "Set up the integration for discord. Allows you to see info and use in-game commands on discord."),
],
ammunation: [],
antiCheat: [
//commandData("addacscriptwl", addAntiCheatWhiteListedScriptCommand, "<script name>", getStaffFlagValue("developer"), true, true),
//commandData("delacscriptwl", removeAntiCheatWhiteListedScriptCommand, "<script name>", getStaffFlagValue("developer"), true, true),
//commandData("addacscriptbl", addAntiCheatBlackListedScriptCommand, "<script name>", getStaffFlagValue("developer"), true, true),
//commandData("delacscriptbl", removeAntiCheatBlackListedScriptCommand, "<script name>", getStaffFlagValue("developer"), true, true),
//commandData("setacscriptbl", toggleAntiCheatScriptBlackListCommand, "<0/1 state>", getStaffFlagValue("developer"), true, true),
//commandData("setacscriptwl", toggleAntiCheatScriptWhiteListCommand, "<0/1 state>", getStaffFlagValue("developer"), true, true),
//commandData("setac", toggleGlobalAntiCheatCommand, "<0/1 state>", getStaffFlagValue("developer"), true, true),
//commandData("ac", getGlobalAntiCheatStatusCommand, "<0/1 state>", getStaffFlagValue("developer"), true, true),
],
ban: [
commandData("aban", accountBanCommand, "<player name/id> <reason>", getStaffFlagValue("manageBans"), true, true, "Bans a player's account."),
commandData("cban", subAccountBanCommand, "<player name/id> <reason>", getStaffFlagValue("manageBans"), true, true, "Bans a player's character."),
@@ -64,23 +77,29 @@ function loadCommands() {
commandData("bizreloadall", reloadAllBusinessesCommand, "", getStaffFlagValue("manageBusinesses"), true, false, "Reloads all businesses from the database"),
commandData("bizlock", lockBusinessCommand, "", getStaffFlagValue("none"), true, true, "Locks a business"),
commandData("bizbuy", buyBusinessCommand, "", getStaffFlagValue("none"), true, true, "Purchases a business"),
commandData("bizfee", setBusinessEntranceFeeCommand, "<amount>", getStaffFlagValue("none"), true, true, "Sets a fee to charge players when they enter the business."),
commandData("biztill", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true, "Shows the business's till (cash register) amount"),
commandData("bizbalance", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true, "Shows the business's till (cash register) amount"),
commandData("bizwithdraw", withdrawFromBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true, "Take money out of the business till (cash register)"),
commandData("bizdeposit", depositIntoBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true, "Put money into the business till (cash register)"),
commandData("buy", buyFromBusinessCommand, "<slot> [amount]", getStaffFlagValue("none"), true, true, "Buy items from a business"),
commandData("bizstock", stockItemOnBusinessFloorCommand, "<item name> <amount> <sell price>", getStaffFlagValue("none"), true, true, "Uses storage items to restock the business with."),
commandData("bizstore", storeItemInBusinessStorageCommand, "<item name> <amount>", getStaffFlagValue("none"), true, true, "Moves items from the business to the business storage"),
commandData("bizorder", orderItemForBusinessCommand, "<item name> <amount> <sell price>", getStaffFlagValue("none"), true, true, "Moves items from the business storage to the business."),
commandData("bizorder", orderItemForBusinessCommand, "<item name> <amount> <sell price>", getStaffFlagValue("none"), true, true, "Orders items to sell from a business"),
commandData("bizitemprice", setBusinessItemSellPriceCommand, "<item slot> <sell price>", getStaffFlagValue("none"), true, true, "Sets the purchase price of a business item"),
commandData("bizname", setBusinessNameCommand, "<name>", getStaffFlagValue("none"), true, true, "Changes a business name"),
commandData("bizowner", setBusinessOwnerCommand, "<player name/id>", getStaffFlagValue("none"), true, true, "Changes the owner of a business"),
commandData("bizbuyprice", setBusinessBuyPriceCommand, "<amount>", getStaffFlagValue("none"), true, true, "Changes the owner of a business"),
commandData("bizblip", setBusinessBlipCommand, "<type name/model id>", getStaffFlagValue("manageBusinesses"), true, true, "Sets the business blip display"),
commandData("bizpickup", setBusinessPickupCommand, "<type name/model id>", getStaffFlagValue("manageBusinesses"), true, true, "Sets the business pickup display"),
commandData("bizinfo", getBusinessInfoCommand, "[id]", getStaffFlagValue("none"), true, true, "Shows business information"),
commandData("bizentrance", moveBusinessEntranceCommand, "", getStaffFlagValue("manageBusinesses"), true, true, "Shows business information"),
commandData("bizexit", moveBusinessExitCommand, "", getStaffFlagValue("manageBusinesses"), true, true, "Moves the exit (interior point) of the business"),
commandData("bizinttype", setBusinessInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageBusinesses"), true, true, "Changes the business' interior"),
commandData("bizdefaultitems", giveDefaultItemsToBusinessCommand, "<item template>", getStaffFlagValue("manageItems"), true, true, "Gives the business the default items based on template name"),
commandData("bizdelflooritems", deleteBusinessFloorItemsCommand, "", getStaffFlagValue("manageItems"), true, true, "Destroys all items on the business floor (for-sale items)"),
commandData("bizdelstorageitems", deleteBusinessStorageItemsCommand, "", getStaffFlagValue("manageItems"), true, true, "Destroys all items in the business's storage"),
],
chat: [
commandData("me", meActionCommand, "<message>", getStaffFlagValue("none"), true, false),
@@ -109,32 +128,35 @@ function loadCommands() {
commandData("clanmembertag", setClanMemberTagCommand, "<player name/id> <tag>", getStaffFlagValue("none"), true, true),
commandData("clanranktitle", setClanRankTitleCommand, "<rank id> <title>", getStaffFlagValue("none"), true, true),
commandData("clanmembertitle", setClanMemberTitleCommand, "<player name/id> <title>", getStaffFlagValue("none"), true, true),
commandData("addrankflag", addClanRankFlagCommand, "<rank name/id> <flag name>", getStaffFlagValue("none"), true, true),
commandData("delrankflag", removeClanRankFlagCommand, "<rank name/id> <flag name>", getStaffFlagValue("none"), true, true),
commandData("addmemberflag", addClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true),
commandData("delmemberflag", removeClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true),
commandData("addclanrankflag", addClanRankFlagCommand, "<rank name/id> <flag name>", getStaffFlagValue("none"), true, true),
commandData("delclanrankflag", removeClanRankFlagCommand, "<rank name/id> <flag name>", getStaffFlagValue("none"), true, true),
commandData("addclanmemberflag", addClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true),
commandData("delclanmemberflag", removeClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true),
],
class: [],
client: [],
colour: [],
command: [
commandData("cmdenabletype", enableAllCommandsByType, "<type>", getStaffFlagValue("developer"), true, true),
commandData("cmddisabletype", disableAllCommandsByType, "<type>", getStaffFlagValue("developer"), true, true),
commandData("cmdenable", enableCommand, "<command>", getStaffFlagValue("developer"), true, true),
commandData("cmddisable", disableCommand, "<command>", getStaffFlagValue("developer"), true, true),
commandData("cmdenabletype", enableAllCommandsByType, "<type>", getStaffFlagValue("developer"), true, true, "Enables all commands by type."),
commandData("cmddisabletype", disableAllCommandsByType, "<type>", getStaffFlagValue("developer"), true, true, "Disables all commands by type."),
commandData("cmdenable", enableCommand, "<command>", getStaffFlagValue("developer"), true, true, "Enable a specific command"),
commandData("cmddisable", disableCommand, "<command>", getStaffFlagValue("developer"), true, true, "Disables a specific command"),
],
config: [
commandData("settime", setTimeCommand, "<hour> [minute]", getStaffFlagValue("manageServer"), true, true),
commandData("setweather", setWeatherCommand, "<weather id/name>", getStaffFlagValue("manageServer"), true, true),
commandData("setsnow", setSnowingCommand, "<falling snow> <ground snow>", getStaffFlagValue("manageServer"), true, true),
commandData("setlogo", toggleServerLogoCommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true),
commandData("setgui", toggleServerGUICommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true),
commandData("settime", setTimeCommand, "<hour> [minute]", getStaffFlagValue("manageServer"), true, true, "Set the time. Hours are required, minute is optional and will default to 0"),
commandData("setweather", setWeatherCommand, "<weather id/name>", getStaffFlagValue("manageServer"), true, true, "Change the weather to specified type."),
commandData("setsnow", setSnowingCommand, "<falling snow> <ground snow>", getStaffFlagValue("manageServer"), true, true, "Toggles winter/snow"),
commandData("setlogo", toggleServerLogoCommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true, "Toggles the corner server logo display on/off"),
commandData("setgui", toggleServerGUICommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true, "Toggles server GUI on/off"),
//commandData("setguicolours", setServerGUIColoursCommand, "<red> <green> <blue>", getStaffFlagValue("manageServer"), true, true),
commandData("newcharspawn", setNewCharacterSpawnPositionCommand, "", getStaffFlagValue("manageServer"), true, true),
commandData("newcharcash", setNewCharacterMoneyCommand, "<amount>", getStaffFlagValue("manageServer"), true, true),
commandData("newcharskin", setNewCharacterSkinCommand, "[skin id]", getStaffFlagValue("manageServer"), true, true),
commandData("jobinfo", getJobInfoCommand, "", getStaffFlagValue("none"), true, true),
commandData("joblocinfo", getJobLocationInfoCommand, "", getStaffFlagValue("none"), true, true),
commandData("newcharspawn", setNewCharacterSpawnPositionCommand, "", getStaffFlagValue("manageServer"), true, true, "Sets the starting spawn position for new characters"),
commandData("newcharcash", setNewCharacterMoneyCommand, "<amount>", getStaffFlagValue("manageServer"), true, true, "Sets the starting money for new characters"),
commandData("newcharskin", setNewCharacterSkinCommand, "[skin id]", getStaffFlagValue("manageServer"), true, true, "Sets the default skin for new characters"),
commandData("jobinfo", getJobInfoCommand, "", getStaffFlagValue("none"), true, true, "Get info for nearest or specified job"),
commandData("joblocinfo", getJobLocationInfoCommand, "", getStaffFlagValue("none"), true, true, "Get info for nearest or specified job location"),
commandData("reloadcfg", reloadServerConfigurationCommand, "", getStaffFlagValue("manageServer"), true, true, "Loads and applies the server configuration"),
commandData("reloademailcfg", reloadEmailConfigurationCommand, "", getStaffFlagValue("developer"), true, true, "Loads and applies the email configuration"),
commandData("reloaddbcfg", reloadDatabaseConfigurationCommand, "", getStaffFlagValue("developer"), true, true, "Loads and applies the database configuration"),
],
core: [],
database: [
@@ -148,11 +170,14 @@ function loadCommands() {
commandData("saveall", saveAllServerDataCommand, "", getStaffFlagValue("developer"), true, true),
commandData("docmd", simulateCommandForPlayerCommand, "<player name/id> <command> [params]", getStaffFlagValue("developer"), true, true),
commandData("docmdall", simulateCommandForAllPlayersCommand, "<command> [params]", getStaffFlagValue("developer"), true, true),
commandData("docmdall", simulateCommandForAllPlayersCommand, "<command> [params]", getStaffFlagValue("developer"), true, true),
commandData("addloglvl", addServerLogLevelCommand, "<log level name>", getStaffFlagValue("developer"), true, true),
commandData("delloglvl", removeServerLogLevelCommand, "<log level name>", getStaffFlagValue("developer"), true, true),
//commandData("loglvl", getServerLogLevelCommand, "<log level name>", getStaffFlagValue("developer"), true, true),
],
discord: [],
email: [
commandData("testemail", testEmailCommand, "<email address>", getStaffFlagValue("developer"), true, true),
],
help: [
commandData("help", helpCommand, "", getStaffFlagValue("none"), false, false),
],
@@ -165,34 +190,46 @@ function loadCommands() {
commandData("housedesc", setHouseDescriptionCommand, "", getStaffFlagValue("none"), true, false),
commandData("houselock", lockUnlockHouseCommand, "", getStaffFlagValue("none"), true, false),
commandData("houseowner", setHouseOwnerCommand, "", getStaffFlagValue("none"), true, false),
//commandData("housebuyprice", setHouseBuyPriceCommand, "", getStaffFlagValue("none"), true, false),
//commandData("houserentprice", setHouseRentPriceCommand, "", getStaffFlagValue("none"), true, false),
commandData("houseblip", setHouseBlipCommand, "<type name/model id>", getStaffFlagValue("manageHouses"), true, true),
commandData("housepickup", setHousePickupCommand, "<type name/model id>", getStaffFlagValue("manageHouses"), true, true),
commandData("houseinfo", getHouseInfoCommand, "[id]", getStaffFlagValue("none"), true, true),
commandData("houseentrance", moveHouseEntranceCommand, "", getStaffFlagValue("manageHouses"), true, true),
commandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("manageHouses"), true, true),
commandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageHouses"), true, true),
],
item: [
commandData("i", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("none"), true, false),
commandData("addgrounditem", createGroundItemCommand, "<item name/id>", getStaffFlagValue("manageItems"), true, false),
commandData("delgrounditem", deleteGroundItemCommand, "", getStaffFlagValue("manageItems"), true, false),
commandData("pickup", pickupItemCommand, "", getStaffFlagValue("none"), true, false),
commandData("drop", dropItemCommand, "[slot]", getStaffFlagValue("none"), true, false),
commandData("put", putItemCommand, "[slot]", getStaffFlagValue("none"), true, false),
commandData("take", takeItemCommand, "[slot]", getStaffFlagValue("none"), true, false),
commandData("use", useItemCommand, "[slot]", getStaffFlagValue("none"), true, false),
commandData("inv", listPlayerInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("inventory", listPlayerInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("i", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("none"), true, false, "Switches to the item in the specified slot of your inventory."),
commandData("addgrounditem", createGroundItemCommand, "<item name/id>", getStaffFlagValue("manageItems"), true, false, "Spawns a new item on the ground at your position."),
commandData("delgrounditem", deleteGroundItemCommand, "", getStaffFlagValue("manageItems"), true, false, "Destroys the nearest item on the ground."),
commandData("pickup", pickupItemCommand, "", getStaffFlagValue("none"), true, false, "Picks up the nearest item."),
commandData("drop", dropItemCommand, "[slot]", getStaffFlagValue("none"), true, false, "Drops your currently equipped item or the item in the specified slot"),
commandData("put", putItemCommand, "[slot]", getStaffFlagValue("none"), true, false, "Puts an item from your inventory into the nearest item place (vehicle trunk/dash, house, business, etc)"),
commandData("take", takeItemCommand, "[slot]", getStaffFlagValue("none"), true, false, "Takes an item from the nearest item place (vehicle trunk, dash, house, business, etc)"),
commandData("use", useItemCommand, "", getStaffFlagValue("none"), true, false, "Uses the currently equipped item"),
commandData("inv", listPlayerInventoryCommand, "", getStaffFlagValue("none"), true, false, "Shows the items in your inventory"),
commandData("inventory", listPlayerInventoryCommand, "", getStaffFlagValue("none"), true, false, "Shows the items in your inventory"),
commandData("items", listItemInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("houseitems", listHouseInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("bizstorage", listBusinessStorageInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("bizfloor", listBusinessFloorInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("items", listItemInventoryCommand, "", getStaffFlagValue("none"), true, false, "Shows the items in your inventory"),
commandData("houseitems", listHouseInventoryCommand, "", getStaffFlagValue("none"), true, false, "Shows the items in the house's storage"),
commandData("bizstorage", listBusinessStorageInventoryCommand, "", getStaffFlagValue("none"), true, false, "Shows the items in the business's extra storage (not buyable)"),
commandData("bizfloor", listBusinessFloorInventoryCommand, "", getStaffFlagValue("none"), true, false, "Shows the items that can be bought from the business"),
commandData("buylist", listBusinessFloorInventoryCommand, "", getStaffFlagValue("none"), true, false, "Shows the items that can be bought from the business"),
commandData("power", toggleItemEnabledCommand, "", getStaffFlagValue("none"), true, false),
commandData("freq", setWalkieTalkieFrequencyCommand, "[frequncy number]", getStaffFlagValue("none"), true, false),
//commandData("call", callWithPhoneCommand, "[number]", getStaffFlagValue("none"), true, false),
//commandData("speakerphone", togglePhoneSpeakerCommand, "", getStaffFlagValue("none"), true, false),
commandData("radio", walkieTalkieChatCommand, "", getStaffFlagValue("none"), true, false),
commandData("r", walkieTalkieChatCommand, "", getStaffFlagValue("none"), true, false),
commandData("additemtype", createItemTypeCommand, "<name>", getStaffFlagValue("manageItems"), true, false),
commandData("itemusetype", setItemTypeUseTypeCommand, "<item type> <use type>", getStaffFlagValue("manageItems"), true, false),
commandData("itemuseval", setItemTypeUseValueCommand, "<item type> <use value>", getStaffFlagValue("manageItems"), true, false),
commandData("itemorderprice", setItemTypeOrderPriceCommand, "<item type> <price>", getStaffFlagValue("manageItems"), true, false),
commandData("itemriskmult", setItemTypeRiskMultiplierCommand, "<item type> <risk multiplier>", getStaffFlagValue("manageItems"), true, false),
],
job: [
commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false),
@@ -204,8 +241,6 @@ function loadCommands() {
commandData("uniform", jobUniformCommand, "[uniform]", getStaffFlagValue("none"), true, false),
commandData("equip", jobEquipmentCommand, "[equipment]", getStaffFlagValue("none"), true, false),
commandData("radio", jobRadioCommand, "", getStaffFlagValue("none"), true, false),
commandData("r", jobRadioCommand, "", getStaffFlagValue("none"), true, false),
commandData("department", jobDepartmentRadioCommand, "", getStaffFlagValue("none"), true, false),
commandData("d", jobDepartmentRadioCommand, "", getStaffFlagValue("none"), true, false),
@@ -213,8 +248,8 @@ function loadCommands() {
commandData("fare", taxiSetFareCommand, "", getStaffFlagValue("none"), true, false),
// Police
commandData("tazer", policeTazerCommand, "", getStaffFlagValue("none"), true, false),
commandData("cuff", policeCuffCommand, "", getStaffFlagValue("none"), true, false),
//commandData("tazer", policeTazerCommand, "", getStaffFlagValue("none"), true, false),
//commandData("cuff", policeCuffCommand, "", getStaffFlagValue("none"), true, false),
commandData("detain", policeDetainCommand, "", getStaffFlagValue("none"), true, false),
commandData("drag", policeDragCommand, "", getStaffFlagValue("none"), true, false),
commandData("search", policeSearchCommand, "", getStaffFlagValue("none"), true, false),
@@ -248,9 +283,12 @@ function loadCommands() {
commandData("idea", submitIdeaCommand, "<message>", getStaffFlagValue("none"), true, true),
commandData("bug", submitBugReportCommand, "<message>", getStaffFlagValue("none"), true, true),
commandData("enter", enterExitPropertyCommand, "", getStaffFlagValue("none"), true, true),
commandData("exit", enterExitPropertyCommand, "", getStaffFlagValue("none"), true, false),
commandData("cursor", toggleMouseCursorCommand, "", getStaffFlagValue("none"), true, false),
commandData("mousecam", toggleMouseCameraCommand, "", getStaffFlagValue("none"), true, false),
commandData("yes", playerPromptAnswerYesCommand, "", getStaffFlagValue("none"), true, false),
commandData("no", playerPromptAnswerNoCommand, "", getStaffFlagValue("none"), true, false),
commandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("none"), true, false),
commandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level>", getStaffFlagValue("none"), true, false),
],
moderation: [
commandData("kick", kickClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true),
@@ -265,7 +303,7 @@ function loadCommands() {
commandData("gotobiz", gotoBusinessCommand, "<business id/name>", getStaffFlagValue("basicModeration"), true, true),
commandData("gotohouse", gotoHouseCommand, "<house id/name>", getStaffFlagValue("basicModeration"), true, true),
commandData("gotojob", gotoJobLocationCommand, "<job id/name> <location id>", getStaffFlagValue("basicModeration"), true, true),
//commandData("gotoloc", gotoLocationCommand, "<location name>", getStaffFlagValue("basicModeration"), true, true),
commandData("gotoloc", gotoGameLocationCommand, "<location name>", getStaffFlagValue("basicModeration"), true, true),
commandData("fr", teleportForwardCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true),
commandData("ba", teleportBackwardCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true),
commandData("lt", teleportLeftCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true),
@@ -291,6 +329,18 @@ function loadCommands() {
commandData("usechar", useCharacterCommand, "<character id>", getStaffFlagValue("none"), true, false),
],
translate: [],
trigger: [
commandData("addtrig", createTriggerCommand, "<trigger name>", getStaffFlagValue("manageServer"), true, false),
commandData("deltrig", deleteTriggerCommand, "<trigger id>", getStaffFlagValue("manageServer"), true, false),
commandData("addtrigcond", addTriggerConditionCommand, "<trigger id> <condition name>", getStaffFlagValue("manageServer"), true, false),
commandData("deltrigcond", removeTriggerConditionCommand, "<trigger id> <condition id>", getStaffFlagValue("manageServer"), true, false),
commandData("addtrigresp", addTriggerResponseCommand, "<trigger id> <response name>", getStaffFlagValue("manageServer"), true, false),
commandData("deltrigresp", removeTriggerResponseCommand, "<trigger id> <response name>", getStaffFlagValue("manageServer"), true, false),
commandData("triggers", listTriggersCommand, "[search value]", getStaffFlagValue("manageServer"), true, false),
commandData("trigcond", listTriggerConditionsCommand, "<trigger id>", getStaffFlagValue("manageServer"), true, false),
commandData("trigresp", listTriggerResponsesCommand, "<trigger id>", getStaffFlagValue("manageServer"), true, false),
commandData("trigtoggle", toggleTriggerEnabledCommand, "<trigger id> [0/1 state]", getStaffFlagValue("manageServer"), true, false),
],
utilities: [],
vehicle: [
commandData("addveh", createVehicleCommand, "<model id/name>", getStaffFlagValue("manageVehicles"), true, false),
@@ -327,6 +377,8 @@ function loadCommands() {
};
}
// ===========================================================================
function addAllCommandHandlers() {
for(let i in serverCommands) {
for(let j in serverCommands[i]) {
@@ -335,7 +387,7 @@ function addAllCommandHandlers() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getCommand(command) {
let commandGroups = getCommands()
@@ -351,49 +403,49 @@ function getCommand(command) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getCommandData(command) {
return getCommand(command);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getCommands() {
return serverCommands;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function commandData(command, handlerFunction, syntaxString = "", requiredStaffFlags = getStaffFlagValue("none"), requireLogin = true, allowOnDiscord = true, usageHelpMessage) {
return new serverClasses.commandData(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, usageHelpMessage);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesCommandRequireLogin(command) {
return getCommand(command).requireLogin;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getCommandRequiredPermissions(command) {
return getCommand(command).requiredStaffFlags;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getCommandSyntaxText(command) {
return `/${command} ${getCommand(command).syntaxString}`;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isCommandAllowedOnDiscord(command) {
return getCommand(command).allowOnDiscord;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function disableCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -413,7 +465,7 @@ function disableCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function enableCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -433,7 +485,7 @@ function enableCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function disableAllCommandsByType(command, params, client) {
if(areParamsEmpty(params)) {
@@ -456,7 +508,7 @@ function disableAllCommandsByType(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function enableAllCommandsByType(command, params, client) {
if(areParamsEmpty(params)) {
@@ -479,14 +531,14 @@ function enableAllCommandsByType(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerCommand(event, client, command, params) {
//processPlayerCommand(command, params, client)
processPlayerCommand(command, params, client)
}
addEventHandler("OnPlayerCommand", onPlayerCommand);
// ---------------------------------------------------------------------------
// ===========================================================================
function processPlayerCommand(command, params, client) {
if(builtInCommands.indexOf(toLowerCase(command)) != -1) {
@@ -540,7 +592,7 @@ function processPlayerCommand(command, params, client) {
commandData.handlerFunction(toLowerCase(command), params, client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
addCommandHandler("cmd", function(command, params, client) {
if(!isConsole(client)) {
@@ -554,7 +606,7 @@ addCommandHandler("cmd", function(command, params, client) {
getCommand(newCommand).handlerFunction(newCommand, newParams, client);
});
// ---------------------------------------------------------------------------
// ===========================================================================
function listAllCommands() {
for(let i in serverCommands) {
@@ -564,7 +616,7 @@ function listAllCommands() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesCommandExist(command) {
if(getCommandData(command)) {
@@ -574,4 +626,4 @@ function doesCommandExist(command) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -2,14 +2,16 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: const.js
// DESC: Provides constants
// TYPE: Server (JavaScript)
// ===========================================================================
// Prompts (used for client GUI prompt responses)
const AG_PROMPT_NONE = 0;
const AG_PROMPT_CREATEFIRSTCHAR = 1;
const AG_PROMPT_BIZORDER = 2;
// Job Types
const AG_JOB_NONE = 0;
@@ -22,7 +24,7 @@ const AG_JOB_GARBAGE = 6;
const AG_JOB_WEAPON = 7;
const AG_JOB_DRUG = 8;
// Pickup Owner Types
// Pickup Types
const AG_PICKUP_NONE = 0;
const AG_PICKUP_JOB = 1;
const AG_PICKUP_BUSINESS_ENTRANCE = 2;
@@ -31,54 +33,48 @@ const AG_PICKUP_HOUSE_ENTRANCE = 4;
const AG_PICKUP_HOUSE_EXIT = 5;
const AG_PICKUP_EXIT = 5;
// Sphere Types
const AG_SPHERE_NONE = 0;
const AG_SPHERE_JOB = 1;
const AG_SPHERE_BUSINESS = 2;
const AG_SPHERE_HOUSE = 3;
// Vehicle Owner Types
const AG_VEHOWNER_NONE = 0;
const AG_VEHOWNER_PLAYER = 1;
const AG_VEHOWNER_JOB = 2;
const AG_VEHOWNER_CLAN = 3;
const AG_VEHOWNER_FACTION = 4;
const AG_VEHOWNER_PUBLIC = 5;
const AG_VEHOWNER_BIZ = 6;
const AG_VEHOWNER_NONE = 0; // Not owned
const AG_VEHOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
const AG_VEHOWNER_JOB = 2; // Owned by a job
const AG_VEHOWNER_CLAN = 3; // Owned by a clan
const AG_VEHOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
const AG_VEHOWNER_PUBLIC = 5; // Public vehicle. Anybody can drive it.
const AG_VEHOWNER_BIZ = 6; // Owned by a business (also includes dealerships since they're businesses)
// Business Owner Types
const AG_BIZOWNER_NONE = 0;
const AG_BIZOWNER_PLAYER = 1;
const AG_BIZOWNER_JOB = 2;
const AG_BIZOWNER_CLAN = 3;
const AG_BIZOWNER_FACTION = 4;
const AG_BIZOWNER_PUBLIC = 5;
const AG_BIZOWNER_NONE = 0; // Not owned
const AG_BIZOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
const AG_BIZOWNER_JOB = 2; // Owned by a job
const AG_BIZOWNER_CLAN = 3; // Owned by a clan
const AG_BIZOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
const AG_BIZOWNER_PUBLIC = 5; // Public Business. Used for goverment/official places like police, fire, city hall, DMV, etc
// House Owner Types
const AG_HOUSEOWNER_NONE = 0;
const AG_HOUSEOWNER_PLAYER = 1;
const AG_HOUSEOWNER_JOB = 2;
const AG_HOUSEOWNER_CLAN = 3;
const AG_HOUSEOWNER_FACTION = 4;
const AG_HOUSEOWNER_PUBLIC = 5;
const AG_HOUSEOWNER_NONE = 0; // Not owned
const AG_HOUSEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const AG_HOUSEOWNER_JOB = 2; // Owned by a job
const AG_HOUSEOWNER_CLAN = 3; // Owned by a clan
const AG_HOUSEOWNER_FACTION = 4; // Owned by a faction
const AG_HOUSEOWNER_PUBLIC = 5; // Is a public house. Technically not owned. This probably won't be used.
// Business Location Types
const AG_BIZLOC_NONE = 0;
const AG_BIZLOC_FUEL = 1;
const AG_BIZLOC_DRIVETHRU = 2;
const AG_BIZLOC_VENDMACHINE = 3;
const AG_BIZLOC_NONE = 0; // None
const AG_BIZLOC_FUEL = 1; // Fuel pump
const AG_BIZLOC_DRIVETHRU = 2; // Drivethrough
const AG_BIZLOC_VENDMACHINE = 3; // Vending machine
// Account Contact Types
const AG_CONTACT_NONE = 0;
const AG_CONTACT_NEUTRAL = 1;
const AG_CONTACT_FRIEND = 2;
const AG_CONTACT_BLOCKED = 3;
const AG_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
const AG_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
const AG_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
// Job Work Types (Currently Unused)
const AG_JOBWORKTYPE_NONE = 0;
const AG_JOBWORKTYPE_ROUTE = 1; // Jobs that use routes. Bus, trash collector, mail, etc
const AG_JOBWORKTYPE_SELL = 2; // Jobs that sell items to other players and NPCs. Drugs, guns, etc
const AG_JOBWORKTYPE_SERVICE = 3; // Services to other players and NPCs. Taxi ride, mechanic fix, etc
const AG_JOBWORKTYPE_ROUTE = 1; // Jobs that use routes. Bus, trash collector, mail, etc
const AG_JOBWORKTYPE_SELL = 2; // Jobs that sell items to other players and NPCs. Drugs, guns, etc
const AG_JOBWORKTYPE_SERVICE = 3; // Services to other players and NPCs. Taxi ride, mechanic fix, etc
// Vehicle Seats
const AG_VEHSEAT_DRIVER = 0;
@@ -181,7 +177,7 @@ const AG_ITEM_USETYPE_BEER = 20; // Subtle drunk effect. Replenis
const AG_ITEM_USETYPE_WINE = 21; // Moderate drunk effect. Replenishes moderate amount of health.
const AG_ITEM_USETYPE_LIQUOR = 22; // Heavy drunk effect. Replenishes large amount of health.
const AG_ITEM_USETYPE_COFFEE = 23; // Replenishes moderate amount of health.
const AG_ITEM_USETYPE_AMMO_ROUND = 23; // Bullet. Loads into magazine.
const AG_ITEM_USETYPE_AMMO_ROUND = 23; // Bullet. Loads into magazine. Not used at the moment
const AG_ITEM_USETYPE_HANDCUFF = 24; //
const AG_ITEM_USETYPE_ROPE = 25; //
const AG_ITEM_USETYPE_BLINDFOLD = 26; //
@@ -198,6 +194,7 @@ const AG_ITEM_USETYPE_EXTINGUISHER = 36; //
const AG_ITEM_USETYPE_SPRAYPAINT = 37; //
const AG_ITEM_USETYPE_PEPPERSPRAY = 38; //
const AG_ITEM_USETYPE_FLASHLIGHT = 39; //
const AG_ITEM_USETYPE_AIRPLANETICKET = 40; //
// Item Drop Types
const AG_ITEM_DROPTYPE_NONE = 0; // Can't be dropped
@@ -237,34 +234,53 @@ const AG_JOBROUTESTATE_LASTSTOP = 2; // Player is heading to the last
const AG_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 AG_JOBROUTESTATE_ATSTOP = 4; // For bus/trash stops that freeze player, this is the state when they're at one
// Tutorial States
const AG_TUTORIAL_STATE_NONE = 0;
const AG_TUTORIAL_STATE_FINISHED = 1;
const AG_TUTORIAL_STATE_STARTING = 2;
const AG_TUTORIAL_STATE_PICKUPITEM = 3;
const AG_TUTORIAL_STATE_SWITCHITEM = 4;
const AG_TUTORIAL_STATE_USEITEM = 5;
const AG_TUTORIAL_STATE_PUTITEM = 6;
const AG_TUTORIAL_STATE_TAKEITEM = 7;
const AG_TUTORIAL_STATE_EXITBIZ = 9;
const AG_TUTORIAL_STATE_DROPITEM = 10;
// Item Occupied States
const AG_ITEM_ACTION_NONE = 0;
const AG_ITEM_ACTION_USE = 1;
const AG_ITEM_ACTION_PICKUP = 2;
const AG_ITEM_ACTION_DROP = 3;
const AG_ITEM_ACTION_SWITCH = 4;
const AG_ITEM_ACTION_PUT = 5;
const AG_ITEM_ACTION_TAKE = 6;
const AG_ITEM_ACTION_NONE = 0; // None
const AG_ITEM_ACTION_USE = 1; // Using item
const AG_ITEM_ACTION_PICKUP = 2; // Picking up item
const AG_ITEM_ACTION_DROP = 3; // Dropping item
const AG_ITEM_ACTION_SWITCH = 4; // Switching item
const AG_ITEM_ACTION_PUT = 5; // Putting item (into trunk, dash, crate, etc)
const AG_ITEM_ACTION_TAKE = 6; // Taking item (from trunk, dash, crate, etc)
// Ped States
const AG_PEDSTATE_NONE = 2;
const AG_PEDSTATE_READY = 1;
const AG_PEDSTATE_DRIVER = 2;
const AG_PEDSTATE_PASSENGER = 3;
const AG_PEDSTATE_DEAD = 4;
const AG_PEDSTATE_ENTERINGPROPERTY = 5;
const AG_PEDSTATE_EXITINGPROPERTY = 6;
const AG_PEDSTATE_ENTERINGVEHICLE = 7;
const AG_PEDSTATE_EXITINGVEHICLE = 8;
const AG_PEDSTATE_NONE = 2; // None
const AG_PEDSTATE_READY = 1; // Ready
const AG_PEDSTATE_DRIVER = 2; // Driving a vehicle
const AG_PEDSTATE_PASSENGER = 3; // In a vehicle as passenger
const AG_PEDSTATE_DEAD = 4; // Dead
const AG_PEDSTATE_ENTERINGPROPERTY = 5; // Entering a property
const AG_PEDSTATE_EXITINGPROPERTY = 6; // Exiting a property
const AG_PEDSTATE_ENTERINGVEHICLE = 7; // Entering a vehicle
const AG_PEDSTATE_EXITINGVEHICLE = 8; // Exiting a vehicle
const AG_PEDSTATE_BINDED = 9; // Binded by rope or handcuffs
const AG_PEDSTATE_TAZED = 10; // Under incapacitating effect of tazer
const AG_PEDSTATE_INTRUNK = 11; // In vehicle trunk
const AG_PEDSTATE_INITEM = 12; // In item (crate, box, etc)
const AG_PEDSTATE_HANDSUP = 13; // Has hands up (surrendering)
const AG_PEDSTATE_SPAWNING = 14; // Spawning
const AG_2FA_STATE_NONE = 0; // None
const AG_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
const AG_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
const AG_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
const AG_FORGOTPASS_STATE_NONE = 0; // None
const AG_FORGOTPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
const AG_FORGOTPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
const AG_NPC_COND_MATCH_NONE = 0; // None (invalid)
const AG_NPC_COND_MATCH_EQ = 1; // Must be equal to
const AG_NPC_COND_MATCH_GT = 2; // Must be greater than
const AG_NPC_COND_MATCH_LT = 3; // Must be less than
const AG_NPC_COND_MATCH_GTEQ = 4; // Must be greater than or equal to
const AG_NPC_COND_MATCH_LTEQ = 5; // Must be less than or equal to
const AG_NPC_COND_MATCH_CONTAINS = 6; // Must contain string (case insensitive)
const AG_NPC_COND_MATCH_CONTAINS_CASE = 7; // Must contain string (case sensitive)
const AG_NPC_COND_MATCH_EXACT = 8; // Must match string exactly (case insensitive)
const AG_NPC_COND_MATCH_EXACT_CASE = 9; // Must match string exactly (case insensitive)
const AG_BIZ_TYPE_NONE = 0; // None (invalid)
const AG_BIZ_TYPE_NORMAL = 1; // Normal business (sells items)
const AG_BIZ_TYPE_BANK = 2; // Bank
const AG_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: core.js
// DESC: Provides core data structures, function, and operations
// TYPE: Server (JavaScript)
@@ -10,9 +10,9 @@
let scriptVersion = "1.0";
let serverStartTime = 0;
let logLevel = LOG_DEBUG;
let logLevel = LOG_ALL;
// -------------------------------------------------------------------------
// ===========================================================================
let serverData = {
vehicles: [],
@@ -389,7 +389,7 @@ let serverData = {
],
};
// -------------------------------------------------------------------------
// ===========================================================================
function initServerData() {
// Pre-allocate translation cache language slots
@@ -399,10 +399,16 @@ function initServerData() {
global.getServerData().translation.cache.fill(translationCacheFrom);
}
// -------------------------------------------------------------------------
// ===========================================================================
function getServerData() {
return serverData;
}
// -------------------------------------------------------------------------
// ===========================================================================
function getModNatives() {
return modNatives;
}
// ===========================================================================

View File

@@ -2,33 +2,25 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: database.js
// DESC: Provides database handling, functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// -------------------------------------------------------------------------
let databaseConfig = {
host: "127.0.0.1",
user: "gtac_main",
pass: "d8NEzoNIFadanisuKuzEgOSOxOjiG6",
name: "gtac_main",
port: 3306,
usePersistentConnection: true,
}
// ===========================================================================
let persistentDatabaseConnection = null;
// -------------------------------------------------------------------------
// ===========================================================================
function initDatabaseScript() {
logToConsole(LOG_DEBUG, "[Asshat.Database]: Initializing database script ...");
logToConsole(LOG_DEBUG, "[Asshat.Database]: Database script initialized successfully!");
logToConsole(LOG_INFO, "[Asshat.Database]: Initializing database script ...");
databaseConfig = loadDatabaseConfiguration();
logToConsole(LOG_INFO, "[Asshat.Database]: Database script initialized successfully!");
}
// -------------------------------------------------------------------------
// ===========================================================================
function connectToDatabase() {
if(persistentDatabaseConnection == null) {
@@ -43,79 +35,98 @@ function connectToDatabase() {
logToConsole(LOG_DEBUG, "[Asshat.Database] Database connection successful!");
return persistentDatabaseConnection;
} else {
//logToConsole(LOG_DEBUG, "[Asshat.Database] Using existing database connection.");
logToConsole(LOG_DEBUG, "[Asshat.Database] Using existing database connection.");
return persistentDatabaseConnection;
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function disconnectFromDatabase(dbConnection) {
if(!databaseConfig.usePersistentConnection) {
dbConnection.close();
try {
dbConnection.close();
logToConsole(LOG_DEBUG, `[Asshat.Database] Database connection closed successfully`);
} catch(error) {
logToConsole(LOG_ERROR, `[Asshat.Database] Database connection could not be closed! (Error: ${error})`);
}
}
return true;
}
// -------------------------------------------------------------------------
// ===========================================================================
function queryDatabase(dbConnection, queryString) {
logToConsole(LOG_DEBUG, `[Asshat.Database] Query string: ${queryString}`);
return dbConnection.query(queryString);
}
// -------------------------------------------------------------------------
// ===========================================================================
function escapeDatabaseString(dbConnection, unsafeString) {
function escapeDatabaseString(dbConnection, unsafeString = "") {
if(!dbConnection) {
dbConnection = connectToDatabase();
}
return dbConnection.escapeString(unsafeString);
if(typeof unsafeString == "string") {
return dbConnection.escapeString(unsafeString);
}
return unsafeString;
}
// -------------------------------------------------------------------------
// ===========================================================================
function getDatabaseInsertId(dbConnection) {
return dbConnection.insertId;
}
// -------------------------------------------------------------------------
// ===========================================================================
function getQueryNumRows(dbQuery) {
return dbQuery.numRows;
}
// -------------------------------------------------------------------------
// ===========================================================================
function getDatabaseError(dbConnection) {
return dbConnection.error;
}
// -------------------------------------------------------------------------
// ===========================================================================
function freeDatabaseQuery(dbQuery) {
dbQuery.free();
if(dbQuery != null) {
dbQuery.free();
}
return;
}
// -------------------------------------------------------------------------
// ===========================================================================
function fetchQueryAssoc(dbQuery) {
return dbQuery.fetchAssoc();
}
// -------------------------------------------------------------------------
// ===========================================================================
function quickDatabaseQuery(queryString) {
let dbConnection = connectToDatabase();
let insertId = 0;
if(dbConnection) {
logToConsole(LOG_DEBUG, `[Asshat.Database] Query string: ${queryString}`);
let dbQuery = queryDatabase(dbConnection, queryString);
if(getDatabaseInsertId(dbConnection)) {
insertId = getDatabaseInsertId(dbConnection);
logToConsole(LOG_DEBUG, `[Asshat.Database] Query returned insert id ${insertId}`);
}
if(dbQuery) {
freeDatabaseQuery(dbQuery);
try {
freeDatabaseQuery(dbQuery);
logToConsole(LOG_DEBUG, `[Asshat.Database] Query result free'd successfully`);
} catch(error) {
logToConsole(LOG_ERROR, `[Asshat.Database] Query result could not be free'd! (Error: ${error})`);
}
}
disconnectFromDatabase(dbConnection);
@@ -129,21 +140,9 @@ function quickDatabaseQuery(queryString) {
return false;
}
// -------------------------------------------------------------------------
// ===========================================================================
function executeDatabaseQueryCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isPlayerLoggedIn(client)) {
messagePlayerError(client, "You must be logged in to use this command!");
return false;
}
}
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messagePlayerError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -172,4 +171,22 @@ function executeDatabaseQueryCommand(command, params, client) {
return true;
}
// -------------------------------------------------------------------------
// ===========================================================================
function setConstantsAsGlobalVariablesInDatabase() {
let dbConnection = connectToDatabase();
let entries = Object.entries(global);
for(let i in entries) {
logToConsole(LOG_DEBUG, `[Asshat.Database] Checking entry ${i} (${entries[i]})`);
if(toString(i).slice(0, 3).indexOf("AG_") != -1) {
logToConsole(LOG_DEBUG, `[Asshat.Database] Adding ${i} (${entries[i]}) to database global variables`);
}
}
}
// ===========================================================================
function loadDatabaseConfiguration() {
let databaseConfigFile = loadTextFile("config/database.json");
return JSON.parse(databaseConfigFile);
}

View File

@@ -2,14 +2,14 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: developer.js
// DESC: Provides developer operation, commands, functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initDeveloperScript() {
logToConsole(LOG_DEBUG, "[Asshat.Developer]: Initializing developer script ...");
logToConsole(LOG_INFO, "[Asshat.Developer]: Initializing developer script ...");
// Use GTAC command handlers for these since they need to be available on console
//addCommandHandler("sc", executeServerCodeCommand);
@@ -18,69 +18,107 @@ function initDeveloperScript() {
//addCommandHandler("allcmd", simulateCommandForAllPlayersCommand);
//addCommandHandler("addloglvl", setServerLogLevelCommand);
logToConsole(LOG_DEBUG, "[Asshat.Developer]: Developer script initialized successfully!");
logToConsole(LOG_INFO, "[Asshat.Developer]: Developer script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function p(params) {
return getPlayerFromParams(params);
}
// ===========================================================================
function o(params) {
return getElementsByType(ELEMENT_OBJECT)[params];
}
// ===========================================================================
function io(params) {
return getItemData(params).object;
}
// ===========================================================================
function pd(params) {
return getPlayerData(getPlayerFromParams(params));
}
// ===========================================================================
function cv(params) {
return getClosestVehicle(getPlayerPosition(getPlayerFromParams(params)));
}
// ===========================================================================
function iv(params) {
return getPlayerVehicle(getPlayerFromParams(params));
}
// ===========================================================================
function bd(params) {
return getBusinessFromParams(params);
}
// ===========================================================================
function hd(params) {
return getHouseFromParams(params);
}
// ===========================================================================
function jd(params) {
return getJobFromParams(params);
}
// ===========================================================================
function jld(params, jobLocationIndex) {
return getJobFromParams(params).locations[jobLocationIndex];
}
// ===========================================================================
function vd(params) {
return getVehicleData(getVehicleFromParams(params));
}
// ===========================================================================
function pad(params) {
return getPlayerData(getPlayerFromParams(params)).accountData;
}
// ===========================================================================
function pcsd(params) {
return getPlayerCurrentSubAccount(getPlayerFromParams(params));
}
// ===========================================================================
function psd(params, subAccountIndex) {
return getPlayerData(getPlayerFromParams(params)).subAccounts[subAccountIndex];
}
// ===========================================================================
function pv(params) {
return getPlayerVehicle(getPlayerFromParams(params));
}
// ===========================================================================
function pvd(params) {
return getVehicleData(getPlayerVehicle(getPlayerFromParams(params)));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addServerLogLevelCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -118,7 +156,7 @@ function addServerLogLevelCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removeServerLogLevelCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -156,7 +194,7 @@ function removeServerLogLevelCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function simulateCommandForPlayerCommand(command, params, client) {
if(getCommand(command).requireLogin) {
@@ -197,7 +235,7 @@ function simulateCommandForPlayerCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function simulateCommandForAllPlayersCommand(command, params, client) {
if(getCommand(command).requireLogin) {
@@ -237,7 +275,7 @@ function simulateCommandForAllPlayersCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function executeServerCodeCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -259,7 +297,7 @@ function executeServerCodeCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function executeClientCodeCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -288,16 +326,23 @@ function executeClientCodeCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveAllServerDataCommand(command, params, client) {
messageAdmins(`[#FF9900]Saving all server data to database ...`);
messageAdmins(`[#FF9900]Vortrex has forced a manual save of all data. Initiating ...`);
saveAllServerDataToDatabase();
messageAdmins(`[#FF9900]All server data saved to database!`);
messageAdmins(`[#FF9900]All server data saved to database successfully!`);
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function testEmailCommand(command, params, client) {
sendEmail(params, "Player", "Test email", "Just testing the SMTP module for the server!");
return true;
}
// ===========================================================================
function restartGameModeCommand(command, params, client) {
messagePlayerNormal(null, `[#FF9900]The server game mode is restarting!`, getColourByName("orange"));
@@ -306,10 +351,10 @@ function restartGameModeCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clientRunCodeFail(client, returnTo, code) {
let returnClient = getClients()[returnTo];
let returnClient = getClientFromIndex(returnTo);
if(!returnClient) {
return false;
}
@@ -318,10 +363,10 @@ function clientRunCodeFail(client, returnTo, code) {
messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clientRunCodeSuccess(client, returnTo, returnVal, code) {
let returnClient = getClients()[returnTo];
let returnClient = getClientFromIndex(returnTo);
if(!returnClient) {
return false;
}
@@ -331,7 +376,7 @@ function clientRunCodeSuccess(client, returnTo, returnVal, code) {
messagePlayerNormal(returnClient, `Returns: ${returnVal}`, getColourByName("yellow"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function submitIdea(client, ideaText) {
let position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
@@ -352,7 +397,7 @@ function submitIdea(client, ideaText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function submitBugReport(client, bugText) {
let position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
@@ -373,10 +418,32 @@ function submitBugReport(client, bugText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isDevelopmentServer() {
return intToBool(server.getCVar("devserver"));
return intToBool(server.getCVar("devserver") || 0);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function migrateSubAccountsToPerServerData() {
let dbConnection = connectToDatabase();
let dbQuery = false;
let dbAssoc = false;
if(dbConnection) {
dbQuery = queryDatabase(dbConnection, `SELECT * FROM sacct_main`);
if(dbQuery) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
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"]}`);
if(dbQuery2) {
freeDatabaseQuery(dbQuery2);
}
}
freeDatabaseQuery(dbQuery);
}
}
}
// ===========================================================================

View File

@@ -2,12 +2,19 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: discord.js
// DESC: Provides discord bridging and connection functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initDiscordScript() {
logToConsole(LOG_INFO, "[Asshat.Discord]: Initializing discord script ...");
logToConsole(LOG_INFO, "[Asshat.Discord]: Discord script initialized successfully!");
}
// ===========================================================================
/*
addEventHandler("OnDiscordCommand", function(command, params, discordUser) {
let commandData = getCommand(command);
@@ -31,7 +38,7 @@ addEventHandler("OnDiscordCommand", function(command, params, discordUser) {
});
*/
// ---------------------------------------------------------------------------
// ===========================================================================
function messageDiscordUser(discordUser, messageText) {
let socketData = JSON.stringify({
@@ -44,7 +51,7 @@ function messageDiscordUser(discordUser, messageText) {
sendDiscordSocketData(socketData);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendDiscordSocketData(socketData) {
if(!getDiscordSocket()) {
@@ -54,7 +61,7 @@ function sendDiscordSocketData(socketData) {
getDiscordSocket().send(module.hash.encodeBase64(socketData) + "\r\n");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isClientFromDiscord(client) {
if(client == null) {
@@ -68,34 +75,34 @@ function isClientFromDiscord(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getDiscordSocket() {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getDiscordUserData(discordUserId) {
return loadAccountFromDiscordUserId(discordUserId);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messageDiscordChatChannel(message) {
let gameEmoji = getGameEmojiForDiscord(getServerGame());
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messageDiscordAdminChannel(message) {
let gameEmoji = getGameEmojiForDiscord(getServerGame());
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messageDiscordEventChannel(message) {
let gameEmoji = getGameEmojiForDiscord(getServerGame());
}
// ---------------------------------------------------------------------------
// ===========================================================================

28
scripts/server/economy.js Normal file
View File

@@ -0,0 +1,28 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: economy.js
// DESC: Provides economy/financial utils, functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initEconomyScript() {
logToConsole(LOG_INFO, "[Asshat.Economy]: Initializing economy script ...");
logToConsole(LOG_INFO, "[Asshat.Economy]: Economy script initialized successfully!");
}
// ===========================================================================
function getTimeDisplayUntilPlayerPayDay(client) {
return getTimeDifferenceDisplay(sdl.ticks-getPlayerData(client).payDayTickStart);
}
// ===========================================================================
function applyServerInflationMultiplier(value) {
return toInteger(Math.round(value*getServerConfig().inflationMultiplier))
}
// ===========================================================================

47
scripts/server/email.js Normal file
View File

@@ -0,0 +1,47 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: email.js
// DESC: Provides email handling, functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initEmailScript() {
logToConsole(LOG_INFO, "[Asshat.Email]: Initializing email script ...");
emailConfig = loadEmailConfiguration();
logToConsole(LOG_INFO, "[Asshat.Email]: Email script initialized successfully!");
}
// ===========================================================================
function sendEmail(toEmail, toName, subject, body) {
module.smtp.send(
emailConfig.smtp.host,
emailConfig.smtp.port,
emailConfig.smtp.useTLS,
emailConfig.smtp.username,
emailConfig.smtp.password,
toEmail,
toName,
subject,
body,
emailConfig.smtp.from,
emailConfig.smtp.fromName);
}
// ===========================================================================
function loadEmailConfiguration() {
let emailConfigFile = loadTextFile("config/email.json");
return JSON.parse(emailConfigFile);
}
// ===========================================================================
function getEmailConfig() {
return emailConfig;
}
// ===========================================================================

View File

@@ -2,21 +2,19 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
function initEventScript() {
logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ...");
logToConsole(LOG_INFO, "[Asshat.Event]: Initializing event script ...");
addAllEventHandlers();
logToConsole(LOG_DEBUG, "[Asshat.Event]: Event script initialized!");
logToConsole(LOG_INFO, "[Asshat.Event]: Event script initialized!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addAllEventHandlers() {
addEventHandler("onResourceStart", onResourceStart);
@@ -35,7 +33,7 @@ function addAllEventHandlers() {
addEventHandler("onPedExitVehicle", onPedExitingVehicle);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerConnect(event, ipAddress, port) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Client connecting (IP: ${ipAddress})`);
@@ -45,37 +43,45 @@ function onPlayerConnect(event, ipAddress, port) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerJoin(event, client) {
fadeCamera(client, true, 1.0);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerJoined(event, client) {
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
//savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;
messagePlayerNormal(null, `👋 ${client.name} has left the server (${disconnectReasons[quitReasonId]})`, getColourByName("softYellow"));
updateConnectionLogOnQuit(client, quitReasonId);
if(isPlayerLoggedIn(client)) {
messagePlayerNormal(null, `👋 ${client.name} has left the server (${disconnectReasons[quitReasonId]})`, getColourByName("softYellow"));
savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerChat(event, client, messageText) {
event.preventDefault();
if(!getPlayerData(client).loggedIn) {
messagePlayerError(client, "You need to login before you can chat!");
return false;
if(!isNull(getPlayerData(client))) {
if(!getPlayerData(client).loggedIn) {
messagePlayerError(client, "You need to login before you can chat!");
return false;
}
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
return false;
}
}
messageText = messageText.substring(0, 128);
@@ -83,13 +89,16 @@ function onPlayerChat(event, client, messageText) {
messagePlayerNormal(null, `${getCharacterFullName(client)}: [#FFFFFF]${messageText}`, getPlayerColour(client));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onProcess(event, deltaTime) {
checkVehicleBuying();
//checkPlayerSpawning();
//checkPlayerPedState();
//checkVehicleBurning();
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPedEnteringVehicle(event, ped, vehicle, seat) {
if(ped.isType(ELEMENT_PLAYER)) {
@@ -105,10 +114,11 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) {
}
if(getVehicleData(vehicle).locked) {
if(doesClientHaveVehicleKeys(client, vehicle)) {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(doesPlayerHaveKeyBindForCommand(client, "lock")) {
messagePlayerTip(client, `You can also press [#AAAAAA]${sdl.getKeyName(getPlayerKeyBindForCommand(client, "lock").key)} [#FFFFFF]to lock and unlock vehicles.`);
messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press [#AAAAAA]${sdl.getKeyName(getPlayerKeyBindForCommand(client, "lock").key)} [#FFFFFF]to unlock it.`);
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
}
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
@@ -117,17 +127,25 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPedExitingVehicle(event, ped, vehicle) {
//if(ped.isType(ELEMENT_PLAYER)) {
// let client = getClientFromPlayerElement(ped);
// getPlayerData(client).pedState = AG_PEDSTATE_EXITINGVEHICLE;
//}
if(!getVehicleData(vehicle)) {
return false;
}
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = AG_PEDSTATE_EXITINGVEHICLE;
}
if(!getVehicleData(vehicle).spawnLocked) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onResourceStart(event, resource) {
logToConsole(LOG_WARN, `[Asshat.Event] ${resource.name} started!`);
@@ -137,7 +155,7 @@ function onResourceStart(event, resource) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onResourceStop(event, resource) {
logToConsole(LOG_WARN, `[Asshat.Event] ${resource.name} stopped!`);
@@ -151,89 +169,112 @@ function onResourceStop(event, resource) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerEnteredSphere(client, sphere) {
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerExitedSphere(client, sphere) {
}
// ---------------------------------------------------------------------------
// ===========================================================================
async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
if(client == null) {
return false;
}
async function onPlayerEnteredVehicle(client) {
if(client.player == null) {
return false;
}
await waitUntil(() => client.player.vehicle != null);
let vehicle = client.player.vehicle;
await waitUntil(() => client != null && client.player != null && client.player.vehicle != null);
//setTimeout(function() {
//if(client.player.vehicle == null) {
// onPlayerEnteredVehicle(client, clientVehicle, seat);
//}
if(vehicle.owner != -1) {
return false;
}
let vehicle = client.player.vehicle;
if(!getVehicleData(vehicle)) {
return false;
}
if(vehicle.syncer != client.index) {
if(getPlayerVehicleSeat(client) == AG_VEHSEAT_DRIVER) {
vehicle.setSyncer(client, true);
}
}
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
if(vehicle.owner != -1) {
return false;
}
getPlayerData(client).lastVehicle = vehicle;
if(!getVehicleData(vehicle)) {
return false;
}
if(getPlayerVehicleSeat(client) == AG_VEHSEAT_DRIVER) {
vehicle.engine = getVehicleData(vehicle).engine;
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
if(getVehicleData(vehicle).buyPrice > 0) {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for sale! Cost: [#AAAAAA]$${getVehicleData(vehicle).buyPrice}`);
messagePlayerTip(client, `Use /vehbuy if you want to buy it.`);
} else if(getVehicleData(vehicle).rentPrice > 0) {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for rent! Cost: [#AAAAAA]$${getVehicleData(vehicle).rentPrice} per minute`);
messagePlayerTip(client, `Use /vehrent if you want to rent it.`);
} else {
if(!getVehicleData(vehicle).engine) {
if(doesClientHaveVehicleKeys(client, vehicle)) {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
if(doesPlayerHaveKeyBindForCommand(client, "engine")) {
messagePlayerTip(client, `You can also press [#AAAAAA]${sdl.getKeyName(getPlayerKeyBindForCommand(client, "engine").key)} [#FFFFFF]to start and stop the engine.`);
getPlayerData(client).lastVehicle = vehicle;
if(getPlayerVehicleSeat(client) == AG_VEHSEAT_DRIVER) {
vehicle.engine = getVehicleData(vehicle).engine;
if(getVehicleData(vehicle).buyPrice > 0) {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for sale! Cost: [#AAAAAA]$${getVehicleData(vehicle).buyPrice}`);
messagePlayerTip(client, `Use /vehbuy if you want to buy it.`);
} else if(getVehicleData(vehicle).rentPrice > 0) {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for rent! Cost: [#AAAAAA]$${getVehicleData(vehicle).rentPrice} per minute`);
messagePlayerTip(client, `Use /vehrent if you want to rent it.`);
} else {
if(!getVehicleData(vehicle).engine) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
if(doesPlayerHaveKeyBindForCommand(client, "engine")) {
messagePlayerTip(client, `You can also press [#AAAAAA]${sdl.getKeyName(getPlayerKeyBindForCommand(client, "engine").key)} [#FFFFFF]to start and stop the engine.`);
}
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
}
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
//setPlayerControlState(client, false);
}
//setPlayerControlState(client, false);
}
}
let currentSubAccount = getPlayerCurrentSubAccount(client);
let currentSubAccount = getPlayerCurrentSubAccount(client);
if(isPlayerWorking(client)) {
if(getVehicleData(vehicle).ownerType == AG_VEHOWNER_JOB) {
if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
if(isPlayerWorking(client)) {
if(getVehicleData(vehicle).ownerType == AG_VEHOWNER_JOB) {
if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
}
}
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
stopReturnToJobVehicleCountdown(client);
}
}
}
}
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, radioStations[getVehicleData(vehicle).streamingRadioStation].url);
setPlayerStreamingRadioVolume(client, getPlayerData(client).streamingRadioVolume);
}
}
}
//}, client.ping+500);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerExitedVehicle(client) {
function onPlayerExitedVehicle(client, vehicle) {
getPlayerData(client).pedState = AG_PEDSTATE_READY;
let vehicle = getPlayerData(client).lastVehicle;
//let vehicle = getPlayerData(client).lastVehicle;
if(!getVehicleData(vehicle)) {
return false;
@@ -248,88 +289,178 @@ function onPlayerExitedVehicle(client) {
}
}
}
playRadioStreamForPlayer(client, "");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerDeath(client, position) {
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`);
getPlayerData(client).pedState = AG_PEDSTATE_DEAD;
updatePlayerSpawnedState(client, false);
setPlayerControlState(client, false);
setTimeout(function() {
fadePlayerCamera(client, false, 1.0);
fadeCamera(client, false, 1.0);
setTimeout(function() {
client.despawnPlayer();
if(getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestJail(position);
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
spawnPlayer(client, closestJail.position, closestJail.heading, getPlayerCurrentSubAccount(client).skin);
if(getServerGame() == GAME_GTA_IV) {
spawnPlayer(client, closestJail.position, closestJail.heading, getPlayerCurrentSubAccount(client).skin);
} else {
spawnPlayer(client, closestJail.position, closestJail.heading, getPlayerCurrentSubAccount(client).skin);
}
fadeCamera(client, true, 1.0);
updatePlayerSpawnedState(client, true);
} else {
let closestHospital = getClosestHospital(position);
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
spawnPlayer(client, closestHospital.position, closestHospital.heading, getPlayerCurrentSubAccount(client).skin);
if(getServerGame() == GAME_GTA_IV) {
spawnPlayer(client, closestHospital.position, closestHospital.heading, getPlayerCurrentSubAccount(client).skin);
} else {
spawnPlayer(client, closestHospital.position, closestHospital.heading, getPlayerCurrentSubAccount(client).skin);
}
fadeCamera(client, true, 1.0);
updatePlayerSpawnedState(client, true);
}
}, 2000);
}, 1000);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPedSpawn(ped) {
if(ped.type == ELEMENT_PLAYER) {
setTimeout(onPlayerSpawn, 500, ped);
}
//if(ped.type == ELEMENT_PLAYER) {
// setTimeout(onPlayerSpawn, 500, ped);
//}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function onPlayerSpawn(ped) {
if(getClientFromPlayerElement(ped) == null) {
setTimeout(onPlayerSpawn, 500, ped);
function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
if(client.player == null) {
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
setTimeout(onPlayerSpawn, 500, client);
return false;
}
let client = getClientFromPlayerElement(ped);
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[Asshat.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if(!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
client.disconnect();
return false;
}
if(!isPlayerSwitchingCharacter(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
if(getServerGame() == GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
setEntityData(client.player, "ag.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
setEntityData(client.player, "ag.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
}
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
setEntityData(client.player, "ag.scale", getPlayerCurrentSubAccount(client).pedScale, true);
if(isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
return false;
}
messagePlayerAlert(client, `You are now playing as: [#0099FF]${getCharacterFullName(client)}`, getColourByName("white"));
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"));
restorePlayerCamera(client, false, 1.0);
updatePlayerSpawnedState(client, true);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
updateAllPlayerNameTags();
getPlayerData(client).switchingCharacter = false;
updatePlayerCash(client);
sendPlayerJobType(client, getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client)));
setPlayer2DRendering(client, true, true, true, true, true, true);
updatePlayerSnowState(client);
updatePlayerHotBar(client);
setEntityData(client.player, "ag.scale", getPlayerCurrentSubAccount(client).pedScale, true);
//logToConsole(LOG_DEBUG, `[Asshat.Event] Setting player skin for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).skin}`);
//setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin);
sendExcludedModelsForGroundSnowToPlayer(client);
sendRemovedWorldObjectsToPlayer(client);
//if(getPlayerData(client).pedState != AG_PEDSTATE_READY) {
restorePlayerCamera(client);
setTimeout(function() {
syncPlayerProperties(client);
}, 1000);
logToConsole(LOG_DEBUG, `[Asshat.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
getPlayerData(client).ped = client.player;
if(getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
updatePlayerShowLogoState(client, true);
}
logToConsole(LOG_DEBUG, `[Asshat.Event] Sending ${getPlayerDisplayForConsole(client)} the 'now playing as' message`);
messagePlayerAlert(client, `You are now playing as: [#0099FF]${getCharacterFullName(client)}`, getColourByName("white"));
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"));
getPlayerData(client).pedState = AG_PEDSTATE_READY;
logToConsole(LOG_DEBUG, `[Asshat.Event] Updating spawned state for ${getPlayerDisplayForConsole(client)} to true`);
updatePlayerSpawnedState(client, true);
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
logToConsole(LOG_DEBUG, `[Asshat.Event] Updating all player name tags`);
updateAllPlayerNameTags();
logToConsole(LOG_DEBUG, `[Asshat.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
updatePlayerCash(client);
logToConsole(LOG_DEBUG, `[Asshat.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
logToConsole(LOG_DEBUG, `[Asshat.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
setPlayer2DRendering(client, true, true, true, true, true, true);
logToConsole(LOG_DEBUG, `[Asshat.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
updatePlayerSnowState(client);
logToConsole(LOG_DEBUG, `[Asshat.Event] Sending ground snow excluded models to ${getPlayerDisplayForConsole(client)}`);
sendExcludedModelsForGroundSnowToPlayer(client);
logToConsole(LOG_DEBUG, `[Asshat.Event] Sending removed world objects to ${getPlayerDisplayForConsole(client)}`);
sendRemovedWorldObjectsToPlayer(client);
if(getServerGame() == GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
setEntityData(client.player, "ag.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
setEntityData(client.player, "ag.fightStyle", getPlayerCurrentSubAccount(client).fightStyle, true);
}
logToConsole(LOG_DEBUG, `[Asshat.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
if(getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
updatePlayerShowLogoState(client, true);
}
logToConsole(LOG_DEBUG, `[Asshat.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
cachePlayerHotBarItems(client);
logToConsole(LOG_DEBUG, `[Asshat.Event] Syncing ${getPlayerDisplayForConsole(client)}'s hotbar`);
updatePlayerHotBar(client);
logToConsole(LOG_DEBUG, `[Asshat.Event] Sending custom keybinds to ${getPlayerDisplayForConsole(client)}`);
sendAccountKeyBindsToClient(client);
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
getPlayerData(client).switchingCharacter = false;
getPlayerData(client).inBusiness = (getPlayerCurrentSubAccount(client).inBusiness != 0) ? getBusinessIdFromDatabaseId(getPlayerCurrentSubAccount(client).inBusiness) : -1;
getPlayerData(client).inHouse = (getPlayerCurrentSubAccount(client).inHouse != 0) ? getHouseIdFromDatabaseId(getPlayerCurrentSubAccount(client).inHouse) : -1;
logToConsole(LOG_DEBUG, `[Asshat.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
getPlayerData(client).pedState = AG_PEDSTATE_READY;
setTimeout(function() {
syncPlayerProperties(client);
}, 1000);
getPlayerData(client).payDayTickStart = sdl.ticks;
//}
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: fishing.js
// DESC: Provides fishing functions and commands
// TYPE: Server (JavaScript)
@@ -37,7 +37,7 @@ let fishingLocations = [
],
];
// ---------------------------------------------------------------------------
// ===========================================================================
let fishingCatchables = [
// Fish
@@ -65,4 +65,11 @@ let fishingCatchables = [
["Soggy Dildo", 0, 0, 0, 0],
];
// ---------------------------------------------------------------------------
// ===========================================================================
function initFishingScript() {
logToConsole(LOG_INFO, "[Asshat.Fishing]: Initializing fishing script ...");
logToConsole(LOG_INFO, "[Asshat.Fishing]: Fishing script initialized successfully!");
}
// ===========================================================================

View File

@@ -1,8 +1,8 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: game-data.js
// DESC: Provides coords, ids, names, and other data for the games
// TYPE: Shared (JavaScript)
@@ -1578,18 +1578,19 @@ let gameData = {
"Carl 'CJ' Johnson",
"The Truth",
"Maccer",
"Andre",
"Barry 'Big Bear' Thorne",
"Emmet",
"INVALID",
"INVALID",
"INVALID",
"Taxi Driver/Train Driver",
"Janitor",
"Unknown",
"Normal Ped",
"Old Woman",
"Casino Croupier",
"Rich Woman",
"Street Girl",
"Normal Ped",
"Mr.Whittaker (Rs Haul Owner)",
"Mr.Whittaker (RS Haul Owner)",
"Airport Ground Worker",
"Businessman",
"Beach Visitor",
@@ -1616,7 +1617,7 @@ let gameData = {
"Normal Ped",
"Normal Ped",
"Normal Ped",
"Jethro",
"INVALID",
"Normal Ped",
"Normal Ped",
"Beach Visitor",
@@ -1639,7 +1640,7 @@ let gameData = {
"Colonel Fuhrberger",
"Prostitute",
"Prostitute",
"Kendl Johnson",
"INVALID",
"Pool Player",
"Pool Player",
"Priest/Preacher",
@@ -1648,6 +1649,7 @@ let gameData = {
"Security Guard",
"Hippy",
"Hippy",
"INVALID",
"Prostitute",
"Stewardess",
"Homeless",
@@ -1659,7 +1661,7 @@ let gameData = {
"White Elvis",
"Blue Elvis",
"Prostitute",
"Ryder With Robbery Mask",
"INVALID",
"Stripper",
"Normal Ped",
"Normal Ped",
@@ -1675,32 +1677,32 @@ let gameData = {
"Rollerskater",
"Biker",
"Normal Ped",
"Balla",
"Balla",
"Balla",
"Grove Street Families",
"Grove Street Families",
"Grove Street Families",
"Los Santos Vagos",
"Los Santos Vagos",
"Los Santos Vagos",
"The Russian Mafia",
"The Russian Mafia",
"The Russian Mafia",
"Varios Los Aztecas",
"Varios Los Aztecas",
"Varios Los Aztecas",
"Ballas Gang Member",
"Ballas Gang Member",
"Ballas Gang Member",
"Grove Street Families Gang Member",
"Grove Street Families Gang Member",
"Grove Street Families Gang Member",
"Los Santos Vagos Gang Member",
"Los Santos Vagos Gang Member",
"Los Santos Vagos Gang Member",
"Russian Mafioso",
"Russian Mafioso",
"Russian Mafioso",
"Varios Los Aztecas Gang Member",
"Varios Los Aztecas Gang Member",
"Varios Los Aztecas Gang Member",
"Triad",
"Triad",
"Johhny Sindacco",
"INVALID",
"Triad Boss",
"Da Nang Boy",
"Da Nang Boy",
"Da Nang Boy",
"The Mafia",
"The Mafia",
"The Mafia",
"The Mafia",
"Italian Mafioso",
"Italian Mafioso",
"Italian Mafioso",
"Italian Mafioso",
"Farm Inhabitant",
"Farm Inhabitant",
"Farm Inhabitant",
@@ -1722,7 +1724,7 @@ let gameData = {
"Crack Maker",
"Businessman",
"Businesswoman",
"Big Smoke Armored",
"INVALID",
"Businesswoman",
"Normal Ped",
"Prostitute",
@@ -1781,7 +1783,7 @@ let gameData = {
"Burger Shot Cashier",
"Cab Driver",
"Prostitute",
"Su Xi Mu (Suzie)",
"INVALID",
"Oriental Noodle Stand Vendor",
"Oriental Boating School Instructor",
"Clothes Shop Staff",
@@ -1846,7 +1848,7 @@ let gameData = {
"Sean 'Sweet' Johnson",
"Lance 'Ryder' Wilson",
"Mafia Boss",
"T-Bone Mendez",
"INVALID",
"Paramedic",
"Paramedic",
"Paramedic",
@@ -1862,7 +1864,7 @@ let gameData = {
"Federal Agent",
"Army Soldier",
"Desert Sheriff",
"Zero",
"INVALID",
"Ken Rosenberg",
"Kent Paul",
"Cesar Vialpando",
@@ -1872,7 +1874,23 @@ let gameData = {
"Jizzy B.",
"Madd Dogg",
"Catalina",
"Claude Speed"
"Claude Speed",
// 300
"Lance 'Ryder' Wilson 2",
"Lance 'Ryder' Wilson (robbery mask)",
"Emmet",
"Andre",
"Denise",
"Jethro",
"Zero",
"T-Bone Mendez",
"Johnny Sindacco",
"Janitor",
"Barry 'Big Bear' Thorne (Skinny)",
"Melvin 'Big Smoke' Harris (Vest)",
"Psycho",
"Barry 'Big Bear' Thorne (Fat)",
],
],
weaponModels: [
@@ -2125,115 +2143,7 @@ let gameData = {
// More will be added soon!
],
[ // GTA EFLC
// Police Stations
["Broker Police Station", [894.99, -357.39, 18.185], 2.923],
["South Bohan Police Station", [435.40, 1592.29, 17.353], 3.087],
["Northern Gardens Police Station", [974.93, 1870.45, 23.073], -1.621],
["South Slopes Police Station", [1233.25, -89.13, 28.034], 1.568],
["Middle Part East Police Station", [50.12, 679.88, 15.316], 1.569],
["East Holland Police Station", [85.21, 1189.82, 14.755], 3.127],
["Francis International Airport Police Station", [2170.87, 448.87, 6.085], 1.501],
["Chinatown Police Station", [213.12, -211.70, 10.752], 0.200],
["Acter Police Station", [-1714.95, 276.31, 22.134], 1.127],
["Port Tudor Police Station", [-1220.73, -231.53, 3.024], 2.210],
["Leftwood Police Station", [-927.66, 1263.63, 24.587], -0.913],
// Fire Stations
["Broker Fire Station", [953.13, 95.90, 35.004], 1.595],
["Northwood Fire Station", [-271.02, 1542.15, 20.420], -1.160],
["Northern Gardens Fire Station", [1120.47, 1712.36, 10.534], -0.682],
["Francis International Airport FIre Station", [2364.87, 166.83, 5.813], 0.156],
["Chinatown Fire Station", [295.40, -336.88, 4.963], 2.887],
["Berchem Fire Station", [-1574.90, 546.54, 25.449], -0.509],
["Tudor Fire Station", [-2144.97, 164.15, 12.051], -2.149],
// Safehouses
["Hove Beach Safehouse Parking", [904.27, -498.00, 14.522], 3.127],
["South Bohan Safehouse", [589.42, 1402.15, 10.364], 0.007],
// Hospitals
["Schottler Medical Center", [1199.59, 196.78, 33.554], 1.633],
["Northern Gardens Medical Center", [980.71, 1831.61, 23.898], -0.049],
["Leftwood Hospital", [-1317.27, 1277.20, 22.370], 2.246],
["Acter Medical Center", [-1538.43, 344.58, 20.943], -0.156],
// Fuel Stations
["Hove Beach Fuel Station", [1128.51, -359.55, 18.441], -0.052],
["Lancaster Fuel Station", [108.37, 1135.13, 13.975], 0.007],
["The Meat Quarter Fuel Station", [-434.30, -19.47, 9.864], 1.469],
["Cerveza Heights Fuel Station", [1123.50, 328.84, 29.245], -0.154],
["Tudor Fuel Station", [-1389.91, 29.19, 6.875], 0.982],
// Restaurants
["Star Junction Burger Shot", [-174.00, 276.96, 14.818], -0.029],
["South Bohan Burger Shot", [441.95, 1516.64, 16.289], -2.682],
["Industrial Burger Shot", [1096.93, 1598.33, 16.721], -2.289],
// Night Clubs/Strip Clubs/Bars
["Perestroika Club", [957.58, -292.58, 19.644], -0.009],
["Triangle Club", [1210.90, 1718.18, 16.667], 1.819],
// TW@ Cafes
["Outlook Internet Cafe", [977.42, -169.11, 24.013], 1.844],
["Berchem Internet Cafe", [-1584.46, 466.05, 25.398], -2.441],
// Pay-n-Sprays
["Hove Beach Pay-n-Spray", [1058.57, -282.58, 20.760], -3.135],
["Leftwood Pay-n-Spray", [-1148.69, 1171.52, 16.457], -0.059],
// Clothes Shops
["Hove Beach Russian Clothes Shop", [896.31, -442.59, 15.888], 1.500],
// Car Wash
["Willis Car Wash", [1831.02, 360.20, 22.061], -1.515],
["Tudor Car Wash", [-1371.68, 35.13, 7.028], 1.029],
// Gun Shops
["Downtown Broker Gun Shop", [1054.11, 86.84, 33.408], -1.574],
["Chinatown Gun Shop", [65.43, -342.36, 14.767], -1.589],
["Port Tudor Gun Shop", [-1338.77, 307.61, 13.378], -1.530],
// Train Stations
["Hove Beach Train Station", [1000.41, -544.82, 14.854], -1.576],
["Schottler Train Station", [1303.93, -37.75, 28.377], 3.065],
["Cerveza Heights Train Station", [1386.87, 374.13, 23.063], 3.111],
["Lynch Street Train Station", [1594.73, 364.80, 25.226], -0.965],
["East Park Train Station", [-35.78, 634.79, 14.663], -0.050],
["West Park Train Station", [-377.13, 677.05, 14.679], -0.069],
["North Park Train Station", [-135.08, 1153.95, 14.773], -1.567],
["Vespucci Circus Train Station", [-85.11, 1427.04, 20.421], 1.501],
["Frankfort Low Train Station", [-331.94, 1427.05, 12.617], 1.541],
["Frankfort High Train Station", [-343.79, 1433.12, 12.283], 0.113],
["Vauxite Train Station", [-483.38, 1333.91, 17.481], 1.509],
["Quartz Street West Train Station", [-545.54, 926.22, 9.945], -1.524],
["Manganese West Train Station", [-461.60, 530.56, 9.857], 3.091],
["Frankfort Ave Train Station", [-377.52, 371.91, 14.762], -3.125],
["Suffolk Train Station", [-252.77, -171.83, 14.447], 1.594],
["Feldspar Train Station", [-350.62, -335.35, 4.909], -2.287],
["City Hall Train Station", [-115.31, -501.22, 14.755], -1.365],
["Castle Gardens Train Station", [82.95, -757.81, 4.965], -1.006],
["Emerald Train Station", [116.57, -318.15, 14.768], 1.499],
["Easton Train Station", [-35.76, -18.50, 14.769], 3.137],
["Manganese East Train Station", [131.46, 522.74, 14.661], 0.005],
["Quartz Street East Train Station", [134.35, 910.15, 14.717], -0.112],
["San Quentin Ave Train Station", [373.12, 1625.93, 16.347], -2.249],
["Windmill Street Train Station", [749.97, 1447.44, 14.252], -0.120],
["Francis International Airport Train Station", [2297.57, 474.62, 6.086], 0.066],
// Misc
["Hove Beach Laundromat", [1011.74, -325.33, 20.339], -1.402],
["The Exchange Docks", [-354.68, -661.62, 4.791], 2.066],
["Firefly Island Bowling", [1198.99, -681.49, 16.445], -0.017],
["Broker Bus Depot", [1004.15, 279.19, 31.512], -2.193],
["The Lost MC Clubhouse", [-1713.29, 358.25, 25.449], 2.566],
["Alderney State Correctional Facility", [-1155.21, -374.34, 2.885], -1.680],
["Chinatown Bank of Liberty", [-34.92, -466.80, 14.75], -1.52],
["Suffolk Church", [-274.30, -281.63, 14.36], 1.56],
// More will be added soon!
],
[],
],
gtaivSkinModels: [
//["Nico Bellic", 1862763509],
@@ -2823,12 +2733,151 @@ let gameData = {
]
],
fightStyles: [
false,
[ // GTA III
],
[ // GTA VC
],
[ // GTA SA
["Default", [4, 6]],
["Boxing", [5, 6]],
["Kung Fu", [6, 6]],
["Kick Boxing", [7, 6]],
["Unnamed", [8, 6]],
],
[ // GTA UG
],
[ // GTA IV
]
],
walkStyles: [
false,
[ // GTA III
"Man",
"Ped",
"Player",
"Rocket",
"One Handed Weapon",
"Two Handed Weapon",
"Baseball Bat",
"Shuffle",
"Old Man",
"Gang 1",
"Gang 2",
"Fat Man",
"Old Fat Man",
"Woman",
"Shopping",
"Busy Woman",
"Sexy Woman",
"Old Woman",
"Fat Woman",
"Panic Chunky",
"Player Back",
"Player Left",
"Player Right",
"Rocket Back",
"Rocket Left",
"Rocket Right",
],
[ // GTA VC
],
[ // GTA SA
],
[ // GTA UG
],
[ // GTA IV
]
],
policeStations: [
[],
[ // GTA III
[1143.875, -675.1875, 14.97], // Portland
[340.25, -1123.375, 25.98], // Staunton Island
[-1253.0, -138.1875, 58.75], // Shoreside Vale
],
[ // GTA Vice City
[399.77, -468.90, 11.73], // Washington Beach
[508.96, 512.07, 12.10], // Vice Point
[-657.43, 762.31, 11.59], // Downtown
[-885.08, -470.44, 13.11], // Little Havana
],
],
fireStations: [
[],
[ // GTA III
[1103.70, -52.45, 7.49], // Portland
[-78.48, -436.80, 16.17], // Staunton Island
[-1202.10, -14.67, 53.20], // Shoreside Vale
],
[ // GTA Vice City
[-695.15, 912.58, 11.08], // Downtown
],
],
hospitals: [
[],
[ // GTA III
],
[ // GTA Vice City
[-822.57, 1152.82, 12.41], // Downtown (Shuman Health Care Center)
[-885.08, -470.44, 13.11], // Little Havana (West Haven Community Health Care Center)
[-133.19, -980.76, 10.46], // Ocean Beach (Ocean View Hospital)
],
],
payAndSprays: [
[],
[ // GTA III
[925.4, -360.3, 10.83], // Portland
[-1142.4, 35.01, 58.61], // Shoreside Vale
],
[ // GTA Vice City
[-869.95, -119.06, 10.63], // Little Haiti
[-910.82, -1265.96, 11.79], // Viceport
],
],
ammuNations: [
[],
[ // GTA III
[1068.3, -400.9, 15.24], // Portland
[348.2, -717.9, 26.43], // Staunton Island
],
[ // GTA Vice City
[-676.32, 1204.98, 11.10], // Downtown
],
],
};
// ---------------------------------------------------------------------------
// ===========================================================================
function getGameData() {
return gameData;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getAllowedSkinDataBySkinId(skinId) {
for(let i in allowedSkins[getGame()]) {
if(allowedSkins[getGame()][i][0] == skinId) {
return i;
}
}
return 0;
}
// ===========================================================================

View File

@@ -2,67 +2,121 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: gui.js
// DESC: Provides GUI functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
function showPlayerPromptGUI(client) {
function initGUIScript() {
logToConsole(LOG_INFO, "[Asshat.GUI]: Initializing GUI script ...");
logToConsole(LOG_INFO, "[Asshat.GUI]: GUI script initialized successfully!");
}
// ---------------------------------------------------------------------------
function showPlayerPhoneGUI(client) {
}
// ---------------------------------------------------------------------------
function showPlayerItemInventoryGUI(client) {
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerPromptAnswerNo(client) {
if(!getEntityData(client, "ag.prompt")) {
if(getPlayerData(client).promptType == AG_PROMPT_NONE) {
return false;
}
switch(getEntityData(client, "ag.prompt")) {
logToConsole(LOG_DEBUG, `[Asshat.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
switch(getPlayerData(client).promptType) {
case AG_PROMPT_CREATEFIRSTCHAR:
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters")
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");
setTimeout(function() { client.disconnect(); }, 5000);
break;
case AG_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(canPlayerUseGUI(client)) {
showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled");
} else {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} canceled the order of ${getPlayerData(client).businessOrderAmount} ${getPlayerData(client).businessOrderItem} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness)}`);
messagePlayerError(client, "You canceled the order!");
}
} else {
showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled");
}
break;
default:
break;
}
client.removeData("ag.prompt");
getPlayerData(client).promptType = AG_PROMPT_NONE;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerPromptAnswerYes(client) {
if(!getEntityData(client, "ag.prompt")) {
if(getPlayerData(client).promptType == AG_PROMPT_NONE) {
return false;
}
switch(getEntityData(client, "ag.prompt")) {
logToConsole(LOG_DEBUG, `[Asshat.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
switch(getPlayerData(client).promptType) {
case AG_PROMPT_CREATEFIRSTCHAR:
//getPlayerData(client).creatingCharacter = true;
//spawnPlayer(client, getServerConfig().characterSelectPedPosition, getServerConfig().characterSelectPedHeading, allowedSkins[getServerGame()][0][0], getServerConfig().characterSelectInterior, getServerConfig().characterSelectDimension);
//showCharacterSelectCameraToPlayer(client);
//setTimeout(function() {
// forcePlayerIntoSkinSelect(client);
//}, 750);
showPlayerNewCharacterGUI(client);
break;
case AG_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
logToConsole(LOG_DEBUG, `[Asshat.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)`);
showPlayerErrorGUI(client, "This business doesn't have enough money! Deposit some using /bizdeposit", "Business Order Canceled");
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
} else {
logToConsole(LOG_DEBUG, `[Asshat.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");
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, AG_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount);
cacheBusinessItems(getPlayerData(client).businessOrderBusiness);
getBusinessData(getPlayerData(client).businessOrderBusiness).till -= getPlayerData(client).businessOrderCost;
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
}
} else {
showPlayerErrorGUI(client, `You aren't ordering anything for a business!`, `Business Order Canceled`);
}
break;
default:
break;
}
client.removeData("ag.prompt");
getPlayerData(client).promptType = AG_PROMPT_NONE;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function canPlayerUseGUI(client) {
return (getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client));
}
// ===========================================================================
function playerPromptAnswerYesCommand(command, params, client) {
playerPromptAnswerYes(client);
}
// ===========================================================================
function playerPromptAnswerNoCommand(command, params, client) {
playerPromptAnswerNo(client);
}
// ===========================================================================

View File

@@ -2,16 +2,21 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: help.js
// DESC: Provides update info, help commands, and documentation
// TYPE: Server (JavaScript)
// ===========================================================================
// -------------------------------------------------------------------------
function initHelpScript() {
logToConsole(LOG_INFO, "[Asshat.Help]: Initializing help script ...");
logToConsole(LOG_INFO, "[Asshat.Help]: Help script initialized successfully!");
}
// ===========================================================================
let randomTips = [
`[#FFFFFF]Press [#0066FF]E [#FFFFFF]near a taxi if you need a ride.`,
`[#FFFFFF]Hold [#0066FF]E [#FFFFFF]to hail a nearby taxi if you need a ride.`,
`[#FFFFFF]Press [#0066FF]G [#FFFFFF]to enter a vehicle as passenger.`,
`[#FFFFFF]Banks can provide loans. Use [#AAAAAA]/help loans [#FFFFFF] for more details.`,
`[#FFFFFF]Want to make a clan? Use [#AAAAAA]/help clans [#FFFFFF] for details.`,
@@ -24,9 +29,12 @@ let randomTips = [
`[#FFFFFF]You can find most locations by using [#AAAAAA]/gps`,
`[#FFFFFF]Use /notips if you don't want to see tips and extra information`,
`[#FFFFFF]Want to advertise your business? Visit the news station and place an /ad today!`,
`[#FFFFFF]You can edit your keybinds using [#AAAAAA]/keybind`,
`[#FFFFFF]You can change your quick item display. Choices are GTAV-style pie menu or Minecraft-style hotbar`,
`[#FFFFFF]Press I to see your inventory, and use number keys to select an item`,
];
// -------------------------------------------------------------------------
// ===========================================================================
function helpCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -47,6 +55,10 @@ function helpCommand(command, params, client) {
showVehicleDealershipHelpMessage(client);
break;
case "business":
showBusinessHelpMessage(client);
break;
case "job":
showJobHelpMessage(client);
break;
@@ -111,8 +123,9 @@ function helpCommand(command, params, client) {
// == Vehicle Tuneup ===========================
// == Bindable Keys ============================
// == Clothes ==================================
// == Business =================================
// -------------------------------------------------------------------------
// ===========================================================================
function showMainHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Help [#FF9900]=================================");
@@ -121,7 +134,7 @@ function showMainHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#A9A9A9]ammunation, skins, mechanic, dealership, discord, colours, keys");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showAccountHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Account Help [#FF9900]=============================");
@@ -130,7 +143,7 @@ function showAccountHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some settings you can use: [#AAAAAA]/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showVehicleHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Help [#FF9900]=============================");
@@ -141,7 +154,7 @@ function showVehicleHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Don't forget to register and insure your vehicle! Use [#AAAAAA]/gps [#FFFFFF]to find a DMV for this.");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showVehicleDealershipHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Dealerships [#FF9900]======================");
@@ -151,7 +164,7 @@ function showVehicleDealershipHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]A new car for sale will appear when you drive away from the dealer.");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showJobHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Job Help [#FF9900]=================================");
@@ -162,7 +175,7 @@ function showJobHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]When entering a job vehicle, information on how to do the job will be shown to you.");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showChatHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Chat Help [#FF9900]================================");
@@ -172,7 +185,7 @@ function showChatHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some have shorter names available ([#AAAAAA]/t [#FFFFFF]for talk, [#AAAAAA]/s [#FFFFFF]for shout, etc)");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showRulesHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Server Rules [#FF9900]=============================");
@@ -183,28 +196,28 @@ function showRulesHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Keep English in main chats. If you aren't good at English, use [#AAAAAA]/help language");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showWebsiteHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Website [#FF9900]=============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]The website is [#AAAAAA]https://asshatgaming.com");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showDiscordHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Discord [#FF9900]=============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Join our discord! [#AAAAAA]https://discord.gg/4TQ3TGB529");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showAnimationHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Animations [#FF9900]===============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Animations are not yet available.");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showAmmunationHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Ammunation [#FF9900]===============================");
@@ -214,7 +227,7 @@ function showAmmunationHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Weapons can also be purchased illegally from weapon dealers and clans.");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showClothesHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Clothes [#FF9900]==================================");
@@ -223,16 +236,28 @@ function showClothesHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some skins are restricted to jobs, clans, or for other reasons.");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showBindKeysHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Bindable Keys [#FF9900]============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]You can set your own keys binds. Use [#AAAAAA]/keybinds [#FFFFFF]to add, remove, or change your keys.");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Default keys are: [#0066FF]K [#FFFFFF]for engine, [#0066FF]I [#FFFFFF]for lights, and [#0066FF]L [#FFFFFF]for lock/unlock");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Default keys are: [#0066FF]K [#FFFFFF]for vehicle engine, [#0066FF]I [#FFFFFF]for lights, and [#0066FF]L [#FFFFFF]for lock/unlock");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF][#0066FF]I [#FFFFFF]to see your items and [#0066FF]1-9 [#FFFFFF]to equip an item or [#0066FF]0 (zero) [#FFFFFF]to equip none.");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF][#0066FF]U [#FFFFFF]to use or [#0066FF]O [#FFFFFF]to drop your current item, and [#0066FF]P [#FFFFFF]to pickup an item from the ground.");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Your keybinds will automatically be usable on all servers");
}
// -------------------------------------------------------------------------
// ===========================================================================
function showBusinessHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Business [#FF9900]=================================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Use /buy to purchase items or /bizitems to see a list of what's for sale at any business");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Businesses are shown with blue names above the icon at their entrance.");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Business owner commands: [#AAAAAA]/bizorder, /biz");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]A new car for sale will appear when you drive away from the dealer.");
}
// ===========================================================================
function showEnteredDriverSeatHasKeysHelpTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.enteredDriverSeat) {
@@ -241,7 +266,7 @@ function showEnteredDriverSeatHasKeysHelpTip(client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function showApproachJobWhileUnemployedTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachJobWhileUnemployed) {
@@ -250,7 +275,7 @@ function showApproachJobWhileUnemployedTip(client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function showTakeNearbyJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.takeJobWhileUnemployed) {
@@ -259,7 +284,7 @@ function showTakeNearbyJobTip(client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function showApproachCurrentJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachCurrentJob) {
@@ -269,7 +294,7 @@ function showApproachCurrentJobTip(client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function showApproachOtherJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachCurrentJob) {
@@ -279,7 +304,7 @@ function showApproachOtherJobTip(client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function showStartedWorkingTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.startedWorking) {
@@ -289,7 +314,7 @@ function showStartedWorkingTip(client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function showApproachOwnedVehicleTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachOwnedVehicle) {
@@ -298,7 +323,7 @@ function showApproachOwnedVehicleTip(client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================
function showApproachClanVehicleTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachAnyVehicle) {
@@ -307,4 +332,4 @@ function showApproachClanVehicleTip(client) {
}
}
// -------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,26 +2,33 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: house.js
// DESC: Provides house commands, functions, and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initHouseScript() {
logToConsole(LOG_DEBUG, "[Asshat.House]: Initializing house script ...");
logToConsole(LOG_INFO, "[Asshat.House]: Initializing house script ...");
getServerData().houses = loadHousesFromDatabase();
createAllHousePickups();
createAllHouseBlips();
if(getServerConfig().createHousePickups) {
createAllHousePickups();
}
if(getServerConfig().createHousePickups) {
createAllHouseBlips();
}
setAllHouseIndexes();
logToConsole(LOG_DEBUG, "[Asshat.House]: House script initialized successfully!");
logToConsole(LOG_INFO, "[Asshat.House]: House script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadHousesFromDatabase() {
logToConsole(LOG_DEBUG, "[Asshat.House]: Loading houses from database ...");
logToConsole(LOG_INFO, "[Asshat.House]: Loading houses from database ...");
let tempHouses = [];
let dbConnection = connectToDatabase();
let dbAssoc;
@@ -33,18 +40,18 @@ function loadHousesFromDatabase() {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempHouseData = new serverClasses.houseData(dbAssoc);
tempHouses.push(tempHouseData);
logToConsole(LOG_DEBUG, `[Asshat.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
logToConsole(LOG_VERBOSE, `[Asshat.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
}
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_DEBUG, `[Asshat.House]: ${tempHouses.length} houses loaded from database successfully!`);
logToConsole(LOG_INFO, `[Asshat.House]: ${tempHouses.length} houses loaded from database successfully!`);
return tempHouses;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createHouseCommand(command, params, client) {
let tempHouseData = createHouse(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getServerGame()].house, getGameConfig().blipSprites[getServerGame()].house, getPlayerInterior(client), getPlayerDimension(client));
@@ -58,7 +65,7 @@ function createHouseCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]created house [#11CC11]${tempHouseData.description}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function lockUnlockHouseCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
@@ -73,7 +80,7 @@ function lockUnlockHouseCommand(command, params, client) {
messagePlayerSuccess(client, `House '${getHouseData(houseId).description}' ${getLockedUnlockedTextFromBool((getHouseData(houseId).locked))}!`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setHouseDescriptionCommand(command, params, client) {
let newHouseDescription = toString(params);
@@ -91,7 +98,7 @@ function setHouseDescriptionCommand(command, params, client) {
messageAdmins(`${client.name} renamed house [#11CC11]${oldDescription} [#FFFFFF]to [#11CC11]${getHouseData(houseId).description}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setHouseOwnerCommand(command, params, client) {
let newHouseOwner = getPlayerFromParams(params);
@@ -112,7 +119,7 @@ function setHouseOwnerCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]owner to [#AAAAAA]${newHouseOwner.name}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setHouseClanCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
@@ -134,7 +141,7 @@ function setHouseClanCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]owner to the [#FF9900]${getClanData(clanId).name} [#FFFFFF]clan!`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setHousePickupCommand(command, params, client) {
let typeParam = params || "house";
@@ -159,7 +166,7 @@ function setHousePickupCommand(command, params, client) {
if(getHouseData(houseId).entrancePickupModel != -1) {
if(getHouseData(houseId).entrancePickup != null) {
destroyElement(getHouseData(houseId).entrancePickup);
deleteGameElement(getHouseData(houseId).entrancePickup);
}
createHouseEntrancePickup(houseId);
@@ -168,7 +175,7 @@ function setHousePickupCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]pickup display to [#AAAAAA]${toLowerCase(typeParam)}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setHouseInteriorTypeCommand(command, params, client) {
let splitParams = params.split(" ");
@@ -176,7 +183,7 @@ function setHouseInteriorTypeCommand(command, params, client) {
let houseId = getHouseFromParams(splitParams[1]) || (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
if(!getHouseData(houseId)) {
messagePlayerError(client, "Business not found!");
messagePlayerError(client, "House not found!");
return false;
}
@@ -218,7 +225,7 @@ function setHouseInteriorTypeCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]interior type to [#AAAAAA]${toLowerCase(typeParam)}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setHouseBlipCommand(command, params, client) {
let typeParam = params || "house";
@@ -243,7 +250,7 @@ function setHouseBlipCommand(command, params, client) {
if(getHouseData(houseId).entranceBlipModel != -1) {
if(getHouseData(houseId).entranceBlip != null) {
destroyElement(getHouseData(houseId).entranceBlip);
deleteGameElement(getHouseData(houseId).entranceBlip);
}
createHouseEntranceBlip(houseId);
@@ -252,7 +259,7 @@ function setHouseBlipCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]blip display to [#AAAAAA]${toLowerCase(typeParam)}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function moveHouseEntranceCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
@@ -275,7 +282,7 @@ function moveHouseEntranceCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]moved house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]entrance to their position`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function moveHouseExitCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
@@ -298,7 +305,7 @@ function moveHouseExitCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]moved house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]exit to their position`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteHouseCommand(command, params, client) {
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
@@ -313,7 +320,7 @@ function deleteHouseCommand(command, params, client) {
deleteHouse(houseId, getPlayerData(client).accountData.databaseId);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteHouse(houseId, whoDeleted = 0) {
let tempHouseData = getServerData().houses[houseId];
@@ -340,7 +347,7 @@ function deleteHouse(houseId, whoDeleted = 0) {
getServerData().houses.splice(houseId, 1);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removePlayerFromHouses(client) {
if(isPlayerInAnyHouse(client)) {
@@ -348,7 +355,7 @@ function removePlayerFromHouses(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createHouse(description, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInteriorId = 0, entranceVirtualWorld = 0, exitInteriorId = -1, exitVirtualWorld = -1, exitPickupModel = -1, exitBlipModel = -1) {
let tempHouseData = new serverClasses.houseData(false);
@@ -371,7 +378,7 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup
return tempHouseData;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getHouseDataFromDatabaseId(databaseId) {
let matchingHouses = getServerData().houses.filter(b => b.databaseId == databaseId)
@@ -381,7 +388,7 @@ function getHouseDataFromDatabaseId(databaseId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getClosestHouseEntrance(position) {
let houses = getServerData().houses;
@@ -394,7 +401,7 @@ function getClosestHouseEntrance(position) {
return closest;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerHouse(client) {
if(doesEntityDataExist(client, "ag.inHouse")) {
@@ -404,40 +411,71 @@ function getPlayerHouse(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveAllHousesToDatabase() {
logToConsole(LOG_INFO, `[Asshat.House]: Saving all server houses to database ...`);
for(let i in getServerData().houses) {
saveHouseToDatabase(i);
}
logToConsole(LOG_INFO, `[Asshat.House]: Saving all server houses to database ...`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveHouseToDatabase(houseId) {
let tempHouseData = getServerData().houses[houseId];
logToConsole(LOG_DEBUG, `[Asshat.House]: Saving house '${tempHouseData.databaseId}' to database ...`);
logToConsole(LOG_VERBOSE, `[Asshat.House]: Saving house '${tempHouseData.databaseId}' to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
if(tempHouseData.databaseId == 0) {
let dbQueryString = `INSERT INTO house_main (house_server, house_description, house_owner_type, house_owner_id, house_locked, house_entrance_pos_x, house_entrance_pos_y, house_entrance_pos_z, house_entrance_rot_z, house_entrance_int, house_entrance_vw, house_exit_pos_x, house_exit_pos_y, house_exit_pos_z, house_exit_rot_z, house_exit_int, house_exit_vw, house_has_interior) VALUES (${getServerId()}, '${safeHouseDescription}', ${tempHouseData.ownerType}, ${tempHouseData.ownerId}, ${boolToInt(tempHouseData.locked)}, ${tempHouseData.entrancePosition.x}, ${tempHouseData.entrancePosition.y}, ${tempHouseData.entrancePosition.z}, ${tempHouseData.entranceRotation}, ${tempHouseData.entranceInterior}, ${tempHouseData.entranceDimension}, ${tempHouseData.exitPosition.x}, ${tempHouseData.exitPosition.y}, ${tempHouseData.exitPosition.z}, ${tempHouseData.exitRotation}, ${tempHouseData.exitInterior}, ${tempHouseData.exitDimension}, ${boolToInt(tempHouseData.hasInterior)})`;
queryDatabase(dbConnection, dbQueryString);
getServerData().houses[houseId].databaseId = getDatabaseInsertId(dbConnection);
} else {
let dbQueryString = `UPDATE house_main SET house_description='${safeHouseDescription}', house_owner_type=${tempHouseData.ownerType}, house_owner_id=${tempHouseData.ownerId}, house_locked=${boolToInt(tempHouseData.locked)}, house_entrance_pos_x=${tempHouseData.entrancePosition.x}, house_entrance_pos_y=${tempHouseData.entrancePosition.y}, house_entrance_pos_z=${tempHouseData.entrancePosition.z}, house_entrance_rot_z=${tempHouseData.entranceRotation}, house_entrance_int=${tempHouseData.entranceInterior}, house_entrance_vw=${tempHouseData.entranceDimension}, house_exit_pos_x=${tempHouseData.exitPosition.x}, house_exit_pos_y=${tempHouseData.exitPosition.y}, house_exit_pos_z=${tempHouseData.exitPosition.z}, house_exit_rot_z=${tempHouseData.exitRotation}, house_exit_int=${tempHouseData.exitInterior}, house_exit_vw=${tempHouseData.exitDimension}, house_has_interior=${boolToInt(tempHouseData.hasInterior)} WHERE house_id=${tempHouseData.databaseId}`;
queryDatabase(dbConnection, dbQueryString);
let dbQueryString =
`UPDATE house_main SET
house_description='${safeHouseDescription}',
house_owner_type=${tempHouseData.ownerType},
house_owner_id=${tempHouseData.ownerId},
house_locked=${boolToInt(tempHouseData.locked)},
house_entrance_pos_x=${tempHouseData.entrancePosition.x},
house_entrance_pos_y=${tempHouseData.entrancePosition.y},
house_entrance_pos_z=${tempHouseData.entrancePosition.z},
house_entrance_rot_z=${tempHouseData.entranceRotation},
house_entrance_int=${tempHouseData.entranceInterior},
house_entrance_vw=${tempHouseData.entranceDimension},
house_exit_pos_x=${tempHouseData.exitPosition.x},
house_exit_pos_y=${tempHouseData.exitPosition.y},
house_exit_pos_z=${tempHouseData.exitPosition.z},
house_exit_rot_z=${tempHouseData.exitRotation},
house_exit_int=${tempHouseData.exitInterior},
house_exit_vw=${tempHouseData.exitDimension},
house_buy_price=${tempHouseData.buyPrice},
house_rent_price=${tempHouseData.rentPrice},
house_has_interior=${boolToInt(tempHouseData.hasInterior)}
WHERE house_id=${tempHouseData.databaseId}`;
//dbQueryString = dbQueryString.trim();
dbQueryString = dbQueryString.replace(/(?:\r\n|\r|\n|\t)/g, "");
let dbQuery = queryDatabase(dbConnection, dbQueryString);
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
}
disconnectFromDatabase(dbConnection);
return true;
}
logToConsole(LOG_DEBUG, `[Asshat.house]: Saved house '${tempHouseData.description}' to database!`);
logToConsole(LOG_VERBOSE, `[Asshat.House]: Saved house '${tempHouseData.description}' to database!`);
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createAllHousePickups() {
for(let i in getServerData().houses) {
@@ -446,7 +484,7 @@ function createAllHousePickups() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createAllHouseBlips() {
for(let i in getServerData().houses) {
@@ -455,7 +493,7 @@ function createAllHouseBlips() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createHouseEntrancePickup(houseId) {
if(getHouseData(houseId).entrancePickupModel != -1) {
@@ -480,7 +518,7 @@ function createHouseEntrancePickup(houseId) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createHouseEntranceBlip(houseId) {
if(getHouseData(houseId).entranceBlipModel != -1) {
@@ -499,7 +537,7 @@ function createHouseEntranceBlip(houseId) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createHouseExitPickup(houseId) {
if(getHouseData(houseId).hasInterior) {
@@ -521,7 +559,7 @@ function createHouseExitPickup(houseId) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createHouseExitBlip(houseId) {
if(getHouseData(houseId).hasInterior) {
@@ -542,7 +580,7 @@ function createHouseExitBlip(houseId) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getHouseOwnerTypeText(ownerType) {
switch(ownerType) {
@@ -566,7 +604,7 @@ function getHouseOwnerTypeText(ownerType) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getHouseInfoCommand(command, params, client) {
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
@@ -607,13 +645,13 @@ function getHouseInfoCommand(command, params, client) {
messagePlayerNormal(client, `🏠 [#11CC11][House Info] [#FFFFFF]Description: [#AAAAAA]${getHouseData(houseId).description}, [#FFFFFF]Owner: [#AAAAAA]${ownerName} (${getHouseOwnerTypeText(getHouseData(houseId).ownerType)}), [#FFFFFF]Locked: [#AAAAAA]${getYesNoFromBool(intToBool(getHouseData(houseId).locked))}, [#FFFFFF]ID: [#AAAAAA]${houseId}/${getHouseData(houseId).databaseId}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerInAnyHouse(client) {
return doesEntityDataExist(client, "ag.inHouse");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getHouseData(houseId) {
if(typeof getServerData().houses[houseId] != "undefined") {
@@ -621,53 +659,53 @@ function getHouseData(houseId) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesHouseHaveInterior(houseId) {
return getHouseData(houseId).hasInterior;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteHouseEntrancePickup(houseId) {
if(getHouseData(houseId).entrancePickup != null) {
//removeFromWorld(getHouseData(houseId).entrancePickup);
destroyElement(getHouseData(houseId).entrancePickup);
deleteGameElement(getHouseData(houseId).entrancePickup);
getHouseData(houseId).entrancePickup = null;
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteHouseExitPickup(houseId) {
if(getHouseData(houseId).exitPickup != null) {
//removeFromWorld(getHouseData(houseId).exitPickup);
destroyElement(getHouseData(houseId).exitPickup);
deleteGameElement(getHouseData(houseId).exitPickup);
getHouseData(houseId).exitPickup = null;
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteHouseEntranceBlip(houseId) {
if(getHouseData(houseId).entranceBlip != null) {
//removeFromWorld(getHouseData(houseId).entranceBlip);
destroyElement(getHouseData(houseId).entranceBlip);
deleteGameElement(getHouseData(houseId).entranceBlip);
getHouseData(houseId).entranceBlip = null;
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteHouseExitBlip(houseId) {
if(getHouseData(houseId).exitBlip != null) {
//removeFromWorld(getHouseData(houseId).exitBlip);
destroyElement(getHouseData(houseId).exitBlip);
deleteGameElement(getHouseData(houseId).exitBlip);
getHouseData(houseId).exitBlip = null;
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function reloadAllHousesCommand(command, params, client) {
let clients = getClients();
@@ -692,7 +730,7 @@ function reloadAllHousesCommand(command, params, client) {
messageAdminAction(`All houses have been reloaded by an admin!`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function exitHouse(client) {
let houseId = getPlayerHouse(client);
@@ -704,7 +742,7 @@ function exitHouse(client) {
removeEntityData(client, "ag.inHouse");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setAllHouseIndexes() {
for(let i in getServerData().houses) {
@@ -712,4 +750,24 @@ function setAllHouseIndexes() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function cacheAllHouseItems() {
for(let i in getServerData().houses) {
cacheHouseItems(i);
}
}
// ===========================================================================
function cacheHouseItems(houseId) {
getHouseData(houseId).itemCache = [];
for(let i in getServerData().items) {
if(getItemData(i).ownerType == AG_ITEM_OWNER_HOUSE && getItemData(i).ownerId == getHouseData(houseId).databaseId) {
getHouseData(houseId).itemCache.push(i);
}
}
}
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -2,10 +2,10 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: drink.js
// DESC: Provides features and usage for the drink item type
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,10 +2,10 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: food.js
// DESC: Provides features and usage for the food item type
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -0,0 +1,37 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: handcuff.js
// DESC: Provides features and usage for the handcuff item type
// TYPE: Server (JavaScript)
// ===========================================================================
// ===========================================================================
function isPlayerHandCuffed(client) {
return (getPlayerData(client).pedState == AG_PEDSTATE_BINDED);
}
// ===========================================================================
function handCuffPlayer(client) {
getPlayerData(client).pedState = AG_PEDSTATE_BINDED;
setPlayerControlState(client, false);
}
// ===========================================================================
function unHandCuffPlayer(client) {
getPlayerData(client).pedState = AG_PEDSTATE_READY;
setPlayerControlState(client, true);
}
// ===========================================================================
function isPlayerSurrendered(client) {
return (getPlayerData(client).pedState == AG_PEDSTATE_TAZED || getPlayerData(client).pedState == AG_PEDSTATE_HANDSUP);
}
// ===========================================================================

View File

@@ -2,10 +2,43 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: phone.js
// DESC: Provides features and usage for the phone item type
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
// ===========================================================================
function getItemWithPhoneNumber(phoneNumber) {
for(let i in getServerData().items) {
if(getItemTypeData(getItemData(i).itemTypeIndex).useType == AG_ITEM_USETYPE_PHONE) {
if(getItemData(i).value == phoneNumber) {
return i;
}
}
}
return -1;
}
// ===========================================================================
function isPhoneItemEnabled(itemIndex) {
return getItemData(itemIndex).enabled;
}
// ===========================================================================
function ringPhoneForNearbyPlayers(itemIndex) {
if(isPhoneItemEnabled(itemIndex)) {
}
}
// ===========================================================================
function phoneTransmit(radioFrequency, messageText, transmittingPlayer) {
phoneOutgoingToNearbyPlayers(transmittingPlayer, messageText);
}
// ===========================================================================

View File

@@ -0,0 +1,31 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: handcuff.js
// DESC: Provides features and usage for the handcuff item type
// TYPE: Server (JavaScript)
// ===========================================================================
// ===========================================================================
function isPlayerTied(client) {
return (getPlayerData(client).pedState == AG_PEDSTATE_BINDED);
}
// ===========================================================================
function ropeTiePlayer(client) {
getPlayerData(client).pedState = AG_PEDSTATE_BINDED;
setPlayerControlState(client, false);
}
// ===========================================================================
function ropeUnTiePlayer(client) {
getPlayerData(client).pedState = AG_PEDSTATE_READY;
setPlayerControlState(client, true);
}
// ===========================================================================

View File

@@ -0,0 +1,36 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: tazer.js
// DESC: Provides features and usage for the tazer item type
// TYPE: Server (JavaScript)
// ===========================================================================
// ===========================================================================
function isPlayerTazed(client) {
return (getPlayerData(client).pedState == AG_PEDSTATE_TAZED);
}
// ===========================================================================
function tazePlayer(client) {
getPlayerData(client).pedState = AG_PEDSTATE_TAZED;
setPlayerControlState(client, false);
setTimeout(function() {
unTazePlayer(client);
doActionToNearbyPlayers(client, `The tazer effect wears off`);
}, getGlobalConfig().tazerEffectDuration);
}
// ===========================================================================
function unTazePlayer(client) {
getPlayerData(client).pedState = AG_PEDSTATE_READY;
setPlayerControlState(client, true);
}
// ===========================================================================

View File

@@ -2,16 +2,16 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: walkie-talkie.js
// DESC: Provides features and usage for the walkie-talkie item type
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerActiveWalkieTalkieFrequency(client) {
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client);
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, AG_ITEM_USETYPE_WALKIETALKIE);
if(walkieTalkieSlot != -1) {
if(getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot])) {
@@ -24,40 +24,44 @@ function getPlayerActiveWalkieTalkieFrequency(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
walkieTalkieOutgoingToNearbyPlayers(transmittingPlayer, messageText);
let clients = getPlayingClients();
let clients = getClients();
for(let i in clients) {
if(!samePlayer(transmittingPlayer, clients[i])) {
if(getPlayerActiveWalkieTalkieFrequency(clients[i]) == radioFrequency) {
walkieTalkieIncomingToNearbyPlayers(clients[i], messageText);
}
}
if(isPlayerSpawned(clients[i])) {
if(!isSamePlayer(transmittingPlayer, clients[i])) {
if(getPlayerActiveWalkieTalkieFrequency(clients[i]) == radioFrequency) {
if(getItemData(getPlayerData(clients[i]).hotBarItems[getPlayerFirstItemSlotByUseType(clients[i], AG_ITEM_USETYPE_WALKIETALKIE)]).enabled) {
walkieTalkieIncomingToNearbyPlayers(clients[i], messageText);
}
}
}
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function walkieTalkieOutgoingToNearbyPlayers(client, messageText) {
let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
for(let i in clients) {
messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} [#AAAAAA](to radio): [#FFFFFF]${messageText}`);
messagePlayerNormal(clients[i], `[#CCCCCC]${getCharacterFullName(client)} [#AAAAAA](to radio): [#FFFFFF]${messageText}`);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function walkieTalkieIncomingToNearbyPlayers(client, messageText) {
let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().walkieTalkieSpeakerDistance);
for(let i in clients) {
messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} [#AAAAAA](from radio): [#FFFFFF]${messageText}`);
messagePlayerNormal(clients[i], `[#CCCCCC]${getCharacterFullName(client)} [#AAAAAA](from radio): [#FFFFFF]${messageText}`);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setWalkieTalkieFrequencyCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -97,7 +101,23 @@ function setWalkieTalkieFrequencyCommand(command, params, client) {
}
getItemData(getPlayerActiveItem(client)).value = params*100;
messagePlayerSuccess(client, `You set the frequency of you walkie talkie in slot ${getPlayerData(client).activeHotbarSlot} to ${getItemValueDisplay(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) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, AG_ITEM_USETYPE_WALKIETALKIE);
if(!getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) {
messagePlayerError(client, "Please turn on a walkie talkie first!");
return false;
}
walkieTalkieTransmit(getPlayerActiveWalkieTalkieFrequency(client), params, client);
}
// ===========================================================================

View File

@@ -2,23 +2,30 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: job.js
// DESC: Provides job functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initJobScript() {
logToConsole(LOG_DEBUG, "[Asshat.Job]: Initializing job script ...");
logToConsole(LOG_INFO, "[Asshat.Job]: Initializing job script ...");
getServerData().jobs = loadJobsFromDatabase();
createAllJobPickups();
createAllJobBlips();
if(getServerConfig().createJobPickups) {
createAllJobPickups();
}
if(getServerConfig().createJobBlips) {
createAllJobBlips();
}
setAllJobDataIndexes();
logToConsole(LOG_DEBUG, "[Asshat.Job]: Job script initialized successfully!");
logToConsole(LOG_INFO, "[Asshat.Job]: Job script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadJobsFromDatabase() {
logToConsole(LOG_DEBUG, "[Asshat.Job]: Loading jobs from database ...");
@@ -50,7 +57,7 @@ function loadJobsFromDatabase() {
return tempJobs;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAllJobEquipmentFromDatabase() {
for(let i in getServerData().jobs) {
@@ -58,7 +65,7 @@ function loadAllJobEquipmentFromDatabase() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAllJobUniformsFromDatabase() {
for(let i in getServerData().jobs) {
@@ -66,7 +73,7 @@ function loadAllJobUniformsFromDatabase() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadAllJobLocationsFromDatabase() {
for(let i in getServerData().jobs) {
@@ -74,7 +81,7 @@ function loadAllJobLocationsFromDatabase() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadJobEquipmentsFromDatabase(jobDatabaseId) {
logToConsole(LOG_DEBUG, `[Asshat.Job]: Loading job equipments for job ${jobDatabaseId} from database ...`);
@@ -104,7 +111,7 @@ function loadJobEquipmentsFromDatabase(jobDatabaseId) {
return tempJobEquipments;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadJobLocationsFromDatabase(jobDatabaseId) {
logToConsole(LOG_DEBUG, `[Asshat.Job]: Loading job locations for job ${jobDatabaseId} from database ...`);
@@ -133,7 +140,7 @@ function loadJobLocationsFromDatabase(jobDatabaseId) {
return tempJobLocations;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadJobUniformsFromDatabase(jobDatabaseId) {
logToConsole(LOG_DEBUG, `[Asshat.Job]: Loading job uniforms for job ${jobDatabaseId} from database ...`);
@@ -162,7 +169,7 @@ function loadJobUniformsFromDatabase(jobDatabaseId) {
return tempJobUniforms;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadJobEquipmentItemsFromDatabase(jobEquipmentDatabaseId) {
logToConsole(LOG_DEBUG, `[Asshat.Job]: Loading job equipment items for job equipment ${jobEquipmentDatabaseId} from database ...`);
@@ -191,7 +198,7 @@ function loadJobEquipmentItemsFromDatabase(jobEquipmentDatabaseId) {
return tempJobEquipmentItems;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createAllJobBlips() {
logToConsole(LOG_DEBUG, `[Asshat.Job] Spawning all job location blips ...`);
@@ -205,7 +212,7 @@ function createAllJobBlips() {
logToConsole(LOG_DEBUG, `[Asshat.Job] All job location blips spawned!`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createAllJobPickups() {
logToConsole(LOG_DEBUG, `[Asshat.Job] Spawning all job location pickups ...`);
@@ -231,7 +238,7 @@ function createAllJobPickups() {
logToConsole(LOG_DEBUG, `[Asshat.Job] All job location pickups (${pickupCount}) spawned!`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showJobInformationToPlayer(client, jobType) {
if(!canPlayerUseJobs(client)){
@@ -267,7 +274,7 @@ function showJobInformationToPlayer(client, jobType) {
break;
case AG_JOB_FIRE:
if(!canClientUseFireJob(client)){
if(!canClientUseFireJob(client)) {
return false;
}
messagePlayerInfo(client, "== Job Help =================================");
@@ -319,7 +326,7 @@ function showJobInformationToPlayer(client, jobType) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function takeJobCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -336,7 +343,7 @@ function takeJobCommand(command, params, client) {
}
if(getPlayerCurrentSubAccount(client).job > AG_JOB_NONE) {
messagePlayerError(client, "You already have a job! Use /quitjob to quit your job.");
messagePlayerError(client, `[#FFFFFF]You already have a job! Use [#AAAAAA]/quitjob [#FFFFFF]to quit your current job.`);
return false;
}
@@ -346,11 +353,11 @@ function takeJobCommand(command, params, client) {
}
takeJob(client, closestJobLocation.jobIndex);
messagePlayerSuccess(client, "You now have the " + toString(jobData.name) + " job");
messagePlayerSuccess(client, `[#FFFFFF]You now have the [#FFFF00]${jobData.name} [#FFFFFF]job`);
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function startWorkingCommand(command, params, client) {
if(!canPlayerUseJobs(client)){
@@ -383,7 +390,7 @@ function startWorkingCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function stopWorkingCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -407,13 +414,14 @@ function stopWorkingCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function startWorking(client) {
if(!canPlayerUseJobs(client)){
return false;
}
getPlayerCurrentSubAccount(client).skin = getPlayerSkin(client);
storePlayerItemsInJobLocker(client);
messagePlayerInfo(client, "Your personal items have been stored in your locker while you work");
@@ -460,7 +468,7 @@ function startWorking(client) {
//showStartedWorkingTip(client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getJobInfoCommand(command, params, client) {
let closestJobLocation = getClosestJobLocation(getPlayerPosition(client));
@@ -468,7 +476,7 @@ function getJobInfoCommand(command, params, client) {
messagePlayerInfo(client, `[#FFFF00][Job Info] [#FFFFFF]Name: [#AAAAAA]${getJobData(closestJobLocation.job).name}, [#FFFFFF]Enabled: [#AAAAAA]${getYesNoFromBool(intToBool(getJobData(closestJobLocation.job).enabled))}, [#FFFFFF]Whitelisted: [#AAAAAA]${getYesNoFromBool(intToBool(getJobData(closestJobLocation.job).whiteListEnabled))}, [#FFFFFF]Blacklisted: [#AAAAAA]${getYesNoFromBool(intToBool(getJobData(closestJobLocation.job).blackListEnabled))}, [#FFFFFF]ID: [#AAAAAA]${getJobData(closestJobLocation.job).id}/${closestJobLocation.job}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getJobLocationInfoCommand(command, params, client) {
let closestJobLocation = getClosestJobLocation(getPlayerPosition(client));
@@ -476,7 +484,7 @@ function getJobLocationInfoCommand(command, params, client) {
messagePlayerInfo(client, `[#FFFF00][Job Location Info] [#FFFFFF]Job: [#AAAAAA]${getJobData(closestJobLocation.job).name} (${getJobData(closestJobLocation.job).id}/${closestJobLocation.job}), [#FFFFFF]Enabled: [#AAAAAA]${getYesNoFromBool(closestJobLocation.enabled)}, [#FFFFFF]Database ID: [#AAAAAA]${closestJobLocation.databaseId}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function givePlayerJobEquipment(client, equipmentId) {
if(!canPlayerUseJobs(client)) {
@@ -499,7 +507,7 @@ function givePlayerJobEquipment(client, equipmentId) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function stopWorking(client) {
if(!canPlayerUseJobs(client)){
@@ -533,6 +541,8 @@ function stopWorking(client) {
getPlayerCurrentSubAccount(client).lastJobVehicle = false;
}
setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin);
deleteJobItems(client);
restorePlayerJobLockerItems(client);
let jobId = getPlayerCurrentSubAccount(client).job;
@@ -575,7 +585,7 @@ function stopWorking(client) {
sendPlayerWorkingState(client, false);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function jobUniformCommand(command, params, client) {
if(!getPlayerJob(client)) {
@@ -606,16 +616,18 @@ function jobUniformCommand(command, params, client) {
return false;
}
messagePlayerSuccess(client, `You have been given a [#AAAAAA]${uniforms[uniformId-1].name} [#FFFFFF]uniform and you can put it on from your inventory.`);
setPlayerSkin(client, getJobData(jobId).uniforms[uniformId-1].skin);
let itemId = createItem(getItemTypeFromParams("Uniform"), getJobData(jobId).uniforms[uniformId].skin, AG_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId);
let freeSlot = getPlayerFirstEmptyHotBarSlot(client);
getPlayerData(client).hotBarItems[freeSlot] = itemId;
getPlayerData(client).jobEquipmentCache.push(itemId);
updatePlayerHotBar(client);
//messagePlayerSuccess(client, `You have been given a [#AAAAAA]${uniforms[uniformId-1].name} [#FFFFFF]uniform and you can put it on from your inventory.`);
meActionToNearbyPlayers(client, `puts on ${getProperDeterminerForName(getJobData(jobId).uniforms[uniformId-1].name)} ${getJobData(jobId).uniforms[uniformId-1].name} uniform`);
//let itemId = createItem(getItemTypeFromParams("Outfit"), getJobData(jobId).uniforms[uniformId-1].skin, AG_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId);
//let freeSlot = getPlayerFirstEmptyHotBarSlot(client);
//getPlayerData(client).hotBarItems[freeSlot] = itemId;
//getPlayerData(client).jobEquipmentCache.push(itemId);
//updatePlayerHotBar(client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function jobEquipmentCommand(command, params, client) {
if(!getPlayerJob(client)) {
@@ -652,11 +664,12 @@ function jobEquipmentCommand(command, params, client) {
return false;
}
deleteJobItems(client);
givePlayerJobEquipment(client, equipmentId-1);
messagePlayerSuccess(client, `You have been given the ${equipments[equipmentId-1].name} equipment`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function quitJobCommand(command, params, client) {
if(!canPlayerUseJobs(client)){
@@ -668,7 +681,7 @@ function quitJobCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function jobRadioCommand(command, params, client) {
if(!canPlayerUseJobs(client)){
@@ -678,30 +691,29 @@ function jobRadioCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function jobDepartmentRadioCommand(command, params, client) {
if(!canPlayerUseJobs(client)){
return false;
}
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getJobType(jobId) {
return getJobData(jobId).type;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveJobType(client, jobType) {
return (getJobType(getPlayerCurrentSubAccount(client).job) == jobType) ? true : false;
return (getJobType(getJobIdFromDatabaseId(getPlayerCurrentSubAccount(client).job)) == jobType) ? true : false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getJobData(jobId) {
if(typeof getServerData().jobs[jobId] != "undefined") {
@@ -711,22 +723,22 @@ function getJobData(jobId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function quitJob(client) {
stopWorking(client);
getPlayerCurrentSubAccount(client).job = AG_JOB_NONE;
sendPlayerJobType(client, 0);
getPlayerCurrentSubAccount(client).job = 0;
sendPlayerJobType(client, -1);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function takeJob(client, jobId) {
getPlayerCurrentSubAccount(client).job = getJobData(jobId).databaseId;
sendPlayerJobType(client, getJobData(jobId).databaseId);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function reloadAllJobsCommand(command, params, client) {
forceAllPlayersToStopWorking();
@@ -746,7 +758,7 @@ function reloadAllJobsCommand(command, params, client) {
messageAdminAction(`All server jobs have been reloaded by an admin!`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createJobLocationCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -766,7 +778,7 @@ function createJobLocationCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteJobLocationCommand(command, params, client) {
let closestJobLocation = getClosestJobLocation(getPlayerPosition(client));
@@ -781,7 +793,7 @@ function deleteJobLocationCommand(command, params, client) {
getJobData(tempJob).locations.splice(tempIndex, 1);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function toggleJobLocationEnabledCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -795,7 +807,7 @@ function toggleJobLocationEnabledCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(closestJobLocation.enabled)} location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${getJobData(closestJobLocation.jobIndex).name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function toggleJobEnabledCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -809,7 +821,7 @@ function toggleJobEnabledCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(getJobData(jobId).enabled)} [#FFFFFF]the [#AAAAAA]${getJobData(jobId).name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function toggleJobWhiteListCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -823,7 +835,7 @@ function toggleJobWhiteListCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(getJobData(jobId).whiteListEnabled)} [#FFFFFF]the whitelist for the [#AAAAAA]${getJobData(jobId).name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function toggleJobBlackListCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -837,7 +849,7 @@ function toggleJobBlackListCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(getJobData(jobId).blackListEnabled)} [#FFFFFF]the blacklist for the [#AAAAAA]${getJobData(jobId).name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addPlayerToJobBlackListCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -867,7 +879,7 @@ function addPlayerToJobBlackListCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]added ${getCharacterFullName(targetClient)} [#FFFFFF]to the blacklist for the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removePlayerFromJobBlackListCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -897,7 +909,7 @@ function removePlayerFromJobBlackListCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]removed ${getCharacterFullName(targetClient)} [#FFFFFF]from the blacklist for the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addPlayerToJobWhiteListCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -927,7 +939,7 @@ function addPlayerToJobWhiteListCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]added ${getCharacterFullName(targetClient)} [#FFFFFF]to the whitelist for the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removePlayerFromJobWhiteListCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -957,7 +969,7 @@ function removePlayerFromJobWhiteListCommand(command, params, client) {
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]removed ${getCharacterFullName(targetClient)} [#FFFFFF]from the whitelist for the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function forceAllPlayersToStopWorking() {
getClients().forEach(function(client) {
@@ -967,7 +979,7 @@ function forceAllPlayersToStopWorking() {
});
}
// ---------------------------------------------------------------------------
// ===========================================================================
function jobStartRouteCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -995,7 +1007,7 @@ function jobStartRouteCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function jobStopRouteCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -1022,7 +1034,7 @@ function jobStopRouteCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerInJobVehicle(client) {
if(getPlayerVehicle(client)) {
@@ -1035,7 +1047,7 @@ function isPlayerInJobVehicle(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerWorking(client) {
if(!getPlayerCurrentSubAccount(client)) {
@@ -1044,7 +1056,7 @@ function isPlayerWorking(client) {
return getPlayerCurrentSubAccount(client).isWorking;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function startJobRoute(client) {
if(doesPlayerHaveJobType(client, AG_JOB_BUS)) {
@@ -1070,59 +1082,66 @@ function startJobRoute(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function stopJobRoute(client, successful = false) {
function stopJobRoute(client, successful = false, alertPlayer = true) {
stopReturnToJobVehicleCountdown(client);
sendPlayerStopJobRoute(client);
if(doesPlayerHaveJobType(client, AG_JOB_BUS)) {
respawnVehicle(getPlayerData(client).busRouteVehicle);
messagePlayerAlert(client, `You stopped the ${getBusRouteData(getPlayerData(client).busRouteIsland, getPlayerData(client).busRoute).name} bus route! Your bus has been returned to the bus depot.`, getColourByName("yellow"));
getPlayerData(client).busRouteVehicle = false;
getPlayerData(client).busRoute = false;
getPlayerData(client).busRouteStop = false;
getPlayerData(client).busRouteIsland = false;
respawnVehicle(getPlayerData(client).jobRouteVehicle);
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = false;
getPlayerData(client).jobRouteStop = false;
getPlayerData(client).jobRouteIsland = false;
if(alertPlayer) {
messagePlayerAlert(client, `You stopped the ${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} bus route! Your bus has been returned to the bus depot.`, getColourByName("yellow"));
}
} else if(doesPlayerHaveJobType(client, AG_JOB_GARBAGE)) {
respawnVehicle(getPlayerData(client).garbageRouteVehicle);
messagePlayerAlert(client, `You stopped the ${getBusRouteData(getPlayerData(client).garbageRouteIsland, getPlayerData(client).garbageRoute).name} garbage route! Your trashmaster has been returned to the bus depot.`, getColourByName("yellow"));
getPlayerData(client).garbageRouteVehicle = false;
getPlayerData(client).garbageRoute = false;
getPlayerData(client).garbageRouteStop = false;
getPlayerData(client).garbageRouteIsland = false;
respawnVehicle(getPlayerData(client).jobRouteVehicle);
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = false;
getPlayerData(client).jobRouteStop = false;
getPlayerData(client).jobRouteIsland = false;
if(alertPlayer) {
messagePlayerAlert(client, `You stopped the ${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} garbage route! Your trashmaster has been returned to the bus depot.`, getColourByName("yellow"));
}
} else if(doesPlayerHaveJobType(client, AG_JOB_POLICE)) {
respawnVehicle(getPlayerData(client).jobRouteVehicle);
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = false;
getPlayerData(client).jobRouteStop = false;
getPlayerData(client).jobRouteIsland = false;
if(alertPlayer) {
messagePlayerAlert(client, `You stopped the ${getPolicePatrolRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} patrol route! Your police car has been returned to the station.`, getColourByName("yellow"));
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerOnJobRoute(client) {
if(doesPlayerHaveJobType(client, AG_JOB_BUS)) {
if(getPlayerData(client).busRoute) {
return true;
}
} else if(doesPlayerHaveJobType(client, AG_JOB_GARBAGE)) {
if(getPlayerData(client).garbageRoute) {
return true;
}
if(typeof getPlayerData(client).jobRoute == "number") {
return true;
}
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerJobRouteVehicle(client) {
if(!isPlayerOnJobRoute(client)) {
return false;
}
if(doesPlayerHaveJobType(client, AG_JOB_BUS)) {
return getPlayerData(client).busRouteVehicle;
} else if(doesPlayerHaveJobType(client, AG_JOB_GARBAGE)) {
return getPlayerData(client).garbageRouteVehicle;
}
return getPlayerData(client).jobRouteVehicle;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function startReturnToJobVehicleCountdown(client) {
getPlayerData(client).returnToJobVehicleTick = getGlobalConfig().returnToJobVehicleTime;
@@ -1141,7 +1160,7 @@ function startReturnToJobVehicleCountdown(client) {
}, 1000);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function stopReturnToJobVehicleCountdown(client) {
if(getPlayerData(client).returnToJobVehicleTimer != null) {
@@ -1152,7 +1171,7 @@ function stopReturnToJobVehicleCountdown(client) {
//getPlayerData(client).returnToJobVehicleTick = 0;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function canPlayerUseJob(client, jobId) {
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageJobs"))) {
@@ -1178,29 +1197,29 @@ function canPlayerUseJob(client, jobId) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteJobLocation(jobLocationData) {
if(jobLocationData.pickup) {
destroyElement(jobLocationData.pickup);
deleteGameElement(jobLocationData.pickup);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function freezeJobVehicleForRouteStop(client) {
getVehicleData(getPlayerVehicle(client)).engine = false;
getPlayerVehicle(client).engine = false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function unFreezeJobVehicleForRouteStop(client) {
getVehicleData(getPlayerVehicle(client)).engine = true;
getPlayerVehicle(client).engine = true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getJobIdFromDatabaseId(databaseId) {
for(let i in getServerData().jobs) {
@@ -1211,7 +1230,7 @@ function getJobIdFromDatabaseId(databaseId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setAllJobDataIndexes() {
for(let i in getServerData().jobs) {
@@ -1248,7 +1267,7 @@ function setAllJobDataIndexes() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createJobLocation(jobId, position, interior, dimension) {
let jobLocationData = new serverClasses.jobLocationData(false);
@@ -1266,7 +1285,7 @@ function createJobLocation(jobId, position, interior, dimension) {
saveJobLocationToDatabase(jobLocationData);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveJobToDatabase(jobData) {
if(jobData == null) {
@@ -1284,7 +1303,22 @@ function saveJobToDatabase(jobData) {
queryDatabase(dbConnection, dbQueryString);
jobData.databaseId = getDatabaseInsertId(dbConnection);
} else {
let dbQueryString = `UPDATE job_main SET job_name='${safeName}', job_enabled=${boolToInt(jobData.enabled)}, job_pickup=${jobData.pickupModel}, job_blip=${jobData.blipModel}, job_type=${jobData.type}, job_colour_r=${jobData.colourArray[0]}, job_colour_g=${jobData.colourArray[1]}, job_colour_b=${jobData.colourArray[2]} WHERE job_id=${jobData.databaseId}`;
let dbQueryString =
`UPDATE job_main SET
job_name='${safeName}',
job_enabled=${boolToInt(jobData.enabled)},
job_pickup=${jobData.pickupModel},
job_blip=${jobData.blipModel},
job_type=${jobData.type},
job_colour_r=${jobData.colourArray[0]},
job_colour_g=${jobData.colourArray[1]},
job_colour_b=${jobData.colourArray[2]},
job_walkietalkiefreq=${jobData.walkieTalkieFrequency},
job_wl=${jobData.whiteListEnabled},
job_bl=${jobData.blackListEnabled}
WHERE job_id=${jobData.databaseId}`;
queryDatabase(dbConnection, dbQueryString);
}
disconnectFromDatabase(dbConnection);
@@ -1295,7 +1329,7 @@ function saveJobToDatabase(jobData) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveJobLocationToDatabase(jobLocationData) {
if(jobLocationData == null) {
@@ -1309,7 +1343,7 @@ function saveJobLocationToDatabase(jobLocationData) {
// If job location hasn't been added to database, ID will be 0
if(jobLocationData.databaseId == 0) {
let dbQueryString = `INSERT INTO job_loc (job_loc_job, job_loc_enabled, job_loc_pos_x, job_loc_pos_y, job_loc_pos_z, job_loc_int, job_loc_vw) VALUES (${jobLocationData.job}, ${boolToInt(jobLocationData.enabled)}, ${jobLocationData.position.x}, ${jobLocationData.position.y}, ${jobLocationData.position.z}, ${jobLocationData.interior}, ${jobLocationData.dimension})`;
logToConsole(LOG_DEBUG, dbQueryString);
queryDatabase(dbConnection, dbQueryString);
jobLocationData.databaseId = getDatabaseInsertId(dbConnection);
} else {
@@ -1324,7 +1358,7 @@ function saveJobLocationToDatabase(jobLocationData) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveJobEquipmentToDatabase(jobEquipmentData) {
if(jobEquipmentData == null) {
@@ -1353,7 +1387,7 @@ function saveJobEquipmentToDatabase(jobEquipmentData) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveJobEquipmentItemToDatabase(jobEquipmentItemData) {
if(jobEquipmentItemData == null) {
@@ -1381,7 +1415,7 @@ function saveJobEquipmentItemToDatabase(jobEquipmentItemData) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveJobUniformToDatabase(jobUniformData) {
if(jobUniformData == null) {
@@ -1410,7 +1444,7 @@ function saveJobUniformToDatabase(jobUniformData) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function saveAllJobsToDatabase() {
for(let i in getServerData().jobs) {
@@ -1434,25 +1468,25 @@ function saveAllJobsToDatabase() {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteJobLocationBlip(jobId, locationId) {
if(getJobData(jobId).locations[locationId].blip != null) {
destroyElement(getJobData(jobId).locations[locationId].blip);
deleteGameElement(getJobData(jobId).locations[locationId].blip);
getJobData(jobId).locations[locationId].blip = null;
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteJobLocationPickup(jobId, locationId) {
if(getServerData().jobs[jobId].locations[locationId].pickup != null) {
destroyElement(getJobData(jobId).locations[locationId].pickup);
deleteGameElement(getJobData(jobId).locations[locationId].pickup);
getServerData().jobs[jobId].locations[locationId].pickup = null;
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createJobLocationPickup(jobId, locationId) {
if(getJobData(jobId).pickupModel != -1) {
@@ -1464,16 +1498,16 @@ function createJobLocationPickup(jobId, locationId) {
getJobData(jobId).locations[locationId].pickup = gta.createPickup(pickupModelId, getJobData(jobId).locations[locationId].position, getGameConfig().pickupTypes[getServerGame()].job);
getJobData(jobId).locations[locationId].pickup.dimension = getJobData(jobId).locations[locationId].dimension;
addToWorld(getJobData(jobId).locations[locationId].pickup);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "ag.owner.type", AG_PICKUP_JOB, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, locationId, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, AG_LABEL_JOB, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, getServerData().jobs[jobId].name, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, jobId, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "ag.owner.id", locationId, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "ag.label.type", AG_LABEL_JOB, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "ag.label.name", getJobData(jobId).name, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "ag.label.jobType", getJobData(jobId).databaseId, true);
addToWorld(getJobData(jobId).locations[locationId].pickup);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function createJobLocationBlip(jobId, locationId) {
if(getJobData(jobId).blipModel != -1) {
@@ -1490,7 +1524,7 @@ function createJobLocationBlip(jobId, locationId) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerJob(client) {
let jobDatabaseId = getPlayerCurrentSubAccount(client).job;
@@ -1503,7 +1537,7 @@ function getPlayerJob(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function canPlayerUseJobs(client) {
if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getServerBitFlags().moderationFlags.jobBanned)) {
@@ -1513,7 +1547,7 @@ function canPlayerUseJobs(client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getJobIndexFromDatabaseId(databaseId) {
for(let i in getServerData().jobs) {
@@ -1524,13 +1558,13 @@ function getJobIndexFromDatabaseId(databaseId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isJobWhiteListed(jobId) {
return getJobData(jobId).whiteListEnabled;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerOnJobWhiteList(client, jobId) {
for(let i in getJobData(jobId).whiteList) {
@@ -1542,13 +1576,13 @@ function isPlayerOnJobWhiteList(client, jobId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isJobBlackListed(jobId) {
return getJobData(jobId).blackListEnabled;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerOnJobBlackList(client, jobId) {
for(let i in getJobData(jobId).blackList) {
@@ -1560,7 +1594,7 @@ function isPlayerOnJobBlackList(client, jobId) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerArrivedAtJobRouteStop(client) {
if(!isPlayerOnJobRoute(client)) {
@@ -1576,4 +1610,19 @@ function playerArrivedAtJobRouteStop(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteJobItems(client) {
for(let i in getPlayerData(client).jobEquipmentCache) {
for(let j in getPlayerData(client).hotBarItems) {
if(getPlayerData(client).hotBarItems[j] == getPlayerData(client).jobEquipmentCache[i]) {
getPlayerData(client).hotBarItems[j] = -1;
}
}
deleteItem(getPlayerData(client).jobEquipmentCache[i]);
}
updatePlayerHotBar(client);
}
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: bus.js
// DESC: Provides bus driver job functions and usage
// TYPE: Job (JavaScript)
@@ -360,7 +360,7 @@ let busRoutes = [
],
];
// ---------------------------------------------------------------------------
// ===========================================================================
function getRandomBusRoute(island) {
if(busRoutes[getServerGame()][island].length == 1) {
@@ -369,7 +369,7 @@ function getRandomBusRoute(island) {
return getRandom(0, busRoutes[getServerGame()][island].length-1);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getNextStopOnBusRoute(island, busRoute, busRouteStop) {
if(!isLastStopOnBusRoute(island, busRoute, busRouteStop)) {
@@ -379,7 +379,7 @@ function getNextStopOnBusRoute(island, busRoute, busRouteStop) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isLastStopOnBusRoute(island, busRoute, busRouteStop) {
if(busRouteStop == busRoutes[getServerGame()][island][busRoute].positions.length-1) {
@@ -388,27 +388,27 @@ function isLastStopOnBusRoute(island, busRoute, busRouteStop) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showNextBusStop(client) {
getPlayerData(client).jobRouteStop = getNextStopOnBusRoute(getPlayerData(client).jobRouteStop, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop);
showCurrentBusStop(client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showCurrentBusStop(client) {
sendJobRouteStopToPlayer(client, getBusRouteStopPosition(getPlayerIsland(client), getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop), getColourByName("busDriverGreen"))
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerArrivedAtBusStop(client) {
if(isLastStopOnBusRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
respawnVehicle(getPlayerData(client).jobRouteVehicle);
messagePlayerNormal(client, `You finished the ${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} bus route! You earned $${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout} and your bus has been returned to the bus depot.`, getColourByName("yellow"));
getPlayerCurrentSubAccount(client).cash += getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout;
updatePlayerCash(client);
getPlayerData(client).payDayAmount += getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout*getServerData().inflationMultiplier;
messagePlayerNormal(client, `You finished the ${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} bus route!. Your bus has been returned to the bus depot.`, getColourByName("yellow"));
messagePlayerNormal(client, `You earned $${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout*getServerData().inflationMultiplier}. Your total paycheck of [#AAAAAA]${getPlayerData(client).payDayAmount} will be received in [#AAAAAA]${getTimeDifferenceDisplay(sdl.ticks-getPlayerData(client).payDayTickStart)}`);
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = 0;
getPlayerData(client).jobRouteStop = 0;
@@ -426,16 +426,16 @@ function playerArrivedAtBusStop(client) {
}, 5000);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getBusRouteStopPosition(island, busRoute, busRouteStop) {
return busRoutes[getServerGame()][island][busRoute].positions[busRouteStop];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getBusRouteData(island, busRoute) {
return busRoutes[getServerGame()][island][busRoute];
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: drug.js
// DESC: Provides drug runner/dealer job functions and usage
// TYPE: Job (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: fire.js
// DESC: Provides firefighter job functions and usage
// TYPE: Job (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: garbage.js
// DESC: Provides garbage collector job functions and usage
// TYPE: Job (JavaScript)
@@ -15,6 +15,7 @@ let garbageRoutes = [
{ // ROUTE 0
name: "Portland #1",
island: 0,
payout: 150,
positions: [
toVector3(1169.8, -45.54, 10.4),
toVector3(928, -59.1, 8.61),
@@ -37,6 +38,7 @@ let garbageRoutes = [
{ // ROUTE 0
name: "Staunton #1",
island: 1,
payout: 150,
positions: [
toVector3(49.85, -1539.9, 26.6),
toVector3(49.71, -1458.1, 26.6),
@@ -70,7 +72,7 @@ let garbageRoutes = [
],
];
// ---------------------------------------------------------------------------
// ===========================================================================
function getRandomGarbageRoute(island) {
if(garbageRoutes[getServerGame()][island].length == 1) {
@@ -79,7 +81,7 @@ function getRandomGarbageRoute(island) {
return getRandom(0, garbageRoutes[getServerGame()][island].length-1);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getNextStopOnGarbageRoute(island, garbageRoute, garbageRouteStop) {
if(!isLastStopOnGarbageRoute(island, garbageRoute, garbageRouteStop)) {
@@ -89,7 +91,7 @@ function getNextStopOnGarbageRoute(island, garbageRoute, garbageRouteStop) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isLastStopOnGarbageRoute(island, garbageRoute, garbageRouteStop) {
if(garbageRouteStop == garbageRoutes[getServerGame()][island][garbageRoute].positions.length-1) {
@@ -98,27 +100,27 @@ function isLastStopOnGarbageRoute(island, garbageRoute, garbageRouteStop) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showNextGarbageStop(client) {
getPlayerData(client).jobRouteStop = getNextStopOnGarbageRoute(getPlayerData(client).jobRouteStop, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop);
showCurrentGarbageStop(client);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function showCurrentGarbageStop(client) {
triggerNetworkEvent("ag.showGarbageStop", client, getGarbageRouteStopPosition(getPlayerIsland(client), getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop), getColourByName("garbageDriverGreen"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerArrivedAtGarbageStop(client) {
if(isLastStopOnGarbageRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
respawnVehicle(getPlayerData(client).jobRouteVehicle);
messagePlayerNormal(client, `You finished the ${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} garbage route! You earned $${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout} and your trashmaster has been returned to the garbage depot.`, getColourByName("yellow"));
getPlayerCurrentSubAccount(client).cash += getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout;
updatePlayerCash(client);
getPlayerData(client).payDayAmount += getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout*getServerData().inflationMultiplier;
messagePlayerNormal(client, `You finished the ${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} garbage route! Your trashmaster has been returned to the garbage depot.`, getColourByName("yellow"));
messagePlayerNormal(client, `You earned $${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout*getServerData().inflationMultiplier}. Your total paycheck of [#AAAAAA]${getPlayerData(client).payDayAmount} will be received in [#AAAAAA]${getTimeDifferenceDisplay(sdl.ticks-getPlayerData(client).payDayTickStart)}: $${getPlayerData(client).payDayAmount}`);
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = 0;
getPlayerData(client).jobRouteStop = 0;
@@ -135,16 +137,16 @@ function playerArrivedAtGarbageStop(client) {
}, 5000);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getGarbageRouteStopPosition(island, garbageRoute, garbageRouteStop) {
return garbageRoutes[getServerGame()][island][garbageRoute].positions[garbageRouteStop];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getGarbageRouteData(island, garbageRoute) {
return garbageRoutes[getServerGame()][island][garbageRoute];
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: medic.js
// DESC: Provides paramedic job functions and usage
// TYPE: Job (JavaScript)

View File

@@ -0,0 +1,261 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ===========================================================================
// FILE: pizza-delivery.js
// DESC: Provides pizza delivery driver job functions and usage
// TYPE: Job (JavaScript)
// ===========================================================================
let pizzaDeliveryStops = [
false,
[ // GTA 3 (1)
[ // PORTLAND ISLAND (0)
toVector3(1269, -1056.4, 14.75),
toVector3(1088.7, -968.8, 14.91),
toVector3(1059.1, -870.9, 14.91),
toVector3(917.6, -815.9, 14.91),
toVector3(851.1, -766.1, 14.91),
toVector3(838.8, -598.7, 14.91),
toVector3(959.3, -581.6, 14.91),
toVector3(853.1, -485.9, 14.91),
toVector3(838.8, -312.68, 6.8),
toVector3(913.9, -177.4, 4.91),
toVector3(1123.3, -67.74, 7.41),
toVector3(1043.6, -191.63, 4.91),
toVector3(1213.2, -281.3, 25.76),
toVector3(1193.3, -474.3, 24.98),
toVector3(1335.4, -499.7, 45.28),
toVector3(1220.3, -341.4, 26.38),
toVector3(1122.6, -475.6, 19.91),
toVector3(1309.2, -642.4, 12.3),
toVector3(1350.5, -845, 14.91),
toVector3(1322.2, -1025.3, 14.76),
toVector3(1307.5, -995.54, 14.88),
],
[ // STAUNTON ISLAND (1)
toVector3(-1.11, -388.4, 16.11),
toVector3(-15.75, -735.3, 26.15),
toVector3(33.63, -1029.4, 26.11),
toVector3(-53.92, -1233.4, 26.11),
toVector3(126.58, -1323.7, 26.11),
toVector3(189.39, -1285.6, 26.11),
toVector3(266.9, -1179.1, 26.11),
toVector3(283.93, -1370.2, 26.11),
toVector3(144.44, -1455.5, 26.11),
toVector3(34.5, -1511.7, 26.11),
toVector3(325.31, -1579, 26.03),
toVector3(302.33, -1417.7, 26.11),
toVector3(309.76, -1290, 26.11),
toVector3(378.5, -1235.1, 26.11),
toVector3(404, -1376.3, 26.11),
toVector3(189.07, -1159.3, 26.11),
toVector3(189.44, -956.9, 26.11),
toVector3(254.18, -722.3, 26.11),
toVector3(383.4, -704.2, 26.11),
toVector3(429.3, -420.6, 22.04),
toVector3(570.9, -336.4, 19.71),
toVector3(267.46, 91.12, 15.96),
toVector3(99.13, -31.96, 16.11),
toVector3(243.94, -187.01, 21.31),
toVector3(99.17, -263.44, 16.11),
toVector3(-26.92, -283.73, 16.11),
],
],
[ // GTA VC
[ // WESTERN ISLAND (0)
toVector3(-997.698, 175.8, 10.704),
toVector3(-607.007, 659.024, 10.9994),
toVector3(-665.23, 843.213, 11.3572),
toVector3(-669.703, 1174.17, 10.9954),
toVector3(19.0071, 967.446, 10.8685),
toVector3(-441.901, 1099.23, 10.9998),
toVector3(-1048.15, 1341.77, 8.76068),
toVector3(-870.697, 1049.45, 11.0081),
toVector3(-683.681, 610.935, 11.0217),
toVector3(-1011.02, 291.984, 11.3042),
toVector3(-1185.89, -264.69, 11.5162),
toVector3(-1106.57, -300.12, 11.189),
toVector3(-1012.97, -372.445, 10.8688),
toVector3(-1018.07, -573.031, 11.0513),
toVector3(-1184.86, -647.271, 11.565),
toVector3(-1034.59, -908.376, 14.0954),
toVector3(-990.653, -1074.29, 14.7919),
toVector3(-1199.02, -946.758, 14.7914),
toVector3(-1431.57, -780.312, 14.7926),
toVector3(-1282.71, -785.966, 14.7917),
toVector3(-1204.48, -939.911, 14.7917),
toVector3(-1006.98, -1079.19, 14.7916),
toVector3(-928.565, -1257.33, 11.9578),
toVector3(-912.603, -1442.4, 11.8644),
toVector3(-683.223, -1389.97, 11.0019),
toVector3(-799.104, -1062.2, 11.0011),
toVector3(-812.002, -672.31, 11.0046),
toVector3(-834.03, -477.273, 11.0118),
toVector3(-840.406, -307.896, 11.0001),
toVector3(-829.729, -119.308, 11.0004),
toVector3(-903.957, 33.4505, 10.6344),
toVector3(-1002.04, -37.9656, 10.9094),
toVector3(-1066.83, -13.3146, 11.3389),
toVector3(-1067.5, 109.544, 11.3122),
toVector3(-1003.59, 171.078, 10.8953),
toVector3(-748.054, 198.243, 11.2455),
toVector3(-850, -110.625, 11.0203),
toVector3(-898.862, -280.373, 10.6645),
toVector3(-1082.1, -294.416, 11.2065),
],
],
[ // GTA SA
[ // LOS SANTOS ISLAND (0)
toVector3(1823.79, -1852.66, 13.5144),
toVector3(1804.12, -1609.59, 13.4419),
toVector3(1660.32, -1510.09, 13.4877),
toVector3(1612.54, -1322.23, 17.4085),
toVector3(1778.93, -1286.59, 13.5744),
toVector3(1854.72, -1208.16, 20.9552),
toVector3(1659.95, -1158.07, 23.8315),
toVector3(1461.6, -1031.05, 23.7518),
toVector3(1277.71, -1036.63, 31.6085),
toVector3(1322.74, -1151.38, 23.7558),
toVector3(1194.26, -1334.15, 13.4953),
toVector3(1081.29, -1392.64, 13.7023),
toVector3(1034.65, -1555.27, 13.4591),
toVector3(1033.26, -1782.3, 13.6323),
toVector3(1262.27, -1855, 13.4887),
toVector3(1445.39, -1875.5, 13.4944),
toVector3(1742.23, -2168.78, 13.557),
toVector3(1943.35, -2169.25, 13.4741),
toVector3(1963.51, -1969.6, 13.5867),
toVector3(1824.2, -1886.48, 13.4287),
toVector3(1824.17, -1851.5, 13.5134),
toVector3(1853.95, -1395.48, 13.4882),
toVector3(1659.33, -1158.59, 23.8368),
toVector3(1375.08, -1139.12, 23.7585),
toVector3(1186.53, -1139.9, 23.8007),
toVector3(1021.63, -1139.48, 23.7568),
toVector3(965.119, -1100.04, 23.7962),
toVector3(1058.53, -1042.64, 32.03),
toVector3(1238.74, -1041.7, 31.8307),
toVector3(1377.08, -977.352, 32.2744),
toVector3(1461.71, -731.011, 93.5068),
toVector3(1248.83, -729.438, 94.7962),
toVector3(932.221, -828.904, 94.6709),
toVector3(717.372, -982.938, 52.8477),
toVector3(452.042, -1182.3, 66.3269),
toVector3(287.664, -1221.08, 75.3682),
toVector3(225.497, -1346.85, 51.5658),
toVector3(438.728, -1720.92, 9.92785),
toVector3(894.789, -1788.3, 13.5674),
toVector3(919.419, -1592.92, 13.4843),
toVector3(939.902, -1408.49, 13.3463),
toVector3(1207.53, -1329.3, 13.5012),
toVector3(1324.24, -1282.88, 13.4815),
toVector3(1296.85, -1551.41, 13.4839),
toVector3(1294.85, -1811.15, 13.4816),
toVector3(1649.38, -1875.42, 13.4858),
toVector3(1819.59, -1870.9, 13.4987),
toVector3(1823.94, -1853.88, 13.5103),
toVector3(1823.97, -1655.31, 13.4738),
toVector3(1854.81, -1409.54, 13.4829),
toVector3(1869.02, -1152.77, 23.8096),
toVector3(1975.68, -1104.29, 25.5835),
toVector3(2077.6, -985.15, 50.0375),
toVector3(2161.61, -1022.78, 62.5533),
toVector3(2173.38, -1148.91, 24.9203),
toVector3(2166.28, -1267.17, 23.9138),
toVector3(2087.27, -1298.99, 23.9193),
toVector3(2008.67, -1338.34, 23.9207),
toVector3(2026.04, -1468.12, 14.867),
toVector3(2108.83, -1684.64, 13.4771),
toVector3(2185.67, -1745.22, 13.4681),
toVector3(2287.18, -1734.76, 13.4821),
toVector3(2411.06, -1793.34, 13.4746),
toVector3(2451.02, -1934.86, 13.4209),
toVector3(2529.97, -1750.13, 13.479),
toVector3(2685.6, -1659.48, 11.4476),
toVector3(2739.7, -1524.93, 29.6406),
toVector3(2739.95, -1278.48, 57.8435),
toVector3(2683.93, -1068.66, 69.2199),
toVector3(2578.78, -1045.36, 69.5098),
toVector3(2326.9, -1128.69, 27.8126),
toVector3(2367.83, -1270.92, 23.941),
toVector3(2324.15, -1382.25, 23.9621),
toVector3(2137.14, -1382.12, 23.9376),
toVector3(2010.74, -1459.87, 13.4914),
toVector3(1824.35, -1562.74, 13.4622),
toVector3(1818.98, -1872.52, 13.5075),
toVector3(1823.79, -1852.66, 13.5144),
toVector3(1804.12, -1609.59, 13.4419),
toVector3(1660.32, -1510.09, 13.4877),
toVector3(1612.54, -1322.23, 17.4085),
toVector3(1778.93, -1286.59, 13.5744),
toVector3(1854.72, -1208.16, 20.9552),
toVector3(1659.95, -1158.07, 23.8315),
toVector3(1461.6, -1031.05, 23.7518),
toVector3(1277.71, -1036.63, 31.6085),
toVector3(1322.74, -1151.38, 23.7558),
toVector3(1194.26, -1334.15, 13.4953),
toVector3(1081.29, -1392.64, 13.7023),
toVector3(1034.65, -1555.27, 13.4591),
toVector3(1033.26, -1782.3, 13.6323),
toVector3(1262.27, -1855, 13.4887),
toVector3(1445.39, -1875.5, 13.4944),
toVector3(1742.23, -2168.78, 13.557),
toVector3(1943.35, -2169.25, 13.4741),
toVector3(1963.51, -1969.6, 13.5867),
toVector3(1824.2, -1886.48, 13.4287),
],
],
// GTA UG
[
],
// GTA IV
[
],
];
// ===========================================================================
function getRandomPizzaDeliveryStop(island) {
if(pizzaDeliveryStops[getServerGame()][island].length == 1) {
return 0;
}
return getRandom(0, pizzaDeliveryStops[getServerGame()][island].length-1);
}
// ===========================================================================
function showCurrentPizzaDeliveryStop(client) {
sendJobDeliveryPointToPlayer(client, getPizzaDeliveryStopPosition(getPlayerIsland(client), getPlayerData(client).jobRoute), getColourByName("deliveryPurple"))
}
// ===========================================================================
function playerArrivedAtPizzaDeliveryDestination(client) {
respawnVehicle(getPlayerData(client).jobDeliveryVehicle);
let payout = applyServerInflationMultiplier(getPizzaDeliveryPay(getPlayerData(client).jobDeliveryStart, getPlayerData(client).jobDeliveryStop));
getPlayerData(client).payDayAmount += payout;
messagePlayerNormal(client, `You delivered the pizza! Return to the pizza restaurant if you want to deliver another pizza.`, getColourByName("yellow"));
messagePlayerNormal(client, `You earned $${payout}. Your total paycheck of [#AAAAAA]${getPlayerData(client).payDayAmount} will be received in [#AAAAAA]${getTimeDisplayUntilPlayerPayDay(client)}`);
getPlayerData(client).jobDeliveryVehicle = false;
getPlayerData(client).jobDeliveryStart = 0;
getPlayerData(client).jobDeliveryStop = 0;
}
// ===========================================================================
function getPizzaDeliveryPay(startPoint, stopPoint) {
return Math.floor(getDistance(startPoint, stopPoint));
}
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: police.js
// DESC: Provides police officer job functions and usage
// TYPE: Job (JavaScript)
@@ -73,7 +73,7 @@ let patrolRoutes = [
],
];
// ---------------------------------------------------------------------------
// ===========================================================================
function policeTazerCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -99,7 +99,7 @@ function policeTazerCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function policeCuffCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -125,7 +125,7 @@ function policeCuffCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function policeArrestCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -151,7 +151,7 @@ function policeArrestCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function policeSearchCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -177,7 +177,7 @@ function policeSearchCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function policeDragCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -203,7 +203,7 @@ function policeDragCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function policeDetainCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
@@ -229,13 +229,13 @@ function policeDetainCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerArivedAtPolicePatrolPoint(client) {
if(isLastStopOnPolicePatrolRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
messagePlayerNormal(client, `You finished the ${getPatrolRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} patrol route! You earned $${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout}`, getColourByName("yellow"));
messagePlayerNormal(client, `You finished the ${getPatrolRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} patrol route! You earned $${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout*getServerData().inflationMultiplier}`, getColourByName("yellow"));
messagePlayerNormal(client, `You can either continue driving the patrol route again, or use /stoproute to end your patrol.`, getColourByName("yellow"));
getPlayerCurrentSubAccount(client).cash += getPolicePatrolRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout;
getPlayerCurrentSubAccount(client).cash += getPolicePatrolRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout*getServerData().inflationMultiplier;
updatePlayerCash(client);
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = 0;
@@ -250,4 +250,4 @@ function playerArivedAtPolicePatrolPoint(client) {
showCurrentPolicePatrolPoint(client);
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: taxi.js
// DESC: Provides taxi driver job functions and usage
// TYPE: Job (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: weapon.js
// DESC: Provides weapons dealer job functions and usage
// TYPE: Job (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: keybind.js
// DESC: Provides keybind handlers and functions
// TYPE: Server (JavaScript)
@@ -126,14 +126,15 @@ let bindableKeys = {
SDLK_RALT: "rightalt",
};
// ---------------------------------------------------------------------------
// ===========================================================================
function initKeyBindScript() {
logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Initializing key bind script ...");
logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Key bind script initialized!");
logToConsole(LOG_INFO, "[Asshat.KeyBind]: Initializing key bind script ...");
getGlobalConfig().keyBind = loadKeyBindConfiguration();
logToConsole(LOG_INFO, "[Asshat.KeyBind]: Key bind script initialized!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
@@ -163,7 +164,7 @@ function addKeyBindCommand(command, params, client) {
messagePlayerSuccess(client, `You binded the [#AAAAAA]${sdl.getKeyName(keyId)} [#FFFFFF]key to command: [#AAAAAA]/${tempCommand} ${tempParams}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removeKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
@@ -186,7 +187,7 @@ function removeKeyBindCommand(command, params, client) {
messagePlayerSuccess(client, `You removed the keybind for the [#AAAAAA]${sdl.getKeyName(keyId)} [#FFFFFF]key`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addPlayerKeyBind(client, keyId, tempCommand, tempParams) {
let keyBindData = new serverClasses.keyBindData(keyId, `${tempCommand} ${tempParams}`);
@@ -194,7 +195,7 @@ function addPlayerKeyBind(client, keyId, tempCommand, tempParams) {
sendAddAccountKeyBindToClient(client, getPlayerKeyBindForKey(client, keyId));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removePlayerKeyBind(client, keyId) {
quickDatabaseQuery(`DELETE FROM acct_hotkey WHERE acct_hotkey_acct = ${getPlayerData(client).accountData.databaseId} AND acct_hotkey_key = ${keyId}`);
@@ -206,7 +207,7 @@ function removePlayerKeyBind(client, keyId) {
sendRemoveAccountKeyBindToClient(client, keyId);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveKeyBindForCommand(client, command) {
let accountKeyBinds = getPlayerData(client).accountData.keyBinds;
@@ -218,7 +219,7 @@ function doesPlayerHaveKeyBindForCommand(client, command) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerKeyBindForCommand(client, command) {
let accountKeyBinds = getPlayerData(client).accountData.keyBinds;
@@ -230,7 +231,7 @@ function getPlayerKeyBindForCommand(client, command) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function doesPlayerHaveKeyBindForKey(client, key) {
let accountKeyBinds = getPlayerData(client).accountData.keyBinds;
@@ -242,7 +243,7 @@ function doesPlayerHaveKeyBindForKey(client, key) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerKeyBindForKey(client, key) {
let accountKeyBinds = getPlayerData(client).accountData.keyBinds;
@@ -254,7 +255,7 @@ function getPlayerKeyBindForKey(client, key) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerUsedKeyBind(client, key) {
if(!isPlayerLoggedIn(client)) {
@@ -281,7 +282,7 @@ function playerUsedKeyBind(client, key) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function sendAccountKeyBindsToClient(client) {
for(let i in getPlayerData(client).accountData.keyBinds) {
@@ -289,7 +290,7 @@ function sendAccountKeyBindsToClient(client) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getKeyIdFromParams(params) {
let tempParams = toLowerCase(toString(params));
@@ -306,4 +307,11 @@ function getKeyIdFromParams(params) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadKeyBindConfiguration() {
let keyBindConfigFile = loadTextFile("config/keybind.json");
return JSON.parse(keyBindConfigFile);
}
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: locale.js
// DESC: Provides locale structures, functions and usage
// TYPE: Server (JavaScript)

View File

@@ -2,13 +2,18 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: messaging.js
// DESC: Provides messaging functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
function initMessagingScript() {
logToConsole(LOG_INFO, "[Asshat.Messaging]: Initializing messaging script ...");
logToConsole(LOG_INFO, "[Asshat.Messaging]: Messaging script initialized successfully!");
}
// ===========================================================================
function messageAdminAction(messageText) {
messagePlayerNormal(null, `⚠️ ${messageText}`, getColourByName("orange"));
@@ -18,7 +23,7 @@ function messageAdminAction(messageText) {
//logToConsole(LOG_INFO, `[Asshat.Messaging] ADMIN: ${messageText}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
if(isConsole(client)) {
@@ -35,7 +40,7 @@ function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
//}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messageAdmins(messageText, colour = COLOUR_WHITE) {
let clients = getClients();
@@ -51,7 +56,7 @@ function messageAdmins(messageText, colour = COLOUR_WHITE) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerError(client, messageText) {
if(isConsole(client)) {
@@ -66,7 +71,7 @@ function messagePlayerError(client, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerSyntax(client, messageText) {
if(isConsole(client)) {
@@ -81,7 +86,7 @@ function messagePlayerSyntax(client, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerAlert(client, messageText) {
if(isConsole(client)) {
@@ -96,7 +101,7 @@ function messagePlayerAlert(client, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerSuccess(client, messageText) {
if(isConsole(client)) {
@@ -111,7 +116,7 @@ function messagePlayerSuccess(client, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerInfo(client, messageText) {
if(isConsole(client)) {
@@ -126,7 +131,7 @@ function messagePlayerInfo(client, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerTip(client, messageText) {
if(isConsole(client)) {
@@ -141,25 +146,25 @@ function messagePlayerTip(client, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerTalk(client, talkingClient, messageText) {
messagePlayerNormal(client, `${getClientSubAccountName(talkingClient)} says: ${messageText}`, getColourByType("talkMessage"));
messagePlayerNormal(client, `🗣️ ${getClientSubAccountName(talkingClient)} says: ${messageText}`, getColourByType("talkMessage"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerWhisper(client, whisperingClient, messageText) {
messagePlayerNormal(client, `${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`, getColourByType("whisperMessage"));
messagePlayerNormal(client, `🤫 ${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`, getColourByType("whisperMessage"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerShout(client, shoutingClient, messageText) {
messagePlayerNormal(client, `${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`, getColourByType("shoutMessage"));
messagePlayerNormal(client, `🗣️ ${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`, getColourByType("shoutMessage"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerDoAction(client, doingActionClient, messageText) {
if(!isClientFromDiscord(client)) {
@@ -167,22 +172,22 @@ function messagePlayerDoAction(client, doingActionClient, messageText) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerMeAction(client, doingActionClient, messageText) {
messagePlayerNormal(client, `${getClientSubAccountName(doingActionClient)} ${messageText}`, getColourByType("meActionMessage"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerClanChat(client, clanChattingClient, messageText) {
messagePlayerNormal(client, `(${getClientSubAccountClanRank(clanChattingClient)}) ${getClientSubAccountName(clanChattingClient)} says (clan): ${messageText}`, getColourByType("clanChatMessage"));
messagePlayerNormal(client, `👥 (${getClientSubAccountClanRank(clanChattingClient)}) ${getClientSubAccountName(clanChattingClient)} says (clan): ${messageText}`, getColourByType("clanChatMessage"));
}
// ---------------------------------------------------------------------------
// ===========================================================================
function messagePlayerAdminChat(client, adminChattingClient, messageText) {
messagePlayerNormal(client, `[ADMIN CHAT] [#AAAAAA]${getPlayerData(adminChattingClient).accountData.staffTitle} [#CCCCCC]${getPlayerData(adminChattingClient).accountData.name}: [#FFFFFF]${messageText}`, getColourByType("orange"));
messagePlayerNormal(client, `🛡️ [ADMIN CHAT] [#AAAAAA]${getPlayerData(adminChattingClient).accountData.staffTitle} [#CCCCCC]${getPlayerData(adminChattingClient).accountData.name}: [#FFFFFF]${messageText}`, getColourByType("orange"));
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,45 +2,45 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: misc.js
// DESC: Provides any uncategorized functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// ---------------------------------------------------------------------------
// ===========================================================================
function initMiscScript() {
logToConsole(LOG_DEBUG, "[Asshat.Misc]: Initializing misc script ...");
logToConsole(LOG_DEBUG, "[Asshat.Misc]: Misc script initialized successfully!");
logToConsole(LOG_INFO, "[Asshat.Misc]: Initializing misc script ...");
logToConsole(LOG_INFO, "[Asshat.Misc]: Misc script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPositionCommand(command, params, client) {
let position = client.player.position;
let position = getPlayerPosition(client);
messagePlayerNormal(client, `Your position is: ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s position is: ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`);
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function toggleMouseCursorCommand(command, params, client) {
sendPlayerMouseCursorToggle(client);
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function toggleMouseCameraCommand(command, params, client) {
sendPlayerMouseCameraToggle(client);
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setNewCharacterSpawnPositionCommand(command, params, client) {
let position = client.player.position;
@@ -51,7 +51,7 @@ function setNewCharacterSpawnPositionCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setNewCharacterMoneyCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -68,7 +68,7 @@ function setNewCharacterMoneyCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setNewCharacterSkinCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -89,7 +89,7 @@ function setNewCharacterSkinCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function submitIdeaCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -103,7 +103,7 @@ function submitIdeaCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function submitBugReportCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -117,17 +117,9 @@ function submitBugReportCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function enterExitPropertyCommand(command, params, client) {
if(getPlayerData(client).pedState != AG_PEDSTATE_READY) {
if(getPlayerData(client).pedState == AG_PEDSTATE_ENTERINGVEHICLE) {
sendPlayerClearPedState(client);
} else {
return false;
}
}
if(isPlayerInAnyHouse(client)) {
let inHouse = getServerData().houses[getPlayerHouse(client)];
if(getDistance(inHouse.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) {
@@ -135,6 +127,7 @@ function enterExitPropertyCommand(command, params, client) {
meActionToNearbyPlayers(client, "tries to open the house door but fails because it's locked");
return false;
}
clearPlayerStateToEnterExitProperty(client);
getPlayerData(client).pedState = AG_PEDSTATE_EXITINGPROPERTY;
meActionToNearbyPlayers(client, "opens the door and exits the house");
fadeCamera(client, false, 1.0);
@@ -154,8 +147,8 @@ function enterExitPropertyCommand(command, params, client) {
}, 1000);
}, 1100);
removeEntityData(client, "ag.inHouse");
return true;
}
return true;
}
if(isPlayerInAnyBusiness(client)) {
@@ -166,6 +159,7 @@ function enterExitPropertyCommand(command, params, client) {
return false;
}
getPlayerData(client).pedState = AG_PEDSTATE_EXITINGPROPERTY;
clearPlayerStateToEnterExitProperty(client)
meActionToNearbyPlayers(client, "opens the door and exits the business");
fadeCamera(client, false, 1.0);
disableCityAmbienceForPlayer(client);
@@ -185,13 +179,13 @@ function enterExitPropertyCommand(command, params, client) {
}, 1100);
removeEntityData(client, "ag.inBusiness");
logToConsole(LOG_DEBUG, `[Asshat.Misc] ${getPlayerDisplayForConsole(client)} entered business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
return true;
}
return true;
}
if(getServerData().businesses.length > 0) {
let closestBusinessId = getClosestBusinessEntrance(getPlayerPosition(client));
let closestBusiness = getBusinessData(closestBusinessId)
let closestBusiness = getBusinessData(closestBusinessId);
if(getDistance(closestBusiness.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) {
if(!doesBusinessHaveInterior(closestBusinessId)) {
messagePlayerAlert(client, "This business does not have an interior.");
@@ -204,8 +198,8 @@ function enterExitPropertyCommand(command, params, client) {
return false;
}
clearPlayerStateToEnterExitProperty(client)
meActionToNearbyPlayers(client, "opens the door and enters the business");
getPlayerData(client).pedState = AG_PEDSTATE_ENTERINGPROPERTY;
fadeCamera(client, false, 1.0);
disableCityAmbienceForPlayer(client);
@@ -240,8 +234,8 @@ function enterExitPropertyCommand(command, params, client) {
return false;
}
clearPlayerStateToEnterExitProperty(client)
meActionToNearbyPlayers(client, "opens the door and enters the house");
getPlayerData(client).pedState = AG_PEDSTATE_ENTERINGPROPERTY;
fadeCamera(client, false, 1.0);
disableCityAmbienceForPlayer(client);
@@ -265,12 +259,14 @@ function enterExitPropertyCommand(command, params, client) {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function loadGameFixesResource() {
switch(getServerGame()) {
case GAME_GTA_III:
findResourceByName("asshat-gta3").start();
if(findResourceByName("asshat-gta3") != null) {
findResourceByName("asshat-gta3").start();
}
break;
default:
@@ -279,7 +275,7 @@ function loadGameFixesResource() {
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerInfoCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -296,7 +292,7 @@ function getPlayerInfoCommand(command, params, client) {
messagePlayerInfo(client, `[#AAAAAA][Player Info] [#FFFFFF]Account: [#AAAAAA]${getPlayerData(targetClient).accountData.name}[${getPlayerData(targetClient).accountData.databaseId}], [#FFFFFF]Character: [#AAAAAA]${getCharacterFullName(client)}[${getPlayerCurrentSubAccount(client).databaseId}], [#FFFFFF]Connected: [#AAAAAA]${getTimeDifferenceDisplay(Math.ceil(sdl.tick/1000), getPlayerData(targetClient).connectTime)} ago, [#FFFFFF]Game Version: [#AAAAAA]${targetClient.gameVersion}, [#FFFFFFF]Client Version: [#AAAAAA]${getPlayerData(targetClient).clientVersion}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerChangeAFKState(client, afkState) {
if(afkState) {
@@ -306,4 +302,41 @@ function playerChangeAFKState(client, afkState) {
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function checkPlayerSpawning() {
let clients = getClients();
for(let i in clients) {
if(!isConsole(clients[i])) {
if(getPlayerData(clients[i])) {
if(getPlayerData(clients[i]).loggedIn) {
if(!getPlayerData(clients[i]).ped) {
if(clients[i].player != null) {
//getPlayerData(clients[i]).ped = clients[i].player;
onPlayerSpawn(clients[i].player);
}
}
}
}
}
}
}
// ===========================================================================
function showPlayerPrompt(client, promptType, promptMessage, promptTitle) {
if(promptType == AG_PROMPT_NONE) {
return false;
}
getPlayerData(client).promptType = promptType;
if(canPlayerUseGUI(client)) {
showPlayerPromptGUI(client, promptMessage, promptTitle);
} else {
messagePlayerNormal(client, `${promptMessage}`);
messagePlayerInfo(client, `[#FFFFFF]Use [#AAAAAA]/yes or [#AAAAAA]/no`);
}
}
// ===========================================================================

View File

@@ -2,16 +2,18 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: moderation.js
// DESC: Provides moderation commands, functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initModerationScript() {
logToConsole(LOG_INFO, "[Asshat.Moderation]: Initializing moderation script ...");
logToConsole(LOG_INFO, "[Asshat.Moderation]: Moderation script initialized successfully!");
}
// ---------------------------------------------------------------------------
// ===========================================================================
function kickClientCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -37,7 +39,7 @@ function kickClientCommand(command, params, client) {
targetClient.disconnect();
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setClientStaffTitleCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -68,7 +70,7 @@ function setClientStaffTitleCommand(command, params, client) {
targetClient.disconnect();
}
// ---------------------------------------------------------------------------
// ===========================================================================
function muteClientCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -91,10 +93,10 @@ function muteClientCommand(command, params, client) {
}
messageAdminAction(`${targetClient.name} has been muted by an admin!`);
setEntityData(targetClient, "ag.muted", true, false);
getPlayerData(targetClient).muted = true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function unMuteClientCommand(command, params, client) {
@@ -118,10 +120,10 @@ function unMuteClientCommand(command, params, client) {
}
messageAdminAction(`${targetClient.name} has been unmuted by an admin!`);
removeEntityData(targetClient, "ag.muted");
getPlayerData(targetClient).muted = false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function freezeClientCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -144,10 +146,11 @@ function freezeClientCommand(command, params, client) {
}
messageAdminAction(`${toString(targetClient.name)} has been frozen by an admin!`);
setPlayerFrozenState(client, state);
//setPlayerFrozenState(client, state);
setPlayerControlState(client, false);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function unFreezeClientCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -170,10 +173,11 @@ function unFreezeClientCommand(command, params, client) {
}
messageAdminAction(`${toString(targetClient.name)} has been un-frozen by an admin!`);
sendPlayerFrozenState(client, false);
//sendPlayerFrozenState(client, false);
setPlayerControlState(client, true);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function gotoPlayerCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -198,7 +202,7 @@ function gotoPlayerCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported to [#AAAAAA]${targetClient.name}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function gotoVehicleCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -216,13 +220,13 @@ function gotoVehicleCommand(command, params, client) {
setTimeout(function() {
setPlayerPosition(client, getPosAbovePos(getVehiclePosition(vehicle), 3.0));
setPlayerInterior(client, 0);
setPlayerDimension(client, getVehicleDimension(vehicle));
setPlayerDimension(client, getElementDimension(vehicle));
}, 500);
messagePlayerSuccess(client, `You teleported to a [#CC22CC]${getVehicleName(vehicle)} [#AAAAAA](ID ${vehicle.id})`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function gotoBusinessCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -247,7 +251,32 @@ function gotoBusinessCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported to business [#0099FF]${getBusinessData(businessId).name} [#AAAAAA](ID ${businessId})`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function gotoGameLocationCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let gameLocationId = getGameLocationFromParams(params)
if(!gameLocationId) {
messagePlayerError(client, "That game location doesn't exist!");
return false;
}
setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
setTimeout(function() {
setPlayerPosition(client, getGameData().locations[gameLocationId][1]);
setPlayerInterior(client, 0);
setPlayerDimension(client, 0);
}, 500);
messagePlayerSuccess(client, `You teleported to game location [#AAAAAA]${getGameData().locations[gameLocationId][0]}`);
}
// ===========================================================================
function gotoHouseCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -272,7 +301,7 @@ function gotoHouseCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported to business [#0099FF]${getHouseData(houseId).description} [#AAAAAA](ID ${houseId})`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function gotoJobLocationCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -304,7 +333,7 @@ function gotoJobLocationCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported to location [#AAAAAA]${jobLocationId} [#FFFFFF]for the [#AAAAAA]${getJobData(jobId).name} [#FFFFFF]job`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function gotoPositionCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -331,7 +360,7 @@ function gotoPositionCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported to coordinates [#AAAAAA]${x}, ${y}, ${z} with interior ${int} and dimension ${vw}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function teleportForwardCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -344,7 +373,7 @@ function teleportForwardCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported forward ${params} meters`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function teleportBackwardCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -357,7 +386,7 @@ function teleportBackwardCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported backward [#AAAAAA]${params} [#FFFFFF]meters`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function teleportLeftCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -370,7 +399,7 @@ function teleportLeftCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported left [#AAAAAA]${params} [#FFFFFF]meters`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function teleportUpCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -383,7 +412,7 @@ function teleportUpCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported up [#AAAAAA]${params} [#FFFFFF]meters`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function teleportDownCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -396,7 +425,7 @@ function teleportDownCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported down [#AAAAAA]${params} [#FFFFFF]meters`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function teleportRightCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -409,7 +438,7 @@ function teleportRightCommand(command, params, client) {
messagePlayerSuccess(client, `You teleported right [#AAAAAA]${params} [#FFFFFF]meters`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerInteriorCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -434,7 +463,7 @@ function playerInteriorCommand(command, params, client) {
messagePlayerSuccess(client, `You set ${targetClient.name}'s interior to [#AAAAAA]${interiorId}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function playerVirtualWorldCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -459,7 +488,7 @@ function playerVirtualWorldCommand(command, params, client) {
messagePlayerSuccess(client, `You set [#AAAAAA]${targetClient.name}'s [#FFFFFF]virtual world to [#AAAAAA]${dimensionId}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -493,7 +522,7 @@ function getPlayerCommand(command, params, client) {
messagePlayerAlert(targetClient, `An admin has teleported you to their location`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function addStaffFlagCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -527,7 +556,7 @@ function addStaffFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You have ${getBoolRedGreenInlineColour(true)}given [#AAAAAA]${targetClient.name} [#FFFFFF]the [#AAAAAA]${flagName} [#FFFFFF]staff flag`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function takeStaffFlagCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -561,7 +590,7 @@ function takeStaffFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You have ${getBoolRedGreenInlineColour(false)}taken [#FFFFFF]the [#AAAAAA]${flagName} [#FFFFFF]staff flag from [#AAAAAA]${targetClient.name}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function clearStaffFlagsCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -595,7 +624,7 @@ function clearStaffFlagsCommand(command, params, client) {
messagePlayerSuccess(client, `You have removed all staff flags from [#AAAAAA]${targetClient.name}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getStaffFlagsCommand(command, params, client) {
if(getCommand(command).requireLogin) {
@@ -636,7 +665,7 @@ function getStaffFlagsCommand(command, params, client) {
messagePlayerInfo(client, `[#FFFFFF]${targetClient.name}'s staff flags: [#AAAAAA]${tempStaffFlags.join("[#FFFFFF], [#AAAAAA]")}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function allStaffFlagsCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -656,7 +685,7 @@ function allStaffFlagsCommand(command, params, client) {
messagePlayerInfo(client, `[#FFFFFF]Staff flags: [#AAAAAA]${getServerBitFlagKeys().join("[#FFFFFF], [#AAAAAA]")}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function givePlayerMoneyCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -679,4 +708,4 @@ function givePlayerMoneyCommand(command, params, client) {
messagePlayerAlert(client, `An admin gave you [#AAAAAA]$${amount}`);
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: native.js
// DESC: Provides util function to wrap mod-specific stuff
// TYPE: Server (JavaScript)
@@ -10,107 +10,98 @@
// Use data for each because args are probably gonna be way different for each mod
// ---------------------------------------------------------------------------
function getServerGame() {
return server.game;
}
// ---------------------------------------------------------------------------
function agGetPedPosition(ped) {
return ped.position;
}
// ---------------------------------------------------------------------------
function agGetPedRotation(ped) {
return ped.heading;
}
// ---------------------------------------------------------------------------
function agGetPedSkin(ped) {
return ped.modelIndex;
}
// ---------------------------------------------------------------------------
function agSetPedSkin(ped, skinId) {
return ped.modelIndex = skinId;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerPosition(client) {
if(client.player != null) {
return client.player.position;
if(getServerGame() == GAME_GTA_IV) {
return getPlayerData(client).syncPosition;
} else {
if(client.player != null) {
return client.player.position;
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerPosition(client, position) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s position to ${position.x}, ${position.y}, ${position.z}`);
sendPlayerSetPosition(client, position);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerHeading(client) {
return client.player.heading;
if(getServerGame() == GAME_GTA_IV) {
return getPlayerData(client).syncHeading;
} else {
if(client.player != null) {
return client.player.heading;
}
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerHeading(client, heading) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s heading to ${heading}`);
sendPlayerSetHeading(client, heading);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerVehicle(client) {
return client.player.vehicle;
if(getServerGame() == GAME_GTA_IV) {
return getPlayerData().syncVehicle;
} else {
if(client.player.vehicle) {
return client.player.vehicle;
}
}
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerDimension(client) {
return client.player.dimension;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerInterior(client) {
if(getPlayerData(client)) {
if(getPlayerCurrentSubAccount(client)) {
return getPlayerCurrentSubAccount(client).interior;
}
}
return getPlayerCurrentSubAccount(client).interior || 0;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerDimension(client, dimension) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
client.player.dimension = dimension;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerInterior(client, interior) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
sendPlayerSetInterior(client, interior);
getPlayerCurrentSubAccount(client).interior = interior;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerInAnyVehicle(client) {
return (client.player.vehicle != null);
if(getServerGame() == GAME_GTA_IV) {
return (getPlayerData().syncVehicle != null);
} else {
return (client.player.vehicle != null);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerVehicleSeat(client) {
if(!getPlayerVehicle(client)) {
if(!isPlayerInAnyVehicle(client)) {
return false;
}
@@ -123,39 +114,40 @@ function getPlayerVehicleSeat(client) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerSpawned(client) {
return (client.player != null);
return getPlayerData(client).spawned;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getVehiclePosition(vehicle) {
return vehicle.position;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getVehicleHeading(vehicle) {
return vehicle.heading;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getVehicleSyncer(vehicle) {
return getElementSyncer(vehicle);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getVehicleForNetworkEvent(vehicle) {
return vehicle;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function deleteGameElement(element) {
logToConsole(LOG_DEBUG, `Destroying game element ${element.id} (Type: ${element.type})`);
if(element != null) {
destroyElement(element);
return true;
@@ -163,81 +155,153 @@ function deleteGameElement(element) {
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function isPlayerInFrontVehicleSeat(client) {
return (getPlayerVehicleSeat(client) == 0 || getPlayerVehicleSeat(client) == 1);
}
// ---------------------------------------------------------------------------
// ===========================================================================
function removePlayerFromVehicle(client) {
logToConsole(LOG_DEBUG, `Removing ${getPlayerDisplayForConsole(client)} from their vehicle`);
sendPlayerRemoveFromVehicle(client);
return true;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerSkin(client, skin) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${skin} (${getSkinNameFromId(skin)})`);
client.player.modelIndex = skin;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerSkin(client) {
return client.player.modelIndex;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerHealth(client, health) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${health}`);
sendPlayerSetHealth(client, health);
}
// ===========================================================================
function getPlayerHealth(client) {
return client.player.health;
}
// ===========================================================================
function setPlayerArmour(client, armour) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${armour}`);
sendPlayerSetArmour(client, armour);
}
// ===========================================================================
function getPlayerArmour(client) {
return client.player.armour;
}
// ===========================================================================
function setPlayerCash(client, amount) {
getPlayerCurrentSubAccount(client).cash = amount;
updatePlayerCash(client);
}
// ===========================================================================
function givePlayerCash(client, amount) {
getPlayerCurrentSubAccount(client).cash = getPlayerCurrentSubAccount(client).cash + amount;
updatePlayerCash(client);
}
// ===========================================================================
function takePlayerCash(client, amount) {
getPlayerCurrentSubAccount(client).cash = getPlayerCurrentSubAccount(client).cash - amount;
updatePlayerCash(client);
}
// ===========================================================================
function disconnectPlayer(client) {
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
client.disconnect();
return false;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getElementSyncer(element) {
return getClients()[element.syncer];
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerWeaponAmmo(client) {
client.player.weaponAmmunition + client.player.weaponClipAmmunition;
return client.player.weaponAmmunition;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setPlayerVelocity(client, velocity) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`);
client.player.velocity = velocity;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getPlayerVelocity(client, velocity) {
return client.player.velocity;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function getElementDimension(element) {
return element.dimension;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function setElementDimension(element, dimension) {
return element.dimension = dimension;
}
// ---------------------------------------------------------------------------
// ===========================================================================
function givePlayerHealth(client, amount) {
if(getPlayerHealth(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to 100`);
setPlayerHealth(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client)+amount}`);
setPlayerHealth(client, getPlayerHealth(client)+amount);
}
}
// ---------------------------------------------------------------------------
// ===========================================================================
function givePlayerArmour(client, amount) {
if(getPlayerArmour(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to 100`);
setPlayerArmour(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client)+amount}`);
setPlayerArmour(client, getPlayerArmour(client)+amount);
}
}
// ===========================================================================
function getServerGame() {
return getGame();
}
// ===========================================================================

View File

@@ -2,118 +2,12 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: npc.js
// DESC: Provides NPC usage and functions
// TYPE: Server (JavaScript)
// ===========================================================================
const triggerSource = {
player,
npc,
vehicle,
business,
house,
};
// ---------------------------------------------------------------------------
const NPC = {
Trigger: {
farProximity, // Comes within a far distance of NPC
mediumProximity, // Comes within a medium distance of NPC
nearProximity, // Comes within a close distance of NPC
enterLineOfSight, // Enters the NPC's line of sight
exitLineOfSight, // Leaves the NPC's line of sight
pedCollision, // Bumps into ped on foot
vehicleCollision, // Bumps into ped with a vehicle
shootGun, // Shoots a gun (target isn't a factor, it's just about only shooting a gun in general)
swingMelee, // Swings a melee weapon (target doesnt matter, it's just about only swinging a melee weapon in general)
hotwireVehicleStart, // Begin attempt to hotwire a vehicle
hotwireVehicleFail, // Failed to hotwire a vehicle
hotwireVehicleSucceed, // Succeeded at hotwiring a vehicle
vehicleAlarmStart, // Vehicle alarm goes off
vehicleAlarmStop, // Vehicle alarm shuts off (disabled, battery dead, damaged, or just turned off legitly)
sirenStart, // Any vehicle with a siren that gets activated
sirenStop, // Any vehicle with a siren that gets deactivated
vehicleEnter, // Enters any vehicle
vehicleExit, // Exits any vehicle
propertyEnter, // Enters any interior
propertyExit, // Exits any interior
attackedByMelee, // Any element is attacked by melee weapon
attackedByGun, // Any element is attacked by gun
attackedByFist, // Any element is attacked by fist
},
Condition: {
isInLineOfSight,
isFarProximity,
isMediumProximity,
isNearProximity,
isEnemyClan,
isAllyClan,
isSameClan,
isNotInClan,
isLawEnforcement,
isFirefighter,
isParamedic,
isCriminal,
hasWantedLevel,
isSelfVehicle,
isPlayerVehicle,
isOtherVehicle,
isClanVehicle,
isEmergencyVehicle,
isPoliceVehicle,
isDriver,
isInFrontSeat,
isInSeatId,
vehicleLocked,
vehicleHotwired,
isPistol,
isShotgun,
isAutomatic,
isRifle,
isAssaultRifle,
isSniper,
isRPG,
isFlameThrower,
isTalking,
isShouting,
isWhispering,
},
Response: {
shout,
talk,
whisper,
switchWeapon,
shootWeapon,
aimWeapon,
fleeSprint,
fleeWalk,
fleeRun,
attackMelee,
attackFist,
walkToward,
runToward,
sprintToward,
crouch,
phoneCall,
walkieTalkieMessage,
switchRadioStation,
toggleSiren,
fleeTo,
driveTo,
enterVehicle,
exitVehicle,
pullOutOfVehicle,
enterProperty,
}
};
// ---------------------------------------------------------------------------
function npcTrigger(triggerName, triggerSource) {
}
// ---------------------------------------------------------------------------
// ===========================================================================

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: biker.js
// DESC: Provides biker NPC interaction and functionality
// TYPE: Server (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: drugdealer.js
// DESC: Provides drug dealer NPC interaction and functionality
// TYPE: Server (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: firefighter.js
// DESC: Provides firefighter NPC interaction and functionality
// TYPE: Server (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: gangsta.js
// DESC: Provides street gang/hoodlum NPC interaction and functionality
// TYPE: Server (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: mafia.js
// DESC: Provides mafia/mafioso NPC interaction and functionality
// TYPE: Server (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: normal.js
// DESC: Provides normal/generic civilian NPC interaction and functionality
// TYPE: Server (JavaScript)

View File

@@ -2,7 +2,7 @@
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// ===========================================================================
// FILE: paramedic.js
// DESC: Provides paramedic NPC interaction and functionality
// TYPE: Server (JavaScript)

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