Compare commits
310 Commits
separate-r
...
gtaiv
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0142e369c9 | ||
|
|
dc79b4b12a | ||
|
|
64b5ea2fba | ||
|
|
808cdfc359 | ||
|
|
4b3c313cef | ||
|
|
b04c2121ba | ||
|
|
2e6c0b05f5 | ||
|
|
88779b3229 | ||
|
|
aa05a066e2 | ||
|
|
53ebd0ebd5 | ||
|
|
9e4f1145f7 | ||
|
|
7b7c697f87 | ||
|
|
82c3412598 | ||
|
|
87fed4bce9 | ||
|
|
6e0bf2a8ee | ||
|
|
28111c4771 | ||
|
|
d0748c9152 | ||
|
|
7139f0e4bc | ||
|
|
c1c4820c45 | ||
|
|
c90932a602 | ||
|
|
9cf0dc38c7 | ||
|
|
7a71c08c3d | ||
|
|
beec73daed | ||
|
|
47c1c277af | ||
|
|
32a2a02b52 | ||
|
|
efbcc8b1f9 | ||
|
|
8320acb9ec | ||
|
|
2c67147239 | ||
|
|
da722de87d | ||
|
|
3d55e70657 | ||
|
|
9b4ad628c8 | ||
|
|
e2ec0b85b6 | ||
|
|
502b211840 | ||
|
|
13c039d7a9 | ||
|
|
3a87131185 | ||
|
|
710f41f9da | ||
|
|
7ccbff0ae9 | ||
|
|
7ae1b8bf48 | ||
|
|
5be864f77c | ||
|
|
f301469072 | ||
|
|
e6f5e31e98 | ||
|
|
98769435be | ||
|
|
4fac1cb350 | ||
|
|
364e3ef3ab | ||
|
|
8b1fcc1cc1 | ||
|
|
48a5d6a543 | ||
|
|
5e82edbf0d | ||
|
|
a96b7e6e2e | ||
|
|
d30116cac6 | ||
|
|
4621048f0f | ||
|
|
b27effbfcd | ||
|
|
b0602bb0ca | ||
|
|
6981cfdc5b | ||
|
|
cb0a0f518e | ||
|
|
6db5cad667 | ||
|
|
703843549c | ||
|
|
2d3eb800b3 | ||
|
|
fd10ae6665 | ||
|
|
521b0a406c | ||
|
|
e94da0eb95 | ||
|
|
8e9f8eb7d8 | ||
|
|
348fb2e469 | ||
|
|
49aa8c35fe | ||
|
|
dc633e7e83 | ||
|
|
08b065a650 | ||
|
|
54cfcdcdc5 | ||
|
|
425f405897 | ||
|
|
7569aff3d4 | ||
|
|
d2452979f8 | ||
|
|
7ccc9d92cc | ||
|
|
0b54145764 | ||
|
|
ab4339c46b | ||
|
|
215124a0bc | ||
|
|
f6614ff92b | ||
|
|
f69ca2ac59 | ||
|
|
149e3f3fa5 | ||
|
|
ad5dd488b9 | ||
|
|
8de8a30d1f | ||
|
|
a1e9ad0b42 | ||
|
|
0fd711dc0b | ||
|
|
3a501f0b39 | ||
|
|
af699acd24 | ||
|
|
258af788c7 | ||
|
|
17481001b0 | ||
|
|
2c28b17047 | ||
|
|
2c6401e9ed | ||
|
|
bb4b821db7 | ||
|
|
b7bc0ca8a8 | ||
|
|
a8843dba20 | ||
|
|
945a44506b | ||
|
|
784129e8e6 | ||
|
|
1f381732b3 | ||
|
|
277c4a2697 | ||
|
|
73fbf6f655 | ||
|
|
da65e74ef1 | ||
|
|
900ec4ab39 | ||
|
|
f5b388b045 | ||
|
|
9cedecf40c | ||
|
|
f4adc3c3e9 | ||
|
|
2efccb638f | ||
|
|
225d78c60d | ||
|
|
4d607d3c5d | ||
|
|
4ede78bd7c | ||
|
|
468cd46750 | ||
|
|
dfaf611a1e | ||
|
|
f03502e380 | ||
|
|
5973553171 | ||
|
|
6970d40f42 | ||
|
|
13cf75262a | ||
|
|
c486c00a02 | ||
|
|
3f0e8548d8 | ||
|
|
c28815b61c | ||
|
|
206f7e691e | ||
|
|
afdbbdbaa5 | ||
|
|
2102d7a0d7 | ||
|
|
d1bdc069fd | ||
|
|
42bb527844 | ||
|
|
da6d12c8d7 | ||
|
|
07e65591d0 | ||
|
|
c3d0f826db | ||
|
|
e65cd0b4be | ||
|
|
ab697557ef | ||
|
|
73757ebbc5 | ||
|
|
6b73be287b | ||
|
|
26e5617ccb | ||
|
|
c73c8b6b9a | ||
|
|
ef3c8049ea | ||
|
|
2b5307077f | ||
|
|
e6be16c30f | ||
|
|
d30a3bcb29 | ||
|
|
2eb58fa8cf | ||
|
|
8de1204ed7 | ||
|
|
b4b3996e00 | ||
|
|
a04b442df6 | ||
|
|
74062a7d36 | ||
|
|
d04b5549a6 | ||
|
|
59e704ee19 | ||
|
|
7a89d8bcba | ||
|
|
be237dc0aa | ||
|
|
8785255366 | ||
|
|
a69aec9222 | ||
|
|
a3fe0f8708 | ||
|
|
9e3f5d4a8f | ||
|
|
11685eacf6 | ||
|
|
6b914f8056 | ||
|
|
9be2a7a95b | ||
|
|
b1d8beb23b | ||
|
|
25e79b26d6 | ||
|
|
140749e8c0 | ||
|
|
25543b5f07 | ||
|
|
8ca7a8bdfd | ||
|
|
da7e0c35d1 | ||
|
|
99a21f9892 | ||
|
|
945d44d878 | ||
|
|
a52590ea56 | ||
|
|
713022da47 | ||
|
|
8b66e7914d | ||
|
|
e52c3a0e8d | ||
|
|
f83a602047 | ||
|
|
34ec6e60f8 | ||
|
|
883cac8f47 | ||
|
|
e6be6d7241 | ||
|
|
5c5e2d027e | ||
|
|
03febd8076 | ||
|
|
a37262b32f | ||
|
|
805f843e05 | ||
|
|
087c03cae4 | ||
|
|
a83a4f91af | ||
|
|
8e587b13ad | ||
|
|
cd87b90ac7 | ||
|
|
362f20a059 | ||
|
|
315bd5f926 | ||
|
|
78f53f7af7 | ||
|
|
09bbca49db | ||
|
|
0625dcd5c1 | ||
|
|
1e5ea4fd87 | ||
|
|
74bc330596 | ||
|
|
e67b3eeb23 | ||
|
|
d5d7f8b98f | ||
|
|
2bb4e9a23b | ||
|
|
1d61ec26db | ||
|
|
8d620882ce | ||
|
|
9285cf6fd3 | ||
|
|
8e24b35c29 | ||
|
|
2a0f2443d4 | ||
|
|
9539eb20f8 | ||
|
|
35251372c5 | ||
|
|
179556b878 | ||
|
|
eb582a666d | ||
|
|
2587ee6cdf | ||
|
|
340c96eab2 | ||
|
|
17c342be54 | ||
|
|
0595f25f3f | ||
|
|
a9f82b4150 | ||
|
|
df949a35f7 | ||
|
|
c5cef51655 | ||
|
|
334a7637f6 | ||
|
|
89bcbf9a8a | ||
|
|
0ec8608b2b | ||
|
|
9c937b76fb | ||
|
|
20502f5bca | ||
|
|
e17f6f3c4e | ||
|
|
cb86419f2b | ||
|
|
2f7f3a1b00 | ||
|
|
dd3f027c1e | ||
|
|
beb7e2070c | ||
|
|
ff6768d64d | ||
|
|
72562688e7 | ||
|
|
defee4c76e | ||
|
|
66840a0de9 | ||
|
|
ab7c73d7da | ||
|
|
b86d2c7bcb | ||
|
|
3fe5894499 | ||
|
|
ea018c7b65 | ||
|
|
d71335ed5f | ||
|
|
5f687b7b01 | ||
|
|
91bfed4f8e | ||
|
|
725d7cff66 | ||
|
|
3484602114 | ||
|
|
bfc434a38f | ||
|
|
1d59183811 | ||
|
|
14148da429 | ||
|
|
a13dfa220d | ||
|
|
e017313b58 | ||
|
|
acd03cc124 | ||
|
|
69dc299621 | ||
|
|
2b34fb708a | ||
|
|
8cceaa7e6a | ||
|
|
2181550618 | ||
|
|
763241d2ce | ||
|
|
0f6ab26ca9 | ||
|
|
ad672a5912 | ||
|
|
49e0c4afeb | ||
|
|
7883d3503a | ||
|
|
43e41a1139 | ||
|
|
ad1f7a3c7f | ||
|
|
d90dc8e7b8 | ||
|
|
644a188929 | ||
|
|
7c2249aa5d | ||
|
|
ae1185856d | ||
|
|
732d268e04 | ||
|
|
931a0d5ab0 | ||
|
|
13267a7e32 | ||
|
|
d7a66fb503 | ||
|
|
5ba69fca4d | ||
|
|
98e936fc71 | ||
|
|
71e13e2323 | ||
|
|
51c01b9c94 | ||
|
|
6fa3eb9997 | ||
|
|
bd0a994225 | ||
|
|
3ea19927a5 | ||
|
|
16fd26dc9a | ||
|
|
4c8630c174 | ||
|
|
e260d6176c | ||
|
|
7b77c99fb0 | ||
|
|
f121b473aa | ||
|
|
e7e2fb16d1 | ||
|
|
bbc41a5f3f | ||
|
|
cb029ff2e8 | ||
|
|
a403530f11 | ||
|
|
6d826c48cc | ||
|
|
87ca42c48a | ||
|
|
90face486b | ||
|
|
f1affc2f8f | ||
|
|
78005a7d17 | ||
|
|
70a1520f56 | ||
|
|
7373f1454e | ||
|
|
35f9e1fe3d | ||
|
|
66f351a16e | ||
|
|
fe42541dab | ||
|
|
b7271029f7 | ||
|
|
326286bdc5 | ||
|
|
f9701e81a7 | ||
|
|
282832b30a | ||
|
|
53eaddbfce | ||
|
|
731d0d6905 | ||
|
|
f0d5d6b361 | ||
|
|
d9c007c4bc | ||
|
|
519796fd60 | ||
|
|
318a01eea1 | ||
|
|
02e80a47ab | ||
|
|
1e4bc2a19d | ||
|
|
4e0bce571f | ||
|
|
4392cea694 | ||
|
|
c8992ce2de | ||
|
|
a9e30d79e3 | ||
|
|
3676e1ac85 | ||
|
|
a84acae095 | ||
|
|
ef19191cc9 | ||
|
|
234e50e035 | ||
|
|
9653b7c7c5 | ||
|
|
a7e070fbe1 | ||
|
|
6b6d2ed7b8 | ||
|
|
1380d749f4 | ||
|
|
facd9cf97f | ||
|
|
116865a2d9 | ||
|
|
673942e945 | ||
|
|
a239cd554e | ||
|
|
e794976e50 | ||
|
|
7d5d660ad9 | ||
|
|
eab4d6cfe8 | ||
|
|
a0c61c4f9c | ||
|
|
35f3d527c5 | ||
|
|
e54cacd3d2 | ||
|
|
7a90cbb867 | ||
|
|
dbde2ed35f | ||
|
|
7e7f729997 | ||
|
|
8f02c5c3d8 | ||
|
|
d6f767e321 | ||
|
|
e965e15ad2 |
50
IDEAS.md
@@ -14,7 +14,8 @@
|
||||
### 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.
|
||||
### Bouncers
|
||||
* Nightclubs, bars, etc can employ "bouncer" peds that either prevent entry to certain people, or kick people out.
|
||||
---
|
||||
### Background ambience.
|
||||
* Anonymous city traffic and pedestrians
|
||||
@@ -51,9 +52,9 @@
|
||||
### 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.
|
||||
* Try attach to nearest vehicle.
|
||||
---
|
||||
### Item System
|
||||
### Item System (FINISHED)
|
||||
* 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.
|
||||
@@ -68,21 +69,21 @@
|
||||
* 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 (NEEDS SPAWNED)
|
||||
* 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 (FINISHED)
|
||||
* Admin abilities
|
||||
* Moderation (muted/frozen/etc)
|
||||
* LEO abilities
|
||||
* LEO abilities (skipped for now)
|
||||
* Clan abilities
|
||||
* Account Settings
|
||||
* etc
|
||||
---
|
||||
### Interiors
|
||||
### Interiors (FINISHED)
|
||||
* 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.
|
||||
@@ -174,8 +175,6 @@
|
||||
* Concealable smaller weapon.
|
||||
* Officers usually have a utility belt. Allow it to hold equipment as well.
|
||||
---
|
||||
###
|
||||
---
|
||||
### Vehicle Trunks
|
||||
* Can hold tied up players/peds
|
||||
* Can hold items
|
||||
@@ -230,10 +229,10 @@
|
||||
* Tweakers
|
||||
* Bouncers
|
||||
---
|
||||
### Accents
|
||||
### Accents (FINISHED)
|
||||
* Shown before message ... "[Japanese] John Smith says: hello"
|
||||
* Pre-set accent choices
|
||||
* Custom accent
|
||||
* Custom accent (skipped for now)
|
||||
---
|
||||
### 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.
|
||||
@@ -333,7 +332,8 @@
|
||||
---
|
||||
### Pointing
|
||||
* Key to point sort of like FiveM has.
|
||||
* Use a 3D primitive on the spot thats pointed to, if no anim available.
|
||||
* Use a 3D primitive on the spot thats pointed to.
|
||||
* Use pointing (finger?) animation if 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.
|
||||
@@ -350,20 +350,20 @@ Obviously this would still be using slashes for commands still. The way this wor
|
||||
* Ice cream cone
|
||||
* Cotton Candy
|
||||
* Snow cone
|
||||
|
||||
* Misc
|
||||
* Gas Can
|
||||
---
|
||||
### Quick Reply
|
||||
### Quick Reply (FINISHED)
|
||||
* When somebody sends a private message, use /reply to quickly reply without having to find their ID to use the private message command
|
||||
---
|
||||
### Item management commands
|
||||
### Item management commands (ALMOST FINISHED)
|
||||
* Item Types
|
||||
* Create
|
||||
* Set base price
|
||||
* Set model
|
||||
* Set drop position offset
|
||||
* Set drop rotation offset
|
||||
* Set forward
|
||||
---
|
||||
### Tutorial
|
||||
* Pick up item (grab bottle of beer off ground)
|
||||
@@ -378,4 +378,22 @@ Obviously this would still be using slashes for commands still. The way this wor
|
||||
### Animation/emote, action, and message menu wheels
|
||||
So with new Steam Deck being available now, and all the other attempts to use mobile devices that either emulate or stream the older GTA PC games, I figure we'd need a way for players to interact with each other using them. Roleplay is usually a very chat-oriented gamemode, but I can probably make things easier with simple controls. Also customizable messages, animations, and actions for each menu/wheel slot
|
||||
The inventory system is already planned to use a hotbar/wheel but I don't have all the images for it yet
|
||||
---
|
||||
---
|
||||
### Fishing
|
||||
* Fishing works near water or on a boat (I have a way to detect both)
|
||||
* Use the bat swing anim for casting line, and the crouch anim for applying bait.
|
||||
* Bait is used same as ammo item for a weapon. Hold the fishing rod, make sure bait is in inventory, and press use (default U) to apply bait.
|
||||
* Use a "press and hold" key to cast a line to a custom distance. Show progress bar to indicate how far the line will be cast.
|
||||
* Place a single-use particle effect on the water (distance to front of player) to show where the casted line hits.
|
||||
* Use particle effects (water spray or splash effect) to display a fish being hooked.
|
||||
* Slowly move the particle effect to the player to show it being reeled in as the player holds the reel key.
|
||||
* Random selection of predefined catch items, both junk and fish.
|
||||
* Player would be wise to bring a bucket or crate to keep the fish in, using existing /take and /put system like any other item.
|
||||
**This will need extra stuff added to keybinds system for duration key holding**
|
||||
---
|
||||
### GPS indicator like the 3D Fallout games
|
||||
An indicator at the bottom, showing compass direction and a dot or something in the direction of the GPS location. Like an object marker.
|
||||
In-world indicator too, when player gets close and is in line of sight
|
||||
---
|
||||
### Item/Object pickup and move like the 3D Fallout games
|
||||
Fallout 3 and New Vegas have a neat feature where you can "grab" an object and fling it around while the key is pressed. Could be implemented for items in GTACRP servers
|
||||
5
TODO.md
@@ -20,4 +20,7 @@
|
||||
* Drug growing/manufacturing
|
||||
---
|
||||
== Bug Fixes
|
||||
* Check natives for if player is console (getPlayerPosition, etc)
|
||||
* Check natives for if player is console (getPlayerPosition, etc)
|
||||
|
||||
* Add command to copy account keybinds to other server(s)
|
||||
* Add command to reset all account keybinds to default
|
||||
112
config/client/locale.json
Normal file
@@ -0,0 +1,112 @@
|
||||
[
|
||||
{
|
||||
"id": 0,
|
||||
"englishName": "English",
|
||||
"stringsFile": "english.json",
|
||||
"isoCode": "en",
|
||||
"flagImageFile": "uk.png",
|
||||
"countries": ["gb", "us", "au", "bz", "ca", "ie", "jm", "nz", "za", "tt"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "Vortrex"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"englishName": "Russian",
|
||||
"stringsFile": "russian.json",
|
||||
"isoCode": "ru",
|
||||
"flagImageFile": "ru.png",
|
||||
"countries": ["ru", "ua"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "VNDTTS"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"englishName": "Polish",
|
||||
"stringsFile": "polish.json",
|
||||
"isoCode": "pl",
|
||||
"flagImageFile": "pl.png",
|
||||
"countries": ["pl"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "Suprise444"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"englishName": "Spanish",
|
||||
"stringsFile": "spanish.json",
|
||||
"isoCode": "es",
|
||||
"flagImageFile": "es.png",
|
||||
"countries": ["es", "ar", "bo", "cl", "co", "cr", "do", "ec", "sv", "gt", "hn", "mx", "ni", "pa", "py", "pe", "pr", "uy", "ve"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "PerikiyoXD"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"englishName": "Chinese",
|
||||
"stringsFile": "chinese.json",
|
||||
"isoCode": "zh",
|
||||
"flagImageFile": "cn.png",
|
||||
"countries": ["cn", "hk", "sg", "tw"],
|
||||
"requiresUnicode": true,
|
||||
"contributor": "Renzuko_Ctone"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"englishName": "Arabic",
|
||||
"stringsFile": "arabic.json",
|
||||
"isoCode": "ar",
|
||||
"flagImageFile": "sa.png",
|
||||
"countries": ["dz", "bh", "eg", "iq", "jo", "kw", "lb", "ly", "ma", "om", "qa", "sa", "sy", "tn", "ae", "ye"],
|
||||
"requiresUnicode": true,
|
||||
"contributor": "! KASIR"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"englishName": "Slovak",
|
||||
"stringsFile": "slovak.json",
|
||||
"isoCode": "sk",
|
||||
"flagImageFile": "sk.png",
|
||||
"countries": ["sk"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "UAKLAUS"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"englishName": "German",
|
||||
"stringsFile": "german.json",
|
||||
"isoCode": "de",
|
||||
"flagImageFile": "de.png",
|
||||
"countries": ["de", "at", "be", "ch", "li", "lu"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "Sladernimo"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"englishName": "French",
|
||||
"stringsFile": "french.json",
|
||||
"isoCode": "fr",
|
||||
"flagImageFile": "fr.png",
|
||||
"countries": ["fr", "cd", "bj", "bf", "cd", "cg", "ga", "gn", "ml", "mc", "ne", "sn"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "Cocam"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"englishName": "Japanese",
|
||||
"stringsFile": "japanese.json",
|
||||
"isoCode": "jp",
|
||||
"flagImageFile": "jp.png",
|
||||
"countries": ["jp"],
|
||||
"requiresUnicode": true,
|
||||
"contributor": "Cocam"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"englishName": "Finnish",
|
||||
"stringsFile": "finnish.json",
|
||||
"isoCode": "fi",
|
||||
"flagImageFile": "fi.png",
|
||||
"countries": ["fi"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "SIMBA_MEOW"
|
||||
}
|
||||
]
|
||||
117
config/locale.json
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"apiEmail": "example@example.com",
|
||||
"defaultLanguageId": 0,
|
||||
"translateURL": "http://api.mymemory.translated.net/get?de={3}&q={0}&langpair={1}|{2}",
|
||||
"locales": [
|
||||
{
|
||||
"id": 0,
|
||||
"englishName": "English",
|
||||
"stringsFile": "english.json",
|
||||
"isoCode": "en",
|
||||
"flagImageFile": "uk.png",
|
||||
"countries": ["gb", "us", "au", "bz", "ca", "ie", "jm", "nz", "za", "tt"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "Vortrex"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"englishName": "Russian",
|
||||
"stringsFile": "russian.json",
|
||||
"isoCode": "ru",
|
||||
"flagImageFile": "ru.png",
|
||||
"countries": ["ru", "ua"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "VNDTTS"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"englishName": "Polish",
|
||||
"stringsFile": "polish.json",
|
||||
"isoCode": "pl",
|
||||
"flagImageFile": "pl.png",
|
||||
"countries": ["pl"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "Suprise444"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"englishName": "Spanish",
|
||||
"stringsFile": "spanish.json",
|
||||
"isoCode": "es",
|
||||
"flagImageFile": "es.png",
|
||||
"countries": ["es", "ar", "bo", "cl", "co", "cr", "do", "ec", "sv", "gt", "hn", "mx", "ni", "pa", "py", "pe", "pr", "uy", "ve"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "PerikiyoXD"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"englishName": "Chinese",
|
||||
"stringsFile": "chinese.json",
|
||||
"isoCode": "zh",
|
||||
"flagImageFile": "cn.png",
|
||||
"countries": ["cn", "hk", "sg", "tw"],
|
||||
"requiresUnicode": true,
|
||||
"contributor": "Renzuko_Ctone"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"englishName": "Arabic",
|
||||
"stringsFile": "arabic.json",
|
||||
"isoCode": "ar",
|
||||
"flagImageFile": "sa.png",
|
||||
"countries": ["dz", "bh", "eg", "iq", "jo", "kw", "lb", "ly", "ma", "om", "qa", "sa", "sy", "tn", "ae", "ye"],
|
||||
"requiresUnicode": true,
|
||||
"contributor": "! KASIR"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"englishName": "Slovak",
|
||||
"stringsFile": "slovak.json",
|
||||
"isoCode": "sk",
|
||||
"flagImageFile": "sk.png",
|
||||
"countries": ["sk"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "UAKLAUS"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"englishName": "German",
|
||||
"stringsFile": "german.json",
|
||||
"isoCode": "de",
|
||||
"flagImageFile": "de.png",
|
||||
"countries": ["de", "at", "be", "ch", "li", "lu"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "Sladernimo"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"englishName": "French",
|
||||
"stringsFile": "french.json",
|
||||
"isoCode": "fr",
|
||||
"flagImageFile": "fr.png",
|
||||
"countries": ["fr", "cd", "bj", "bf", "cd", "cg", "ga", "gn", "ml", "mc", "ne", "sn"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "Cocam"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"englishName": "Japanese",
|
||||
"stringsFile": "japanese.json",
|
||||
"isoCode": "jp",
|
||||
"flagImageFile": "jp.png",
|
||||
"countries": ["jp"],
|
||||
"requiresUnicode": true,
|
||||
"contributor": "Cocam"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"englishName": "Finnish",
|
||||
"stringsFile": "finnish.json",
|
||||
"isoCode": "fi",
|
||||
"flagImageFile": "fi.png",
|
||||
"countries": ["fi"],
|
||||
"requiresUnicode": false,
|
||||
"contributor": "SIMBA_MEOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
files/fonts/pricedown.ttf
Normal file
BIN
files/fonts/roboto-regular.ttf
Normal file
BIN
files/images/asshat-logo.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
files/images/flags/cn.png
Normal file
|
After Width: | Height: | Size: 109 KiB |
BIN
files/images/flags/de.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
files/images/flags/es.png
Normal file
|
After Width: | Height: | Size: 289 KiB |
BIN
files/images/flags/fi.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
files/images/flags/fr.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
files/images/flags/jp.png
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
files/images/flags/pl.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
files/images/flags/ru.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
files/images/flags/sa.png
Normal file
|
After Width: | Height: | Size: 269 KiB |
BIN
files/images/flags/sk.png
Normal file
|
After Width: | Height: | Size: 117 KiB |
BIN
files/images/flags/uk.png
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
files/images/gtac-logo.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
files/images/mafiac-logo.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
files/images/server-logo.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
files/images/skins/none.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
127
meta.xml
@@ -22,8 +22,10 @@
|
||||
<script src="scripts/server/ban.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/bitflag.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/business.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/casino.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/chat.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/clan.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/client.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/crime.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/database.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/developer.js" type="server" language="javascript" />
|
||||
@@ -47,6 +49,7 @@
|
||||
<script src="scripts/server/misc.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/npc.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/netevents.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/paintball.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/race.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/radio.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/security.js" type="server" language="javascript" />
|
||||
@@ -79,28 +82,150 @@
|
||||
<script src="scripts/server/item/rope.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/item/tazer.js" type="server" language="javascript" />
|
||||
|
||||
<!-- Extra Client Files -->
|
||||
<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" />
|
||||
<!--<file type="client" src="files/images/server-logo.png" />-->
|
||||
<file type="client" src="files/images/asshat-logo.png" />
|
||||
|
||||
<!-- GUI -->
|
||||
<script src="scripts/client/gui/2fa.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/bizmgr.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/changepass.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/charselect.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/clanmgr.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/error.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/housemgr.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/info.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/login.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/list.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/newchar.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/register.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/resetpass.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/yesno.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui/localechooser.js" type="client" language="javascript" />
|
||||
|
||||
<!-- Client Scripts -->
|
||||
<script src="scripts/client/afk.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/animation.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/business.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/chatbox.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/chat.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/event.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gui.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/gps.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/house.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/item.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/job.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/keybind.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/label.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/locale.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/logo.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/main.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/messaging.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/mousecam.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/nametag.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/npc.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/radio.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/scoreboard.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/netevents.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/skin-select.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/sync.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/time.nut" type="client" language="squirrel" />
|
||||
<script src="scripts/client/utilities.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/vehicle.js" type="client" language="javascript" />
|
||||
|
||||
<!-- Locale Files -->
|
||||
<file type="client" src="config/client/locale.json" />
|
||||
<file type="client" src="locale/english.json" />
|
||||
<file type="client" src="locale/russian.json" />
|
||||
<file type="client" src="locale/polish.json" />
|
||||
<file type="client" src="locale/spanish.json" />
|
||||
<file type="client" src="locale/french.json" />
|
||||
<file type="client" src="locale/japanese.json" />
|
||||
<file type="client" src="locale/german.json" />
|
||||
<file type="client" src="locale/slovak.json" />
|
||||
<file type="client" src="locale/finnish.json" />
|
||||
<file type="client" src="locale/chinese.json" />
|
||||
<file type="client" src="locale/arabic.json" />
|
||||
|
||||
<!-- International Flag Images -->
|
||||
<file type="client" src="files/images/flags/uk.png" />
|
||||
<file type="client" src="files/images/flags/de.png" />
|
||||
<file type="client" src="files/images/flags/fr.png" />
|
||||
<file type="client" src="files/images/flags/pl.png" />
|
||||
<file type="client" src="files/images/flags/es.png" />
|
||||
<file type="client" src="files/images/flags/jp.png" />
|
||||
<file type="client" src="files/images/flags/sk.png" />
|
||||
<file type="client" src="files/images/flags/sa.png" />
|
||||
<file type="client" src="files/images/flags/cn.png" />
|
||||
<file type="client" src="files/images/flags/fi.png" />
|
||||
<file type="client" src="files/images/flags/ru.png" />
|
||||
|
||||
<!-- MexUI -->
|
||||
<file type="client" src="third-party/mexui/Images/down-arrow.png" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/mexui.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Native.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Utility.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entity/Transition.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entity/StyleableEntity.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entity/Component.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Component/Control.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Component/Entry.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Component/Event.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Component/Window.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entity/ControlAxis.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entity/ControlWithEntries.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entry/DropDownItem.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entry/GridColumn.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entry/GridRow.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entry/ListRow.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entry/Tab.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Entry/TreeRow.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Button.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/CheckBox.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/DropDown.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Grid.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Image.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Line.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/List.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/ProgressBar.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/RadioButton.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Rectangle.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/ScrollBar.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Slider.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/TabPanel.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Text.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/TextInput.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Tree.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Character.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Characters.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Day.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Date.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Digit.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Digits.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Hour.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Integer.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Letter.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/LetterDigit.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Letters.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/LettersDigits.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Minute.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Month.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Number.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Password.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/PositiveInteger.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/PositiveNumber.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/RangedInteger.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/RangedNumber.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Second.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/TextArea.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Time.js" />
|
||||
<script language="javascript" type="client" src="third-party/mexui/Core/Control/Week.js" />
|
||||
<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" />
|
||||
|
||||
<!-- Startup -->
|
||||
<script src="scripts/server/startup.js" type="server" language="javascript" />
|
||||
<script src="scripts/client/startup.js" type="client" language="javascript" />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: afk.js
|
||||
// DESC: Provides AFK detection
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: animation.js
|
||||
// DESC: Provides animation functions and usage
|
||||
@@ -10,7 +11,7 @@
|
||||
function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
let ped = getElementFromId(pedId);
|
||||
|
||||
if(ped == null) {
|
||||
if (ped == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,37 +19,37 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animationData[0]} for ped ${pedId}`);
|
||||
|
||||
let freezePlayer = false;
|
||||
switch(animationData.moveType) {
|
||||
case VRR_ANIMMOVE_FORWARD: {
|
||||
switch (animationData.moveType) {
|
||||
case AGRP_ANIMMOVE_FORWARD: {
|
||||
setElementCollisionsEnabled(ped, false);
|
||||
if(ped.isSyncer) {
|
||||
if (ped.isSyncer) {
|
||||
setElementPosition(ped, getPosInFrontOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
|
||||
}
|
||||
freezePlayer = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_ANIMMOVE_BACK: {
|
||||
case AGRP_ANIMMOVE_BACK: {
|
||||
setElementCollisionsEnabled(pedId, false);
|
||||
if(ped.isSyncer) {
|
||||
if (ped.isSyncer) {
|
||||
setElementPosition(pedId, getPosBehindPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
|
||||
}
|
||||
freezePlayer = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_ANIMMOVE_LEFT: {
|
||||
case AGRP_ANIMMOVE_LEFT: {
|
||||
setElementCollisionsEnabled(pedId, false);
|
||||
if(ped.isSyncer) {
|
||||
if (ped.isSyncer) {
|
||||
setElementPosition(pedId, getPosToLeftOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
|
||||
}
|
||||
freezePlayer = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_ANIMMOVE_RIGHT: {
|
||||
case AGRP_ANIMMOVE_RIGHT: {
|
||||
setElementCollisionsEnabled(pedId, false);
|
||||
if(ped.isSyncer) {
|
||||
if (ped.isSyncer) {
|
||||
setElementPosition(pedId, getPosToRightOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
|
||||
}
|
||||
freezePlayer = true;
|
||||
@@ -60,21 +61,21 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
}
|
||||
}
|
||||
|
||||
if(getGame() < VRR_GAME_GTA_IV) {
|
||||
if(animationData.animType == VRR_ANIMTYPE_NORMAL || animationData.animType == VRR_ANIMTYPE_SURRENDER) {
|
||||
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() < AGRP_GAME_GTA_IV) {
|
||||
if (animationData.animType == AGRP_ANIMTYPE_NORMAL || animationData.animType == AGRP_ANIMTYPE_SURRENDER) {
|
||||
if (getGame() == AGRP_GAME_GTA_VC || getGame() == AGRP_GAME_GTA_SA) {
|
||||
ped.clearAnimations();
|
||||
} else {
|
||||
ped.clearObjective();
|
||||
}
|
||||
ped.addAnimation(animationData.groupId, animationData.animId);
|
||||
|
||||
if(ped == localPlayer && freezePlayer == true) {
|
||||
if (ped == localPlayer && freezePlayer == true) {
|
||||
inAnimation = true;
|
||||
setLocalPlayerControlState(false, false);
|
||||
localPlayer.collisionsEnabled = false;
|
||||
}
|
||||
} else if(animationData.animType == VRR_ANIMTYPE_BLEND) {
|
||||
} else if (animationData.animType == AGRP_ANIMTYPE_BLEND) {
|
||||
ped.position = ped.position;
|
||||
ped.blendAnimation(animationData.groupId, animationData.animId, animationData.animSpeed);
|
||||
}
|
||||
@@ -89,17 +90,17 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
function forcePedAnimation(pedId, animSlot) {
|
||||
let ped = getElementFromId(pedId);
|
||||
|
||||
if(ped == null) {
|
||||
if (ped == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let animationData = getAnimationData(animSlot);
|
||||
|
||||
if(getGame() < VRR_GAME_GTA_IV) {
|
||||
if (getGame() < AGRP_GAME_GTA_IV) {
|
||||
ped.position = ped.position;
|
||||
ped.addAnimation(animationData.groupId, animationData.animId);
|
||||
|
||||
if(ped == localPlayer) {
|
||||
if (ped == localPlayer) {
|
||||
inAnimation = true;
|
||||
setLocalPlayerControlState(false, false);
|
||||
localPlayer.collisionsEnabled = false;
|
||||
@@ -115,34 +116,24 @@ function forcePedAnimation(pedId, animSlot) {
|
||||
function makePedStopAnimation(pedId) {
|
||||
let ped = getElementFromId(pedId);
|
||||
|
||||
if(ped == null) {
|
||||
if (ped == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getGame() != VRR_GAME_GTA_IV) {
|
||||
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() != AGRP_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_VC || getGame() == AGRP_GAME_GTA_SA) {
|
||||
ped.clearAnimations();
|
||||
} else {
|
||||
ped.clearObjective();
|
||||
}
|
||||
}
|
||||
|
||||
if(ped == localPlayer) {
|
||||
if(getGame() != VRR_GAME_GTA_IV) {
|
||||
if (ped == localPlayer) {
|
||||
if (getGame() != AGRP_GAME_GTA_IV) {
|
||||
localPlayer.collisionsEnabled = true;
|
||||
}
|
||||
setLocalPlayerControlState(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @param {number} animationSlot - The slot index of the animation
|
||||
* @return {AnimationData} The animation's data (array)
|
||||
*/
|
||||
function getAnimationData(animationSlot, gameId = getGame()) {
|
||||
return getGameConfig().animations[gameId][animationSlot];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: business.js
|
||||
// DESC: Provides business functions and usage
|
||||
@@ -27,8 +28,8 @@ class BusinessData {
|
||||
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Business] Received business ${businessId} (${name}) from server`);
|
||||
|
||||
if(!areServerElementsSupported()) {
|
||||
if(getBusinessData(businessId) != false) {
|
||||
if (!areServerElementsSupported()) {
|
||||
if (getBusinessData(businessId) != false) {
|
||||
let businessData = getBusinessData(businessId);
|
||||
businessData.name = name;
|
||||
businessData.entrancePosition = entrancePosition;
|
||||
@@ -38,10 +39,10 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
||||
businessData.hasItems = hasItems;
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} already exists. Checking blip ...`);
|
||||
if(blipModel == -1) {
|
||||
if(businessData.blipId != -1) {
|
||||
if (blipModel == -1) {
|
||||
if (businessData.blipId != -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been removed by the server`);
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
|
||||
} else {
|
||||
destroyElement(getElementFromId(blipId));
|
||||
@@ -53,18 +54,18 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip is unchanged`);
|
||||
}
|
||||
} else {
|
||||
if(businessData.blipId != -1) {
|
||||
if (businessData.blipId != -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been changed by the server`);
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.setBlipCoordinates(businessData.blipId, businessData.entrancePosition);
|
||||
natives.changeBlipSprite(businessData.blipId, businessData.blipModel);
|
||||
natives.setBlipMarkerLongDistance(businessData.blipId, false);
|
||||
natives.setBlipAsShortRange(tempBusinessData.blipId, true);
|
||||
natives.changeBlipNameFromAscii(businessData.blipId, `${businessData.name.substr(0, 24)}${(businessData.name.length > 24) ? " ...": ""}`);
|
||||
natives.changeBlipNameFromAscii(businessData.blipId, `${businessData.name.substr(0, 24)}${(businessData.name.length > 24) ? " ..." : ""}`);
|
||||
}
|
||||
} else {
|
||||
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
|
||||
if(blipId != -1) {
|
||||
if (blipId != -1) {
|
||||
tempBusinessData.blipId = blipId;
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||
@@ -73,9 +74,9 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
||||
} else {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} doesn't exist. Adding ...`);
|
||||
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
|
||||
if(blipModel != -1) {
|
||||
if (blipModel != -1) {
|
||||
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
|
||||
if(blipId != -1) {
|
||||
if (blipId != -1) {
|
||||
tempBusinessData.blipId = blipId;
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||
@@ -100,8 +101,8 @@ function getBusinessData(businessId) {
|
||||
|
||||
let businesses = getServerData().businesses;
|
||||
|
||||
for(let i in businesses) {
|
||||
if(businesses[i].businessId == businessId) {
|
||||
for (let i in businesses) {
|
||||
if (businesses[i].businessId == businessId) {
|
||||
return businesses[i];
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,7 @@ function getBusinessData(businessId) {
|
||||
// ===========================================================================
|
||||
|
||||
function setAllBusinessDataIndexes() {
|
||||
for(let i in getServerData().businesses) {
|
||||
for (let i in getServerData().businesses) {
|
||||
getServerData().businesses[i].index = i;
|
||||
}
|
||||
}
|
||||
|
||||
235
scripts/client/chat.js
Normal file
@@ -0,0 +1,235 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: chatbox.js
|
||||
// DESC: Provides extra chatbox features
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let chatTimeStampsEnabled = false;
|
||||
let chatEmojiEnabled = false;
|
||||
|
||||
let chatBoxHistory = [];
|
||||
let bottomMessageIndex = 0;
|
||||
let maxChatBoxHistory = 500;
|
||||
|
||||
let scrollAmount = 1;
|
||||
let maxChatBoxLines = 6;
|
||||
|
||||
let chatAutoHideDelay = 0;
|
||||
let chatLastUse = 0;
|
||||
|
||||
let scrollUpKey = false;
|
||||
let scrollDownKey = false;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initChatBoxScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Chat]: Initializing chat script ...");
|
||||
scrollUpKey = getKeyIdFromParams("pageup");
|
||||
scrollDownKey = getKeyIdFromParams("pagedown");
|
||||
bindChatBoxKeys();
|
||||
logToConsole(LOG_DEBUG, "[VRR.Chat]: Chat script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function bindChatBoxKeys() {
|
||||
bindKey(toInteger(scrollUpKey), KEYSTATE_DOWN, chatBoxScrollUp);
|
||||
bindKey(toInteger(scrollDownKey), KEYSTATE_DOWN, chatBoxScrollDown);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function unBindChatBoxKeys() {
|
||||
unbindKey(toInteger(scrollUpKey));
|
||||
unbindKey(toInteger(scrollDownKey));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function receiveChatBoxMessageFromServer(messageString, colour, hour, minute, second) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Chat]: Received chatbox message from server: ${messageString}`);
|
||||
|
||||
// Just in case it's hidden by auto hide
|
||||
//setChatWindowEnabled(true);
|
||||
|
||||
//let timeStamp = findResourceByName("agrp_time").exports.getCurrentUnixTimeStampSquirrel();
|
||||
|
||||
hour = fillLeadingZeros(hour, 2);
|
||||
minute = fillLeadingZeros(minute, 2);
|
||||
second = fillLeadingZeros(second, 2);
|
||||
|
||||
addToChatBoxHistory(messageString, colour, hour, minute, second);
|
||||
|
||||
//let unixTimeStampMS = new Date().getTime();
|
||||
//let timeStampDate = new Date(unixTimeStampMS);
|
||||
//let timeStampDate = new Date(timeStamp);
|
||||
//let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`;
|
||||
|
||||
let outputString = messageString;
|
||||
if (chatTimeStampsEnabled == true) {
|
||||
//timeStampString = `{TIMESTAMPCOLOUR}[${findResourceByName("agrp_time").exports.getTimeStampOutput(timeStamp)}]{MAINCOLOUR}`;
|
||||
let timeStampString = `{TIMESTAMPCOLOUR}[${hour}:${minute}:${second}] `;
|
||||
outputString = `${timeStampString}${messageString}`;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Chat]: Changed colours in string: ${outputString}`);
|
||||
outputString = replaceColoursInMessage(`${outputString}`);
|
||||
|
||||
if (chatEmojiEnabled == true) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Chat]: Enabled emoji in string: ${outputString}`);
|
||||
outputString = replaceEmojiInMessage(outputString);
|
||||
}
|
||||
|
||||
if (profanityFilterEnabled == true) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Chat]: Removed profanity in string: ${outputString}`);
|
||||
outputString = replaceProfanityInMessage(outputString);
|
||||
}
|
||||
|
||||
message(outputString, colour);
|
||||
bottomMessageIndex = chatBoxHistory.length - 1;
|
||||
|
||||
chatLastUse = getCurrentUnixTimestamp();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setChatScrollLines(amount) {
|
||||
scrollAmount = amount;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setChatTimeStampsState(state) {
|
||||
chatTimeStampsEnabled = state;
|
||||
updateChatBox();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setChatEmojiState(state) {
|
||||
chatEmojiEnabled = state;
|
||||
updateChatBox();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setChatAutoHideDelay(delay) {
|
||||
chatAutoHideDelay = delay * 1000;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function addToChatBoxHistory(messageString, colour, hour, minute, second) {
|
||||
chatBoxHistory.push([messageString, colour, hour, minute, second]);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function chatBoxScrollUp() {
|
||||
if (bottomMessageIndex > maxChatBoxLines) {
|
||||
bottomMessageIndex = bottomMessageIndex - scrollAmount;
|
||||
updateChatBox();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function chatBoxScrollDown() {
|
||||
if (bottomMessageIndex < chatBoxHistory.length - 1) {
|
||||
bottomMessageIndex = bottomMessageIndex + scrollAmount;
|
||||
updateChatBox();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function clearChatBox() {
|
||||
for (let i = 0; i <= maxChatBoxLines; i++) {
|
||||
message("", COLOUR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function updateChatBox() {
|
||||
clearChatBox();
|
||||
for (let i = bottomMessageIndex - maxChatBoxLines; i <= bottomMessageIndex; i++) {
|
||||
if (typeof chatBoxHistory[i] != "undefined") {
|
||||
let outputString = chatBoxHistory[i][0];
|
||||
if (chatTimeStampsEnabled == true) {
|
||||
//let timeStampDate = new Date(chatBoxHistory[i][2]);
|
||||
//let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`;
|
||||
//let timeStampText = findResourceByName("agrp_time").exports.getTimeStampOutput(chatBoxHistory[i][2]);
|
||||
let timeStampText = `${chatBoxHistory[i][2]}:${chatBoxHistory[i][3]}:${chatBoxHistory[i][4]}`;
|
||||
|
||||
outputString = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${chatBoxHistory[i][0]}`;
|
||||
}
|
||||
|
||||
outputString = replaceColoursInMessage(outputString);
|
||||
|
||||
if (chatEmojiEnabled == true) {
|
||||
outputString = replaceEmojiInMessage(outputString);
|
||||
}
|
||||
|
||||
if (profanityFilterEnabled == true) {
|
||||
outputString = replaceProfanityInMessage(outputString);
|
||||
}
|
||||
|
||||
message(outputString, chatBoxHistory[i][1]);
|
||||
} else {
|
||||
message("", COLOUR_WHITE);
|
||||
}
|
||||
}
|
||||
chatLastUse = getCurrentUnixTimestamp();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processMouseWheelForChatBox(mouseId, deltaCoordinates, flipped) {
|
||||
// There isn't a way to detect whether chat input is active, but mouse cursor is forced shown when typing so ¯\_(ツ)_/¯
|
||||
if (!gui.cursorEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!flipped) {
|
||||
if (deltaCoordinates.y > 0) {
|
||||
chatBoxScrollUp();
|
||||
} else {
|
||||
chatBoxScrollDown();
|
||||
}
|
||||
} else {
|
||||
if (deltaCoordinates.y > 0) {
|
||||
chatBoxScrollDown();
|
||||
} else {
|
||||
chatBoxScrollUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkChatAutoHide() {
|
||||
return false;
|
||||
|
||||
// Make sure chat input isn't active
|
||||
if (gui.cursorEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't process auto-hide if it's disabled
|
||||
if (chatAutoHideDelay == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getCurrentUnixTimestamp() - chatLastUse >= chatAutoHideDelay) {
|
||||
setChatWindowEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,171 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: chatbox.js
|
||||
// DESC: Provides extra chatbox features
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let chatBoxHistory = [];
|
||||
let bottomMessageIndex = 0;
|
||||
let maxChatBoxHistory = 500;
|
||||
|
||||
let scrollAmount = 1;
|
||||
let maxChatBoxLines = 6;
|
||||
|
||||
let chatAutoHideDelay = 0;
|
||||
let chatLastUse = 0;
|
||||
|
||||
let scrollUpKey = false;
|
||||
let scrollDownKey = false;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initChatBoxScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Initializing chatbox script ...");
|
||||
scrollUpKey = getKeyIdFromParams("pageup");
|
||||
scrollDownKey = getKeyIdFromParams("pagedown");
|
||||
bindChatBoxKeys();
|
||||
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Chatbox script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function bindChatBoxKeys() {
|
||||
bindKey(toInteger(scrollUpKey), KEYSTATE_DOWN, chatBoxScrollUp);
|
||||
bindKey(toInteger(scrollDownKey), KEYSTATE_DOWN, chatBoxScrollDown);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function unBindChatBoxKeys() {
|
||||
unbindKey(toInteger(scrollUpKey));
|
||||
unbindKey(toInteger(scrollDownKey));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function receiveChatBoxMessageFromServer(messageString, colour) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Received chatbox message from server: ${messageString}`);
|
||||
|
||||
// Just in case it's hidden by auto hide
|
||||
//setChatWindowEnabled(true);
|
||||
|
||||
let colouredString = replaceColoursInMessage(messageString);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Changed colours in string: ${colouredString}`);
|
||||
|
||||
addToChatBoxHistory(colouredString, colour);
|
||||
//if(bottomMessageIndex >= chatBoxHistory.length-1) {
|
||||
message(colouredString, colour);
|
||||
bottomMessageIndex = chatBoxHistory.length-1;
|
||||
//}
|
||||
|
||||
chatLastUse = getCurrentUnixTimestamp();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setChatScrollLines(amount) {
|
||||
scrollAmount = amount;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setChatAutoHideDelay(delay) {
|
||||
chatAutoHideDelay = delay*1000;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function addToChatBoxHistory(messageString, colour) {
|
||||
chatBoxHistory.push([messageString, colour]);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function chatBoxScrollUp() {
|
||||
if(bottomMessageIndex > maxChatBoxLines) {
|
||||
bottomMessageIndex = bottomMessageIndex-scrollAmount;
|
||||
updateChatBox();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function chatBoxScrollDown() {
|
||||
if(bottomMessageIndex < chatBoxHistory.length-1) {
|
||||
bottomMessageIndex = bottomMessageIndex+scrollAmount;
|
||||
updateChatBox();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function clearChatBox() {
|
||||
for(let i = 0 ; i <= maxChatBoxLines ; i++) {
|
||||
message("", COLOUR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function updateChatBox() {
|
||||
clearChatBox();
|
||||
for(let i = bottomMessageIndex-maxChatBoxLines ; i <= bottomMessageIndex ; i++) {
|
||||
if(typeof chatBoxHistory[i] != "undefined") {
|
||||
message(chatBoxHistory[i][0], chatBoxHistory[i][1]);
|
||||
} else {
|
||||
message("", COLOUR_WHITE);
|
||||
}
|
||||
}
|
||||
chatLastUse = getCurrentUnixTimestamp();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processMouseWheelForChatBox(mouseId, deltaCoordinates, flipped) {
|
||||
// There isn't a way to detect whether chat input is active, but mouse cursor is forced shown when typing so ¯\_(ツ)_/¯
|
||||
if(!gui.cursorEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!flipped) {
|
||||
if(deltaCoordinates.y > 0) {
|
||||
chatBoxScrollUp();
|
||||
} else {
|
||||
chatBoxScrollDown();
|
||||
}
|
||||
} else {
|
||||
if(deltaCoordinates.y > 0) {
|
||||
chatBoxScrollDown();
|
||||
} else {
|
||||
chatBoxScrollUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkChatAutoHide() {
|
||||
return false;
|
||||
|
||||
// Make sure chat input isn't active
|
||||
if(gui.cursorEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't process auto-hide if it's disabled
|
||||
if(chatAutoHideDelay == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getCurrentUnixTimestamp()-chatLastUse >= chatAutoHideDelay) {
|
||||
setChatWindowEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: content.js
|
||||
// DESC: Provides connection to extra content resources
|
||||
@@ -9,10 +10,10 @@
|
||||
|
||||
function getCustomImage(imageName) {
|
||||
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
|
||||
if(contentResource != null) {
|
||||
if(contentResource.isStarted) {
|
||||
if (contentResource != null) {
|
||||
if (contentResource.isStarted) {
|
||||
let image = contentResource.exports.getCustomImage(imageName);
|
||||
if(image != null) {
|
||||
if (image != null) {
|
||||
return image;
|
||||
}
|
||||
}
|
||||
@@ -24,10 +25,10 @@ function getCustomImage(imageName) {
|
||||
|
||||
function getCustomFont(fontName) {
|
||||
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
|
||||
if(contentResource != null) {
|
||||
if(contentResource.isStarted) {
|
||||
if (contentResource != null) {
|
||||
if (contentResource.isStarted) {
|
||||
let font = contentResource.exports.getCustomFont(fontName);
|
||||
if(font != null) {
|
||||
if (font != null) {
|
||||
return font;
|
||||
}
|
||||
}
|
||||
@@ -39,10 +40,10 @@ function getCustomFont(fontName) {
|
||||
|
||||
function getCustomAudio(audioName) {
|
||||
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
|
||||
if(contentResource != null) {
|
||||
if(contentResource.isStarted) {
|
||||
if (contentResource != null) {
|
||||
if (contentResource.isStarted) {
|
||||
let audioFile = contentResource.exports.getCustomAudio(audioName);
|
||||
if(audioFile != null) {
|
||||
if (audioFile != null) {
|
||||
return audioFile;
|
||||
}
|
||||
}
|
||||
@@ -54,8 +55,8 @@ function getCustomAudio(audioName) {
|
||||
|
||||
function playCustomAudio(audioName, volume = 0.5, loop = false) {
|
||||
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
|
||||
if(contentResource != null) {
|
||||
if(contentResource.isStarted) {
|
||||
if (contentResource != null) {
|
||||
if (contentResource.isStarted) {
|
||||
contentResource.exports.playCustomAudio(audioName, volume, loop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: event.js
|
||||
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
|
||||
@@ -9,71 +10,75 @@
|
||||
|
||||
function initEventScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Event]: Initializing event script ...");
|
||||
addCustomEvents();
|
||||
addAllEventHandlers();
|
||||
logToConsole(LOG_DEBUG, "[VRR.Event]: Event script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function addCustomEvents() {
|
||||
addEvent("OnLocalPlayerEnterSphere", 1);
|
||||
addEvent("OnLocalPlayerExitSphere", 1);
|
||||
addEvent("OnLocalPlayerEnteredVehicle", 1);
|
||||
addEvent("OnLocalPlayerExitedVehicle", 1);
|
||||
addEvent("OnLocalPlayerSwitchWeapon", 2);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function addAllEventHandlers() {
|
||||
bindEventHandler("OnResourceStart", thisResource, onResourceStart);
|
||||
bindEventHandler("OnResourceReady", thisResource, onResourceReady);
|
||||
bindEventHandler("OnResourceStop", thisResource, onResourceStop);
|
||||
|
||||
addEventHandler("OnResourceStart", onResourceStart);
|
||||
addEventHandler("OnResourceReady", onResourceReady);
|
||||
addEventHandler("OnResourceStop", 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("OnPedChangeWeapon", onPedChangeWeapon);
|
||||
addEventHandler("OnPedInflictDamage", onPedInflictDamage);
|
||||
|
||||
addEventHandler("OnLostFocus", onLostFocus);
|
||||
addEventHandler("OnFocus", onFocus);
|
||||
|
||||
addEventHandler("OnCameraProcess", onCameraProcess);
|
||||
|
||||
addEventHandler("OnMouseWheel", onMouseWheel);
|
||||
|
||||
addEventHandler("OnEntityProcess", onEntityProcess);
|
||||
|
||||
if (findResourceByName("v-events") != null) {
|
||||
if (findResourceByName("v-events").isStarted) {
|
||||
addEventHandler("OnPedEnteredVehicleEx", onPedEnteredVehicle);
|
||||
addEventHandler("OnPedExitedVehicleEx", onPedExitedVehicle);
|
||||
addEventHandler("OnPedEnteredSphereEx", onPedEnteredSphere);
|
||||
addEventHandler("OnPedExitedSphereEx", onPedExitedSphere);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onResourceStart(event, resource) {
|
||||
sendResourceStartedSignalToServer();
|
||||
if (resource == thisResource) {
|
||||
sendResourceStartedSignalToServer();
|
||||
}
|
||||
|
||||
if (resource == findResourceByName("v-events")) {
|
||||
// Remove and re-add events, in case v-events was loaded after agrp_main
|
||||
removeEventHandler("OnPedEnteredVehicleEx");
|
||||
removeEventHandler("OnPedExitedVehicleEx");
|
||||
removeEventHandler("OnPedEnteredSphereEx");
|
||||
removeEventHandler("OnPedExitedSphereEx");
|
||||
|
||||
addEventHandler("OnPedEnteredVehicleEx", onPedEnteredVehicle);
|
||||
addEventHandler("OnPedExitedVehicleEx", onPedExitedVehicle);
|
||||
addEventHandler("OnPedEnteredSphereEx", onPedEnteredSphere);
|
||||
addEventHandler("OnPedExitedSphereEx", onPedExitedSphere);
|
||||
}
|
||||
//garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onResourceStop(event, resource) {
|
||||
sendResourceStoppedSignalToServer();
|
||||
if (resource == thisResource) {
|
||||
sendResourceStoppedSignalToServer();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onResourceReady(event, resource) {
|
||||
sendResourceReadySignalToServer();
|
||||
if (resource == thisResource) {
|
||||
sendResourceReadySignalToServer();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -90,9 +95,6 @@ function onProcess(event, deltaTime) {
|
||||
processSync();
|
||||
processLocalPlayerControlState();
|
||||
processLocalPlayerVehicleControlState();
|
||||
processLocalPlayerSphereEntryExitHandling();
|
||||
processLocalPlayerVehicleEntryExitHandling();
|
||||
processJobRouteSphere();
|
||||
forceLocalPlayerEquippedWeaponItem();
|
||||
processWantedLevelReset();
|
||||
processGameSpecifics();
|
||||
@@ -109,6 +111,8 @@ function onProcess(event, deltaTime) {
|
||||
function onKeyUp(event, keyCode, scanCode, keyModifiers) {
|
||||
processSkinSelectKeyPress(keyCode);
|
||||
//processKeyDuringAnimation();
|
||||
processGUIKeyPress(keyCode);
|
||||
processToggleGUIKeyPress(keyCode);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -118,13 +122,17 @@ function onDrawnHUD(event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (localPlayer == null) {
|
||||
if (!localPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
processSmallGameMessageRendering();
|
||||
processScoreBoardRendering();
|
||||
processLabelRendering();
|
||||
processLogoRendering();
|
||||
processItemActionRendering();
|
||||
processSkinSelectRendering();
|
||||
processNameTagRendering();
|
||||
processInteriorLightsRendering();
|
||||
}
|
||||
|
||||
@@ -143,9 +151,9 @@ function onElementStreamIn(event, element) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onLocalPlayerExitedVehicle(event, vehicle, seat) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited vehicle`);
|
||||
sendNetworkEventToServer("agrp.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
|
||||
function onPedExitedVehicle(event, ped, vehicle, seat) {
|
||||
//logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited vehicle`);
|
||||
//sendNetworkEventToServer("agrp.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
|
||||
|
||||
if (inVehicleSeat) {
|
||||
parkedVehiclePosition = false;
|
||||
@@ -155,20 +163,19 @@ function onLocalPlayerExitedVehicle(event, vehicle, seat) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onLocalPlayerEnteredVehicle(event, vehicle, seat) {
|
||||
function onPedEnteredVehicle(event, ped, vehicle, seat) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered vehicle`);
|
||||
//sendNetworkEventToServer("agrp.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
|
||||
|
||||
sendNetworkEventToServer("agrp.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
|
||||
|
||||
//if (areServerElementsSupported()) {
|
||||
//if(inVehicleSeat == 0) {
|
||||
//setVehicleEngine(vehicle, false);
|
||||
//if(!inVehicle.engine) {
|
||||
// parkedVehiclePosition = inVehicle.position;
|
||||
// parkedVehicleHeading = inVehicle.heading;
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
if (areServerElementsSupported()) {
|
||||
if (inVehicleSeat == 0) {
|
||||
setVehicleEngine(vehicle.id, false);
|
||||
if (!inVehicle.engine) {
|
||||
parkedVehiclePosition = inVehicle.position;
|
||||
parkedVehicleHeading = inVehicle.heading;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -180,10 +187,10 @@ function onPedInflictDamage(event, damagedEntity, damagerEntity, weaponId, healt
|
||||
if (!isNull(damagedEntity) && !isNull(damagerEntity)) {
|
||||
if (damagedEntity.isType(ELEMENT_PLAYER)) {
|
||||
if (damagedEntity == localPlayer) {
|
||||
//if(!weaponDamageEnabled[damagerEntity.name]) {
|
||||
preventDefaultEventAction(event);
|
||||
if (!weaponDamageEnabled[damagerEntity.name]) {
|
||||
preventDefaultEventAction(event);
|
||||
}
|
||||
sendNetworkEventToServer("agrp.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,8 +198,7 @@ function onPedInflictDamage(event, damagedEntity, damagerEntity, weaponId, healt
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onLocalPlayerEnterSphere(event, sphere) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered sphere`);
|
||||
function onPedEnteredSphere(event, ped, sphere) {
|
||||
if (sphere == jobRouteLocationSphere) {
|
||||
enteredJobRouteSphere();
|
||||
}
|
||||
@@ -200,8 +206,8 @@ function onLocalPlayerEnterSphere(event, sphere) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onLocalPlayerExitSphere(event, sphere) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited sphere`);
|
||||
function onPedExitedSphere(event, ped, sphere) {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -218,7 +224,7 @@ function onFocus(event) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onLocalPlayerSwitchWeapon(oldWeapon, newWeapon) {
|
||||
function onPedChangeWeapon(event, ped, oldWeapon, newWeapon) {
|
||||
|
||||
}
|
||||
|
||||
@@ -237,13 +243,7 @@ function onMouseWheel(event, mouseId, deltaCoordinates, flipped) {
|
||||
// ===========================================================================
|
||||
|
||||
function onEntityProcess(event, entity) {
|
||||
if (!isSpawned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//if(entity.isType(ELEMENT_PED) && !entity.isType(ELEMENT_PLAYER)) {
|
||||
// processNPCMovement(entity);
|
||||
//}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: gps.js
|
||||
// DESC: Provides GPS functions and usage
|
||||
@@ -17,8 +18,8 @@ let gpsBlipBlinkTimer = null;
|
||||
|
||||
function showGPSLocation(position, colour) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GPS] Showing gps location`);
|
||||
if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
|
||||
if(getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
// Server-side spheres don't show in GTA SA for some reason.
|
||||
gpsSphere = game.createPickup(1318, position, 1);
|
||||
} else {
|
||||
@@ -26,7 +27,7 @@ function showGPSLocation(position, colour) {
|
||||
gpsSphere.colour = colour;
|
||||
}
|
||||
|
||||
if(gpsBlip != null) {
|
||||
if (gpsBlip != null) {
|
||||
destroyElement(gpsBlip);
|
||||
}
|
||||
|
||||
@@ -40,16 +41,16 @@ function showGPSLocation(position, colour) {
|
||||
|
||||
function blinkGPSBlip(times, position, colour) {
|
||||
gpsBlipBlinkTimes = times;
|
||||
gpsBlipBlinkTimer = setInterval(function() {
|
||||
if(gpsBlip != null) {
|
||||
gpsBlipBlinkTimer = setInterval(function () {
|
||||
if (gpsBlip != null) {
|
||||
destroyElement(gpsBlip);
|
||||
gpsBlip = null;
|
||||
} else {
|
||||
gpsBlip = game.createBlip(position, 0, 2, colour);
|
||||
}
|
||||
|
||||
if(gpsBlipBlinkAmount >= gpsBlipBlinkTimes) {
|
||||
if(gpsBlip != null) {
|
||||
if (gpsBlipBlinkAmount >= gpsBlipBlinkTimes) {
|
||||
if (gpsBlip != null) {
|
||||
destroyElement(gpsBlip);
|
||||
gpsBlip = null;
|
||||
}
|
||||
|
||||
280
scripts/client/gui.js
Normal file
@@ -0,0 +1,280 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: gui.js
|
||||
// DESC: Provides GUI functionality and styles (using MexUI)
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
var app = {};
|
||||
|
||||
let mainFont = "Roboto"; // "Arial"
|
||||
|
||||
//let mainLogoPath = (typeof gta == "undefined") ? "files/images/mafiac-logo.png" : "files/images/gtac-logo.png";
|
||||
let mainLogoPath = "files/images/asshat-logo.png";
|
||||
|
||||
let primaryColour = [200, 200, 200];
|
||||
let secondaryColour = [16, 16, 16];
|
||||
let primaryTextColour = [0, 0, 0];
|
||||
let focusedColour = [200, 200, 200];
|
||||
let invalidValueColour = [200, 200, 200];
|
||||
|
||||
let focusedColourOffset = 50;
|
||||
|
||||
let windowAlpha = 200;
|
||||
let windowTitleAlpha = 180;
|
||||
let buttonAlpha = 180;
|
||||
let textInputAlpha = 180;
|
||||
|
||||
let guiReady = false;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let characterData = [];
|
||||
let currentCharacter = 0;
|
||||
|
||||
let inCharacterSelectScreen = false;
|
||||
let creatingCharacter = false;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initGUIScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.GUI]: Initializing GUI script ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.GUI]: GUI script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Initializing GUI ...`);
|
||||
|
||||
initLoginGUI();
|
||||
initRegisterGUI();
|
||||
initNewCharacterGUI();
|
||||
initCharacterSelectGUI();
|
||||
initInfoDialogGUI();
|
||||
initErrorDialogGUI();
|
||||
initYesNoDialogGUI();
|
||||
initTwoFactorAuthenticationGUI();
|
||||
initListGUI();
|
||||
initResetPasswordGUI();
|
||||
initChangePasswordGUI();
|
||||
initLocaleChooserGUI();
|
||||
|
||||
closeAllWindows();
|
||||
guiReady = true;
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] All GUI created successfully!`);
|
||||
|
||||
loadLocaleConfig();
|
||||
|
||||
sendNetworkEventToServer("agrp.guiReady", true);
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function closeAllWindows() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing all GUI windows`);
|
||||
infoDialog.window.shown = false;
|
||||
yesNoDialog.window.shown = false;
|
||||
errorDialog.window.shown = false;
|
||||
register.window.shown = false;
|
||||
login.window.shown = false;
|
||||
newCharacter.window.shown = false;
|
||||
characterSelect.window.shown = false;
|
||||
twoFactorAuth.window.shown = false;
|
||||
listDialog.window.shown = false;
|
||||
passwordReset.window.shown = false;
|
||||
passwordChange.window.shown = false;
|
||||
localeChooser.window.shown = false;
|
||||
|
||||
mexui.setInput(false);
|
||||
mexui.focusedControl = false;
|
||||
|
||||
guiSubmitKey = false;
|
||||
guiLeftKey = false;
|
||||
guiRightKey = false;
|
||||
guiUpKey = false;
|
||||
guiDownKey = false;
|
||||
|
||||
setChatWindowEnabled(true);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isAnyGUIActive() {
|
||||
if (!guiReady) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (infoDialog.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (yesNoDialog.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (errorDialog.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (register.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (login.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newCharacter.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (characterSelect.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (twoFactorAuth.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (listDialog.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (passwordReset.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (passwordChange.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (localeChooser.window.shown == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setGUIColours(red1, green1, blue1, red2, green2, blue2, red3, green3, blue3) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Received new GUI colours from server: ${red1}, ${green1}, ${blue1} / ${red2}, ${green2}, ${blue2} / ${red3}, ${green3}, ${blue3}`);
|
||||
primaryColour = [red1, green1, blue1];
|
||||
secondaryColour = [red2, green2, blue2];
|
||||
primaryTextColour = [red3, green3, blue3];
|
||||
focusedColour = [red1 + focusedColourOffset, green1 + focusedColourOffset, blue1 + focusedColourOffset];
|
||||
|
||||
initGUI();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function hideAllGUI() {
|
||||
closeAllWindows();
|
||||
setChatWindowEnabled(true);
|
||||
guiSubmitKey = false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processGUIKeyPress(keyCode) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Processing key press: ${keyCode}`);
|
||||
|
||||
if (!isAnyGUIActive()) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] GUI is not active. Cancelling keypress processing.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keyCode == SDLK_RETURN || keyCode == SDLK_RETURN2) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is submit (${guiSubmitKey})`);
|
||||
if (guiSubmitKey != false) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling submit key function`);
|
||||
guiSubmitKey.call();
|
||||
}
|
||||
} else if (keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is left (${guiLeftKey})`);
|
||||
if (guiLeftKey != false) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling left key function`);
|
||||
guiLeftKey.call();
|
||||
}
|
||||
} else if (keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is right (${guiRightKey})`);
|
||||
if (guiRightKey != false) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling right key function`);
|
||||
guiRightKey.call();
|
||||
}
|
||||
} else if (keyCode == getKeyIdFromParams("down") || keyCode == getKeyIdFromParams("s")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is down (${guiDownKey})`);
|
||||
if (guiDownKey != false) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling down key function`);
|
||||
guiDownKey.call();
|
||||
}
|
||||
} else if (keyCode == getKeyIdFromParams("up") || keyCode == getKeyIdFromParams("w")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is up (${guiUpKey})`);
|
||||
if (guiUpKey != false) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling up key function`);
|
||||
guiUpKey.call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processToggleGUIKeyPress(keyCode) {
|
||||
if (keyCode == disableGUIKey) {
|
||||
sendNetworkEventToServer("agrp.toggleGUI");
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetGUIStrings() {
|
||||
// Login GUI
|
||||
login.messageLabel.text = getLocaleString("GUILoginWindowLabelEnterPassword");
|
||||
login.passwordInput.placeholder = getLocaleString("GUILoginWindowPasswordPlaceholder");
|
||||
login.loginButton.text = toUpperCase(getLocaleString("GUILoginWindowSubmitButton"));
|
||||
login.forgotPasswordButton.text = toUpperCase(getLocaleString("GUILoginWindowResetPasswordButton"));
|
||||
login.resetPasswordLabel.text = getLocaleString("GUILoginWindowForgotPasswordLabel");
|
||||
|
||||
// Register GUI
|
||||
register.messageLabel.text = getLocaleString("GUIRegisterWindowLabelCreateAccount");
|
||||
register.passwordInput.placeholder = getLocaleString("GUIRegisterWindowPasswordPlaceholder");
|
||||
register.confirmPasswordInput.placeholder = getLocaleString("GUIRegisterWindowConfirmPasswordPlaceholder");
|
||||
register.emailInput.placeholder = getLocaleString("GUIRegisterWindowEmailPlaceholder");
|
||||
register.registerButton.text = toUpperCase(getLocaleString("GUIRegisterWindowSubmitButton"));
|
||||
|
||||
// Change Password GUI
|
||||
passwordChange.window.title = toUpperCase(getLocaleString("GUIChangePasswordWindowTitle"));
|
||||
passwordChange.messageLabel.text = getLocaleString("GUIChangePasswordPasswordLabel");
|
||||
passwordChange.passwordInput.placeholder = getLocaleString("GUIChangePasswordPasswordPlaceholder");
|
||||
passwordChange.confirmPasswordInput.placeholder = getLocaleString("GUIChangePasswordConfirmPasswordPlaceholder");
|
||||
passwordChange.submitButton.text = toUpperCase(getLocaleString("GUIChangePasswordSubmitButton"));
|
||||
|
||||
// Reset Password GUI
|
||||
passwordReset.messageLabel.text = toUpperCase(getLocaleString("GUIResetPasswordConfirmEmailLabel"));
|
||||
passwordReset.emailInput.placeholder = getLocaleString("GUIResetPasswordEmailPlaceholder");
|
||||
passwordReset.resetPasswordButton.text = toUpperCase(getLocaleString("GUIResetPasswordSubmitButton"));
|
||||
passwordReset.backToLoginButton.text = toUpperCase(getLocaleString("GUIResetPasswordLoginButton"));
|
||||
passwordReset.backToLoginLabel.text = getLocaleString("GUIResetPasswordRememberMessage");
|
||||
|
||||
// Character Selection GUI
|
||||
characterSelect.window.title = toUpperCase(getLocaleString("GUICharacterSelectWindowTitle"));
|
||||
characterSelect.cashText.text = getLocaleString("GUICharacterSelectMoneyLabel", "0");
|
||||
characterSelect.clanText.text = getLocaleString("GUICharacterSelectClanLabel", "None");
|
||||
characterSelect.lastPlayedText.text = getLocaleString("GUICharacterSelectLastPlayedLabel", "Never");
|
||||
characterSelect.previousCharacterButton.text = toUpperCase(getLocaleString("GUIPreviousCharacterButton"));
|
||||
characterSelect.nextCharacterButton.text = toUpperCase(getLocaleString("GUINextCharacterButton"));
|
||||
characterSelect.selectCharacterButton.text = toUpperCase(getLocaleString("GUIPlayAsCharacterButton"));
|
||||
characterSelect.newCharacterButton.text = toUpperCase(getLocaleString("GUINewCharacterButton"));
|
||||
|
||||
// Character Creation GUI
|
||||
newCharacter.messageLabel.text = getLocaleString("GUINewCharacterMessageLabel");
|
||||
newCharacter.firstNameInput.placeholder = getLocaleString("GUINewCharacterFirstNamePlaceholder");
|
||||
newCharacter.lastNameInput.placeholder = getLocaleString("GUINewCharacterLastNamePlaceholder");
|
||||
newCharacter.createCharacterButton.text = toUpperCase(getLocaleString("GUINewCharacterSubmitButton"));
|
||||
}
|
||||
136
scripts/client/gui/2fa.js
Normal file
@@ -0,0 +1,136 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: 2fa.js
|
||||
// DESC: Provides two factor authentication GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let twoFactorAuth = {
|
||||
window: null,
|
||||
logoImage: null,
|
||||
qrCode: null,
|
||||
messageLabel: null,
|
||||
codeLabel: null,
|
||||
codeInput: null,
|
||||
submitButton: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initTwoFactorAuthenticationGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating two factor auth GUI ...`);
|
||||
twoFactorAuth.window = mexui.window(game.width / 2 - 150, game.height / 2 - 129, 300, 258, 'LOGIN', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
twoFactorAuth.window.titleBarIconSize = toVector2(0, 0);
|
||||
twoFactorAuth.window.titleBarHeight = 0;
|
||||
|
||||
twoFactorAuth.qrCode = twoFactorAuth.window.image(100, 20, 100, 100, mainLogoPath, {
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
twoFactorAuth.codeLabel = twoFactorAuth.window.text(20, 135, 260, 20, 'Please enter the code sent to your email!', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
twoFactorAuth.codeInput = twoFactorAuth.window.textInput(20, 170, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], textInputAlpha),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
textColour: toColour(200, 200, 200, 150),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
|
||||
},
|
||||
});
|
||||
twoFactorAuth.codeInput.placeholder = "Code";
|
||||
|
||||
twoFactorAuth.submitButton = twoFactorAuth.window.button(20, 205, 260, 30, 'SUBMIT', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
},
|
||||
}, checkTwoFactorAuth);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created two factor auth GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showTwoFactorAuthGUI() {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing two-factor authentication window`);
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
twoFactorAuth.window.shown = true;
|
||||
mexui.focusedControl = twoFactorAuth.codeInput;
|
||||
guiSubmitKey = checkTwoFactorAuth;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function twoFactorAuthFailed(errorMessage) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports two-factor authentication failed. Reason: ${errorMessage}`);
|
||||
twoFactorAuth.messageLabel.text = errorMessage;
|
||||
twoFactorAuth.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||
twoFactorAuth.codeInput.text = "";
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function twoFactorAuthSuccess() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports two-factor authentication was successful`);
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkTwoFactorAuth() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking two-factor authentication with server ...`);
|
||||
sendNetworkEventToServer("agrp.2fa", twoFactorAuth.codeInput.lines[0]);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
9
scripts/client/gui/bizmgr.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: bizmgr.js
|
||||
// DESC: Provides business manager GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
158
scripts/client/gui/changepass.js
Normal file
@@ -0,0 +1,158 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: changepass.js
|
||||
// DESC: Provides change password GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let passwordChange = {
|
||||
window: null,
|
||||
logoImage: null,
|
||||
messageLabel: null,
|
||||
passwordInput: null,
|
||||
confirmPasswordInput: null,
|
||||
submitButton: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initChangePasswordGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password change GUI ...`);
|
||||
passwordChange.window = mexui.window(game.width / 2 - 130, game.height / 2 - 125, 300, 250, 'Change Password', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
}
|
||||
});
|
||||
passwordChange.window.titleBarIconSize = toVector2(0, 0);
|
||||
passwordChange.window.titleBarHeight = 0;
|
||||
passwordChange.window.titleBarShown = false;
|
||||
|
||||
passwordChange.window.image(100, 20, 75, 75, mainLogoPath, {
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
passwordChange.messageLabel = passwordChange.window.text(20, 95, 260, 20, 'Enter a new password', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
passwordChange.passwordInput = passwordChange.window.textInput(20, 130, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 200),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
}
|
||||
});
|
||||
passwordChange.passwordInput.masked = true;
|
||||
passwordChange.passwordInput.placeholder = "Password";
|
||||
|
||||
passwordChange.confirmPasswordInput = passwordChange.window.textInput(20, 160, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 200),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
}
|
||||
});
|
||||
passwordChange.confirmPasswordInput.masked = true;
|
||||
passwordChange.confirmPasswordInput.placeholder = "Confirm password";
|
||||
|
||||
passwordChange.submitButton = passwordChange.window.button(20, 195, 260, 30, 'CHANGE PASSWORD', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(255, 255, 255, 255),
|
||||
textSize: 12.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
},
|
||||
}, checkChangePassword);
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created change password GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function passwordChangeFailed(errorMessage) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports change password failed. Reason: ${errorMessage}`);
|
||||
passwordChange.messageLabel.text = errorMessage;
|
||||
passwordChange.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||
passwordChange.passwordInput.text = "";
|
||||
passwordChange.confirmPasswordInput.text = "";
|
||||
passwordChange.verificationCodeInput.text = "";
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkChangePassword() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password change with server ...`);
|
||||
sendNetworkEventToServer("agrp.checkChangePassword", passwordChange.passwordInput.lines[0], passwordChange.confirmPasswordInput.lines[0]);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showChangePasswordGUI(errorMessage) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing change password window`);
|
||||
closeAllWindows();
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
passwordChange.window.shown = true;
|
||||
passwordChange.messageLabel = errorMessage;
|
||||
mexui.focusedControl = passwordChange.passwordInput;
|
||||
guiSubmitKey = checkChangePassword;
|
||||
|
||||
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), passwordChange.window.position.y + passwordChange.window.size.y + 20));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function passwordChangeSuccess() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports password change was successful`);
|
||||
guiSubmitKey = false;
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
249
scripts/client/gui/charselect.js
Normal file
@@ -0,0 +1,249 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: charselect.js
|
||||
// DESC: Provides character select GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let characterSelect = {
|
||||
window: null,
|
||||
skinImage: null,
|
||||
nameText: null,
|
||||
cashText: null,
|
||||
clanText: null,
|
||||
lastPlayedText: null,
|
||||
previousCharacterButton: null,
|
||||
nextCharacterButton: null,
|
||||
selectCharacterButton: null,
|
||||
newCharacterButton: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initCharacterSelectGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating character select GUI ...`);
|
||||
characterSelect.window = mexui.window(game.width / 2 - 215, game.height / 2 - 83, 430, 190, 'SELECT CHARACTER', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
},
|
||||
title: {
|
||||
textSize: 12.0,
|
||||
textFont: mainFont,
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
}
|
||||
});
|
||||
characterSelect.window.titleBarIconSize = toVector2(0, 0);
|
||||
characterSelect.window.titleBarIconShown = false;
|
||||
characterSelect.window.titleBarHeight = 30;
|
||||
|
||||
characterSelect.nameText = characterSelect.window.text(5, 40, 200, 25, 'Lastname, Firstname', {
|
||||
main: {
|
||||
textSize: 14.0,
|
||||
textAlign: 0.0,
|
||||
textColour: toColour(255, 255, 255, 220),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
}
|
||||
});
|
||||
|
||||
characterSelect.cashText = characterSelect.window.text(5, 65, 200, 25, 'Cash: $0', {
|
||||
main: {
|
||||
textSize: 9.0,
|
||||
textAlign: 0.0,
|
||||
textColour: toColour(255, 255, 255, 220),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
}
|
||||
});
|
||||
|
||||
characterSelect.clanText = characterSelect.window.text(5, 80, 200, 25, 'Clan: None', {
|
||||
main: {
|
||||
textSize: 9.0,
|
||||
textAlign: 0.0,
|
||||
textColour: toColour(255, 255, 255, 220),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
}
|
||||
});
|
||||
|
||||
characterSelect.lastPlayedText = characterSelect.window.text(5, 95, 200, 25, 'Last Played: Never', {
|
||||
main: {
|
||||
textSize: 9.0,
|
||||
textAlign: 0.0,
|
||||
textColour: toColour(255, 255, 255, 220),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
}
|
||||
});
|
||||
|
||||
characterSelect.selectCharacterButton = characterSelect.window.button(85, 130, 260, 25, 'PLAY', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
}
|
||||
}, selectThisCharacter);
|
||||
|
||||
characterSelect.newCharacterButton = characterSelect.window.button(5, 160, 420, 25, 'NEW CHARACTER', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
}
|
||||
}, showNewCharacter);
|
||||
|
||||
characterSelect.previousCharacterButton = characterSelect.window.button(5, 130, 75, 25, 'PREV', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
}
|
||||
}, selectPreviousCharacter);
|
||||
|
||||
characterSelect.nextCharacterButton = characterSelect.window.button(350, 130, 75, 25, 'NEXT', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
}
|
||||
}, selectNextCharacter);
|
||||
|
||||
characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png", {
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
}
|
||||
});
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created character select GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, skinId) {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing character selection window`);
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
characterSelect.nameText.text = `${firstName} ${lastName}`;
|
||||
characterSelect.cashText.text = `Money: $${cash}`;
|
||||
characterSelect.clanText.text = `Clan: ${clan}`;
|
||||
characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`;
|
||||
characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
|
||||
characterSelect.window.shown = true;
|
||||
|
||||
guiSubmitKey = selectThisCharacter;
|
||||
guiLeftKey = selectPreviousCharacter;
|
||||
guiRightKey = selectNextCharacter;
|
||||
|
||||
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), characterSelect.window.position.y + characterSelect.window.size.y + 20));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showNewCharacter() {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing new character dialog window`);
|
||||
showNewCharacterGUI();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function selectNextCharacter() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Requesting next character info from server for character select window`);
|
||||
sendNetworkEventToServer("agrp.nextCharacter");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function selectPreviousCharacter() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Requesting previous character info from server for character select window`);
|
||||
sendNetworkEventToServer("agrp.previousCharacter");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function selectThisCharacter() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Tell server the current shown character was selected in character select window`);
|
||||
sendNetworkEventToServer("agrp.selectCharacter");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function switchCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, skinId) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Updating character info with data from server`);
|
||||
setChatWindowEnabled(false);
|
||||
characterSelect.window.shown = false;
|
||||
characterSelect.nameText.text = `${firstName} ${lastName}`;
|
||||
characterSelect.cashText.text = `Money: $${cash}`;
|
||||
characterSelect.clanText.text = `Clan: ${clan}`;
|
||||
characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`;
|
||||
|
||||
if (characterSelect.skinImage != null) {
|
||||
characterSelect.skinImage.remove();
|
||||
}
|
||||
characterSelect.skinImage = (getGame() == AGRP_GAME_GTA_III) ? characterSelect.window.image(310, 32, 100, 90, `files/images/skins/gta3/${getSkinImage(skinId)}.png`) : characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
|
||||
|
||||
characterSelect.window.shown = true;
|
||||
|
||||
guiSubmitKey = selectThisCharacter;
|
||||
guiLeftKey = selectPreviousCharacter;
|
||||
guiRightKey = selectNextCharacter;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function characterSelectSuccess() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports character selection was successful`);
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getSkinImage(skinId, gameId = getGame()) {
|
||||
if (skinId < 10) {
|
||||
return `Skin_00${skinId}.png`;
|
||||
} else if (skinId > 10 && skinId < 100) {
|
||||
return `Skin_0${skinId}.png`;
|
||||
} else if (skinId > 100) {
|
||||
return `Skin_${skinId}.png`;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
21
scripts/client/gui/clanmgr.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: clanmgr.js
|
||||
// DESC: Provides clan manager GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let clanManager = {
|
||||
window: null,
|
||||
generalTab: null,
|
||||
ranksTab: null,
|
||||
membersTab: null,
|
||||
vehiclesTab: null,
|
||||
businessesTab: null,
|
||||
housesTab: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
86
scripts/client/gui/error.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: error.js
|
||||
// DESC: Provides error box GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let errorDialog = {
|
||||
window: null,
|
||||
messageLabel: null,
|
||||
okayButton: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initErrorDialogGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating error GUI ...`);
|
||||
errorDialog.window = mexui.window(getScreenWidth() / 2 - 200, getScreenHeight() / 2 - 70, 400, 140, 'ERROR', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 11.0,
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
errorDialog.messageLabel = errorDialog.window.text(15, 50, 370, 20, 'Error Message', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(255, 255, 255, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
errorDialog.okayButton = errorDialog.window.button(5, 105, 390, 30, 'OK', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
|
||||
},
|
||||
}, closeErrorDialog);
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created error GUI ...`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showErrorGUI(errorMessage, errorTitle, buttonText) {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`);
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
errorDialog.messageLabel.text = errorMessage;
|
||||
errorDialog.okayButton.text = buttonText;
|
||||
errorDialog.window.title = errorTitle;
|
||||
errorDialog.window.shown = true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function closeErrorDialog() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing error dialog`);
|
||||
errorDialog.window.shown = false;
|
||||
mexui.setInput(false);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
9
scripts/client/gui/games/5-card-poker.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: 5cardpoker.js
|
||||
// DESC: Provides 5-card poker games GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
147
scripts/client/gui/games/betting.js
Normal file
@@ -0,0 +1,147 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: betting.js
|
||||
// DESC: Provides betting GUI (used for multiple casino games)
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let bettingGUI = {
|
||||
window: null,
|
||||
amountLabel: null,
|
||||
fiveThousandLabel: null,
|
||||
fiveThousandPlusButton: null,
|
||||
fiveThousandMinusButton: null,
|
||||
oneThousandLabel: null,
|
||||
oneThousandPlusButton: null,
|
||||
oneThousandMinusButton: null,
|
||||
fiveHundredPlusButton: null,
|
||||
fiveHundredMinusButton: null,
|
||||
oneHundredLabel: null,
|
||||
oneHundredPlusButton: null,
|
||||
oneHundredMinusButton: null,
|
||||
fiftyLabel: null,
|
||||
fiftyPlusButton: null,
|
||||
fiftyMinusButton: null,
|
||||
twentyLabel: null,
|
||||
twentyPlusButton: null,
|
||||
twentyMinusButton: null,
|
||||
tenLabel: null,
|
||||
tenPlusButton: null,
|
||||
tenMinusButton: null,
|
||||
fiveLabel: null,
|
||||
fivePlusButton: null,
|
||||
fiveMinusButton: null,
|
||||
oneLabel: null,
|
||||
onePlusButton: null,
|
||||
oneMinusButton: null,
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initBettingGUI() {
|
||||
bettingGUI.window = mexui.window(getScreenWidth() / 2 - 125, getScreenHeight() / 2 - 250, 250, 500, 'BETTING', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
bettingGUI.window.titleBarIconSize = toVector2(0, 0);
|
||||
bettingGUI.window.titleBarHeight = 0;
|
||||
bettingGUI.window.titleBarShown = false;
|
||||
|
||||
bettingGUI.amountLabel = bettingGUI.window.text(10, 20, 230, 20, 'Amount: 0', {
|
||||
main: {
|
||||
textSize: 20.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
bettingGUI.oneLabel = bettingGUI.window.text(10, 50, 230, 20, '1', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
bettingGUI.fiveLabel = bettingGUI.window.text(10, 65, 230, 20, '1', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
bettingGUI.tenLabel = bettingGUI.window.text(10, 80, 230, 20, '1', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
bettingGUI.fiftyLabel = bettingGUI.window.text(10, 95, 230, 20, '1', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
bettingGUI.hundredLabel = bettingGUI.window.text(10, 95, 230, 20, '1', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
bettingGUI.window.shown = false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showBettingGUI() {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
49
scripts/client/gui/games/blackjack.js
Normal file
@@ -0,0 +1,49 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: blackjack.js
|
||||
// DESC: Provides blackjack game GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let blackJackGUI = {
|
||||
window: null,
|
||||
dealerHand: [],
|
||||
playerHand: [],
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let playerCards = [];
|
||||
let dealerCards = [];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initBlackJackGUI() {
|
||||
// Render a blackjack game in MexUI
|
||||
//logToConsole(LOG_DEBUG, `[VRR.GUI] Creating blackjack GUI ...`);
|
||||
blackJackGUI.window = mexui.window(game.width / 2 - 200, game.height - 150, 400, 400, 'Blackjack', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], 0),
|
||||
},
|
||||
title: {
|
||||
textSize: 11.0,
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
blackJackGUI.window.titleBarShown = false;
|
||||
|
||||
blackJackGUI.window.shown = false;
|
||||
|
||||
//logToConsole(LOG_DEBUG, `[VRR.GUI] Created blackjack GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
9
scripts/client/gui/housemgr.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: housemgr.js
|
||||
// DESC: Provides house manager GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
84
scripts/client/gui/info.js
Normal file
@@ -0,0 +1,84 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: info.js
|
||||
// DESC: Provides info dialog box GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let infoDialog = {
|
||||
window: null,
|
||||
messageLabel: null,
|
||||
okayButton: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initInfoDialogGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating info dialog GUI ...`);
|
||||
infoDialog.window = mexui.window(getScreenWidth() / 2 - 200, getScreenHeight() / 2 - 70, 400, 140, 'Information', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
},
|
||||
title: {
|
||||
textSize: 11.0,
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
infoDialog.messageLabel = infoDialog.window.text(15, 50, 370, 20, 'Information Message', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(255, 255, 255, 220),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
infoDialog.okayButton = infoDialog.window.button(5, 105, 390, 30, 'OK', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
|
||||
},
|
||||
}, closeInfoDialog);
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created info dialog GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function closeInfoDialog() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing info dialog`);
|
||||
infoDialog.window.shown = false;
|
||||
mexui.setInput(false);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showInfoGUI(infoMessage, infoTitle, buttonText) {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`);
|
||||
mexui.setInput(true);
|
||||
infoDialog.messageLabel.text = infoMessage;
|
||||
infoDialog.okayButton.text = buttonText;
|
||||
infoDialog.window.title = infoTitle;
|
||||
infoDialog.window.shown = true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
108
scripts/client/gui/list.js
Normal file
@@ -0,0 +1,108 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: list.js
|
||||
// DESC: Provides simple list GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let listDialog = {
|
||||
window: null,
|
||||
messageLabel: null,
|
||||
listGrid: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initListGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating list dialog GUI ...`);
|
||||
listDialog.window = mexui.window(game.width / 2 - 200, game.height / 2 - 70, 400, 500, 'List', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
},
|
||||
title: {
|
||||
textSize: 11.0,
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 11.0,
|
||||
textColour: toColour(255, 255, 255, 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
hover: {
|
||||
backgroundColour: toColour(205, 60, 60, windowTitleAlpha),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
listDialog.messageLabel = infoDialog.window.text(5, 5, 390, 20, 'Select one', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(255, 255, 255, 220),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
listDialog.listGrid = listDialog.window.grid(5, 25, 390, 450, {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
},
|
||||
column: {
|
||||
lineColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
header: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha - 50),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], windowTitleAlpha),
|
||||
},
|
||||
cell: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], windowTitleAlpha),
|
||||
},
|
||||
row: {
|
||||
lineColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
hover: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 120),
|
||||
}
|
||||
}
|
||||
});
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created list dialog GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showListGUI() {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing login window`);
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
listDialog.window.shown = true;
|
||||
guiSubmitKey = checkListDialogSelection;
|
||||
guiUpKey = selectPreviousListItem;
|
||||
guiDownKey = selectNextListItem;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkListDialogSelection() {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function selectPreviousListItem() {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function selectNextListItem() {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
131
scripts/client/gui/localechooser.js
Normal file
@@ -0,0 +1,131 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: localechooser.js
|
||||
// DESC: Provides locale chooser GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let localeChooser = {
|
||||
window: null,
|
||||
flagImages: [],
|
||||
activeRingImages: [],
|
||||
};
|
||||
|
||||
let flagImageSize = toVector2(30, 30);
|
||||
let flagImageGap = toVector2(5, 5);
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initLocaleChooserGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating locale chooser GUI ...`);
|
||||
localeChooser.window = mexui.window(game.width / 2 - 200, game.height - 150, 60, 60, 'Choose a language', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], 0),
|
||||
},
|
||||
title: {
|
||||
textSize: 11.0,
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
localeChooser.window.titleBarShown = false;
|
||||
|
||||
localeChooser.window.shown = false;
|
||||
|
||||
loadLocaleConfig();
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created locale chooser GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function closeLocaleChooserGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing locale chooser window`);
|
||||
localeChooser.window.shown = false;
|
||||
for (let i in localeChooser.flagImages) {
|
||||
localeChooser.flagImages[i].shown = false;
|
||||
}
|
||||
mexui.setInput(false);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showLocaleChooserGUI(position = toVector2(0.0, 0.0)) {
|
||||
// Disabled for now until image loading crash can be fixed
|
||||
return false;
|
||||
|
||||
if (position.x != 0.0 && position.y != 0.0) {
|
||||
localeChooser.window.position = position;
|
||||
} else {
|
||||
localeChooser.window.position = toVector2((getScreenWidth() / 2) - (localeChooser.window.size.x / 2), getScreenHeight() - 100);
|
||||
}
|
||||
|
||||
//closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing locale chooser window`);
|
||||
mexui.setInput(true);
|
||||
localeChooser.window.shown = true;
|
||||
|
||||
for (let i in localeChooser.flagImages) {
|
||||
localeChooser.flagImages[i].shown = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleLocaleChooserGUI() {
|
||||
if (localeChooser.window.shown) {
|
||||
closeLocaleChooserGUI();
|
||||
} else {
|
||||
showLocaleChooserGUI();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function localeChooserSetLocale(localeId) {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Asking server to change locale to ${localeId}`);
|
||||
sendLocaleSelectToServer(localeId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetLocaleChooserOptions() {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Resetting locale chooser options`);
|
||||
|
||||
// let tempLocaleOptions = getServerData().localeOptions; // getAvailableLocaleOptions();
|
||||
let tempLocaleOptions = getAvailableLocaleOptions();
|
||||
|
||||
localeChooser.window.size = toVector2((tempLocaleOptions.length * (flagImageSize.x + flagImageGap.x)) + flagImageGap.x, flagImageSize.y + flagImageGap.y * 2);
|
||||
localeChooser.window.position = toVector2((getScreenWidth() / 2) - (localeChooser.window.size.x / 2), getScreenHeight() - 100);
|
||||
|
||||
for (let i in localeChooser.flagImages) {
|
||||
localeChooser.flagImages[i].remove();
|
||||
}
|
||||
|
||||
for (let i in tempLocaleOptions) {
|
||||
let imagePath = `files/images/flags/${tempLocaleOptions[i].flagImageFile}`;
|
||||
localeChooser.flagImages[i] = localeChooser.window.image((i * (flagImageSize.x + flagImageGap.x)) + flagImageGap.x, flagImageGap.y, flagImageSize.x, flagImageSize.y, imagePath, {
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
}, function () {
|
||||
localeChooserSetLocale(tempLocaleOptions[i].id);
|
||||
});
|
||||
|
||||
localeChooser.flagImages[i].shown = false;
|
||||
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Created locale chooser option ${tempLocaleOptions[i].englishName} with image ${imagePath}`);
|
||||
|
||||
//localeChooser.activeRingImages.push(activeRingImage);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
199
scripts/client/gui/login.js
Normal file
@@ -0,0 +1,199 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: login.js
|
||||
// DESC: Provides login GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let login = {
|
||||
window: null,
|
||||
logoImage: null,
|
||||
messageLabel: null,
|
||||
passwordInput: null,
|
||||
loginButton: null,
|
||||
forgotPasswordButton: null,
|
||||
resetPasswordLabel: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let loginHTML =
|
||||
`<html>
|
||||
<head>
|
||||
<title>Asshat Gaming Roleplay: Login</title>
|
||||
<style type="text/css" rel="stylesheet">
|
||||
.input-box
|
||||
{
|
||||
font-family: "Roboto";
|
||||
font-size: 14px;
|
||||
border-style: solid;
|
||||
border-colour: #0066AA;
|
||||
border-radius: 2px;
|
||||
color: #0066AA;
|
||||
};
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initLoginGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating login GUI ...`);
|
||||
login.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 135, 300, 275, 'LOGIN', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
login.window.titleBarIconSize = toVector2(0, 0);
|
||||
login.window.titleBarHeight = 0;
|
||||
login.window.titleBarShown = false;
|
||||
|
||||
login.logoImage = login.window.image(100, 20, 100, 100, mainLogoPath, {
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
login.messageLabel = login.window.text(20, 135, 260, 20, 'Please enter your password!', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
login.passwordInput = login.window.textInput(20, 170, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], textInputAlpha),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
textColour: toColour(200, 200, 200, 150),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
|
||||
},
|
||||
});
|
||||
login.passwordInput.masked = true;
|
||||
login.passwordInput.placeholder = "Password";
|
||||
|
||||
login.loginButton = login.window.button(20, 205, 260, 30, 'LOGIN', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
textSize: 12.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
},
|
||||
}, checkLogin);
|
||||
|
||||
login.forgotPasswordButton = login.window.button(180, 240, 100, 15, 'RESET PASS', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
textSize: 8.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
},
|
||||
}, switchToPasswordResetGUI);
|
||||
|
||||
login.resetPasswordLabel = login.window.text(110, 240, 60, 15, 'Forgot your password?', {
|
||||
main: {
|
||||
textSize: 8.0,
|
||||
textAlign: 1.0,
|
||||
textColour: toColour(180, 180, 180, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created login GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showLoginGUI() {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing login window`);
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
login.window.shown = true;
|
||||
mexui.focusedControl = login.passwordInput;
|
||||
guiSubmitKey = checkLogin;
|
||||
|
||||
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), login.window.position.y + login.window.size.y + 20));
|
||||
//showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkLogin() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking login with server ...`);
|
||||
sendNetworkEventToServer("agrp.checkLogin", login.passwordInput.lines[0]);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loginFailed(errorMessage) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports login failed`);
|
||||
login.messageLabel.text = errorMessage;
|
||||
login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||
login.passwordInput.text = "";
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loginSuccess() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports login was successful`);
|
||||
guiSubmitKey = false;
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function switchToPasswordResetGUI() {
|
||||
//closeAllWindows();
|
||||
//logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset dialog window`);
|
||||
//showResetPasswordGUI();
|
||||
sendNetworkEventToServer("agrp.checkResetPassword", "");
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
167
scripts/client/gui/newchar.js
Normal file
@@ -0,0 +1,167 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: newchar.js
|
||||
// DESC: Provides new character creation GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let newCharacter = {
|
||||
window: null,
|
||||
messageLabel: null,
|
||||
firstNameInput: null,
|
||||
lastNameInput: null,
|
||||
createCharacterButton: null,
|
||||
mainLogoImage: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initNewCharacterGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating new character GUI ...`);
|
||||
newCharacter.window = mexui.window(getScreenWidth() / 2 - 130, getScreenHeight() / 2 - 115, 300, 230, 'NEW CHARACTER', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 12.0,
|
||||
textFont: mainFont,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
}
|
||||
});
|
||||
newCharacter.window.titleBarIconSize = toVector2(0, 0);
|
||||
newCharacter.window.titleBarIconShown = false;
|
||||
newCharacter.window.titleBarShown = false;
|
||||
newCharacter.window.titleBarHeight = 30;
|
||||
|
||||
newCharacter.mainLogoImage = newCharacter.window.image(80, 20, 80, 80, mainLogoPath, {
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
newCharacter.messageLabel = newCharacter.window.text(20, 100, 260, 20, 'Name your character', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
newCharacter.firstNameInput = newCharacter.window.textInput(20, 125, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 200),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
}
|
||||
});
|
||||
newCharacter.firstNameInput.placeholder = "First Name";
|
||||
|
||||
newCharacter.lastNameInput = newCharacter.window.textInput(20, 155, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(150, 150, 150, 200),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
}
|
||||
});
|
||||
newCharacter.lastNameInput.placeholder = "Last Name";
|
||||
|
||||
newCharacter.createCharacterButton = newCharacter.window.button(20, 185, 260, 25, 'CREATE CHARACTER', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(255, 255, 255, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
},
|
||||
}, checkNewCharacter);
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created new character GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function newCharacterFailed(errorMessage) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports new character creation failed. Reason: ${errorMessage}`);
|
||||
newCharacter.messageLabel.text = errorMessage;
|
||||
newCharacter.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||
newCharacter.firstNameInput.text = "";
|
||||
newCharacter.lastNameInput.text = "";
|
||||
|
||||
if (!newCharacter.window.shown) {
|
||||
closeAllWindows();
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
setHUDEnabled(false);
|
||||
newCharacter.window.shown = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkNewCharacter() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking new character with server ...`);
|
||||
if (newCharacter.firstNameInput.lines[0].length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newCharacter.lastNameInput.lines[0].length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendNetworkEventToServer("agrp.checkNewCharacter",
|
||||
newCharacter.firstNameInput.lines[0],
|
||||
newCharacter.lastNameInput.lines[0],
|
||||
);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showNewCharacterGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing new character window`);
|
||||
closeAllWindows();
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
newCharacter.window.shown = true;
|
||||
mexui.focusedInput = newCharacter.firstNameInput;
|
||||
guiSubmitKey = checkNewCharacter;
|
||||
|
||||
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), newCharacter.window.position.y + newCharacter.window.size.y + 20));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
179
scripts/client/gui/register.js
Normal file
@@ -0,0 +1,179 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: register.js
|
||||
// DESC: Provides account registration GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let register = {
|
||||
window: null,
|
||||
logoImage: null,
|
||||
messageLabel: null,
|
||||
passwordInput: null,
|
||||
confirmPasswordInput: null,
|
||||
emailInput: null,
|
||||
registerButton: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initRegisterGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating register GUI ...`);
|
||||
register.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 150, 300, 300, 'Register', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
}
|
||||
});
|
||||
register.window.titleBarIconSize = toVector2(0, 0);
|
||||
register.window.titleBarHeight = 0;
|
||||
register.window.titleBarShown = false;
|
||||
|
||||
register.window.image(100, 20, 100, 100, mainLogoPath, {
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
register.messageLabel = register.window.text(20, 125, 260, 20, 'Create an account', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
register.passwordInput = register.window.textInput(20, 150, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 200),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
}
|
||||
});
|
||||
register.passwordInput.masked = true;
|
||||
register.passwordInput.placeholder = "Password";
|
||||
|
||||
register.confirmPasswordInput = register.window.textInput(20, 180, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 200),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
}
|
||||
});
|
||||
register.confirmPasswordInput.masked = true;
|
||||
register.confirmPasswordInput.placeholder = "Confirm password";
|
||||
|
||||
register.emailInput = register.window.textInput(20, 210, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
textColour: toColour(200, 200, 200, 200),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
}
|
||||
});
|
||||
register.emailInput.placeholder = "Email";
|
||||
|
||||
register.registerButton = register.window.button(20, 245, 260, 30, 'CREATE ACCOUNT', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(255, 255, 255, 255),
|
||||
textSize: 12.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
},
|
||||
}, checkRegistration);
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created register GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function registrationFailed(errorMessage) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports registration failed. Reason: ${errorMessage}`);
|
||||
register.messageLabel.text = errorMessage;
|
||||
register.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||
register.passwordInput.text = "";
|
||||
register.confirmPasswordInput.text = "";
|
||||
register.emailInput.text = "";
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkRegistration() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking registration with server ...`);
|
||||
sendNetworkEventToServer("agrp.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showRegistrationGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing registration window`);
|
||||
closeAllWindows();
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
register.window.shown = true;
|
||||
mexui.focusedControl = register.passwordInput;
|
||||
guiSubmitKey = checkRegistration;
|
||||
|
||||
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), register.window.position.y + register.window.size.y + 20));
|
||||
|
||||
//showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function registrationSuccess() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports registration was successful`);
|
||||
guiSubmitKey = false;
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
196
scripts/client/gui/resetpass.js
Normal file
@@ -0,0 +1,196 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: resetpass.js
|
||||
// DESC: Provides password reset GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let passwordReset = {
|
||||
window: null,
|
||||
logoImage: null,
|
||||
messageLabel: null,
|
||||
emailInput: null,
|
||||
resetPasswordButton: null,
|
||||
backToLoginButton: null,
|
||||
backToLoginLabel: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initResetPasswordGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password reset GUI ...`);
|
||||
passwordReset.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 135, 300, 275, 'RESET PASSWORD', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
passwordReset.window.titleBarIconSize = toVector2(0, 0);
|
||||
passwordReset.window.titleBarHeight = 0;
|
||||
passwordReset.window.titleBarShown = false;
|
||||
|
||||
passwordReset.logoImage = passwordReset.window.image(100, 20, 100, 100, mainLogoPath, {
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
passwordReset.messageLabel = passwordReset.window.text(20, 135, 260, 20, 'Please confirm your email', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
passwordReset.emailInput = passwordReset.window.textInput(20, 170, 260, 25, '', {
|
||||
main: {
|
||||
backgroundColour: toColour(0, 0, 0, 120),
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], textInputAlpha),
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
caret: {
|
||||
lineColour: toColour(255, 255, 255, 255),
|
||||
},
|
||||
placeholder: {
|
||||
textColour: toColour(200, 200, 200, 150),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
|
||||
},
|
||||
});
|
||||
passwordReset.emailInput.placeholder = "Email";
|
||||
|
||||
passwordReset.resetPasswordButton = passwordReset.window.button(20, 205, 260, 30, 'RESET PASSWORD', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 12.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
},
|
||||
}, checkResetPassword);
|
||||
|
||||
passwordReset.backToLoginButton = passwordReset.window.button(200, 240, 80, 15, 'LOGIN', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 8.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
},
|
||||
}, switchToLoginGUI);
|
||||
|
||||
passwordReset.backToLoginLabel = passwordReset.window.text(110, 240, 60, 15, 'Remember your password?', {
|
||||
main: {
|
||||
textSize: 8.0,
|
||||
textAlign: 1.0,
|
||||
textColour: toColour(200, 200, 200, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created password reset GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showResetPasswordGUI() {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset window`);
|
||||
setChatWindowEnabled(false);
|
||||
mexui.setInput(true);
|
||||
passwordReset.window.shown = true;
|
||||
mexui.focusedControl = passwordReset.emailInput;
|
||||
guiSubmitKey = checkResetPassword;
|
||||
|
||||
showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), passwordReset.window.position.y + passwordReset.window.size.y + 20));
|
||||
//showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkResetPassword() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password reset with server (${passwordReset.emailInput.lines[0]}) ...`);
|
||||
sendNetworkEventToServer("agrp.checkResetPassword", passwordReset.emailInput.lines[0]);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetPasswordFailed(errorMessage) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports password reset failed`);
|
||||
passwordReset.messageLabel.text = errorMessage;
|
||||
passwordReset.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||
passwordReset.emailInput.text = "";
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetPasswordCodeInputGUI() {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Server reports password reset email confirmation was successful. Asking for code ...`);
|
||||
closeAllWindows();
|
||||
|
||||
passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordCodeInputLabel");
|
||||
//passwordReset.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||
passwordReset.emailInput.lines[0] = "";
|
||||
passwordReset.emailInput.placeholder = getLocaleString("GUIResetPasswordCodePlaceholder");
|
||||
|
||||
guiSubmitKey = checkResetPassword;
|
||||
showResetPasswordGUI();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetPasswordEmailInputGUI() {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Server reports password reset request was approved. Asking for email ...`);
|
||||
closeAllWindows();
|
||||
|
||||
passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordConfirmEmailLabel");
|
||||
//passwordReset.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||
passwordReset.emailInput.text = "";
|
||||
passwordReset.emailInput.placeholder = getLocaleString("GUIResetPasswordEmailPlaceholder");
|
||||
|
||||
guiSubmitKey = checkResetPassword;
|
||||
showResetPasswordGUI();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function switchToLoginGUI() {
|
||||
guiSubmitKey = false;
|
||||
closeAllWindows();
|
||||
showLoginGUI();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
116
scripts/client/gui/yesno.js
Normal file
@@ -0,0 +1,116 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: yesno.js
|
||||
// DESC: Provides yes/no prompt dialog GUI
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
|
||||
let yesNoDialog = {
|
||||
window: null,
|
||||
messageLabel: null,
|
||||
yesButton: null,
|
||||
noButton: null,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initYesNoDialogGUI() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created prompt GUI ...`);
|
||||
yesNoDialog.window = mexui.window(game.width / 2 - 200, game.height / 2 - 70, 400, 140, 'Question', {
|
||||
main: {
|
||||
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
|
||||
transitionTime: 500,
|
||||
},
|
||||
title: {
|
||||
textSize: 11.0,
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
|
||||
},
|
||||
icon: {
|
||||
textSize: 0.0,
|
||||
textColour: toColour(0, 0, 0, 0),
|
||||
backgroundColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
yesNoDialog.messageLabel = yesNoDialog.window.text(15, 50, 370, 20, 'Would you like to answer this question?', {
|
||||
main: {
|
||||
textSize: 10.0,
|
||||
textAlign: 0.5,
|
||||
textColour: toColour(255, 255, 255, 255),
|
||||
textFont: mainFont,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(0, 0, 0, 0),
|
||||
},
|
||||
});
|
||||
|
||||
yesNoDialog.yesButton = yesNoDialog.window.button(5, 105, 193, 30, 'YES', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
|
||||
},
|
||||
}, yesNoDialogAnswerYes);
|
||||
|
||||
yesNoDialog.noButton = yesNoDialog.window.button(203, 105, 192, 30, 'NO', {
|
||||
main: {
|
||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||
textSize: 10.0,
|
||||
textFont: mainFont,
|
||||
textAlign: 0.5,
|
||||
},
|
||||
focused: {
|
||||
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
|
||||
},
|
||||
}, yesNoDialogAnswerNo);
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Created prompt GUI`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonText) {
|
||||
closeAllWindows();
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
|
||||
mexui.setInput(true);
|
||||
|
||||
yesNoDialog.messageLabel.text = "";
|
||||
yesNoDialog.yesButton.text = "";
|
||||
yesNoDialog.noButton.text = "";
|
||||
yesNoDialog.window.title = "";
|
||||
|
||||
yesNoDialog.messageLabel.text = promptMessage;
|
||||
yesNoDialog.yesButton.text = yesButtonText;
|
||||
yesNoDialog.noButton.text = noButtonText;
|
||||
yesNoDialog.window.title = promptTitle;
|
||||
|
||||
yesNoDialog.window.shown = true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function yesNoDialogAnswerNo() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Responding with answer NO to server prompt`);
|
||||
sendNetworkEventToServer("agrp.promptAnswerNo");
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function yesNoDialogAnswerYes() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Responding with answer YES to server prompt`);
|
||||
sendNetworkEventToServer("agrp.promptAnswerYes");
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: house.js
|
||||
// DESC: Provides house functions and usage
|
||||
@@ -25,8 +26,8 @@ class HouseData {
|
||||
function receiveHouseFromServer(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.House] Received house ${houseId} (${name}) from server`);
|
||||
|
||||
if(!areServerElementsSupported()) {
|
||||
if(getHouseData(houseId) != false) {
|
||||
if (!areServerElementsSupported()) {
|
||||
if (getHouseData(houseId) != false) {
|
||||
let houseData = getHouseData(houseId);
|
||||
houseData.description = description;
|
||||
houseData.entrancePosition = entrancePosition;
|
||||
@@ -35,10 +36,10 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
|
||||
houseData.hasInterior = hasInterior;
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} already exists. Checking blip ...`);
|
||||
if(blipModel == -1) {
|
||||
if(houseData.blipId != -1) {
|
||||
if (blipModel == -1) {
|
||||
if (houseData.blipId != -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been removed by the server`);
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.removeBlipAndClearIndex(getHouseData(houseId).blipId);
|
||||
} else {
|
||||
destroyElement(getElementFromId(blipId));
|
||||
@@ -48,18 +49,18 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
|
||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip is unchanged`);
|
||||
}
|
||||
} else {
|
||||
if(houseData.blipId != -1) {
|
||||
if (houseData.blipId != -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been changed by the server`);
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.setBlipCoordinates(houseData.blipId, houseData.entrancePosition);
|
||||
natives.changeBlipSprite(houseData.blipId, houseData.blipModel);
|
||||
natives.setBlipMarkerLongDistance(houseData.blipId, false);
|
||||
natives.setBlipAsShortRange(houseData.blipId, true);
|
||||
natives.changeBlipNameFromAscii(houseData.blipId, `${houseData.name.substr(0, 24)}${(houseData.name.length > 24) ? " ...": ""}`);
|
||||
natives.changeBlipNameFromAscii(houseData.blipId, `${houseData.name.substr(0, 24)}${(houseData.name.length > 24) ? " ..." : ""}`);
|
||||
}
|
||||
} else {
|
||||
let blipId = createGameBlip(houseData.blipModel, houseData.entrancePosition, houseData.name);
|
||||
if(blipId != -1) {
|
||||
if (blipId != -1) {
|
||||
houseData.blipId = blipId;
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||
@@ -68,9 +69,9 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
|
||||
} else {
|
||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} doesn't exist. Adding ...`);
|
||||
let tempHouseData = new HouseData(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior);
|
||||
if(blipModel != -1) {
|
||||
if (blipModel != -1) {
|
||||
let blipId = createGameBlip(tempHouseData.blipModel, tempHouseData.entrancePosition, "House");
|
||||
if(blipId != -1) {
|
||||
if (blipId != -1) {
|
||||
tempHouseData.blipId = blipId;
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||
@@ -89,10 +90,10 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
|
||||
* @param {number} houseId - The ID of the house (initially provided by server)
|
||||
* @return {HouseData} The house's data (class instance)
|
||||
*/
|
||||
function getHouseData(houseId) {
|
||||
function getHouseData(houseId) {
|
||||
let houses = getServerData().houses;
|
||||
for(let i in houses) {
|
||||
if(houses[i].houseId == houseId) {
|
||||
for (let i in houses) {
|
||||
if (houses[i].houseId == houseId) {
|
||||
return houses[i];
|
||||
}
|
||||
}
|
||||
@@ -103,7 +104,7 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
|
||||
// ===========================================================================
|
||||
|
||||
function setAllHouseDataIndexes() {
|
||||
for(let i in getServerData().houses) {
|
||||
for (let i in getServerData().houses) {
|
||||
getServerData().houses[i].index = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: item.js
|
||||
// DESC: Provides item action and hotbar functions
|
||||
@@ -10,7 +11,7 @@
|
||||
let itemActionDelayDuration = 0;
|
||||
let itemActionDelayStart = 0;
|
||||
let itemActionDelayEnabled = false;
|
||||
let itemActionDelayPosition = toVector2(game.width/2-100, game.height-10);
|
||||
let itemActionDelayPosition = toVector2(game.width / 2 - 100, game.height - 10);
|
||||
let itemActionDelaySize = toVector2(200, 5);
|
||||
|
||||
// ===========================================================================
|
||||
@@ -23,22 +24,22 @@ function initItemScript() {
|
||||
// ===========================================================================
|
||||
|
||||
function processItemActionRendering() {
|
||||
if(renderItemActionDelay) {
|
||||
if(itemActionDelayEnabled) {
|
||||
let finishTime = itemActionDelayStart+itemActionDelayDuration;
|
||||
if(sdl.ticks >= finishTime) {
|
||||
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 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: job.js
|
||||
// DESC: Provides job functions and usage
|
||||
@@ -56,9 +57,10 @@ function setLocalPlayerWorkingState(tempWorking) {
|
||||
// ===========================================================================
|
||||
|
||||
function showJobRouteLocation(position, colour) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Showing job route location`);
|
||||
if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
|
||||
if(getGame() == VRR_GAME_GTA_SA) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Showing job route location at ${position.x}, ${position.y}, ${position.z}`);
|
||||
hideJobRouteLocation();
|
||||
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
// Server-side spheres don't show in GTA SA for some reason.
|
||||
jobRouteLocationSphere = game.createPickup(1318, position, 1);
|
||||
} else {
|
||||
@@ -66,7 +68,7 @@ function showJobRouteLocation(position, colour) {
|
||||
jobRouteLocationSphere.colour = colour;
|
||||
}
|
||||
|
||||
if(jobRouteLocationBlip != null) {
|
||||
if (jobRouteLocationBlip != null) {
|
||||
destroyElement(jobRouteLocationBlip);
|
||||
}
|
||||
|
||||
@@ -80,21 +82,7 @@ function showJobRouteLocation(position, colour) {
|
||||
|
||||
function enteredJobRouteSphere() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Entered job route sphere`);
|
||||
|
||||
clearInterval(jobBlipBlinkTimer);
|
||||
jobBlipBlinkAmount = 0;
|
||||
jobBlipBlinkTimes = 0;
|
||||
|
||||
if(jobRouteLocationBlip != null) {
|
||||
destroyElement(jobRouteLocationBlip);
|
||||
jobRouteLocationBlip = null;
|
||||
}
|
||||
|
||||
if(jobRouteLocationSphere != null) {
|
||||
destroyElement(jobRouteLocationSphere);
|
||||
jobRouteLocationSphere = null;
|
||||
}
|
||||
|
||||
hideJobRouteLocation();
|
||||
tellServerPlayerArrivedAtJobRouteLocation();
|
||||
}
|
||||
|
||||
@@ -102,23 +90,23 @@ function enteredJobRouteSphere() {
|
||||
|
||||
function blinkJobRouteLocationBlip(times, position, colour) {
|
||||
jobBlipBlinkTimes = times;
|
||||
jobBlipBlinkTimer = setInterval(function() {
|
||||
if(jobRouteLocationBlip != null) {
|
||||
jobBlipBlinkTimer = setInterval(function () {
|
||||
if (jobRouteLocationBlip != null) {
|
||||
destroyElement(jobRouteLocationBlip);
|
||||
jobRouteLocationBlip = null;
|
||||
} else {
|
||||
jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
|
||||
jobRouteLocationBlip = game.createBlip(position, 0, 3, colour);
|
||||
}
|
||||
|
||||
if(jobBlipBlinkAmount >= jobBlipBlinkTimes) {
|
||||
if(jobRouteLocationBlip != null) {
|
||||
if (jobBlipBlinkAmount >= jobBlipBlinkTimes) {
|
||||
if (jobRouteLocationBlip != null) {
|
||||
destroyElement(jobRouteLocationBlip);
|
||||
jobRouteLocationBlip = null;
|
||||
}
|
||||
|
||||
jobBlipBlinkAmount = 0;
|
||||
jobBlipBlinkTimes = 0;
|
||||
jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
|
||||
jobRouteLocationBlip = game.createBlip(position, 0, 3, colour);
|
||||
clearInterval(jobBlipBlinkTimer);
|
||||
}
|
||||
}, jobBlipBlinkInterval);
|
||||
@@ -127,10 +115,24 @@ function blinkJobRouteLocationBlip(times, position, colour) {
|
||||
// ===========================================================================
|
||||
|
||||
function hideJobRouteLocation() {
|
||||
destroyElement(jobRouteLocationSphere);
|
||||
destroyElement(jobRouteLocationBlip);
|
||||
jobRouteLocationSphere = null;
|
||||
jobRouteLocationBlip = null;
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Hiding job route location`);
|
||||
|
||||
if (jobRouteLocationBlip != null) {
|
||||
destroyElement(jobRouteLocationBlip);
|
||||
jobRouteLocationBlip = null;
|
||||
}
|
||||
|
||||
if (jobRouteLocationSphere != null) {
|
||||
destroyElement(jobRouteLocationSphere);
|
||||
jobRouteLocationSphere = null;
|
||||
}
|
||||
|
||||
if (jobBlipBlinkTimer != null) {
|
||||
clearInterval(jobBlipBlinkTimer);
|
||||
}
|
||||
|
||||
jobBlipBlinkAmount = 0;
|
||||
jobBlipBlinkTimes = 0;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -138,8 +140,8 @@ function hideJobRouteLocation() {
|
||||
function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, pickupModel) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Received job ${jobId} (${name}) from server`);
|
||||
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if(getJobData(jobId) != false) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (getJobData(jobId) != false) {
|
||||
let jobData = getJobData(jobId);
|
||||
jobData.jobLocationId = jobLocationId;
|
||||
jobData.name = name;
|
||||
@@ -148,10 +150,10 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
|
||||
jobData.pickupModel = pickupModel;
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} already exists. Checking blip ...`);
|
||||
if(blipModel == -1) {
|
||||
if(jobData.blipId != -1) {
|
||||
if (blipModel == -1) {
|
||||
if (jobData.blipId != -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been removed by the server`);
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.removeBlipAndClearIndex(getJobData(jobId).blipId);
|
||||
} else {
|
||||
destroyElement(getElementFromId(blipId));
|
||||
@@ -161,18 +163,18 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip is unchanged`);
|
||||
}
|
||||
} else {
|
||||
if(jobData.blipId != -1) {
|
||||
if (jobData.blipId != -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been changed by the server`);
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.setBlipCoordinates(jobData.blipId, jobData.position);
|
||||
natives.changeBlipSprite(jobData.blipId, jobData.blipModel);
|
||||
natives.setBlipMarkerLongDistance(jobData.blipId, false);
|
||||
natives.setBlipAsShortRange(jobData.blipId, true);
|
||||
natives.changeBlipNameFromAscii(jobData.blipId, `${jobData.name.substr(0, 24)}${(jobData.name.length > 24) ? " ...": ""}`);
|
||||
natives.changeBlipNameFromAscii(jobData.blipId, `${jobData.name.substr(0, 24)}${(jobData.name.length > 24) ? " ..." : ""}`);
|
||||
}
|
||||
} else {
|
||||
let blipId = createGameBlip(jobData.blipModel, jobData.position, jobData.name);
|
||||
if(blipId != -1) {
|
||||
if (blipId != -1) {
|
||||
jobData.blipId = blipId;
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||
@@ -181,9 +183,9 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
|
||||
} else {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} doesn't exist. Adding ...`);
|
||||
let tempJobData = new JobData(jobId, jobLocationId, name, position, blipModel, pickupModel);
|
||||
if(blipModel != -1) {
|
||||
if (blipModel != -1) {
|
||||
let blipId = createGameBlip(blipModel, tempJobData.position, tempJobData.name);
|
||||
if(blipId != -1) {
|
||||
if (blipId != -1) {
|
||||
tempJobData.blipId = blipId;
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||
@@ -202,9 +204,9 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
|
||||
* @param {number} job - The ID of the job (initially provided by server)
|
||||
* @return {JobData} The job's data (class instance)
|
||||
*/
|
||||
function getJobData(jobId) {
|
||||
for(let i in getServerData().jobs) {
|
||||
if(getServerData().jobs[i].jobId == jobId) {
|
||||
function getJobData(jobId) {
|
||||
for (let i in getServerData().jobs) {
|
||||
if (getServerData().jobs[i].jobId == jobId) {
|
||||
return getServerData().jobs[i];
|
||||
}
|
||||
}
|
||||
@@ -215,7 +217,7 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
|
||||
// ===========================================================================
|
||||
|
||||
function setAllJobDataIndexes() {
|
||||
for(let i in getServerData().jobs) {
|
||||
for (let i in getServerData().jobs) {
|
||||
jobs[i].index = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: keybind.js
|
||||
// DESC: Provides keybind features
|
||||
@@ -25,13 +26,13 @@ function initKeyBindScript() {
|
||||
function bindAccountKey(key, keyState) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Binded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
|
||||
keyBinds.push(toInteger(key));
|
||||
bindKey(toInteger(key), keyState, function(event) {
|
||||
if(isAnyGUIActive()) {
|
||||
bindKey(toInteger(key), keyState, function (event) {
|
||||
if (isAnyGUIActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(hasKeyBindDelayElapsed()) {
|
||||
if(canLocalPlayerUseKeyBinds()) {
|
||||
if (hasKeyBindDelayElapsed()) {
|
||||
if (canLocalPlayerUseKeyBinds()) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Using keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
|
||||
lastKeyBindUse = sdl.ticks;
|
||||
tellServerPlayerUsedKeyBind(key);
|
||||
@@ -56,7 +57,7 @@ function unBindAccountKey(key) {
|
||||
// ===========================================================================
|
||||
|
||||
function hasKeyBindDelayElapsed() {
|
||||
if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) {
|
||||
if (sdl.ticks - lastKeyBindUse >= keyBindDelayTime) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -66,15 +67,15 @@ function hasKeyBindDelayElapsed() {
|
||||
// ===========================================================================
|
||||
|
||||
function canLocalPlayerUseKeyBinds() {
|
||||
if(isAnyGUIActive()) {
|
||||
if (isAnyGUIActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isSpawned) {
|
||||
if (!isSpawned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(itemActionDelayEnabled) {
|
||||
if (itemActionDelayEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ function canLocalPlayerUseKeyBinds() {
|
||||
// ===========================================================================
|
||||
|
||||
function clearKeyBinds() {
|
||||
for(let i in keyBinds) {
|
||||
for (let i in keyBinds) {
|
||||
unbindKey(keyBinds[i]);
|
||||
}
|
||||
keyBinds = [];
|
||||
|
||||
389
scripts/client/label.js
Normal file
@@ -0,0 +1,389 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: labels.js
|
||||
// DESC: Provides functionality for world labels (3D labels)
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let businessLabels = [];
|
||||
let houseLabels = [];
|
||||
let jobLabels = [];
|
||||
|
||||
let propertyLabelNameFont = null;
|
||||
let propertyLabelLockedFont = null;
|
||||
let propertyLabelHeight = 1.0;
|
||||
|
||||
let jobNameLabelFont = null;
|
||||
let jobHelpLabelFont = null;
|
||||
|
||||
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;
|
||||
|
||||
let propertyLabelLockedOffset = 16;
|
||||
let propertyLabelNameOffset = 18;
|
||||
let propertyLabelPriceOffset = 16;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initLabelScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Label]: Initializing label script ...");
|
||||
propertyLabelNameFont = initLabelPropertyNameFont();
|
||||
propertyLabelLockedFont = initLabelPropertyLockedFont();
|
||||
jobNameLabelFont = initLabelJobNameFont();
|
||||
jobHelpLabelFont = initLabelJobHelpFont();
|
||||
logToConsole(LOG_DEBUG, "[VRR.Label]: Label script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
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, rentPrice, labelInfoType) {
|
||||
if (localPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propertyLabelNameFont == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propertyLabelLockedFont == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (!natives.doesViewportExist(natives.getGameViewportId())) {
|
||||
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!natives.isViewportActive(natives.getGameViewportId())) {
|
||||
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let tempPosition = position;
|
||||
tempPosition.z = tempPosition.z + propertyLabelHeight;
|
||||
let screenPosition = new Vec3(0.0, 0.0, 0.0);
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
|
||||
} else {
|
||||
screenPosition = getScreenFromWorldPosition(tempPosition);
|
||||
}
|
||||
|
||||
if (screenPosition.x < 0 || screenPosition.x > game.width) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let text = "";
|
||||
if (price > "0") {
|
||||
text = getLocaleString("PropertyForSaleLabel", 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(200, 200, 200, 255), false, true, false, true);
|
||||
|
||||
screenPosition.y -= propertyLabelPriceOffset;
|
||||
}
|
||||
|
||||
text = "";
|
||||
if (rentPrice != "0") {
|
||||
text = getLocaleString("PropertyForRentLabel", rentPrice);
|
||||
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
|
||||
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
|
||||
|
||||
screenPosition.y -= propertyLabelPriceOffset;
|
||||
}
|
||||
|
||||
if (isBusiness) {
|
||||
text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open"));
|
||||
} else {
|
||||
text = (locked) ? toUpperCase(getLocaleString("Locked")) : toUpperCase(getLocaleString("Unlocked"));
|
||||
}
|
||||
|
||||
if (!locked && labelInfoType != AGRP_PROPLABEL_INFO_NONE) {
|
||||
let infoText = "";
|
||||
switch (labelInfoType) {
|
||||
case AGRP_PROPLABEL_INFO_ENTER: {
|
||||
if (enterPropertyKey) {
|
||||
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
|
||||
} else {
|
||||
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROPLABEL_INFO_BUY: {
|
||||
infoText = getLocaleString("BusinessBuyItemsLabel", "/buy");
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROPLABEL_INFO_BUYBIZ: {
|
||||
infoText = getLocaleString("BuyBusinessLabel", "/bizbuy");
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROPLABEL_INFO_BUYHOUSE: {
|
||||
infoText = getLocaleString("BuyHouseLabel", "/housebuy");
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROPLABEL_INFO_RENTHOUSE: {
|
||||
infoText = getLocaleString("RentHouseLabel", "/houserent");
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROPLABEL_INFO_ENTERVEHICLE: {
|
||||
infoText = getLocaleString("VehicleDealershipLabel");
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
if (enterPropertyKey) {
|
||||
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
|
||||
} else {
|
||||
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (getDistance(localPlayer.position, position) <= renderLabelDistance - 2) {
|
||||
let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
|
||||
propertyLabelLockedFont.render(infoText, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true);
|
||||
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 -= propertyLabelNameOffset;
|
||||
|
||||
text = name || " ";
|
||||
if (profanityFilterEnabled) {
|
||||
text = replaceProfanityInMessage(text);
|
||||
}
|
||||
|
||||
size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
|
||||
propertyLabelNameFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function renderPropertyExitLabel(position) {
|
||||
if (localPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propertyLabelNameFont == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propertyLabelLockedFont == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (!natives.doesViewportExist(natives.getGameViewportId())) {
|
||||
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!natives.isViewportActive(natives.getGameViewportId())) {
|
||||
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let tempPosition = position;
|
||||
tempPosition.z = tempPosition.z + propertyLabelHeight;
|
||||
let screenPosition = new Vec3(0.0, 0.0, 0.0);
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
|
||||
} else {
|
||||
screenPosition = getScreenFromWorldPosition(tempPosition);
|
||||
}
|
||||
|
||||
if (screenPosition.x < 0 || screenPosition.x > game.width) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let text = "EXIT";
|
||||
let size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
|
||||
propertyLabelNameFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function renderJobLabel(name, position, jobType) {
|
||||
if (localPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (jobNameLabelFont == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (jobHelpLabelFont == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (!natives.doesViewportExist(natives.getGameViewportId())) {
|
||||
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!natives.isViewportActive(natives.getGameViewportId())) {
|
||||
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let tempPosition = position;
|
||||
tempPosition.z = tempPosition.z + propertyLabelHeight;
|
||||
let screenPosition = new Vec3(0.0, 0.0, 0.0);
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
|
||||
} else {
|
||||
screenPosition = getScreenFromWorldPosition(tempPosition);
|
||||
}
|
||||
|
||||
if (screenPosition.x < 0 || screenPosition.x > game.width) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let text = "";
|
||||
if (jobType == localPlayerJobType) {
|
||||
if (localPlayerWorking) {
|
||||
text = getLocaleString("JobEquipAndUniformLabel", "/equip", "/uniform", "/stopwork");
|
||||
} else {
|
||||
text = getLocaleString("StartWorkLabel", "/startwork");
|
||||
}
|
||||
} else {
|
||||
if (localPlayerJobType == 0) {
|
||||
text = getLocaleString("TakeJobLabel", "/takejob");
|
||||
} else {
|
||||
text = getLocaleString("NotYourJobLabel", "/quitjob");
|
||||
}
|
||||
}
|
||||
|
||||
let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true);
|
||||
jobHelpLabelFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true);
|
||||
|
||||
screenPosition.y -= 18;
|
||||
|
||||
text = getLocaleString("JobLabel", name);
|
||||
size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true);
|
||||
jobNameLabelFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function processLabelRendering() {
|
||||
if (renderLabels) {
|
||||
if (!areServerElementsSupported()) {
|
||||
if (localPlayer != null) {
|
||||
getServerData().businesses.forEach((business) => {
|
||||
if (getDistance(localPlayer.position, business.entrancePosition) <= 75.0) {
|
||||
natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255);
|
||||
//renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, makeLargeNumberReadable(business.price), makeLargeNumberReadable(business.rentPrice), business.labelInfoType);
|
||||
}
|
||||
});
|
||||
|
||||
getServerData().houses.forEach((house) => {
|
||||
if (getDistance(localPlayer.position, house.entrancePosition) <= 75.0) {
|
||||
natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255);
|
||||
//renderPropertyEntranceLabel("House", house.entrancePosition, house.locked, true, makeLargeNumberReadable(house.price), makeLargeNumberReadable(house.rentPrice), 0);
|
||||
}
|
||||
});
|
||||
|
||||
getServerData().jobs.forEach((job) => {
|
||||
if (getDistance(localPlayer.position, job.position) <= 75.0) {
|
||||
natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255);
|
||||
//renderJobLabel(job.name, job.position, job.jobType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (areWorldLabelsSupported()) {
|
||||
if (localPlayer != null) {
|
||||
let pickups = getElementsByType(ELEMENT_PICKUP);
|
||||
for (let i in pickups) {
|
||||
if (pickups[i].getData("agrp.label.type") != null) {
|
||||
if (getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
|
||||
if (!pickups[i].isOnScreen) {
|
||||
let price = "0";
|
||||
let rentPrice = "0";
|
||||
let labelInfoType = AGRP_PROPLABEL_INFO_NONE;
|
||||
if (pickups[i].getData("agrp.label.price") != null) {
|
||||
price = makeLargeNumberReadable(pickups[i].getData("agrp.label.price"));
|
||||
}
|
||||
|
||||
if (pickups[i].getData("agrp.label.rentprice") != null) {
|
||||
rentPrice = makeLargeNumberReadable(pickups[i].getData("agrp.label.rentprice"));
|
||||
}
|
||||
|
||||
if (pickups[i].getData("agrp.label.help") != null) {
|
||||
labelInfoType = pickups[i].getData("agrp.label.help");
|
||||
}
|
||||
|
||||
switch (pickups[i].getData("agrp.label.type")) {
|
||||
case AGRP_LABEL_BUSINESS: {
|
||||
renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), true, price, rentPrice, labelInfoType);
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_LABEL_HOUSE: {
|
||||
renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), false, price, rentPrice, labelInfoType);
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_LABEL_JOB: {
|
||||
renderJobLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.jobType"));
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_LABEL_EXIT: {
|
||||
renderPropertyExitLabel(pickups[i].position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: locale.js
|
||||
// DESC: Provides locale functions and usage
|
||||
@@ -8,34 +9,58 @@
|
||||
// ===========================================================================
|
||||
|
||||
function getLocaleString(stringName, ...args) {
|
||||
return findResourceByName("agrp_locale").exports.getLocaleString(localLocaleId, stringName, args);
|
||||
}
|
||||
if (typeof getServerData().localeStrings[localLocaleId][stringName] == undefined) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
let tempString = getServerData().localeStrings[localLocaleId][stringName];
|
||||
|
||||
function getGroupedLocaleString(stringName, index, ...args) {
|
||||
return findResourceByName("agrp_locale").exports.getGroupedLocaleString(localLocaleId, stringName, index, args);
|
||||
if (tempString == "" || tempString == null || tempString == undefined) {
|
||||
return "";
|
||||
}
|
||||
|
||||
for (let i = 1; i <= args.length; i++) {
|
||||
tempString = tempString.replace(`{${i}}`, args[i - 1]);
|
||||
}
|
||||
|
||||
return tempString;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAvailableLocaleOptions() {
|
||||
return findResourceByName("agrp_locale").exports.getAvailableLocaleOptions();
|
||||
return getServerData().localeOptions.filter(localeOption => localeOption.requiresUnicode == false);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getLocales() {
|
||||
return findResourceByName("agrp_locale").exports.getLocales();
|
||||
function loadLocaleConfig() {
|
||||
let configFile = loadTextFile("config/client/locale.json");
|
||||
getServerData().localeOptions = JSON.parse(configFile);
|
||||
|
||||
resetLocaleChooserOptions();
|
||||
loadAllLocaleStrings();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadAllLocaleStrings() {
|
||||
let localeOptions = getServerData().localeOptions;
|
||||
for (let i in localeOptions) {
|
||||
logToConsole(LOG_INFO, `[VRR.Locale] Loading locale strings for ${localeOptions[i].englishName} (${i})`);
|
||||
let localeFile = loadTextFile(`locale/${localeOptions[i].stringsFile}`);
|
||||
let localeData = JSON.parse(localeFile);
|
||||
|
||||
getServerData().localeStrings[i] = localeData;
|
||||
}
|
||||
|
||||
resetGUIStrings();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setLocale(tempLocaleId) {
|
||||
let locales = getLocales();
|
||||
logToConsole(LOG_DEBUG, `[VRR.Locale] Setting locale to ${tempLocaleId} (${locales[tempLocaleId].englishName})`);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Locale] Setting locale to ${tempLocaleId} (${getServerData().localeOptions[tempLocaleId].englishName})`);
|
||||
localLocaleId = tempLocaleId;
|
||||
resetGUIStrings();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
}
|
||||
53
scripts/client/logo.js
Normal file
@@ -0,0 +1,53 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: logo.js
|
||||
// DESC: Provides logo rendering functions
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let logoImage = null;
|
||||
let logoPos = toVector2(game.width - 132, game.height - 132);
|
||||
let logoSize = toVector2(128, 128);
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initLogoScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Logo]: Initializing logo script ...");
|
||||
//logoImage = loadLogoImage();
|
||||
logToConsole(LOG_DEBUG, "[VRR.Logo]: Logo script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadLogoImage() {
|
||||
let logoStream = openFile(mainLogoPath);
|
||||
let tempLogoImage = null;
|
||||
if (logoStream != null) {
|
||||
tempLogoImage = graphics.loadPNG(logoStream);
|
||||
logoStream.close();
|
||||
}
|
||||
|
||||
return tempLogoImage;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processLogoRendering() {
|
||||
if (renderLogo) {
|
||||
if (logoImage != null) {
|
||||
graphics.drawRectangle(logoImage, logoPos, logoSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setServerLogoRenderState(state) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Main] Server logo ${(state) ? "enabled" : "disabled"}`);
|
||||
renderLogo = state;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: main.js
|
||||
// DESC: Main client script (will be reorganized into individual files later)
|
||||
@@ -30,7 +31,7 @@ let renderHotBar = true;
|
||||
let renderItemActionDelay = true;
|
||||
let renderInteriorLights = true;
|
||||
|
||||
let logLevel = LOG_INFO | LOG_DEBUG | LOG_VERBOSE;
|
||||
let logLevel = LOG_DEBUG;
|
||||
|
||||
let weaponDamageEnabled = {};
|
||||
let weaponDamageEvent = {};
|
||||
@@ -48,6 +49,9 @@ let streamingRadio = null;
|
||||
let streamingRadioVolume = 50;
|
||||
let streamingRadioElement = false;
|
||||
|
||||
let enterPropertyKey = null;
|
||||
let disableGUIKey = getKeyIdFromParams("insert");
|
||||
|
||||
let inAnimation = false;
|
||||
let forcedAnimation = null;
|
||||
|
||||
@@ -56,17 +60,27 @@ let calledDeathEvent = false;
|
||||
let interiorLightsEnabled = true;
|
||||
let interiorLightsColour = toColour(0, 0, 0, 150);
|
||||
|
||||
let mouseCameraEnabled = false;
|
||||
|
||||
let currentPickup = false;
|
||||
|
||||
let vehiclePurchaseState = VRR_VEHBUYSTATE_NONE;
|
||||
let vehiclePurchaseState = AGRP_VEHBUYSTATE_NONE;
|
||||
let vehiclePurchasing = null;
|
||||
let vehiclePurchasePosition = null;
|
||||
|
||||
let forceWantedLevel = 0;
|
||||
|
||||
let guiSubmitKey = false;
|
||||
let guiLeftKey = false;
|
||||
let guiRightKey = false;
|
||||
let guiUpKey = false;
|
||||
let guiDownKey = false;
|
||||
|
||||
// Pre-cache all allowed skins
|
||||
let allowedSkins = getAllowedSkins(getGame());
|
||||
|
||||
let profanityFilterEnabled = false;
|
||||
|
||||
let localLocaleId = 0;
|
||||
|
||||
let serverData = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: messaging.js
|
||||
// DESC: Provides messaging/textdraw functions and usage
|
||||
@@ -33,7 +34,7 @@ function initMessagingScript() {
|
||||
function loadSmallGameMessageFonts() {
|
||||
let tempSmallGameMessageFonts = {};
|
||||
let fontStream = openFile("files/fonts/pricedown.ttf");
|
||||
if(fontStream != null) {
|
||||
if (fontStream != null) {
|
||||
tempSmallGameMessageFonts["Pricedown"] = lucasFont.createFont(fontStream, 20.0);
|
||||
fontStream.close();
|
||||
}
|
||||
@@ -49,7 +50,7 @@ function loadSmallGameMessageFonts() {
|
||||
function loadBigGameMessageFont() {
|
||||
let tempBigGameMessageFonts = {};
|
||||
let fontStream = openFile("files/fonts/pricedown.ttf");
|
||||
if(fontStream != null) {
|
||||
if (fontStream != null) {
|
||||
tempBigGameMessageFonts["Pricedown"] = lucasFont.createFont(fontStream, 28.0);
|
||||
fontStream.close();
|
||||
}
|
||||
@@ -63,10 +64,12 @@ function loadBigGameMessageFont() {
|
||||
// ===========================================================================
|
||||
|
||||
function processSmallGameMessageRendering() {
|
||||
if(renderSmallGameMessage) {
|
||||
if(smallGameMessageText != "") {
|
||||
if(smallGameMessageFonts[smallGameMessageFontName] != null) {
|
||||
smallGameMessageFonts[smallGameMessageFontName].render(smallGameMessageText, [0, game.height-90], game.width, 0.5, 0.0, smallGameMessageFonts[smallGameMessageFontName].size, smallGameMessageColour, true, true, false, true);
|
||||
logToConsole(LOG_VERBOSE, "[VRR.Messaging]: Processing small game message rendering ...");
|
||||
if (renderSmallGameMessage) {
|
||||
if (smallGameMessageText != "") {
|
||||
logToConsole(LOG_VERBOSE, `[VRR.Messaging]: Rendering small game message: ${smallGameMessageText}`);
|
||||
if (smallGameMessageFonts[smallGameMessageFontName] != null) {
|
||||
smallGameMessageFonts[smallGameMessageFontName].render(smallGameMessageText, [0, game.height - 90], game.width, 0.5, 0.0, smallGameMessageFonts[smallGameMessageFontName].size, smallGameMessageColour, true, true, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +79,7 @@ function processSmallGameMessageRendering() {
|
||||
|
||||
function showSmallGameMessage(text, colour, duration, fontName) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Messaging] Showing small game message '${text}' using font ${fontName} for ${duration}ms`);
|
||||
if(smallGameMessageText != "") {
|
||||
if (smallGameMessageText != "") {
|
||||
clearTimeout(smallGameMessageTimer);
|
||||
}
|
||||
|
||||
@@ -84,7 +87,7 @@ function showSmallGameMessage(text, colour, duration, fontName) {
|
||||
smallGameMessageColour = colour;
|
||||
smallGameMessageText = text;
|
||||
|
||||
smallGameMessageTimer = setTimeout(function() {
|
||||
smallGameMessageTimer = setTimeout(function () {
|
||||
smallGameMessageText = "";
|
||||
smallGameMessageColour = COLOUR_WHITE;
|
||||
smallGameMessageTimer = null;
|
||||
|
||||
643
scripts/client/mousecam.js
Normal file
@@ -0,0 +1,643 @@
|
||||
|
||||
// ===========================================================================
|
||||
// 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(typeof gta == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (game.standardControls === undefined)
|
||||
{
|
||||
logToConsole(LOG_WARN, "game.standardControls not implemented");
|
||||
return;
|
||||
}
|
||||
game.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 game.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 = game.getMouseSpeed();
|
||||
return [MouseSpeed.x,-MouseSpeed.y];
|
||||
}
|
||||
|
||||
function GetMouseSensitivity()
|
||||
{
|
||||
if (game.getMouseSensitivity === undefined)
|
||||
{
|
||||
//logToConsole(LOG_ERROR, "game.getMouseSensitivity not implemented");
|
||||
return [0.0025,0.003];
|
||||
}
|
||||
let MouseSensitivity = game.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 (game.processLineOfSight === undefined)
|
||||
{
|
||||
logToConsole(LOG_WARN, "game.processLineOfSight not implemented");
|
||||
return [null];
|
||||
}
|
||||
let Result = game.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())
|
||||
{
|
||||
game.setCameraMatrix(mat);
|
||||
return;
|
||||
}
|
||||
pPlaceable.matrix = mat;
|
||||
}
|
||||
|
||||
const UpdateCamera = game.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 ? game.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;
|
||||
}
|
||||
});
|
||||
|
||||
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 = game.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 toggleMouseCamera() {
|
||||
mouseCameraEnabled = !mouseCameraEnabled;
|
||||
}
|
||||
247
scripts/client/nametag.js
Normal file
@@ -0,0 +1,247 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: nametags.js
|
||||
// DESC: Provides nametag rendering
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Configuration
|
||||
let nametagFont = null;
|
||||
let afkStatusFont = null;
|
||||
let pingFont = null;
|
||||
let nametagDistance = 50.0;
|
||||
let nametagWidth = 70;
|
||||
|
||||
let playerNames = {};
|
||||
let playerColours = {};
|
||||
let playerPaused = {};
|
||||
let playerPing = {};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initNameTagScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.NameTag]: Initializing nametag script ...");
|
||||
nametagFont = loadNameTagFont();
|
||||
afkStatusFont = loadPausedStatusFont();
|
||||
logToConsole(LOG_DEBUG, "[VRR.NameTag]: Nametag script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
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) {
|
||||
if (profanityFilterEnabled) {
|
||||
characterName = replaceProfanityInMessage(characterName);
|
||||
}
|
||||
|
||||
playerNames[clientName] = characterName;
|
||||
playerColours[clientName] = colour;
|
||||
playerPaused[clientName] = paused;
|
||||
playerPing[clientName] = ping;
|
||||
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
let client = getPlayerFromParams(clientName);
|
||||
if (client != false) {
|
||||
if (getPlayerPed(client) != null) {
|
||||
getPlayerPed(client).setNametag(characterName, colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function updatePlayerPing(clientName, ping) {
|
||||
playerPing[clientName] = ping;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk, skin) {
|
||||
if (nametagFont == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
alpha *= 0.75;
|
||||
let width = nametagWidth;
|
||||
health = Math.max(0.0, Math.min(1.0, health));
|
||||
armour = Math.max(0.0, Math.min(1.0, armour));
|
||||
|
||||
// Starts at bottom and works it's way up
|
||||
// -------------------------------------------
|
||||
// Health Bar
|
||||
|
||||
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
|
||||
if (getGame() == AGRP_GAME_GTA_III) {
|
||||
// Mickey Hamfists is ridiculously tall. Raise the nametag for him a bit
|
||||
if (skin == 109) {
|
||||
y -= 20;
|
||||
} else {
|
||||
y -= 5;
|
||||
}
|
||||
} else {
|
||||
y -= 5;
|
||||
}
|
||||
} else {
|
||||
y -= 5;
|
||||
}
|
||||
|
||||
if (health > 0.0) {
|
||||
let hx = x - width / 2;
|
||||
let hy = y - 10 / 2;
|
||||
let colourB = toColour(0, 0, 0, Math.floor(255.0 * alpha)); // Background colour (black)
|
||||
graphics.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB);
|
||||
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
|
||||
if (armour > 0.0) {
|
||||
// Go up 10 pixels to draw the next part
|
||||
y -= 10;
|
||||
let hx = x - width / 2;
|
||||
let hy = y - 10 / 2;
|
||||
let colourB = toColour(255, 0, 0, 0); // Background colour (black)
|
||||
graphics.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB);
|
||||
let colour = toColour(255, 255, 255, 255); // Armour bar colour (white)
|
||||
graphics.drawRectangle(null, [hx + 2, hy + 2], [(width - 4) * armour, 10 - 6], colour, colour, colour, colour);
|
||||
}
|
||||
|
||||
y -= 20;
|
||||
|
||||
// Nametag
|
||||
if (nametagFont != null) {
|
||||
let size = nametagFont.measure(text, game.width, 0.0, 0.0, nametagFont.size, false, false);
|
||||
nametagFont.render(text, [x - size[0] / 2, y - size[1] / 2], game.width, 0.0, 0.0, nametagFont.size, colour, false, false, false, true);
|
||||
}
|
||||
|
||||
// Go up another 10 pixels for the next part
|
||||
y -= 20;
|
||||
|
||||
// AFK Status
|
||||
if (afkStatusFont != null) {
|
||||
if (afk) {
|
||||
let size = afkStatusFont.measure(getLocaleString(client, "Paused"), game.width, 0.0, 0.0, afkStatusFont.size, false, false);
|
||||
afkStatusFont.render(getLocaleString(client, "Paused"), [x - size[0] / 2, y - size[1] / 2], game.width, 0.0, 0.0, afkStatusFont.size, toColour(255, 0, 0, 255), false, false, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function updateNametag(element) {
|
||||
if (!areWorldLabelsSupported()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (localPlayer != null) {
|
||||
let playerPos = localPlayer.position;
|
||||
let elementPos = element.position;
|
||||
|
||||
elementPos[2] += 0.9;
|
||||
|
||||
//if(typeof element.getComponentPosition()) {
|
||||
|
||||
let screenPos = getScreenFromWorldPosition(elementPos);
|
||||
if (screenPos[2] >= 0.0) {
|
||||
let health = element.health / 100.0;
|
||||
if (health > 1.0) {
|
||||
health = 1.0;
|
||||
}
|
||||
|
||||
let armour = element.armour / 100.0;
|
||||
if (armour > 1.0) {
|
||||
armour = 1.0;
|
||||
}
|
||||
|
||||
let distance = playerPos.distance(elementPos);
|
||||
if (distance <= nametagDistance) {
|
||||
if (typeof game.processLineOfSight != "undefined") {
|
||||
let losCheck = game.processLineOfSight(playerPos, elementPos, true, false, false, true, true, false, true, true);
|
||||
if (losCheck != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (element.type == ELEMENT_PLAYER) {
|
||||
let name = element.name;
|
||||
let colour = COLOUR_WHITE;
|
||||
let paused = false;
|
||||
let ping = -1;
|
||||
|
||||
if (element.isType(ELEMENT_PLAYER)) {
|
||||
if (typeof playerNames[element.name] != "undefined") {
|
||||
name = playerNames[element.name];
|
||||
}
|
||||
|
||||
if (typeof playerPaused[element.name] != "undefined") {
|
||||
paused = playerPaused[element.name];
|
||||
}
|
||||
|
||||
if (typeof playerColours[element.name] != "undefined") {
|
||||
colour = playerColours[element.name];
|
||||
}
|
||||
|
||||
if (typeof playerPing[element.name] != "undefined") {
|
||||
ping = playerPing[element.name];
|
||||
}
|
||||
}
|
||||
|
||||
drawNametag(screenPos[0], screenPos[1], health, armour, name, ping, 1.0 - distance / nametagDistance, distance, colour, paused, element.skin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClientFromPlayer(player) {
|
||||
getClients().forEach(function (client) {
|
||||
if (getPlayerPed(client) == player) {
|
||||
return client;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processNameTagRendering(event) {
|
||||
//if(getGame() >= GAME_GTA_IV) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
getElementsByType(ELEMENT_PED).forEach(function (ped) {
|
||||
if (ped != localPlayer) {
|
||||
updateNametag(ped);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createColour(alpha, red, green, blue) {
|
||||
return alpha << 24 | red << 16 | green << 8 | blue;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setNameTagDistance(distance) {
|
||||
nametagDistance = distance;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: connected.js
|
||||
// DESC: Provides wrapped natives for GTA Connected and Mafia Connected mods
|
||||
@@ -37,7 +38,7 @@ function getPlayerPosition() {
|
||||
// ===========================================================================
|
||||
|
||||
function setPlayerPosition(position) {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.setCharCoordinates(localPlayer, position);
|
||||
} else {
|
||||
localPlayer.position = position;
|
||||
@@ -72,7 +73,7 @@ function setElementPosition(elementId, position) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteGameElement(elementId, position) {
|
||||
function deleteGameElement(elementId, position = toVector3(0.0, 0.0, 0.0)) {
|
||||
if (!getElementFromId(elementId).isOwner) {
|
||||
return false;
|
||||
}
|
||||
@@ -82,8 +83,25 @@ function deleteGameElement(elementId, position) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteLocalGameElement(element) {
|
||||
destroyGameElement(element);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createGameVehicle(modelIndex, position, heading) {
|
||||
return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading);
|
||||
if (getGame() != AGRP_GAME_GTA_IV) {
|
||||
return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading);
|
||||
} else {
|
||||
let modelId = getGameConfig().vehicles[getGame()][modelIndex][0];
|
||||
if (natives.isModelInCdimage(modelId)) {
|
||||
natives.requestModel(modelId);
|
||||
natives.loadAllObjectsNow();
|
||||
return natives.createCar(modelId, position, true);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -181,7 +199,7 @@ function getVehiclesInRange(position, range) {
|
||||
// ===========================================================================
|
||||
|
||||
function createGameBlip(blipModel, position, name = "") {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
let blipId = natives.addBlipForCoord(position);
|
||||
if (blipId) {
|
||||
natives.changeBlipSprite(blipId, blipModel);
|
||||
@@ -260,7 +278,7 @@ function syncVehicleProperties(vehicle) {
|
||||
vehicle.setSuspensionHeight(suspensionHeight);
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
|
||||
for (let i in allUpgrades) {
|
||||
vehicle.removeUpgrade(i);
|
||||
@@ -276,12 +294,12 @@ function syncVehicleProperties(vehicle) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA || getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (doesEntityDataExist(vehicle, "agrp.livery")) {
|
||||
let livery = getEntityData(vehicle, "agrp.livery");
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
vehicle.setPaintJob(livery);
|
||||
} else if (getGame() == VRR_GAME_GTA_IV) {
|
||||
} else if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
vehicle.livery = livery;
|
||||
}
|
||||
}
|
||||
@@ -309,7 +327,7 @@ function doesEntityDataExist(entity, dataName) {
|
||||
// ===========================================================================
|
||||
|
||||
function syncCivilianProperties(civilian) {
|
||||
if (getGame() == VRR_GAME_GTA_III) {
|
||||
if (getGame() == AGRP_GAME_GTA_III) {
|
||||
if (doesEntityDataExist(civilian, "agrp.scale")) {
|
||||
let scaleFactor = getEntityData(civilian, "agrp.scale");
|
||||
let tempMatrix = civilian.matrix;
|
||||
@@ -321,21 +339,21 @@ function syncCivilianProperties(civilian) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
if (doesEntityDataExist(civilian, "agrp.fightStyle")) {
|
||||
let fightStyle = getEntityData(civilian, "agrp.fightStyle");
|
||||
civilian.setFightStyle(fightStyle[0], fightStyle[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_III) {
|
||||
if (getGame() == AGRP_GAME_GTA_III) {
|
||||
if (doesEntityDataExist(civilian, "agrp.walkStyle")) {
|
||||
let walkStyle = getEntityData(civilian, "agrp.walkStyle");
|
||||
civilian.walkStyle = walkStyle;
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (doesEntityDataExist(civilian, "agrp.bodyPropHair")) {
|
||||
let bodyPropHair = getEntityData(civilian, "agrp.bodyPropHair");
|
||||
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
|
||||
@@ -407,7 +425,7 @@ function preventDefaultEventAction(event) {
|
||||
// ===========================================================================
|
||||
|
||||
function syncPlayerProperties(player) {
|
||||
if (getGame() == VRR_GAME_GTA_III) {
|
||||
if (getGame() == AGRP_GAME_GTA_III) {
|
||||
if (doesEntityDataExist(player, "agrp.scale")) {
|
||||
let scaleFactor = getEntityData(player, "agrp.scale");
|
||||
let tempMatrix = player.matrix;
|
||||
@@ -419,21 +437,21 @@ function syncPlayerProperties(player) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
if (doesEntityDataExist(player, "agrp.fightStyle")) {
|
||||
let fightStyle = getEntityData(player, "agrp.fightStyle");
|
||||
player.setFightStyle(fightStyle[0], fightStyle[1]);
|
||||
}
|
||||
}
|
||||
|
||||
//if(getGame() == VRR_GAME_GTA_SA) {
|
||||
//if(getGame() == AGRP_GAME_GTA_SA) {
|
||||
// if(doesEntityDataExist(player, "agrp.walkStyle")) {
|
||||
// let walkStyle = getEntityData(player, "agrp.walkStyle");
|
||||
// player.walkStyle = walkStyle;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (doesEntityDataExist(player, "agrp.bodyPartHair")) {
|
||||
let bodyPartHead = getEntityData(player, "agrp.bodyPartHair");
|
||||
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
|
||||
@@ -455,7 +473,7 @@ function syncPlayerProperties(player) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (doesEntityDataExist(player, "agrp.bodyPropHair")) {
|
||||
let bodyPropHair = getEntityData(player, "agrp.bodyPropHair");
|
||||
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
|
||||
@@ -516,7 +534,7 @@ function syncPlayerProperties(player) {
|
||||
// ===========================================================================
|
||||
|
||||
function syncObjectProperties(object) {
|
||||
if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
|
||||
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
|
||||
if (doesEntityDataExist(object, "agrp.scale")) {
|
||||
let scaleFactor = getEntityData(object, "agrp.scale");
|
||||
let tempMatrix = object.matrix;
|
||||
@@ -620,21 +638,21 @@ function getScreenHeight() {
|
||||
|
||||
function openAllGarages() {
|
||||
switch (getGame()) {
|
||||
case VRR_GAME_GTA_III:
|
||||
case AGRP_GAME_GTA_III:
|
||||
for (let i = 0; i <= 26; i++) {
|
||||
openGarage(i);
|
||||
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
|
||||
}
|
||||
break;
|
||||
|
||||
case VRR_GAME_GTA_VC:
|
||||
case AGRP_GAME_GTA_VC:
|
||||
for (let i = 0; i <= 32; i++) {
|
||||
openGarage(i);
|
||||
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
|
||||
}
|
||||
break;
|
||||
|
||||
case VRR_GAME_GTA_SA:
|
||||
case AGRP_GAME_GTA_SA:
|
||||
for (let i = 0; i <= 44; i++) {
|
||||
openGarage(i);
|
||||
}
|
||||
@@ -649,21 +667,21 @@ function openAllGarages() {
|
||||
|
||||
function closeAllGarages() {
|
||||
switch (getGame()) {
|
||||
case VRR_GAME_GTA_III:
|
||||
case AGRP_GAME_GTA_III:
|
||||
for (let i = 0; i <= 26; i++) {
|
||||
closeGarage(i);
|
||||
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
|
||||
}
|
||||
break;
|
||||
|
||||
case VRR_GAME_GTA_VC:
|
||||
case AGRP_GAME_GTA_VC:
|
||||
for (let i = 0; i <= 32; i++) {
|
||||
closeGarage(i);
|
||||
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
|
||||
}
|
||||
break;
|
||||
|
||||
case VRR_GAME_GTA_SA:
|
||||
case AGRP_GAME_GTA_SA:
|
||||
for (let i = 0; i <= 44; i++) {
|
||||
closeGarage(i);
|
||||
}
|
||||
@@ -683,7 +701,7 @@ function setPedInvincible(ped, state) {
|
||||
// ===========================================================================
|
||||
|
||||
function setPedLookAt(ped, position) {
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
ped.lookAt(position, 10000);
|
||||
return true;
|
||||
} else {
|
||||
@@ -697,4 +715,10 @@ function setElementHeading(elementId, heading) {
|
||||
getElementFromId(elementId).heading = heading;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deleteLocalPlayerPed() {
|
||||
destroyElement(localPlayer);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,27 +1,30 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: netevents.js
|
||||
// DESC: Provides server communication and cross-endpoint network events
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
function initNetworkEventsScript() {
|
||||
function initServerScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Server]: Initializing server script ...");
|
||||
addAllNetworkEventHandlers();
|
||||
addAllNetworkHandlers();
|
||||
logToConsole(LOG_DEBUG, "[VRR.Server]: Server script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function addAllNetworkEventHandlers() {
|
||||
function addAllNetworkHandlers() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Server]: Adding network handlers ...");
|
||||
|
||||
// Chat history
|
||||
// Chat Box
|
||||
addNetworkEventHandler("m", receiveChatBoxMessageFromServer); // Not prefixed with VRR to make it as small as possible
|
||||
addNetworkEventHandler("agrp.chatScrollLines", setChatScrollLines);
|
||||
addNetworkEventHandler("agrp.chatAutoHideDelay", setChatAutoHideDelay);
|
||||
addNetworkEventHandler("agrp.chatTimeStamps", setChatTimeStampsState);
|
||||
addNetworkEventHandler("agrp.chatEmoji", setChatEmojiState);
|
||||
|
||||
// Messaging (like textdraws and stuff)
|
||||
addNetworkEventHandler("agrp.smallGameMessage", showSmallGameMessage);
|
||||
@@ -59,12 +62,14 @@ function addAllNetworkEventHandlers() {
|
||||
addNetworkEventHandler("agrp.spawn", serverRequestedLocalPlayerSpawn);
|
||||
addNetworkEventHandler("agrp.clearPedState", clearLocalPedState);
|
||||
addNetworkEventHandler("agrp.drunkEffect", setLocalPlayerDrunkEffect);
|
||||
addNetworkEventHandler("agrp.deleteLocalPlayerPed", deleteLocalPlayerPed);
|
||||
|
||||
// Vehicle
|
||||
addNetworkEventHandler("agrp.vehicle", receiveVehicleFromServer);
|
||||
addNetworkEventHandler("agrp.veh.lights", setVehicleLights);
|
||||
addNetworkEventHandler("agrp.veh.engine", setVehicleEngine);
|
||||
addNetworkEventHandler("agrp.veh.repair", repairVehicle);
|
||||
addNetworkEventHandler("agrp.cruiseControl", toggleVehicleCruiseControl);
|
||||
|
||||
// Radio
|
||||
addNetworkEventHandler("agrp.radioStream", playStreamingRadio);
|
||||
@@ -81,6 +86,29 @@ function addAllNetworkEventHandlers() {
|
||||
addNetworkEventHandler("agrp.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
|
||||
addNetworkEventHandler("agrp.weaponDamageEvent", setPlayerWeaponDamageEvent);
|
||||
|
||||
// GUI
|
||||
addNetworkEventHandler("agrp.showRegistration", showRegistrationGUI);
|
||||
addNetworkEventHandler("agrp.showNewCharacter", showNewCharacterGUI);
|
||||
addNetworkEventHandler("agrp.showLogin", showLoginGUI);
|
||||
addNetworkEventHandler("agrp.2fa", showTwoFactorAuthGUI);
|
||||
addNetworkEventHandler("agrp.showResetPasswordCodeInput", resetPasswordCodeInputGUI);
|
||||
addNetworkEventHandler("agrp.showResetPasswordEmailInput", resetPasswordEmailInputGUI);
|
||||
addNetworkEventHandler("agrp.showChangePassword", showChangePasswordGUI);
|
||||
addNetworkEventHandler("agrp.showCharacterSelect", showCharacterSelectGUI);
|
||||
addNetworkEventHandler("agrp.switchCharacterSelect", switchCharacterSelectGUI);
|
||||
addNetworkEventHandler("agrp.showError", showErrorGUI);
|
||||
addNetworkEventHandler("agrp.showInfo", showInfoGUI);
|
||||
addNetworkEventHandler("agrp.showPrompt", showYesNoPromptGUI);
|
||||
addNetworkEventHandler("agrp.loginSuccess", loginSuccess);
|
||||
addNetworkEventHandler("agrp.characterSelectSuccess", characterSelectSuccess);
|
||||
addNetworkEventHandler("agrp.loginFailed", loginFailed);
|
||||
addNetworkEventHandler("agrp.registrationSuccess", registrationSuccess);
|
||||
addNetworkEventHandler("agrp.registrationFailed", registrationFailed);
|
||||
addNetworkEventHandler("agrp.newCharacterFailed", newCharacterFailed);
|
||||
addNetworkEventHandler("agrp.changePassword", showChangePasswordGUI);
|
||||
addNetworkEventHandler("agrp.showLocaleChooser", showLocaleChooserGUI);
|
||||
addNetworkEventHandler("agrp.guiColour", setGUIColours);
|
||||
|
||||
// Business
|
||||
addNetworkEventHandler("agrp.business", receiveBusinessFromServer);
|
||||
|
||||
@@ -92,11 +120,15 @@ function addAllNetworkEventHandlers() {
|
||||
|
||||
// Locale
|
||||
addNetworkEventHandler("agrp.locale", setLocale);
|
||||
addNetworkEventHandler("agrp.localeChooser", toggleLocaleChooserGUI);
|
||||
|
||||
// Misc
|
||||
addNetworkEventHandler("agrp.mouseCursor", toggleMouseCursor);
|
||||
addNetworkEventHandler("agrp.mouseCamera", toggleMouseCamera);
|
||||
addNetworkEventHandler("agrp.clearPeds", clearLocalPlayerOwnedPeds);
|
||||
addNetworkEventHandler("agrp.clearPickups", clearLocalPlayerOwnedPickups);
|
||||
addNetworkEventHandler("agrp.passenger", enterVehicleAsPassenger);
|
||||
addNetworkEventHandler("agrp.logo", setServerLogoRenderState);
|
||||
addNetworkEventHandler("agrp.ambience", setCityAmbienceState);
|
||||
addNetworkEventHandler("agrp.runCode", runClientCode);
|
||||
addNetworkEventHandler("agrp.minuteDuration", setMinuteDuration);
|
||||
@@ -106,7 +138,12 @@ function addAllNetworkEventHandlers() {
|
||||
addNetworkEventHandler("agrp.hotbar", updatePlayerHotBar);
|
||||
addNetworkEventHandler("agrp.showItemActionDelay", showItemActionDelay);
|
||||
addNetworkEventHandler("agrp.set2DRendering", set2DRendering);
|
||||
addNetworkEventHandler("agrp.mouseCameraForce", setMouseCameraState);
|
||||
addNetworkEventHandler("agrp.logLevel", setLogLevel);
|
||||
addNetworkEventHandler("agrp.hideAllGUI", hideAllGUI);
|
||||
addNetworkEventHandler("agrp.nametag", updatePlayerNameTag);
|
||||
addNetworkEventHandler("agrp.nametagDistance", setNameTagDistance);
|
||||
addNetworkEventHandler("agrp.ping", updatePlayerPing);
|
||||
addNetworkEventHandler("agrp.anim", makePedPlayAnimation);
|
||||
addNetworkEventHandler("agrp.stopAnim", makePedStopAnimation);
|
||||
addNetworkEventHandler("agrp.forceAnim", forcePedAnimation);
|
||||
@@ -118,6 +155,7 @@ function addAllNetworkEventHandlers() {
|
||||
addNetworkEventHandler("agrp.elementCollisions", setElementCollisionsEnabled);
|
||||
addNetworkEventHandler("agrp.vehBuyState", setVehiclePurchaseState);
|
||||
addNetworkEventHandler("agrp.holdObject", makePedHoldObject);
|
||||
addNetworkEventHandler("agrp.profanityFilter", setProfanityFilterState);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -146,7 +184,7 @@ function set2DRendering(hudState, labelState, smallGameMessageState, scoreboardS
|
||||
logToConsole(LOG_DEBUG, `[VRR.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`);
|
||||
renderHUD = hudState;
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.displayCash(hudState);
|
||||
natives.displayAmmo(hudState);
|
||||
natives.displayHud(hudState);
|
||||
@@ -292,7 +330,7 @@ function setLogLevel(level) {
|
||||
|
||||
function setLocalPlayerInfiniteRun(state) {
|
||||
if (localPlayer != null) {
|
||||
if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
|
||||
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
|
||||
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), boolToInt(state));
|
||||
}
|
||||
}
|
||||
@@ -302,8 +340,14 @@ function setLocalPlayerInfiniteRun(state) {
|
||||
|
||||
function setLocalPlayerSkin(skinId) {
|
||||
logToConsole(LOG_INFO, `[VRR.Server] Setting locale player skin to ${skinId}`);
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
natives.changePlayerModel(natives.getPlayerId(), skinId);
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (natives.isModelInCdimage(skinId)) {
|
||||
natives.requestModel(skinId);
|
||||
natives.loadAllObjectsNow();
|
||||
if (natives.hasModelLoaded(skinId)) {
|
||||
natives.changePlayerModel(natives.getPlayerId(), skinId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
localPlayer.skin = skinId;
|
||||
}
|
||||
@@ -312,7 +356,7 @@ function setLocalPlayerSkin(skinId) {
|
||||
// ===========================================================================
|
||||
|
||||
function makePedHoldObject(pedId, modelIndex) {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.givePedAmbientObject(natives.getPedFromNetworkId(pedId), getGameConfig().objects[getGame()][modelIndex][1])
|
||||
}
|
||||
}
|
||||
@@ -326,7 +370,7 @@ function sendLocalPlayerNetworkIdToServer() {
|
||||
// ===========================================================================
|
||||
|
||||
function setCutsceneInterior(cutsceneName) {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (cutsceneName == "") {
|
||||
natives.clearCutscene();
|
||||
} else {
|
||||
@@ -341,7 +385,7 @@ function setCutsceneInterior(cutsceneName) {
|
||||
// ===========================================================================
|
||||
|
||||
function makeLocalPlayerPedSpeak(speechName) {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
// if player is in vehicle, allow megaphone (if last arg is "1", it will cancel megaphone echo)
|
||||
// Only speeches with _MEGAPHONE will have the bullhorn effect
|
||||
// Afaik it only works on police voices anyway
|
||||
@@ -350,7 +394,7 @@ function makeLocalPlayerPedSpeak(speechName) {
|
||||
} else {
|
||||
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 1);
|
||||
}
|
||||
} else if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
|
||||
} else if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
|
||||
// Don't have a way to get the ped ref ID and can't use ped in arg
|
||||
//game.SET_CHAR_SAY(game.GET_PLAYER_ID(), int);
|
||||
}
|
||||
@@ -359,7 +403,7 @@ function makeLocalPlayerPedSpeak(speechName) {
|
||||
// ===========================================================================
|
||||
|
||||
function setLocalPlayerAsCopState(state) {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.setPlayerAsCop(natives.getPlayerId(), state);
|
||||
natives.setPoliceIgnorePlayer(natives.getPlayerId(), state);
|
||||
}
|
||||
@@ -368,7 +412,7 @@ function setLocalPlayerAsCopState(state) {
|
||||
// ===========================================================================
|
||||
|
||||
function serverRequestedLocalPlayerSpawn(skinId, position) {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.createPlayer(skinId, position);
|
||||
//if(isCustomCameraSupported()) {
|
||||
// game.restoreCamera(true);
|
||||
@@ -382,4 +426,13 @@ function sendLocaleSelectToServer(localeId) {
|
||||
sendNetworkEventToServer("agrp.localeSelect", localeId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function clearLocalPlayerOwnedPickups() {
|
||||
let pickups = getPickups().filter(pickup => pickup.isLocal == true);
|
||||
for (let i in pickups) {
|
||||
deleteLocalGameElement(pickups[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: npc.js
|
||||
// DESC: Provides NPC functions and processing
|
||||
|
||||
39
scripts/client/object.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: object.js
|
||||
// DESC: Provides object functions and processing
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let movingObject = null;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function startMovingObject(object) {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function stopMovingObject(object, save = true) {
|
||||
if (save) {
|
||||
sendNetworkEventToServer("agrp.objectSave", object.id, object.position, object.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isMovingObject() {
|
||||
return movingObject != null;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getMovingObject() {
|
||||
return movingObject;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: radio.js
|
||||
// DESC: Provides internet streaming radio functions and usage
|
||||
@@ -8,21 +9,21 @@
|
||||
// ===========================================================================
|
||||
|
||||
function playStreamingRadio(url, loop, volume, element = false) {
|
||||
if(streamingRadio != null) {
|
||||
if (streamingRadio != null) {
|
||||
streamingRadio.stop();
|
||||
}
|
||||
|
||||
streamingRadioVolume = volume;
|
||||
|
||||
streamingRadio = audio.createSoundFromURL(url, loop);
|
||||
streamingRadio.volume = volume/100;
|
||||
streamingRadio.volume = volume / 100;
|
||||
streamingRadio.play();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function stopStreamingRadio() {
|
||||
if(streamingRadio != null) {
|
||||
if (streamingRadio != null) {
|
||||
streamingRadio.stop();
|
||||
}
|
||||
streamingRadio = null;
|
||||
@@ -31,16 +32,16 @@ function stopStreamingRadio() {
|
||||
// ===========================================================================
|
||||
|
||||
function setStreamingRadioVolume(volume) {
|
||||
if(streamingRadio != null) {
|
||||
if (streamingRadio != null) {
|
||||
streamingRadioVolume = volume;
|
||||
streamingRadio.volume = volume/100;
|
||||
streamingRadio.volume = volume / 100;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function playAudioFile(audioName, loop, volume) {
|
||||
findResourceByName("connectedrp-extra").exports.playCustomAudio(audioName, volume/100, loop);
|
||||
findResourceByName("connectedrp-extra").exports.playCustomAudio(audioName, volume / 100, loop);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
105
scripts/client/scoreboard.js
Normal file
@@ -0,0 +1,105 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: scoreboard.js
|
||||
// DESC: Provides scoreboard features and rendering
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let scoreBoardTitleFont = null;
|
||||
let scoreBoardListFont = null;
|
||||
|
||||
let pausedColour = COLOUR_RED;
|
||||
|
||||
let scoreboardKey = SDLK_TAB;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initScoreBoardScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.ScoreBoard]: Initializing scoreboard script ...");
|
||||
scoreBoardTitleFont = initScoreBoardTitleFont();
|
||||
scoreBoardListFont = initScoreBoardListFont();
|
||||
logToConsole(LOG_DEBUG, "[VRR.ScoreBoard]: Scoreboard script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initScoreBoardTitleFont() {
|
||||
return lucasFont.createDefaultFont(22.0, "Roboto", "Regular");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initScoreBoardListFont() {
|
||||
return lucasFont.createDefaultFont(12.0, "Roboto", "Light");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processScoreBoardRendering() {
|
||||
if (isAnyGUIActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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";
|
||||
|
||||
if (typeof playerNames[clients[i].name] != "undefined") {
|
||||
name = playerNames[clients[i].name];
|
||||
}
|
||||
|
||||
if (typeof playerPaused[clients[i].name] != "undefined") {
|
||||
paused = playerPaused[clients[i].name];
|
||||
}
|
||||
|
||||
if (typeof playerColours[clients[i].name] != "undefined") {
|
||||
colour = playerColours[clients[i].name];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: skin-select.js
|
||||
// DESC: Provides skin-selector functions and usage
|
||||
@@ -45,7 +46,7 @@ function loadSkinSelectMessageFontBottom() {
|
||||
|
||||
function processSkinSelectKeyPress(keyCode) {
|
||||
if (usingSkinSelector) {
|
||||
if (keyCode == SDLK_PAGEUP) {
|
||||
if (keyCode == SDLK_LEFT || keyCode == SDLK_A) {
|
||||
if (skinSelectorIndex >= allowedSkins.length - 1) {
|
||||
skinSelectorIndex = 1;
|
||||
} else {
|
||||
@@ -53,19 +54,8 @@ function processSkinSelectKeyPress(keyCode) {
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
|
||||
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
let skinId = allowedSkins[skinSelectorIndex][0];
|
||||
if (natives.isModelInCdimage(skinId)) {
|
||||
natives.requestModel(skinId);
|
||||
natives.loadAllObjectsNow();
|
||||
if (natives.hasModelLoaded(skinId)) {
|
||||
natives.changePlayerModel(natives.getPlayerId(), skinId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
|
||||
}
|
||||
} else if (keyCode == SDLK_PAGEDOWN) {
|
||||
setLocalPlayerSkin(allowedSkins[skinSelectorIndex][0]);
|
||||
} else if (keyCode == SDLK_RIGHT || keyCode == SDLK_D) {
|
||||
if (skinSelectorIndex <= 0) {
|
||||
skinSelectorIndex = allowedSkins.length - 1;
|
||||
} else {
|
||||
@@ -73,18 +63,7 @@ function processSkinSelectKeyPress(keyCode) {
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
|
||||
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
let skinId = allowedSkins[skinSelectorIndex][0];
|
||||
if (natives.isModelInCdimage(skinId)) {
|
||||
natives.requestModel(skinId);
|
||||
natives.loadAllObjectsNow();
|
||||
if (natives.hasModelLoaded(skinId)) {
|
||||
natives.changePlayerModel(natives.getPlayerId(), skinId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
|
||||
}
|
||||
setLocalPlayerSkin(allowedSkins[skinSelectorIndex][0]);
|
||||
} else if (keyCode == SDLK_RETURN) {
|
||||
sendNetworkEventToServer("agrp.skinSelected", skinSelectorIndex);
|
||||
toggleSkinSelect(false);
|
||||
@@ -131,7 +110,7 @@ function toggleSkinSelect(state) {
|
||||
game.setCameraLookAt(frontCameraPosition, localPlayer.position, true);
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
let skinId = allowedSkins[skinSelectorIndex][0];
|
||||
if (natives.isModelInCdimage(skinId)) {
|
||||
natives.requestModel(skinId);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: startup.js
|
||||
// DESC: Provides startup/shutdown procedures
|
||||
@@ -8,8 +9,13 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initClientScripts() {
|
||||
initGUIScript();
|
||||
initNameTagScript();
|
||||
initScoreBoardScript();
|
||||
initMessagingScript();
|
||||
initNetworkEventsScript();
|
||||
initServerScript();
|
||||
initLogoScript();
|
||||
initLabelScript();
|
||||
initChatBoxScript();
|
||||
initAFKScript();
|
||||
initKeyBindScript();
|
||||
@@ -20,7 +26,7 @@ function initClientScripts() {
|
||||
// ===========================================================================
|
||||
|
||||
function setUpInitialGame() {
|
||||
if (getGame() == VRR_GAME_GTA_III) {
|
||||
if (getGame() == AGRP_GAME_GTA_III) {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA III ...");
|
||||
|
||||
// Turn off unlimited sprint
|
||||
@@ -39,7 +45,7 @@ function setUpInitialGame() {
|
||||
|
||||
// Provided by mouse camera script (mousecam.js)
|
||||
SetStandardControlsEnabled(true);
|
||||
} else if (getGame() == VRR_GAME_GTA_VC) {
|
||||
} else if (getGame() == AGRP_GAME_GTA_VC) {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA Vice City ...");
|
||||
|
||||
// Turn off unlimited sprint
|
||||
@@ -82,7 +88,7 @@ function setUpInitialGame() {
|
||||
|
||||
// Provided by mouse camera script (mousecam.js)
|
||||
SetStandardControlsEnabled(true);
|
||||
} else if (getGame() == VRR_GAME_GTA_SA) {
|
||||
} else if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA San Andreas ...");
|
||||
// Turn weapon skills down a bit
|
||||
game.setGameStat(STAT_WEAPONTYPE_PISTOL_SKILL, 400);
|
||||
@@ -119,7 +125,7 @@ function setUpInitialGame() {
|
||||
|
||||
// Disables taxi/vigilante/etc and other start mission triggers
|
||||
game.onMission = true;
|
||||
} else if (getGame() == VRR_GAME_GTA_IV) {
|
||||
} else if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.allowEmergencyServices(false);
|
||||
natives.setCreateRandomCops(true);
|
||||
natives.setMaxWantedLevel(0);
|
||||
@@ -181,7 +187,7 @@ function setUpInitialGame() {
|
||||
|
||||
// Some last steps
|
||||
//natives.loadAllObjectsNow();
|
||||
} else if (getGame() == VRR_GAME_MAFIA_ONE) {
|
||||
} else if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
game.mapEnabled = false;
|
||||
game.setTrafficEnabled(false);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: sync.js
|
||||
// DESC: Provides some elements and data sync
|
||||
@@ -46,20 +47,14 @@ function processSync(event, deltaTime) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setVehicleEngine(vehicleId, state) {
|
||||
getElementFromId(vehicleId).engine = state;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setVehicleLights(vehicleId, state) {
|
||||
if (getGame() != VRR_GAME_MAFIA_ONE) {
|
||||
if (getGame() != AGRP_GAME_MAFIA_ONE) {
|
||||
if (!state) {
|
||||
getElementFromId(vehicleId).lightStatus = 2;
|
||||
} else {
|
||||
getElementFromId(vehicleId).lightStatus = 1;
|
||||
}
|
||||
} else if (getGame() == VRR_GAME_GTA_IV) {
|
||||
} else if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (!state) {
|
||||
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0));
|
||||
} else {
|
||||
@@ -127,7 +122,7 @@ function syncVehicleProperties(vehicle) {
|
||||
vehicle.setSuspensionHeight(suspensionHeight);
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
//let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
|
||||
//for(let i in allUpgrades) {
|
||||
// vehicle.removeUpgrade(i);
|
||||
@@ -143,12 +138,12 @@ function syncVehicleProperties(vehicle) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA || getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (doesEntityDataExist(vehicle, "agrp.livery")) {
|
||||
let livery = getEntityData(vehicle, "agrp.livery");
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
vehicle.setPaintJob(livery);
|
||||
} else if (getGame() == VRR_GAME_GTA_IV) {
|
||||
} else if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
vehicle.livery = livery;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +157,7 @@ function syncCivilianProperties(civilian) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_III) {
|
||||
if (getGame() == AGRP_GAME_GTA_III) {
|
||||
if (doesEntityDataExist(civilian, "agrp.scale")) {
|
||||
let scaleFactor = getEntityData(civilian, "agrp.scale");
|
||||
let tempMatrix = civilian.matrix;
|
||||
@@ -174,21 +169,21 @@ function syncCivilianProperties(civilian) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
if (doesEntityDataExist(civilian, "agrp.fightStyle")) {
|
||||
let fightStyle = getEntityData(civilian, "agrp.fightStyle");
|
||||
civilian.setFightStyle(fightStyle[0], fightStyle[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_III) {
|
||||
if (getGame() == AGRP_GAME_GTA_III) {
|
||||
if (doesEntityDataExist(civilian, "agrp.walkStyle")) {
|
||||
let walkStyle = getEntityData(civilian, "agrp.walkStyle");
|
||||
civilian.walkStyle = walkStyle;
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (doesEntityDataExist(civilian, "agrp.bodyPropHair")) {
|
||||
let bodyPropHair = getEntityData(civilian, "agrp.bodyPropHair");
|
||||
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
|
||||
@@ -259,7 +254,7 @@ function syncPlayerProperties(player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_III) {
|
||||
if (getGame() == AGRP_GAME_GTA_III) {
|
||||
if (doesEntityDataExist(player, "agrp.scale")) {
|
||||
let scaleFactor = getEntityData(player, "agrp.scale");
|
||||
let tempMatrix = player.matrix;
|
||||
@@ -271,21 +266,21 @@ function syncPlayerProperties(player) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() == AGRP_GAME_GTA_SA) {
|
||||
if (doesEntityDataExist(player, "agrp.fightStyle")) {
|
||||
let fightStyle = getEntityData(player, "agrp.fightStyle");
|
||||
player.setFightStyle(fightStyle[0], fightStyle[1]);
|
||||
}
|
||||
}
|
||||
|
||||
//if(getGame() == VRR_GAME_GTA_SA) {
|
||||
//if(getGame() == AGRP_GAME_GTA_SA) {
|
||||
// if(doesEntityDataExist(player, "agrp.walkStyle")) {
|
||||
// let walkStyle = getEntityData(player, "agrp.walkStyle");
|
||||
// player.walkStyle = walkStyle;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (doesEntityDataExist(player, "agrp.bodyPartHair")) {
|
||||
let bodyPartHead = getEntityData(player, "agrp.bodyPartHair");
|
||||
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
|
||||
@@ -307,7 +302,7 @@ function syncPlayerProperties(player) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (doesEntityDataExist(player, "agrp.bodyPropHair")) {
|
||||
let bodyPropHair = getEntityData(player, "agrp.bodyPropHair");
|
||||
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
|
||||
@@ -378,7 +373,7 @@ function syncElementProperties(element) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_MAFIA_ONE) {
|
||||
if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
switch (element.type) {
|
||||
case ELEMENT_VEHICLE:
|
||||
syncVehicleProperties(element);
|
||||
@@ -419,7 +414,7 @@ function syncElementProperties(element) {
|
||||
// ===========================================================================
|
||||
|
||||
function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupModel, hasInterior) {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
8
scripts/client/time.nut
Normal file
@@ -0,0 +1,8 @@
|
||||
function getCurrentUnixTimeStampSquirrel() {
|
||||
return time();
|
||||
}
|
||||
|
||||
function getTimeStampOutput(timeStamp) {
|
||||
local dateObj = date(timeStamp);
|
||||
return dateObj.hour + ":" + dateObj.minute + ":" + dateObj.second;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: utilities.js
|
||||
// DESC: Provides util functions and arrays with data
|
||||
@@ -17,9 +18,9 @@ function setLocalPlayerFrozenState(state) {
|
||||
function setLocalPlayerControlState(controlState, cursorState = false) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`);
|
||||
controlsEnabled = controlState;
|
||||
if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
|
||||
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
|
||||
game.SET_PLAYER_CONTROL(game.GET_PLAYER_ID(), boolToInt(controlState));
|
||||
} else if (getGame() != VRR_GAME_GTA_IV) {
|
||||
} else if (getGame() != AGRP_GAME_GTA_IV) {
|
||||
setElementCollisionsEnabled(localPlayer, controlState);
|
||||
setPedInvincible(localPlayer, true);
|
||||
}
|
||||
@@ -47,7 +48,7 @@ function removeLocalPlayerFromVehicle() {
|
||||
|
||||
function restoreLocalCamera() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Camera restored`);
|
||||
if (isCustomCameraSupported()) {
|
||||
if (isGameFeatureSupported("customCamera")) {
|
||||
game.restoreCamera(true);
|
||||
}
|
||||
};
|
||||
@@ -75,9 +76,9 @@ function setCityAmbienceState(state, clearElements = false) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`);
|
||||
game.setTrafficEnabled(state);
|
||||
|
||||
if (getMultiplayerMod() == VRR_MPMOD_GTAC) {
|
||||
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
|
||||
game.setGenerateCarsAroundCamera(state);
|
||||
if (getGame() != VRR_GAME_GTA_SA) {
|
||||
if (getGame() != AGRP_GAME_GTA_SA) {
|
||||
game.setCiviliansEnabled(state);
|
||||
}
|
||||
|
||||
@@ -112,19 +113,20 @@ function runClientCode(code, returnTo) {
|
||||
function enterVehicleAsPassenger() {
|
||||
if (localPlayer.vehicle == null) {
|
||||
let tempVehicle = getClosestVehicle(localPlayer.position);
|
||||
if (getGame() != VRR_GAME_GTA_IV) {
|
||||
if (getGame() != AGRP_GAME_GTA_IV) {
|
||||
if (tempVehicle != null) {
|
||||
localPlayer.enterVehicle(tempVehicle, false);
|
||||
}
|
||||
} else {
|
||||
// Disable for now. GTA IV has built-in passenger entry
|
||||
|
||||
//for(let i = 0 ; i <= natives.getMaximumNumberOfPassengers(tempVehicle); i++) {
|
||||
// if(natives.isCarPassengerSeatFree(tempVehicle, i)) {
|
||||
// natives.taskEnterCarAsPassenger(localPlayer, tempVehicle, i, 10000);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
// else {
|
||||
// Disable for now. GTA IV has built-in passenger entry
|
||||
|
||||
//for(let i = 0 ; i <= natives.getMaximumNumberOfPassengers(tempVehicle); i++) {
|
||||
// if(natives.isCarPassengerSeatFree(tempVehicle, i)) {
|
||||
// natives.taskEnterCarAsPassenger(localPlayer, tempVehicle, i, 10000);
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,13 +135,13 @@ function enterVehicleAsPassenger() {
|
||||
function giveLocalPlayerWeapon(weaponId, ammo, active) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Giving weapon ${weaponId} with ${ammo} ammo`);
|
||||
forceWeapon = weaponId;
|
||||
if (getGame() == VRR_GAME_MAFIA_ONE) {
|
||||
if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
localPlayer.giveWeapon(weaponId, 0, ammo);
|
||||
forceWeaponAmmo = 0;
|
||||
forceWeaponClipAmmo = ammo;
|
||||
} else {
|
||||
localPlayer.giveWeapon(weaponId, ammo, active);
|
||||
if (getGame() < VRR_GAME_GTA_IV) {
|
||||
if (getGame() < AGRP_GAME_GTA_IV) {
|
||||
forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(weaponId));
|
||||
forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(weaponId));
|
||||
} else {
|
||||
@@ -193,7 +195,7 @@ function setLocalPlayerHeading(heading) {
|
||||
|
||||
function setLocalPlayerInterior(interior) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting interior to ${interior}`);
|
||||
if (getMultiplayerMod() == VRR_MPMOD_GTAC) {
|
||||
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
|
||||
if (!isGTAIV()) {
|
||||
localPlayer.interior = interior;
|
||||
game.cameraInterior = interior;
|
||||
@@ -239,7 +241,7 @@ function setLocalPlayerHealth(health) {
|
||||
|
||||
function playPedSpeech(pedName, speechId) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Making ${pedName}'s ped talk (${speechId})`);
|
||||
if (getMultiplayerMod() == VRR_MPMOD_GTAC) {
|
||||
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
|
||||
game.SET_CHAR_SAY(int, int);
|
||||
}
|
||||
}
|
||||
@@ -260,7 +262,7 @@ function getWeaponSlot(weaponId) {
|
||||
// ===========================================================================
|
||||
|
||||
function setLocalPlayerDrunkEffect(amount, duration) {
|
||||
if (getMultiplayerMod() == VRR_MPMOD_GTAC) {
|
||||
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Drunk effect set to ${amount} for ${duration} ms`);
|
||||
drunkEffectAmount = 0;
|
||||
drunkEffectDurationTimer = setInterval(function () {
|
||||
@@ -310,6 +312,14 @@ function clearSelfOwnedVehicles() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setMouseCameraState(state) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(state) ? "Enabled" : "Disabled"} mouse camera`);
|
||||
mouseCameraEnabled = state;
|
||||
SetStandardControlsEnabled(!mouseCameraEnabled);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleMouseCursor() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(!gui.cursorEnabled) ? "Enabled" : "Disabled"} mouse cursor`);
|
||||
gui.showCursor(!gui.cursorEnabled, gui.cursorEnabled);
|
||||
@@ -340,11 +350,15 @@ function setPlayerWeaponDamageEnabled(clientName, state) {
|
||||
|
||||
function setLocalPlayerCash(amount) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting local player money`);
|
||||
if (localPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof localPlayer.money != "undefined") {
|
||||
localPlayer.money = toInteger(amount);
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
natives.setMultiplayerHudCash(amount);
|
||||
}
|
||||
}
|
||||
@@ -420,52 +434,17 @@ function processLocalPlayerVehicleControlState() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processLocalPlayerSphereEntryExitHandling() {
|
||||
let position = getLocalPlayerPosition();
|
||||
|
||||
if (areMarkersSupported()) {
|
||||
getElementsByType(ELEMENT_MARKER).forEach(function (sphere) {
|
||||
if (getDistance(position, sphere.position) <= sphere.radius) {
|
||||
if (!inSphere) {
|
||||
inSphere = sphere;
|
||||
triggerEvent("OnLocalPlayerEnterSphere", null, sphere);
|
||||
}
|
||||
} else {
|
||||
if (inSphere) {
|
||||
inSphere = false;
|
||||
triggerEvent("OnLocalPlayerExitSphere", null, sphere);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processJobRouteSphere() {
|
||||
if (getGame() == VRR_GAME_GTA_SA) {
|
||||
let position = getLocalPlayerPosition();
|
||||
if (jobRouteLocationSphere != null) {
|
||||
if (getDistance(position, jobRouteLocationSphere.position) <= 2.0) {
|
||||
enteredJobRouteSphere();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function forceLocalPlayerEquippedWeaponItem() {
|
||||
if (typeof localPlayer.weapon != "undefined") {
|
||||
if (forceWeapon != 0) {
|
||||
if (localPlayer.weapon != forceWeapon) {
|
||||
localPlayer.weapon = forceWeapon;
|
||||
if (getGame() < VRR_GAME_GTA_IV) {
|
||||
if (getGame() < AGRP_GAME_GTA_IV) {
|
||||
localPlayer.setWeaponClipAmmunition(getWeaponSlot(forceWeapon), forceWeaponClipAmmo);
|
||||
localPlayer.setWeaponAmmunition(getWeaponSlot(forceWeapon), forceWeaponAmmo);
|
||||
}
|
||||
} else {
|
||||
//if(getGame() < VRR_GAME_GTA_IV) {
|
||||
//if(getGame() < AGRP_GAME_GTA_IV) {
|
||||
// forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(forceWeapon));
|
||||
// forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(forceWeapon));
|
||||
//}
|
||||
@@ -491,26 +470,8 @@ function getLocalPlayerPosition() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processLocalPlayerVehicleEntryExitHandling() {
|
||||
if (localPlayer.vehicle) {
|
||||
if (!inVehicle) {
|
||||
inVehicle = localPlayer.vehicle;
|
||||
inVehicleSeat = getLocalPlayerVehicleSeat();
|
||||
triggerEvent("OnLocalPlayerEnteredVehicle", inVehicle, inVehicleSeat);
|
||||
}
|
||||
} else {
|
||||
if (inVehicle) {
|
||||
triggerEvent("OnLocalPlayerExitedVehicle", inVehicle, inVehicleSeat);
|
||||
inVehicle = false;
|
||||
inVehicleSeat = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getVehicleForNetworkEvent(vehicle) {
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
return natives.getNetworkIdFromVehicle(vehicle);
|
||||
}
|
||||
return vehicle.id;
|
||||
@@ -593,7 +554,7 @@ function processNearbyPickups() {
|
||||
// ===========================================================================
|
||||
|
||||
function processGameSpecifics() {
|
||||
if (getGame() < VRR_GAME_GTA_IV) {
|
||||
if (getGame() < AGRP_GAME_GTA_IV) {
|
||||
game.clearMessages();
|
||||
}
|
||||
|
||||
@@ -606,4 +567,11 @@ function getServerData() {
|
||||
return serverData;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setProfanityFilterState(state) {
|
||||
profanityFilterEnabled = state;
|
||||
updateChatBox();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: vehicle.js
|
||||
// DESC: Provides vehicle functions and arrays with data
|
||||
@@ -29,10 +30,10 @@ class VehicleData {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2, colour3 = 0, colour4 = 0, locked = false, lights = false, engine = false, licensePlate = "") {
|
||||
function receiveVehicleFromServer(vehicleId, networkId, position, model, colour1, colour2, colour3 = 0, colour4 = 0, locked = false, lights = false, engine = false, licensePlate = "") {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Vehicle] Received vehicle ${vehicleId} (${getVehicleNameFromModel(model, getGame())}) from server`);
|
||||
|
||||
if (getGame() != VRR_GAME_GTA_IV) {
|
||||
if (getGame() != AGRP_GAME_GTA_IV) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,8 +50,16 @@ function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2,
|
||||
vehicleData.lights = lights;
|
||||
vehicleData.locked = locked;
|
||||
vehicleData.licensePlate = "";
|
||||
vehicleData.networkId = networkId;
|
||||
|
||||
let vehicle = natives.getVehicleFromNetworkId(vehicleId.ivNetworkId);
|
||||
if (natives.getVehicleFromNetworkId(vehicleId.ivNetworkId) != null) {
|
||||
vehicleData.vehicle = natives.getVehicleFromNetworkId(vehicleId.ivNetworkId);
|
||||
} else {
|
||||
let vehicle = createGameVehicle(model, position, heading, colour1, colour2, colour3, colour4);
|
||||
vehicleData.vehicle = vehicle;
|
||||
|
||||
sendNetworkEventToServer("agrp.vehicleCreated", vehicleId, natives.getNetworkIdFromVehicle(vehicle));
|
||||
}
|
||||
} else {
|
||||
//logToConsole(LOG_DEBUG, `[VRR.Vehicle] Vehicle ${vehicleId} doesn't exist. Adding ...`);
|
||||
//let tempVehicleData = new VehicleData(vehicleId, name, position, blipModel, pickupModel);
|
||||
@@ -63,20 +72,20 @@ function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2,
|
||||
// ===========================================================================
|
||||
|
||||
function processVehiclePurchasing() {
|
||||
if (vehiclePurchaseState == VRR_VEHBUYSTATE_TESTDRIVE) {
|
||||
if (vehiclePurchaseState == AGRP_VEHBUYSTATE_TESTDRIVE) {
|
||||
if (getLocalPlayerVehicle() == false) {
|
||||
vehiclePurchaseState = VRR_VEHBUYSTATE_EXITVEH;
|
||||
sendNetworkEventToServer("agrp.vehBuyState", VRR_VEHBUYSTATE_EXITVEH);
|
||||
vehiclePurchaseState = AGRP_VEHBUYSTATE_EXITVEH;
|
||||
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_EXITVEH);
|
||||
return false;
|
||||
} else {
|
||||
if (vehiclePurchasing == getLocalPlayerVehicle()) {
|
||||
if (getDistance(getLocalPlayerVehicle().position, vehiclePurchasePosition) >= 25) {
|
||||
vehiclePurchaseState = VRR_VEHBUYSTATE_FARENOUGH;
|
||||
sendNetworkEventToServer("agrp.vehBuyState", VRR_VEHBUYSTATE_FARENOUGH);
|
||||
vehiclePurchaseState = AGRP_VEHBUYSTATE_FARENOUGH;
|
||||
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_FARENOUGH);
|
||||
}
|
||||
} else {
|
||||
vehiclePurchaseState = VRR_VEHBUYSTATE_WRONGVEH;
|
||||
sendNetworkEventToServer("agrp.vehBuyState", VRR_VEHBUYSTATE_WRONGVEH);
|
||||
vehiclePurchaseState = AGRP_VEHBUYSTATE_WRONGVEH;
|
||||
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_WRONGVEH);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,4 +137,40 @@ function setAllVehicleDataIndexes() {
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleVehicleCruiseControl(vehicle) {
|
||||
if (!vehicle.isSyncer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
cruiseControl = !cruiseControl;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getVehicleSpeed(vehicle) {
|
||||
let matrix = vehicle.matrix;
|
||||
let frontSpeed = true;
|
||||
let vecMoveSpeed = vehicle.velocity;
|
||||
let speed;
|
||||
|
||||
if (frontSpeed) {
|
||||
speed = getDotProduct(vecMoveSpeed[0], vecMoveSpeed[1], vecMoveSpeed[2], matrix.getElement(1 * 4 + 0), matrix.getElement(1 * 4 + 1), matrix.getElement(1 * 4 + 2));
|
||||
} else {
|
||||
speed = getLength(vecMoveSpeed[0], vecMoveSpeed[1], vecMoveSpeed[2]);
|
||||
}
|
||||
|
||||
if (getGame() == AGRP_GAME_GTA_IV || getGame() == AGRP_GAME_GTA_IV_EFLC) {
|
||||
speed /= 40.0;
|
||||
}
|
||||
|
||||
speed = speed * 90;
|
||||
speed = Math.abs(speed);
|
||||
|
||||
return speed;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: accent.js
|
||||
// DESC: Provides accent functions and usage
|
||||
@@ -27,7 +28,7 @@ function doesPlayerHaveAccent(client) {
|
||||
|
||||
function getPlayerAccentInlineOutput(client) {
|
||||
let outputText = "";
|
||||
if(doesPlayerHaveAccent(client)) {
|
||||
if (doesPlayerHaveAccent(client)) {
|
||||
outputText = `[${getPlayerAccentText(client)}] `;
|
||||
}
|
||||
|
||||
@@ -37,14 +38,14 @@ function getPlayerAccentInlineOutput(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setAccentCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let accentId = getAccentFromParams(params);
|
||||
|
||||
if(!accentId) {
|
||||
if (!accentId) {
|
||||
messagePlayerError(client, getLocaleString(client, "AccentNotFound"));
|
||||
return false;
|
||||
}
|
||||
@@ -64,7 +65,7 @@ function listAccentsCommand(command, params, client) {
|
||||
let chunkedList = splitArrayIntoChunks(accentList, 8);
|
||||
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "AccentsListHeader")));
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
@@ -72,14 +73,14 @@ function listAccentsCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getAccentFromParams(params) {
|
||||
if(isNaN(params)) {
|
||||
for(let i in getGlobalConfig().accents) {
|
||||
if(toLowerCase(getGlobalConfig().accents[i]).indexOf(toLowerCase(params)) != -1) {
|
||||
if (isNaN(params)) {
|
||||
for (let i in getGlobalConfig().accents) {
|
||||
if (toLowerCase(getGlobalConfig().accents[i]).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(typeof getGlobalConfig().accents[params] != "undefined") {
|
||||
if (typeof getGlobalConfig().accents[params] != "undefined") {
|
||||
return toInteger(params);
|
||||
}
|
||||
}
|
||||
@@ -97,14 +98,14 @@ function reloadAccentConfigurationCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function addAccentCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let newAccentName = params;
|
||||
|
||||
if(getAccentFromParams(newAccentName) != false) {
|
||||
if (getAccentFromParams(newAccentName) != false) {
|
||||
messagePlayerError(client, `That accent already exists!`)
|
||||
return false;
|
||||
}
|
||||
@@ -117,14 +118,14 @@ function addAccentCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function removeAccentCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let newAccentName = params;
|
||||
|
||||
if(!getAccentFromParams(newAccentName)) {
|
||||
if (!getAccentFromParams(newAccentName)) {
|
||||
messagePlayerError(client, `That accent doesn't exist!`)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: account.js
|
||||
// DESC: Provides account functions and usage
|
||||
@@ -8,35 +9,35 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Account Contact Types
|
||||
const VRR_CONTACT_NONE = 0;
|
||||
const VRR_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
|
||||
const VRR_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
|
||||
const VRR_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
|
||||
const AGRP_CONTACT_NONE = 0;
|
||||
const AGRP_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
|
||||
const AGRP_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
|
||||
const AGRP_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Account Authentication Methods
|
||||
const VRR_ACCT_AUTHMETHOD_NONE = 0; // None
|
||||
const VRR_ACCT_AUTHMETHOD_EMAIL = 1; // Email
|
||||
const VRR_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
|
||||
const VRR_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
|
||||
const VRR_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
|
||||
const VRR_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
|
||||
const AGRP_ACCT_AUTHMETHOD_NONE = 0; // None
|
||||
const AGRP_ACCT_AUTHMETHOD_EMAIL = 1; // Email
|
||||
const AGRP_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
|
||||
const AGRP_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
|
||||
const AGRP_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
|
||||
const AGRP_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Two-Factor Authentication States
|
||||
const VRR_2FA_STATE_NONE = 0; // None
|
||||
const VRR_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
|
||||
const VRR_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
|
||||
const VRR_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
|
||||
const AGRP_2FA_STATE_NONE = 0; // None
|
||||
const AGRP_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
|
||||
const AGRP_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
|
||||
const AGRP_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Reset Password States
|
||||
const VRR_RESETPASS_STATE_NONE = 0; // None
|
||||
const VRR_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
|
||||
const VRR_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
|
||||
const AGRP_RESETPASS_STATE_NONE = 0; // None
|
||||
const AGRP_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
|
||||
const AGRP_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -74,29 +75,28 @@ class AccountData {
|
||||
this.locale = 0;
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = dbAssoc["acct_id"];
|
||||
this.name = dbAssoc["acct_name"];
|
||||
this.password = dbAssoc["acct_pass"];
|
||||
this.registerDate = dbAssoc["acct_when_made"];
|
||||
this.databaseId = toInteger(dbAssoc["acct_id"]);
|
||||
this.name = toString(dbAssoc["acct_name"]);
|
||||
this.password = toString(dbAssoc["acct_pass"]);
|
||||
this.registerDate = toInteger(dbAssoc["acct_when_registered"]);
|
||||
this.flags = {
|
||||
moderation: dbAssoc["acct_svr_mod_flags"],
|
||||
admin: dbAssoc["acct_svr_staff_flags"],
|
||||
moderation: toInteger(dbAssoc["acct_svr_mod_flags"]),
|
||||
admin: toInteger(dbAssoc["acct_svr_staff_flags"]),
|
||||
};
|
||||
this.staffTitle = dbAssoc["acct_svr_staff_title"];
|
||||
this.ircAccount = dbAssoc["acct_irc"];
|
||||
this.discordAccount = dbAssoc["acct_discord"];
|
||||
this.settings = dbAssoc["acct_svr_settings"];
|
||||
this.emailAddress = dbAssoc["acct_email"];
|
||||
this.whenRegistered = dbAssoc["acct_when_registered"];
|
||||
this.ipAddress = dbAssoc["acct_ip"];
|
||||
this.staffTitle = toString(dbAssoc["acct_svr_staff_title"]);
|
||||
this.ircAccount = toInteger(dbAssoc["acct_irc"]);
|
||||
this.discordAccount = toInteger(dbAssoc["acct_discord"]);
|
||||
this.settings = toInteger(dbAssoc["acct_svr_settings"]);
|
||||
this.emailAddress = toString(dbAssoc["acct_email"]);
|
||||
this.ipAddress = toString(dbAssoc["acct_ip"]);
|
||||
|
||||
this.notes = [];
|
||||
this.messages = [];
|
||||
this.contacts = [];
|
||||
this.subAccounts = [];
|
||||
|
||||
this.emailVerificationCode = dbAssoc["acct_code_verifyemail"];
|
||||
this.twoFactorAuthVerificationCode = dbAssoc["acct_code_2fa"];
|
||||
this.emailVerificationCode = toString(dbAssoc["acct_code_verifyemail"]);
|
||||
this.twoFactorAuthVerificationCode = toString(dbAssoc["acct_code_2fa"]);
|
||||
this.chatScrollLines = toInteger(dbAssoc["acct_svr_chat_scroll_lines"]);
|
||||
this.streamingRadioVolume = toInteger(dbAssoc["acct_streaming_radio_volume"]);
|
||||
this.locale = toInteger(dbAssoc["acct_locale"]);
|
||||
@@ -387,6 +387,74 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleChatBoxTimeStampsCommand(command, params, client) {
|
||||
let flagValue = getAccountSettingsFlagValue("ChatBoxTimestamps");
|
||||
|
||||
if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
|
||||
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "ChatBoxTimestampsToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
|
||||
sendPlayerChatBoxTimeStampsState(client, false);
|
||||
} else {
|
||||
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "ChatBoxTimestampsToggle", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
|
||||
sendPlayerChatBoxTimeStampsState(client, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleAccountProfanityFilterCommand(command, params, client) {
|
||||
let flagValue = getAccountSettingsFlagValue("ProfanityFilter");
|
||||
|
||||
if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
|
||||
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "ProfanityFilterSet", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
|
||||
sendPlayerProfanityFilterState(client, false);
|
||||
} else {
|
||||
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "ProfanityFilterSet", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
|
||||
sendPlayerProfanityFilterState(client, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleAccountReplaceEmojiCommand(command, params, client) {
|
||||
let flagValue = getAccountSettingsFlagValue("ChatEmoji");
|
||||
|
||||
if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
|
||||
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "ChatEmojiSet", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
|
||||
sendPlayerChatEmojiState(client, false);
|
||||
} else {
|
||||
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "ChatEmojiSet", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
|
||||
sendPlayerChatEmojiState(client, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleAccountHideBloodCommand(command, params, client) {
|
||||
let flagValue = getAccountSettingsFlagValue("NoBlood");
|
||||
|
||||
if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
|
||||
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "HideBloodSet", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
|
||||
sendPlayerChatBoxTimeStampsState(client, false);
|
||||
} else {
|
||||
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "HideBloodSet", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
|
||||
sendPlayerChatBoxTimeStampsState(client, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function registerCommand(command, params, client) {
|
||||
if (isPlayerRegistered(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "AccountNameAlreadyRegistered"));
|
||||
@@ -675,7 +743,7 @@ function loadAccountFromName(accountName, fullLoad = false) {
|
||||
function loadAccountFromId(accountId, fullLoad = false) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT *, acct_ip AS ipstring FROM acct_main WHERE acct_id = ${accountId} LIMIT 1;`;
|
||||
let dbQueryString = `SELECT acct_main.*, acct_svr.* FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_id = ${accountId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
@@ -765,6 +833,11 @@ function loginSuccess(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} successfully logged in.`);
|
||||
getPlayerData(client).loggedIn = true;
|
||||
|
||||
if (getPlayerData(client).loginTimeout != null) {
|
||||
clearTimeout(getPlayerData(client).loginTimeout);
|
||||
getPlayerData(client).loginTimeout = null;
|
||||
}
|
||||
|
||||
updateConnectionLogOnAuth(client, getPlayerData(client).accountData.databaseId);
|
||||
|
||||
if (doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) {
|
||||
@@ -794,7 +867,7 @@ function loginSuccess(client) {
|
||||
if (getPlayerData(client).subAccounts.length == 0) {
|
||||
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
|
||||
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_CREATEFIRSTCHAR;
|
||||
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
|
||||
} else {
|
||||
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage", `{ALTCOLOUR}/newchar{MAINCOLOUR}`));
|
||||
@@ -847,12 +920,12 @@ function saveAccountToDatabase(accountData) {
|
||||
];
|
||||
|
||||
let data2 = [
|
||||
["acct_svr_settings", accountData.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],
|
||||
["acct_svr_chat_auto_hide_delay", accountData.chatAutoHideDelay],
|
||||
["acct_svr_settings", (accountData.settings != NaN) ? toInteger(accountData.settings) : 0],
|
||||
["acct_svr_staff_title", toString(safeStaffTitle)],
|
||||
["acct_svr_staff_flags", (accountData.flags.admin != NaN) ? toInteger(accountData.flags.admin) : 0],
|
||||
["acct_svr_mod_flags", (accountData.flags.moderation != NaN) ? toInteger(accountData.flags.moderation) : 0],
|
||||
["acct_svr_chat_scroll_lines", (accountData.chatScrollLines != NaN) ? toInteger(accountData.chatScrollLines) : 1],
|
||||
//["acct_svr_chat_auto_hide_delay", accountData.chatAutoHideDelay],
|
||||
];
|
||||
|
||||
let queryString1 = createDatabaseUpdateQuery("acct_main", data, `acct_id=${accountData.databaseId}`);
|
||||
@@ -971,8 +1044,10 @@ function createAccount(name, password, email = "") {
|
||||
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email, acct_when_registered) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}', CURRENT_TIMESTAMP())`);
|
||||
if (getDatabaseInsertId(dbConnection) > 0) {
|
||||
let tempAccountData = loadAccountFromId(getDatabaseInsertId(dbConnection), false);
|
||||
createDefaultAccountServerData(tempAccountData.databaseId);
|
||||
let insertId = getDatabaseInsertId(dbConnection);
|
||||
createDefaultAccountServerData(insertId);
|
||||
let tempAccountData = loadAccountFromId(insertId, false);
|
||||
|
||||
tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId);
|
||||
tempAccountData.notes = loadAccountStaffNotesFromDatabase(tempAccountData.databaseId);
|
||||
tempAccountData.contacts = loadAccountContactsFromDatabase(tempAccountData.databaseId);
|
||||
@@ -986,7 +1061,7 @@ function createAccount(name, password, email = "") {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function checkLogin(client, password) {
|
||||
function checkLogin(client, password) {
|
||||
getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining - 1;
|
||||
if (getPlayerData(client).loginAttemptsRemaining <= 0) {
|
||||
getPlayerData(client).customDisconnectReason = "Kicked - Failed to login";
|
||||
@@ -1027,9 +1102,9 @@ async function checkLogin(client, password) {
|
||||
}
|
||||
|
||||
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
|
||||
//if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
||||
// await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||
//}
|
||||
if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
||||
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1044,14 +1119,15 @@ async function checkLogin(client, password) {
|
||||
}
|
||||
|
||||
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
|
||||
//if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
||||
// await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||
//}
|
||||
if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
||||
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveTwoFactorAuthEnabled(client) && checkForSMTPModule() && getEmailConfig().enabled) {
|
||||
getPlayerData(client).twoFactorAuthCode = toUpperCase(generateRandomString(6));
|
||||
//getPlayerData(client).twoFactorAuthCode = toUpperCase(generateRandomString(6));
|
||||
getPlayerData(client).twoFactorAuthCode = getRandom(100000, 999999);
|
||||
showPlayerTwoFactorAuthenticationGUI(client);
|
||||
sendAccountTwoFactorAuthCode(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerData(client).twoFactorAuthCode);
|
||||
return true;
|
||||
@@ -1065,7 +1141,7 @@ async function checkLogin(client, password) {
|
||||
|
||||
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
|
||||
//if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
||||
// await sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||
// sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -1161,6 +1237,8 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
|
||||
|
||||
getPlayerData(client).accountData = accountData;
|
||||
getPlayerData(client).loggedIn = true;
|
||||
getPlayerData(client).accountData.settings = 0;
|
||||
getPlayerData(client).accountData.needsSaved = true;
|
||||
|
||||
messagePlayerSuccess(client, getLocaleString(client, "RegistrationSuccess"));
|
||||
if (checkForSMTPModule() && getEmailConfig().enabled) {
|
||||
@@ -1191,8 +1269,8 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
|
||||
|
||||
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
|
||||
showPlayerRegistrationSuccessGUI(client);
|
||||
showPlayerPrompt(client, getLocaleString(client, "NoCharactersMessage"), getLocaleString(client, "NoCharactersWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
|
||||
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_CREATEFIRSTCHAR;
|
||||
} else {
|
||||
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage"), `{ALTCOLOUR}/newchar{MAINCOLOUR}`);
|
||||
}
|
||||
@@ -1207,7 +1285,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
}
|
||||
|
||||
switch (getPlayerData(client).passwordResetState) {
|
||||
case VRR_RESETPASS_STATE_EMAILCONFIRM: {
|
||||
case AGRP_RESETPASS_STATE_EMAILCONFIRM: {
|
||||
if (toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) {
|
||||
logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`);
|
||||
showPlayerErrorGUI(client, getLocaleString(client, "GUIErrorResetPasswordFailedInvalidEmail"), getLocaleString(client, "GUIErrorTitle"), getLocaleString(client, "GUIOkButton"));
|
||||
@@ -1215,7 +1293,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
}
|
||||
|
||||
let passwordResetCode = toUpperCase(generateEmailVerificationCode());
|
||||
getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_CODEINPUT;
|
||||
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_CODEINPUT;
|
||||
getPlayerData(client).passwordResetCode = passwordResetCode;
|
||||
showPlayerResetPasswordCodeInputGUI(client);
|
||||
sendPasswordResetEmail(client, passwordResetCode);
|
||||
@@ -1223,11 +1301,11 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_RESETPASS_STATE_CODEINPUT: {
|
||||
case AGRP_RESETPASS_STATE_CODEINPUT: {
|
||||
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted code for password reset (${inputText}) ...`);
|
||||
if (inputText != "") {
|
||||
if (getPlayerData(client).passwordResetCode == toUpperCase(inputText)) {
|
||||
getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_SETPASS;
|
||||
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_SETPASS;
|
||||
showPlayerChangePasswordGUI(client);
|
||||
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`);
|
||||
} else {
|
||||
@@ -1244,10 +1322,10 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_RESETPASS_STATE_NONE: {
|
||||
case AGRP_RESETPASS_STATE_NONE: {
|
||||
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} requested a password reset. Awaiting email input ...`);
|
||||
showPlayerResetPasswordEmailInputGUI(client);
|
||||
getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_EMAILCONFIRM;
|
||||
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_EMAILCONFIRM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1259,8 +1337,8 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
|
||||
function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
if (getPlayerData(client).passwordResetState != VRR_RESETPASS_STATE_SETPASS) {
|
||||
//getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
|
||||
if (getPlayerData(client).passwordResetState != AGRP_RESETPASS_STATE_SETPASS) {
|
||||
//getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_NONE;
|
||||
//disconnectPlayer(client);
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`);
|
||||
return false;
|
||||
@@ -1296,8 +1374,8 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
|
||||
|
||||
saveAccountToDatabase(getPlayerData(client).accountData);
|
||||
|
||||
if (getPlayerData(client).passwordResetState == VRR_RESETPASS_STATE_SETPASS) {
|
||||
getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
|
||||
if (getPlayerData(client).passwordResetState == AGRP_RESETPASS_STATE_SETPASS) {
|
||||
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_NONE;
|
||||
}
|
||||
|
||||
messagePlayerSuccess(client, getLocaleString(client, "PasswordChanged"));
|
||||
@@ -1338,7 +1416,7 @@ function savePlayerToDatabase(client) {
|
||||
//let subAccountData = getPlayerCurrentSubAccount(client);
|
||||
|
||||
if (getPlayerPed(client) != null) {
|
||||
if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != VRR_RETURNTO_TYPE_ADMINGET) {
|
||||
if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != AGRP_RETURNTO_TYPE_ADMINGET) {
|
||||
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition;
|
||||
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z;
|
||||
getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior;
|
||||
@@ -1374,11 +1452,12 @@ function initClient(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setEntityData(client, "agrp.isInitialized", true, false);
|
||||
playerInitialized[client.index] = true;
|
||||
|
||||
sendPlayerGUIColours(client);
|
||||
//setEntityData(client, "agrp.isInitialized", true, false);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Account] Initializing GUI for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
sendPlayerGUIColours(client);
|
||||
sendPlayerGUIInit(client);
|
||||
updatePlayerSnowState(client);
|
||||
|
||||
@@ -1421,8 +1500,9 @@ function initClient(client) {
|
||||
// let iso = module.geoip.getCountryISO(getPlayerIP(client));
|
||||
// let localeId = getLocaleFromCountryISO(iso);
|
||||
//}
|
||||
//showGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto");
|
||||
//showSmallGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto");
|
||||
}
|
||||
startLoginTimeoutForPlayer(client);
|
||||
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
|
||||
}
|
||||
} else {
|
||||
@@ -1440,7 +1520,6 @@ function initClient(client) {
|
||||
getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId);
|
||||
sendAccountKeyBindsToClient(client);
|
||||
}
|
||||
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
@@ -1662,7 +1741,8 @@ function setAccountEmailVerificationCode(accountData, emailVerificationCode) {
|
||||
// ===========================================================================
|
||||
|
||||
function generateEmailVerificationCode() {
|
||||
return generateRandomString(10);
|
||||
//return toUpperCase(generateRandomString(6));
|
||||
return getRandom(100000, 999999);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1742,6 +1822,13 @@ function isAccountSettingFlagEnabled(accountData, flagValue) {
|
||||
return hasBitFlag(accountData.settings, flagValue);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerAccountSettingEnabled(client, flagName) {
|
||||
return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue(flagName));
|
||||
}
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveRandomTipsDisabled(client) {
|
||||
@@ -1781,4 +1868,15 @@ function sendAccountTwoFactorAuthCode(emailAddress, name, twoFactorAuthCode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function startLoginTimeoutForPlayer(client) {
|
||||
getPlayerData(client).loginTimeout = setTimeout(function () {
|
||||
if (isPlayerLoggedIn(client) == false) {
|
||||
getPlayerData(client).customDisconnectReason = "Kicked - Login timeout";
|
||||
disconnectPlayer(client);
|
||||
}
|
||||
}, getGlobalConfig().loginTimeout);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: animation.js
|
||||
// DESC: Provides animation functions and usage
|
||||
@@ -34,8 +35,8 @@ function playPlayerAnimationCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getAnimationData(animationSlot)[3] == VRR_ANIMTYPE_SURRENDER) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_HANDSUP;
|
||||
if (getAnimationData(animationSlot)[3] == AGRP_ANIMTYPE_SURRENDER) {
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_HANDSUP;
|
||||
}
|
||||
|
||||
if (isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
@@ -83,16 +84,6 @@ function showAnimationListCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @param {number} animationSlot - The slot index of the animation
|
||||
* @return {Array} The animation's data (array)
|
||||
*/
|
||||
function getAnimationData(animationSlot, gameId = getGame()) {
|
||||
return getGameConfig().animations[gameId][animationSlot];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerInForcedAnimation(client) {
|
||||
return getPlayerData(client).animationForced;
|
||||
}
|
||||
@@ -108,8 +99,8 @@ function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
|
||||
|
||||
makePedPlayAnimation(getPlayerPed(client), animationSlot, offsetPosition);
|
||||
setEntityData(getPlayerPed(client), "agrp.anim", animationSlot, true);
|
||||
//if(getAnimationData(animationSlot)[9] != VRR_ANIMMOVE_NONE) {
|
||||
// if(getGame() < VRR_GAME_GTA_SA) {
|
||||
//if(getAnimationData(animationSlot)[9] != AGRP_ANIMMOVE_NONE) {
|
||||
// if(getGame() < AGRP_GAME_GTA_SA) {
|
||||
// setPlayerMouseCameraState(client, true);
|
||||
// }
|
||||
//}
|
||||
@@ -141,23 +132,4 @@ function makePlayerStopAnimation(client) {
|
||||
getPlayerData(client).animationForced = false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAnimationFromParams(params) {
|
||||
let animations = getGameConfig().animations[getGame()];
|
||||
if (isNaN(params)) {
|
||||
for (let i in animations) {
|
||||
if (toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (typeof getGameConfig().animations[getGame()][params] != "undefined") {
|
||||
return toInteger(params);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: anticheat.js
|
||||
// DESC: Provides anticheat functions and usage
|
||||
@@ -15,10 +16,10 @@ function initAntiCheatScript() {
|
||||
// ===========================================================================
|
||||
|
||||
function clearPlayerStateToEnterExitProperty(client) {
|
||||
if(getPlayerData(client).pedState != VRR_PEDSTATE_READY) {
|
||||
if(getPlayerData(client).pedState == VRR_PEDSTATE_ENTERINGVEHICLE) {
|
||||
if (getPlayerData(client).pedState != AGRP_PEDSTATE_READY) {
|
||||
if (getPlayerData(client).pedState == AGRP_PEDSTATE_ENTERINGVEHICLE) {
|
||||
sendPlayerClearPedState(client);
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -28,7 +29,7 @@ function clearPlayerStateToEnterExitProperty(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerExemptFromAntiCheat(client) {
|
||||
if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("ExemptFromAntiCheat"))) {
|
||||
if (hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("ExemptFromAntiCheat"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ function isPlayerExemptFromAntiCheat(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function canPlayerUsePoliceJob(client) {
|
||||
if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.policeBanned) {
|
||||
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.policeBanned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ function canPlayerUsePoliceJob(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function canClientUseFireJob(client) {
|
||||
if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.fireBanned) {
|
||||
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.fireBanned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ function canClientUseFireJob(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function canClientUseAmmunations(client) {
|
||||
if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.AmmuBanned) {
|
||||
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.AmmuBanned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ function canClientUseAmmunations(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function canClientUseGuns(client) {
|
||||
if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.GunBanned) {
|
||||
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.GunBanned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: bans.js
|
||||
// DESC: Provides ban functions and usage
|
||||
@@ -8,18 +9,18 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Ban Types
|
||||
const VRR_BANTYPE_NONE = 0;
|
||||
const VRR_BANTYPE_ACCOUNT = 1;
|
||||
const VRR_BANTYPE_SUBACCOUNT = 2;
|
||||
const VRR_BANTYPE_IPADDRESS = 3;
|
||||
const VRR_BANTYPE_SUBNET = 4;
|
||||
const AGRP_BANTYPE_NONE = 0;
|
||||
const AGRP_BANTYPE_ACCOUNT = 1;
|
||||
const AGRP_BANTYPE_SUBACCOUNT = 2;
|
||||
const AGRP_BANTYPE_IPADDRESS = 3;
|
||||
const AGRP_BANTYPE_SUBNET = 4;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class BanData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.type = VRR_BANTYPE_NONE;
|
||||
this.type = AGRP_BANTYPE_NONE;
|
||||
this.detail = "";
|
||||
this.ipAddress = "";
|
||||
this.name = "";
|
||||
@@ -174,7 +175,7 @@ function banAccount(accountId, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let safeReason = dbConnection.escapetoString(reason);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -189,7 +190,7 @@ function banSubAccount(subAccountId, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let safeReason = dbConnection.escapetoString(reason);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -204,7 +205,7 @@ function banIPAddress(ipAddress, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let safeReason = dbConnection.escapetoString(reason);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -219,7 +220,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let safeReason = dbConnection.escapetoString(reason);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -233,7 +234,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
|
||||
function unbanAccount(accountId, adminAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -247,7 +248,7 @@ function unbanAccount(accountId, adminAccountId) {
|
||||
function unbanSubAccount(subAccountId, adminAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -261,7 +262,7 @@ function unbanSubAccount(subAccountId, adminAccountId) {
|
||||
function unbanIPAddress(ipAddress, adminAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -275,7 +276,7 @@ function unbanIPAddress(ipAddress, adminAccountId) {
|
||||
function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -287,7 +288,7 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isAccountBanned(accountId) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_ACCOUNT && ban.detail === accountId);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_ACCOUNT && ban.detail === accountId);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -298,7 +299,7 @@ function isAccountBanned(accountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isSubAccountBanned(subAccountId) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -309,7 +310,7 @@ function isSubAccountBanned(subAccountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isIpAddressBanned(ipAddress) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_IPADDRESS && ban.detail === ipAddress);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_IPADDRESS && ban.detail === ipAddress);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
80
scripts/server/bank.js
Normal file
@@ -0,0 +1,80 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: bank.js
|
||||
// DESC: Provides banking functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// House Owner Types
|
||||
const AGRP_BANK_ACCT_OWNER_NONE = 0; // Not owned
|
||||
const AGRP_BANK_ACCT_OWNER_PLAYER = 1; // Owner is a player (character/subaccount)
|
||||
const AGRP_BANK_ACCT_OWNER_JOB = 2; // Owned by a job
|
||||
const AGRP_BANK_ACCT_OWNER_CLAN = 3; // Owned by a clan
|
||||
const AGRP_BANK_ACCT_OWNER_FACTION = 4; // Owned by a faction
|
||||
const AGRP_BANK_ACCT_OWNER_BIZ = 4; // Owned by a faction
|
||||
const AGRP_BANK_ACCT_OWNER_PUBLIC = 5; // Is a public bank account. Technically not owned. This probably won't be used.
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerAtBank(client) {
|
||||
if (isPositionAtATM(getPlayerPosition(client))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if (getBusinessData(client) != false) {
|
||||
if (getBusinessData(businessId).type == AGRP_BIZ_TYPE_BANK) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPositionAtATM(position) {
|
||||
let atmId = getClosestATM(position);
|
||||
|
||||
let atmData = getServerData().atmLocationCache[atmId];
|
||||
|
||||
if (getDistance(position, atmData[2]) <= getGlobalConfig().atmDistance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestATM(position) {
|
||||
let atmLocations = getServerData().atmLocationCache;
|
||||
let closest = 0;
|
||||
|
||||
for (let i in atmLocations) {
|
||||
if (getDistance(position, atmLocations[i]) < getDistance(position, atmLocations[closest])) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPositionAtATM(position) {
|
||||
let atmId = getClosestATM(position);
|
||||
|
||||
let atmData = getServerData().atmLocationCache[atmId];
|
||||
|
||||
if (getDistance(position, atmData[2]) <= getGlobalConfig().atmDistance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: bitflags.js
|
||||
// DESC: Provides bitwise operations, functions and usage
|
||||
@@ -64,6 +65,7 @@ let serverBitFlagKeys = {
|
||||
"DontSyncClientElements",
|
||||
"IsTester"
|
||||
],
|
||||
/*
|
||||
factionFlagKeys: [
|
||||
"None",
|
||||
"Police",
|
||||
@@ -72,6 +74,7 @@ let serverBitFlagKeys = {
|
||||
"Government",
|
||||
"Generic",
|
||||
],
|
||||
*/
|
||||
clanTypeFlagKeys: [
|
||||
"None",
|
||||
"Illegal",
|
||||
@@ -101,6 +104,24 @@ let serverBitFlagKeys = {
|
||||
"ManageRanks",
|
||||
"Owner",
|
||||
],
|
||||
clanDiscordWebhookFlagKeys: [
|
||||
"None",
|
||||
"ClanName",
|
||||
"ClanMOTD",
|
||||
"ClanTag",
|
||||
"ClanRankEdit",
|
||||
"ClanRankSet",
|
||||
"ClanVehicleEdit",
|
||||
"ClanHouseEdit",
|
||||
"ClanBusinessEdit",
|
||||
"ClanNPCEdit",
|
||||
"ClanMemberInvite",
|
||||
"ClanMemberRemove",
|
||||
"ClanMemberSuspend",
|
||||
"ClanRankFlagSet",
|
||||
"ClanTurfWar",
|
||||
"ClanPointWar",
|
||||
],
|
||||
accountSettingsFlagKeys: [
|
||||
"None",
|
||||
"UseWhiteList",
|
||||
@@ -117,6 +138,12 @@ let serverBitFlagKeys = {
|
||||
"NoKeyBinds",
|
||||
"NoRandomTips",
|
||||
"NoActionTips",
|
||||
"ChatBoxTimestamps",
|
||||
"ProfanityFilter",
|
||||
"ChatAutoHide",
|
||||
"NoPlayerContent",
|
||||
"ChatEmoji",
|
||||
//"NoBlood",
|
||||
],
|
||||
|
||||
// Not going to be used. Use trigger, condition, and response stuff in trigger.js
|
||||
@@ -220,22 +247,38 @@ let serverBitFlagKeys = {
|
||||
"ShowItemsAfterPurchase",
|
||||
"BuyCommandAfterEnterBusiness",
|
||||
],
|
||||
jobRankKeys: [
|
||||
"None",
|
||||
"PublicAccess",
|
||||
"WhiteList",
|
||||
"BlackList",
|
||||
"SetRank",
|
||||
"SetPay",
|
||||
"ManageUniforms",
|
||||
"ManageEquipment",
|
||||
"ManageVehicles",
|
||||
"ManageBusinesses",
|
||||
"Leader",
|
||||
],
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initBitFlagScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.BitFlag]: Initializing bit flag script ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.BitFlag]: Initializing bit flag script ...");
|
||||
serverBitFlags.staffFlags = createBitFlagTable(serverBitFlagKeys.staffFlagKeys);
|
||||
serverBitFlags.moderationFlags = createBitFlagTable(serverBitFlagKeys.moderationFlagKeys);
|
||||
serverBitFlags.accountSettingsFlags = createBitFlagTable(serverBitFlagKeys.accountSettingsFlagKeys);
|
||||
//serverBitFlags.subAccountSettingsFlags = createBitFlagTable(getServerData().subAccountSettingsFlagKeys);
|
||||
serverBitFlags.clanFlags = createBitFlagTable(serverBitFlagKeys.clanFlagKeys);
|
||||
serverBitFlags.clanTypeFlagKeys = createBitFlagTable(serverBitFlagKeys.clanTypeFlagKeys);
|
||||
serverBitFlags.factionFlags = createBitFlagTable(serverBitFlagKeys.factionFlagKeys);
|
||||
serverBitFlags.clanTypeFlags = createBitFlagTable(serverBitFlagKeys.clanTypeFlagKeys);
|
||||
serverBitFlags.clanDiscordWebhookFlags = createBitFlagTable(serverBitFlagKeys.clanDiscordWebhookFlagKeys);
|
||||
//serverBitFlags.factionFlags = createBitFlagTable(serverBitFlagKeys.factionFlagKeys);
|
||||
serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys);
|
||||
serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys);
|
||||
serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys);
|
||||
serverBitFlags.seenHelpTips = createBitFlagTable(serverBitFlagKeys.seenHelpTipsKeys);
|
||||
serverBitFlags.jobRankFlags = createBitFlagTable(serverBitFlagKeys.jobRankKeys);
|
||||
logToConsole(LOG_INFO, "[VRR.BitFlag]: Bit flag script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
@@ -243,25 +286,25 @@ function initBitFlagScript() {
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveStaffPermission(client, requiredFlags) {
|
||||
if(isConsole(client)) {
|
||||
if (isConsole(client)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(requiredFlags == getStaffFlagValue("None")) {
|
||||
if (requiredFlags == getStaffFlagValue("None")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let staffFlags = 0;
|
||||
if(getPlayerData(client)) {
|
||||
if (getPlayerData(client)) {
|
||||
staffFlags = getPlayerData(client).accountData.flags.admin;
|
||||
}
|
||||
|
||||
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
|
||||
if(staffFlags == getStaffFlagValue("All")) {
|
||||
if (staffFlags == getStaffFlagValue("All")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(hasBitFlag(staffFlags, requiredFlags)) {
|
||||
if (hasBitFlag(staffFlags, requiredFlags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -271,27 +314,57 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveClanPermission(client, requiredFlags) {
|
||||
if(isConsole(client)) {
|
||||
if (isConsole(client)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(requiredFlags == getClanFlagValue("None")) {
|
||||
if (requiredFlags == getClanFlagValue("None")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let clanFlags = 0;
|
||||
clanFlags = getPlayerCurrentSubAccount(client).clanFlags | getClanRankFlags(getPlayerCurrentSubAccount(client).clanRank);
|
||||
clanFlags = getPlayerCurrentSubAccount(client).clanFlags | getClanRankData(getPlayerClan(client), getPlayerClanRank(client)).flags;
|
||||
|
||||
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
|
||||
if(clanFlags == getClanFlagValue("All")) {
|
||||
if (clanFlags == getClanFlagValue("All")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(hasBitFlag(clanFlags, requiredFlags)) {
|
||||
if (hasBitFlag(clanFlags, requiredFlags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveJobPermission(client, requiredFlags) {
|
||||
if (isConsole(client)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (requiredFlags == getClanFlagValue("None")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let jobFlags = 0;
|
||||
jobFlags = getPlayerCurrentSubAccount(client).jobFlags | getJobRankData(getPlayerJob(client), getPlayerJobRank(client)).flags;
|
||||
|
||||
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
|
||||
if (jobFlags == getJobFlagValue("All")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasBitFlag(jobFlags, requiredFlags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -301,11 +374,11 @@ function doesPlayerHaveClanPermission(client, requiredFlags) {
|
||||
// ===========================================================================
|
||||
|
||||
function getStaffFlagValue(flagName) {
|
||||
if(flagName == "All") {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(typeof serverBitFlags.staffFlags[flagName] == "undefined") {
|
||||
if (typeof serverBitFlags.staffFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -315,11 +388,11 @@ function getStaffFlagValue(flagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function getClanFlagValue(flagName) {
|
||||
if(flagName == "All") {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(typeof getServerBitFlags().clanFlags[flagName] == "undefined") {
|
||||
if (typeof getServerBitFlags().clanFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -329,11 +402,11 @@ function getClanFlagValue(flagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function getAccountSettingsFlagValue(flagName) {
|
||||
if(flagName == "All") {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(typeof serverBitFlags.accountSettingsFlags[flagName] == "undefined") {
|
||||
if (typeof serverBitFlags.accountSettingsFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -343,11 +416,11 @@ function getAccountSettingsFlagValue(flagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function getModerationFlagValue(flagName) {
|
||||
if(flagName == "All") {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(typeof serverBitFlags.moderationFlags[flagName] == "undefined") {
|
||||
if (typeof serverBitFlags.moderationFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -356,8 +429,22 @@ function getModerationFlagValue(flagName) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClanDiscordWebhookValue(flagName) {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (typeof serverBitFlags.clanDiscordWebhookFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return serverBitFlags.clanDiscordWebhookFlags[flagName];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function givePlayerStaffFlag(client, flagName) {
|
||||
if(!getStaffFlagValue(flagName)) {
|
||||
if (!getStaffFlagValue(flagName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -369,7 +456,7 @@ function givePlayerStaffFlag(client, flagName) {
|
||||
|
||||
function takePlayerStaffFlag(client, flagName) {
|
||||
let flagValue = getStaffFlagValue(flagName);
|
||||
if(!flagValue) {
|
||||
if (!flagValue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -380,7 +467,7 @@ function takePlayerStaffFlag(client, flagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function takePlayerStaffFlag(client, flagName) {
|
||||
if(!getStaffFlagValue(flagName)) {
|
||||
if (!getStaffFlagValue(flagName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: business.js
|
||||
// DESC: Provides business functions and usage
|
||||
@@ -8,41 +9,48 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Business Types
|
||||
const VRR_BIZ_TYPE_NONE = 0; // None (invalid)
|
||||
const VRR_BIZ_TYPE_NORMAL = 1; // Normal business (sells items)
|
||||
const VRR_BIZ_TYPE_BANK = 2; // Bank
|
||||
const VRR_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc)
|
||||
const AGRP_BIZ_TYPE_NONE = 0; // None (invalid)
|
||||
const AGRP_BIZ_TYPE_NORMAL = 1; // Normal business (sells items)
|
||||
const AGRP_BIZ_TYPE_BANK = 2; // Bank
|
||||
const AGRP_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc)
|
||||
const AGRP_BIZ_TYPE_PAINTBALL = 4; // Paintball arena. Player joins paintball/airsoft when they enter
|
||||
const AGRP_BIZ_TYPE_DEALERSHIP = 5; // Vehicle Dealership (also for airplane, boat, etc)
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Business Location Types
|
||||
const VRR_BIZLOC_NONE = 0; // None
|
||||
const VRR_BIZLOC_GATE = 1; // Center of any moveable gate that belongs to the biz
|
||||
const VRR_BIZLOC_GARAGE = 2; // Location for attached garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
|
||||
const VRR_BIZLOC_FUEL = 3; // Fuel pump
|
||||
const VRR_BIZLOC_DRIVETHRU = 4; // Drivethrough
|
||||
const VRR_BIZLOC_VENDMACHINE = 5; // Vending machine
|
||||
const AGRP_BIZ_LOC_NONE = 0; // None
|
||||
const AGRP_BIZ_LOC_GATE = 1; // Center of any moveable gate that belongs to the biz
|
||||
const AGRP_BIZ_LOC_GARAGE = 2; // Location for attached garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
|
||||
const AGRP_BIZ_LOC_FUEL = 3; // Fuel pump
|
||||
const AGRP_BIZ_LOC_DRIVETHRU = 4; // Drivethrough
|
||||
const AGRP_BIZ_LOC_VENDMACHINE = 5; // Vending machine
|
||||
const AGRP_BIZ_LOC_ATM = 6; // ATM
|
||||
const AGRP_BIZ_LOC_PAYPHONE = 7; // Payphone
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Business Owner Types
|
||||
const VRR_BIZOWNER_NONE = 0; // Not owned
|
||||
const VRR_BIZOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
|
||||
const VRR_BIZOWNER_JOB = 2; // Owned by a job
|
||||
const VRR_BIZOWNER_CLAN = 3; // Owned by a clan
|
||||
const VRR_BIZOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
|
||||
const VRR_BIZOWNER_PUBLIC = 5; // Public Business. Used for goverment/official places like police, fire, city hall, DMV, etc
|
||||
const AGRP_BIZ_OWNER_NONE = 0; // Not owned
|
||||
const AGRP_BIZ_OWNER_PLAYER = 1; // Owned by a player (character/subaccount)
|
||||
const AGRP_BIZ_OWNER_JOB = 2; // Owned by a job
|
||||
const AGRP_BIZ_OWNER_CLAN = 3; // Owned by a clan
|
||||
const AGRP_BIZ_OWNER_FACTION = 4; // Owned by a faction (not used at the moment)
|
||||
const AGRP_BIZ_OWNER_PUBLIC = 5; // Public Business. Used for goverment/official places like police, fire, city hall, DMV, etc
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing a businesses' data. Loaded and saved in the database
|
||||
* @property {Array.<BusinessLocationData>} locations
|
||||
* @property {Array.<Number>} floorItemCache
|
||||
* @property {Array.<Number>} storageItemCache
|
||||
*/
|
||||
class BusinessData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.name = "";
|
||||
this.ownerType = VRR_BIZOWNER_NONE;
|
||||
this.ownerType = AGRP_BIZ_OWNER_NONE;
|
||||
this.ownerId = 0;
|
||||
this.buyPrice = 0;
|
||||
this.locked = false;
|
||||
@@ -50,11 +58,12 @@ class BusinessData {
|
||||
this.index = -1;
|
||||
this.needsSaved = false;
|
||||
this.interiorLights = true;
|
||||
this.type = AGRP_BIZ_TYPE_NONE;
|
||||
|
||||
this.floorItemCache = [];
|
||||
this.storageItemCache = [];
|
||||
this.locations = [];
|
||||
this.gameScripts = [];
|
||||
//this.gameScripts = [];
|
||||
|
||||
this.entrancePosition = false;
|
||||
this.entranceRotation = 0.0;
|
||||
@@ -77,9 +86,10 @@ class BusinessData {
|
||||
this.entranceFee = 0;
|
||||
this.till = 0;
|
||||
|
||||
this.streamingRadioStation = -1;
|
||||
this.streamingRadioStation = 0;
|
||||
//this.streamingRadioStationIndex = -1;
|
||||
|
||||
this.labelHelpType = VRR_PROPLABEL_INFO_NONE;
|
||||
this.labelHelpType = AGRP_PROPLABEL_INFO_NONE;
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc["biz_id"]);
|
||||
@@ -90,6 +100,7 @@ class BusinessData {
|
||||
this.locked = intToBool(toInteger(dbAssoc["biz_locked"]));
|
||||
this.hasInterior = intToBool(toInteger(dbAssoc["biz_has_interior"]));
|
||||
this.interiorLights = intToBool(toInteger(dbAssoc["biz_interior_lights"]));
|
||||
this.type = toInteger(dbAssoc["biz_type"]);
|
||||
|
||||
this.entrancePosition = toVector3(toFloat(dbAssoc["biz_entrance_pos_x"]), toFloat(dbAssoc["biz_entrance_pos_y"]), toFloat(dbAssoc["biz_entrance_pos_z"]));
|
||||
this.entranceRotation = toInteger(dbAssoc["biz_entrance_rot_z"]);
|
||||
@@ -109,7 +120,7 @@ class BusinessData {
|
||||
this.till = toInteger(dbAssoc["biz_till"]);
|
||||
|
||||
this.labelHelpType = toInteger(dbAssoc["biz_label_help_type"]);
|
||||
this.streamingRadioStation = toInteger(dbAssoc["biz_radiostation"]);
|
||||
this.streamingRadioStation = toInteger(dbAssoc["biz_radio_station"]);
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -210,7 +221,7 @@ function loadBusinessesFromDatabase() {
|
||||
if (dbQuery.numRows > 0) {
|
||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
let tempBusinessData = new BusinessData(dbAssoc);
|
||||
//tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
|
||||
tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
|
||||
//tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId);
|
||||
tempBusinesses.push(tempBusinessData);
|
||||
logToConsole(LOG_VERBOSE, `[VRR.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`);
|
||||
@@ -397,8 +408,8 @@ function deleteBusinessCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} deleted business {businessBlue}${getBusinessData(businessId).name}`);
|
||||
deleteBusiness(businessId, getPlayerData(client).accountData.databaseId);
|
||||
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} deleted business {businessBlue}${getBusinessData(businessId).name}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -486,7 +497,7 @@ function setBusinessOwnerCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_PLAYER;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_PLAYER;
|
||||
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(newBusinessOwner).databaseId;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
|
||||
@@ -528,7 +539,7 @@ function setBusinessJobCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_JOB;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_JOB;
|
||||
getBusinessData(businessId).ownerId = getJobData(jobId).databaseId;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
|
||||
@@ -561,7 +572,7 @@ function setBusinessClanCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getBusinessData(business).ownerType != VRR_VEHOWNER_PLAYER) {
|
||||
if (getBusinessData(business).ownerType != AGRP_VEHOWNER_PLAYER) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
|
||||
return false;
|
||||
}
|
||||
@@ -572,9 +583,9 @@ function setBusinessClanCommand(command, params, client) {
|
||||
}
|
||||
|
||||
showPlayerPrompt(client, getLocaleString(client, "SetBusinessClanConfirmMessage"), getLocaleString(client, "SetBusinessClanConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
getPlayerData(client).promptType = VRR_PROMPT_BIZGIVETOCLAN;
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_BIZGIVETOCLAN;
|
||||
|
||||
//getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
|
||||
//getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_CLAN;
|
||||
//getBusinessData(businessId).ownerId = getClanData(clanId).databaseId;
|
||||
//getBusinessData(businessId).needsSaved = true;
|
||||
}
|
||||
@@ -605,16 +616,16 @@ function setBusinessRankCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) {
|
||||
let clanId = getClanIdFromDatabaseId(getBusinessData(businessId).ownerId);
|
||||
if (getVehicleData(vehicle).ownerType == AGRP_VEHOWNER_CLAN) {
|
||||
let clanId = getClanIndexFromDatabaseId(getBusinessData(businessId).ownerId);
|
||||
rankId = getClanRankFromParams(clanId, params);
|
||||
if (!getClanRankData(clanId, rankId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "ClanRankInvalid"));
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidClanRank"));
|
||||
return false;
|
||||
}
|
||||
getBusinessData(businessId).rank = getClanRankData(clanId, rankId).databaseId;
|
||||
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${getClanRankData(clanId, rankId).name} {MAINCOLOUR}of the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`);
|
||||
} else if (getBusinessData(businessId).ownerType == VRR_VEHOWNER_JOB) {
|
||||
} else if (getBusinessData(businessId).ownerType == AGRP_VEHOWNER_JOB) {
|
||||
getBusinessData(businessId).rank = rankId;
|
||||
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${rankId} {MAINCOLOUR}of the {jobYellow}${getJobData(getJobIdFromDatabaseId(getBusinessData(businessId).ownerId)).name} {MAINCOLOUR}job!`);
|
||||
}
|
||||
@@ -656,7 +667,7 @@ function setBusinessRankCommand(command, params, client) {
|
||||
let clanRankId = getClanRankFromParams(clanId, params);
|
||||
|
||||
if (!getClanRankData(clanId, clanRankId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "ClanRankInvalid"));
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidClanRank"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -711,7 +722,7 @@ function setBusinessJobCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_JOB;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_JOB;
|
||||
getBusinessData(businessId).ownerId = getJobData(jobId).databaseId;
|
||||
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
@@ -741,7 +752,7 @@ function setBusinessPublicCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_PUBLIC;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_PUBLIC;
|
||||
getBusinessData(businessId).ownerId = 0;
|
||||
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
@@ -771,7 +782,7 @@ function removeBusinessOwnerCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_NONE;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_NONE;
|
||||
getBusinessData(businessId).ownerId = -1;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
|
||||
@@ -836,7 +847,36 @@ function setBusinessEntranceFeeCommand(command, params, client) {
|
||||
|
||||
getBusinessData(businessId).entranceFee = entranceFee;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}entrance fee to [#AAAAAAA]$${entranceFee}`);
|
||||
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} entrance fee to [#AAAAAAA]$${entranceFee}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* This is a command handler function.
|
||||
*
|
||||
* @param {string} command - The command name used by the player
|
||||
* @param {string} params - The parameters/args string used with the command by the player
|
||||
* @param {Client} client - The client/player that used the command
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function setBusinessPaintBallCommand(command, params, client) {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
|
||||
if (!getBusinessData(businessId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!canPlayerManageBusiness(client, businessId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantModifyBusiness"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).type = AGRP_BIZ_TYPE_PAINTBALL;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "BusinessIsNowPaintBall"));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -866,24 +906,24 @@ function getBusinessInfoCommand(command, params, client) {
|
||||
|
||||
let ownerName = "Unknown";
|
||||
switch (businessData.ownerType) {
|
||||
case VRR_BIZOWNER_CLAN:
|
||||
case AGRP_BIZ_OWNER_CLAN:
|
||||
ownerName = getClanData(businessData.ownerId).name;
|
||||
break;
|
||||
|
||||
case VRR_BIZOWNER_JOB:
|
||||
case AGRP_BIZ_OWNER_JOB:
|
||||
ownerName = getJobData(businessData.ownerId).name;
|
||||
break;
|
||||
|
||||
case VRR_BIZOWNER_PLAYER:
|
||||
case AGRP_BIZ_OWNER_PLAYER:
|
||||
let subAccountData = loadSubAccountFromId(businessData.ownerId);
|
||||
ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`;
|
||||
break;
|
||||
|
||||
case VRR_BIZOWNER_PUBLIC:
|
||||
case AGRP_BIZ_OWNER_PUBLIC:
|
||||
ownerName = "Public";
|
||||
break;
|
||||
|
||||
case VRR_BIZOWNER_NONE:
|
||||
case AGRP_BIZ_OWNER_NONE:
|
||||
//submitBugReport(client, `[AUTOMATED REPORT] getBusinessInfoCommand() - Invalid ownerType for business ${businessId}/${getBusinessData(businessId).databaseId}`);
|
||||
ownerName = "None";
|
||||
break;
|
||||
@@ -1236,7 +1276,7 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
|
||||
let itemTypeId = getItemTypeFromParams(getGameConfig().defaultBusinessItems[getGame()][typeParam][i][0]);
|
||||
let itemTypeData = getItemTypeData(itemTypeId);
|
||||
if (itemTypeData) {
|
||||
let newItemIndex = createItem(itemTypeId, itemTypeData.orderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(businessId).databaseId, getGameConfig().defaultBusinessItems[getGame()][typeParam][i][1]);
|
||||
let newItemIndex = createItem(itemTypeId, itemTypeData.orderValue, AGRP_ITEM_OWNER_BIZFLOOR, getBusinessData(businessId).databaseId, getGameConfig().defaultBusinessItems[getGame()][typeParam][i][1]);
|
||||
getItemData(newItemIndex).buyPrice = applyServerInflationMultiplier(itemTypeData.orderPrice) * getGameConfig().defaultBusinessItems[getGame()][typeParam][i][2];
|
||||
}
|
||||
}
|
||||
@@ -1257,7 +1297,7 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function setBusinessEntranceLabelToDealershipCommand(command, params, client) {
|
||||
function setBusinessDealershipCommand(command, params, client) {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
|
||||
if (!getBusinessData(businessId)) {
|
||||
@@ -1265,7 +1305,8 @@ function setBusinessEntranceLabelToDealershipCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).labelHelpType == VRR_PROPLABEL_INFO_ENTERVEHICLE;
|
||||
getBusinessData(businessId).labelHelpType == AGRP_PROPLABEL_INFO_ENTERVEHICLE;
|
||||
getBusinessData(businessId).type = AGRP_BIZ_TYPE_DEALERSHIP;
|
||||
updateBusinessPickupLabelData(businessId);
|
||||
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the business type of {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to dealership`);
|
||||
}
|
||||
@@ -1507,7 +1548,7 @@ function orderItemForBusinessCommand(command, params, client) {
|
||||
|
||||
let orderTotalCost = pricePerItem * amount;
|
||||
|
||||
//getPlayerData(client).promptType = VRR_PROMPT_BIZORDER;
|
||||
//getPlayerData(client).promptType = AGRP_PROMPT_BIZORDER;
|
||||
getPlayerData(client).businessOrderAmount = amount;
|
||||
getPlayerData(client).businessOrderBusiness = businessId;
|
||||
getPlayerData(client).businessOrderItem = itemType;
|
||||
@@ -1516,7 +1557,7 @@ function orderItemForBusinessCommand(command, params, client) {
|
||||
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
showPlayerPrompt(client, `Ordering ${amount} ${getPluralForm(getItemTypeData(itemType).name)} (${getItemValueDisplay(itemType, value)}) at $${makeLargeNumberReadable(pricePerItem)} each will cost a total of $${makeLargeNumberReadable(orderTotalCost)}`, "Business Order Cost");
|
||||
getPlayerData(client).promptType = VRR_PROMPT_BIZORDER;
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_BIZORDER;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1603,7 +1644,7 @@ function buyBusinessCommand(command, params, client) {
|
||||
}
|
||||
|
||||
showPlayerPrompt(client, getLocaleString(client, "BuyBusinessConfirmMessage"), getLocaleString(client, "BuyBusinessConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
getPlayerData(client).promptType = VRR_PROMPT_BIZBUY;
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_BIZBUY;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1687,7 +1728,11 @@ function moveBusinessExitCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getBusinessDataFromDatabaseId(databaseId) {
|
||||
let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId)
|
||||
if (databaseId <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == databaseId)
|
||||
if (matchingBusinesses.length == 1) {
|
||||
return matchingBusinesses[0];
|
||||
}
|
||||
@@ -1850,7 +1895,7 @@ function saveBusinessToDatabase(businessId) {
|
||||
["biz_entrance_vw", tempBusinessData.entranceDimension],
|
||||
["biz_entrance_pickup", tempBusinessData.entrancePickupModel],
|
||||
["biz_entrance_blip", tempBusinessData.entranceBlipModel],
|
||||
["biz_entrance_cutscene", tempBusinessData.entranceCutscene],
|
||||
//["biz_entrance_cutscene", tempBusinessData.entranceCutscene],
|
||||
["biz_exit_pos_x", tempBusinessData.exitPosition.x],
|
||||
["biz_exit_pos_y", tempBusinessData.exitPosition.y],
|
||||
["biz_exit_pos_z", tempBusinessData.exitPosition.z],
|
||||
@@ -1859,14 +1904,14 @@ function saveBusinessToDatabase(businessId) {
|
||||
["biz_exit_vw", tempBusinessData.exitDimension],
|
||||
["biz_exit_pickup", tempBusinessData.exitPickupModel],
|
||||
["biz_exit_blip", tempBusinessData.exitBlipModel],
|
||||
["biz_exit_cutscene", tempBusinessData.exitCutscene],
|
||||
//["biz_exit_cutscene", tempBusinessData.exitCutscene],
|
||||
["biz_has_interior", boolToInt(tempBusinessData.hasInterior)],
|
||||
["biz_interior_lights", boolToInt(tempBusinessData.interiorLights)],
|
||||
["biz_label_help_type", tempBusinessData.labelHelpType],
|
||||
["biz_radiostation", tempBusinessData.streamingRadioStation],
|
||||
["biz_radio_station", toInteger(tempBusinessData.streamingRadioStation)],
|
||||
["biz_custom_interior", boolToInt(tempBusinessData.customInterior)],
|
||||
["biz_buy_price", boolToInt(tempBusinessData.buyPrice)],
|
||||
//["biz_rent_price", boolToInt(tempBusinessData.rentPrice)],
|
||||
["biz_buy_price", tempBusinessData.buyPrice],
|
||||
//["biz_rent_price", tempBusinessData.rentPrice],
|
||||
];
|
||||
|
||||
let dbQuery = null;
|
||||
@@ -1903,7 +1948,7 @@ function createAllBusinessPickups() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("pickups")) {
|
||||
if (!isGameFeatureSupported("pickup")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1929,7 +1974,7 @@ function createAllBusinessBlips() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("blips")) {
|
||||
if (!isGameFeatureSupported("blip")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1957,7 +2002,7 @@ function createBusinessEntrancePickup(businessId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("pickups")) {
|
||||
if (!isGameFeatureSupported("pickup")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2029,7 +2074,7 @@ function createBusinessEntranceBlip(businessId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("blips")) {
|
||||
if (!isGameFeatureSupported("blip")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2091,7 +2136,7 @@ function createBusinessExitPickup(businessId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("pickups")) {
|
||||
if (!isGameFeatureSupported("pickup")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2152,7 +2197,7 @@ function createBusinessExitBlip(businessId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("blips")) {
|
||||
if (!isGameFeatureSupported("blip")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2204,7 +2249,7 @@ function createBusinessExitBlip(businessId) {
|
||||
*
|
||||
*/
|
||||
function deleteBusiness(businessId, whoDeleted = 0) {
|
||||
let tempBusinessData = getServerData().businesses[businessId];
|
||||
let tempBusinessData = getBusinessData(businessId);
|
||||
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
@@ -2213,7 +2258,7 @@ function deleteBusiness(businessId, whoDeleted = 0) {
|
||||
deleteBusinessPickups(businessId);
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `UPDATE biz_main WHERE biz_deleted = 1, biz_when_deleted = UNIX_TIMESTAMP(), biz_who_deleted = ${whoDeleted} WHERE biz_id ${tempBusinessData.databaseId}`);
|
||||
dbQuery = queryDatabase(dbConnection, `UPDATE biz_main SET biz_deleted = 1, biz_when_deleted = UNIX_TIMESTAMP(), biz_who_deleted = ${whoDeleted} WHERE biz_id = ${tempBusinessData.databaseId}`);
|
||||
if (dbQuery) {
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
@@ -2299,17 +2344,17 @@ function exitBusiness(client) {
|
||||
*/
|
||||
function getBusinessOwnerTypeText(ownerType) {
|
||||
switch (ownerType) {
|
||||
case VRR_BIZOWNER_CLAN:
|
||||
case AGRP_BIZ_OWNER_CLAN:
|
||||
return "clan";
|
||||
|
||||
case VRR_BIZOWNER_JOB:
|
||||
case AGRP_BIZ_OWNER_JOB:
|
||||
return "job";
|
||||
|
||||
case VRR_BIZOWNER_PLAYER:
|
||||
case AGRP_BIZ_OWNER_PLAYER:
|
||||
return "player";
|
||||
|
||||
case VRR_BIZOWNER_NONE:
|
||||
case VRR_BIZOWNER_PUBLIC:
|
||||
case AGRP_BIZ_OWNER_NONE:
|
||||
case AGRP_BIZ_OWNER_PUBLIC:
|
||||
return "not owned";
|
||||
|
||||
default:
|
||||
@@ -2324,6 +2369,10 @@ function getBusinessOwnerTypeText(ownerType) {
|
||||
* @return {BusinessData} The business's data (class instance)
|
||||
*/
|
||||
function getBusinessData(businessId) {
|
||||
if (businessId == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof getServerData().businesses[businessId] != null) {
|
||||
return getServerData().businesses[businessId];
|
||||
}
|
||||
@@ -2353,7 +2402,7 @@ function deleteBusinessEntrancePickup(businessId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("pickups")) {
|
||||
if (!isGameFeatureSupported("pickup")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2380,7 +2429,7 @@ function deleteBusinessExitPickup(businessId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("pickups")) {
|
||||
if (!isGameFeatureSupported("pickup")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2403,7 +2452,7 @@ function deleteBusinessEntranceBlip(businessId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("blips")) {
|
||||
if (!isGameFeatureSupported("blip")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2482,6 +2531,19 @@ function reloadAllBusinessesCommand(command, params, client) {
|
||||
function setBusinessDataIndexes() {
|
||||
for (let i in getServerData().businesses) {
|
||||
getServerData().businesses[i].index = i;
|
||||
|
||||
//if (getServerData().businesses[i].streamingRadioStation > 0) {
|
||||
// let radioStationIndex = getRadioStationFromDatabaseId(getServerData().businesses[i].streamingRadioStation);
|
||||
// if (radioStationIndex != -1) {
|
||||
// getServerData().businesses[i].streamingRadioStationIndex = radioStationIndex;
|
||||
// }
|
||||
//}
|
||||
|
||||
for (let j in getServerData().businesses[i].locations) {
|
||||
if (getServerData().businesses[i].locations[j].type == AGRP_BIZ_LOC_ATM) {
|
||||
getServerData().atmLocationCache.push([i, j, getServerData().businesses[i].locations[j].position]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2494,7 +2556,7 @@ function addToBusinessInventory(businessId, itemType, amount, buyPrice) {
|
||||
tempItemData.buyPrice = buyPrice;
|
||||
tempItemData.itemType = getItemTypeData(itemType).databaseId;
|
||||
tempItemData.ownerId = getBusinessData(business).databaseId;
|
||||
tempItemData.ownerType = VRR_ITEMOWNER_BIZ;
|
||||
tempItemData.ownerType = AGRP_ITEMOWNER_BIZ;
|
||||
tempItemData.ownerIndex = businessId;
|
||||
tempItemData.itemTypeIndex = itemType;
|
||||
saveItemToDatabase(tempItemData);
|
||||
@@ -2586,7 +2648,7 @@ function buyFromBusinessCommand(command, params, client) {
|
||||
}
|
||||
|
||||
takePlayerCash(client, totalCost);
|
||||
createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount);
|
||||
createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).value, AGRP_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount);
|
||||
cachePlayerHotBarItems(client);
|
||||
getBusinessData(businessId).till = getBusinessData(businessId).till + totalCost;
|
||||
|
||||
@@ -2596,7 +2658,7 @@ function buyFromBusinessCommand(command, params, client) {
|
||||
}
|
||||
|
||||
let useType = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).useType;
|
||||
if (useType == VRR_ITEM_USETYPE_WEAPON || VRR_ITEM_USETYPE_TAZER || useType == VRR_ITEM_USETYPE_AMMO_CLIP) {
|
||||
if (useType == AGRP_ITEM_USE_TYPE_WEAPON || AGRP_ITEM_USE_TYPE_TAZER || useType == AGRP_ITEM_USE_TYPE_AMMO_CLIP) {
|
||||
if (isPlayerWeaponBanned(client) && !isPlayerExemptFromAntiCheat(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "WeaponBanned"));
|
||||
return false;
|
||||
@@ -2695,7 +2757,7 @@ function storeItemInBusinessStorageCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).ownerType = VRR_ITEM_OWNER_BIZSTORAGE;
|
||||
getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).ownerType = AGRP_ITEM_OWNER_BIZSTORAGE;
|
||||
getBusinessData(businessId).storageItemCache[firstSlot] = getBusinessData(businessId).floorItemCache[itemSlot - 1];
|
||||
getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1;
|
||||
messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} to the business storage in slot ${firstSlot}`);
|
||||
@@ -2739,7 +2801,7 @@ function stockItemOnBusinessFloorCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getItemData(getBusinessData(businessId).storageItemCache[itemSlot - 1]).ownerType = VRR_ITEM_OWNER_BIZFLOOR;
|
||||
getItemData(getBusinessData(businessId).storageItemCache[itemSlot - 1]).ownerType = AGRP_ITEM_OWNER_BIZFLOOR;
|
||||
getBusinessData(businessId).floorItemCache[firstSlot] = getBusinessData(businessId).storageItemCache[itemSlot - 1];
|
||||
getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1;
|
||||
messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} of the business storage to the business floor slot ${firstSlot}`);
|
||||
@@ -2779,14 +2841,14 @@ function cacheBusinessItems(businessId) {
|
||||
|
||||
//let businessData = getBusinessData(businessId);
|
||||
//logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${businessData.name}) ...`);
|
||||
//getBusinessData(businessId).floorItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZFLOOR && item.ownerId == businessData.databaseId).map(i => i.index);
|
||||
//getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId);
|
||||
//getBusinessData(businessId).floorItemCache = getServerData().items.filter(item => item.ownerType == AGRP_ITEM_OWNER_BIZFLOOR && item.ownerId == businessData.databaseId).map(i => i.index);
|
||||
//getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == AGRP_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId);
|
||||
|
||||
logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${getBusinessData(businessId).name}) ...`);
|
||||
for (let i in getServerData().items) {
|
||||
if (getItemData(i).ownerType == VRR_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) {
|
||||
if (getItemData(i).ownerType == AGRP_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) {
|
||||
getBusinessData(businessId).floorItemCache.push(i);
|
||||
} else if (getItemData(i).ownerType == VRR_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) {
|
||||
} else if (getItemData(i).ownerType == AGRP_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) {
|
||||
getBusinessData(businessId).storageItemCache.push(i);
|
||||
}
|
||||
}
|
||||
@@ -2810,41 +2872,41 @@ function updateBusinessPickupLabelData(businessId) {
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).exitPickup != null) {
|
||||
setEntityData(getBusinessData(businessId).exitPickup, "agrp.owner.type", VRR_PICKUP_BUSINESS_EXIT, false);
|
||||
setEntityData(getBusinessData(businessId).exitPickup, "agrp.owner.type", AGRP_PICKUP_BUSINESS_EXIT, false);
|
||||
setEntityData(getBusinessData(businessId).exitPickup, "agrp.owner.id", businessId, false);
|
||||
setEntityData(getBusinessData(businessId).exitPickup, "agrp.label.type", VRR_LABEL_EXIT, true);
|
||||
setEntityData(getBusinessData(businessId).exitPickup, "agrp.label.type", AGRP_LABEL_EXIT, true);
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).entrancePickup != null) {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.owner.type", VRR_PICKUP_BUSINESS_ENTRANCE, false);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.owner.type", AGRP_PICKUP_BUSINESS_ENTRANCE, false);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.owner.id", businessId, false);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.type", VRR_LABEL_BUSINESS, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.type", AGRP_LABEL_BUSINESS, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.name", getBusinessData(businessId).name, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.locked", getBusinessData(businessId).locked, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", VRR_PROPLABEL_INFO_NONE, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_NONE, true);
|
||||
|
||||
switch (getBusinessData(businessId).labelHelpType) {
|
||||
case VRR_PROPLABEL_INFO_ENTERVEHICLE: {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", VRR_PROPLABEL_INFO_ENTERVEHICLE, true);
|
||||
case AGRP_PROPLABEL_INFO_ENTERVEHICLE: {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_ENTERVEHICLE, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROPLABEL_INFO_ENTER: {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", VRR_PROPLABEL_INFO_ENTER, true);
|
||||
case AGRP_PROPLABEL_INFO_ENTER: {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_ENTER, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROPLABEL_INFO_REPAIR: {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", VRR_PROPLABEL_INFO_REPAIR, true);
|
||||
case AGRP_PROPLABEL_INFO_REPAIR: {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_REPAIR, true);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
if (getBusinessData(businessId).hasInterior) {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", VRR_PROPLABEL_INFO_ENTER, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_ENTER, true);
|
||||
} else {
|
||||
if (doesBusinessHaveAnyItemsToBuy(businessId)) {
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", VRR_PROPLABEL_INFO_BUY, true);
|
||||
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_BUY, true);
|
||||
} else {
|
||||
removeEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.help");
|
||||
}
|
||||
@@ -2931,7 +2993,7 @@ function doesBusinessHaveAnyItemsToBuy(businessId) {
|
||||
|
||||
//function clearPlayerBusinessGameScripts(client, businessId) {
|
||||
// for(let i in getBusinessData(businessId).gameScripts) {
|
||||
// sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY);
|
||||
// sendPlayerGameScriptState(client, AGRP_GAMESCRIPT_DENY);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -2953,11 +3015,11 @@ function canPlayerWithdrawFromBusinessTill(client, businessId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
|
||||
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
|
||||
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -2973,11 +3035,11 @@ function canPlayerSetBusinessInteriorLights(client, businessId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
|
||||
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
|
||||
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -2993,11 +3055,11 @@ function canPlayerLockUnlockBusiness(client, businessId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
|
||||
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
|
||||
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -3013,13 +3075,13 @@ function canPlayerManageBusiness(client, businessId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER) {
|
||||
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_PLAYER) {
|
||||
if (getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN) {
|
||||
if (getBusinessData(businessId).ownerType == AGRP_BIZ_OWNER_CLAN) {
|
||||
if (getBusinessData(businessId).ownerId == getPlayerClan(client)) {
|
||||
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) {
|
||||
return true;
|
||||
@@ -3112,6 +3174,7 @@ function getClosestBusinessWithBuyableItemOfUseType(position, useType) {
|
||||
|
||||
function getBusinessesWithBuyableItemOfUseType(useType) {
|
||||
let businesses = getServerData().businesses;
|
||||
let availableBusinesses = [];
|
||||
for (let i in businesses) {
|
||||
if (doesBusinessHaveBuyableItemOfUseType(i, useType)) {
|
||||
availableBusinesses.push(i);
|
||||
|
||||
177
scripts/server/casino.js
Normal file
@@ -0,0 +1,177 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: casino.js
|
||||
// DESC: Provides casino games functions and commands
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
const AGRP_CASINO_GAME_NONE = 0;
|
||||
const AGRP_CASINO_GAME_BLACKJACK = 1;
|
||||
const AGRP_CASINO_GAME_POKER = 2;
|
||||
const AGRP_CASINO_GAME_BACCARAT = 3;
|
||||
const AGRP_CASINO_GAME_ROULETTE = 4;
|
||||
const AGRP_CASINO_GAME_CRAPS = 5;
|
||||
const AGRP_CASINO_GAME_HOLDEM = 6;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
const AGRP_CASINO_DECK_SUIT_NONE = 1;
|
||||
const AGRP_CASINO_DECK_SUIT_CLUBS = 1;
|
||||
const AGRP_CASINO_DECK_SUIT_DIAMONDS = 2;
|
||||
const AGRP_CASINO_DECK_SUIT_HEARTS = 3;
|
||||
const AGRP_CASINO_DECK_SUIT_SPADES = 4;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class DeckCard {
|
||||
constructor(suit, value, imageName) {
|
||||
this.suit = suit;
|
||||
this.value = value;
|
||||
this.imageName = imageName;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let cardDeck = [
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 1, "deckCardClubAce"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 2, "deckCardClubTwo"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 3, "deckCardClubThree"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 4, "deckCardClubFour"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 5, "deckCardClubFive"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 6, "deckCardClubSix"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 7, "deckCardClubSeven"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 8, "deckCardClubEight"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 9, "deckCardClubNine"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 10, "deckCardClubTen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 11, "deckCardClubJack"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 12, "deckCardClubQueen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 13, "deckCardClubKing"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 1, "deckCardDiamondAce"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 2, "deckCardDiamondTwo"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 3, "deckCardDiamondThree"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 4, "deckCardDiamondFour"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 5, "deckCardDiamondFive"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 6, "deckCardDiamondSix"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 7, "deckCardDiamondSeven"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 8, "deckCardDiamondEight"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 9, "deckCardDiamondNine"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 10, "deckCardDiamondTen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 11, "deckCardDiamondJack"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 12, "deckCardDiamondQueen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 13, "deckCardDiamondKing"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 1, "deckCardHeartAce"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 2, "deckCardHeartTwo"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 3, "deckCardHeartThree"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 4, "deckCardHeartFour"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 5, "deckCardHeartFive"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 6, "deckCardHeartSix"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 7, "deckCardHeartSeven"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 8, "deckCardHeartEight"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 9, "deckCardHeartNine"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 10, "deckCardHeartTen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 11, "deckCardHeartJack"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 12, "deckCardHeartQueen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 13, "deckCardHeartKing"),
|
||||
];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createBlackJackDeck() {
|
||||
let deck = [];
|
||||
for (let i in cardDeck) {
|
||||
deck.push(cardDeck[i]);
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function shuffleBlackJackDeck(deck) {
|
||||
// For 1000 turns, switch the values of two random cards
|
||||
// This may need to be lowered for a more optimized shuffling algorithm (reduces server load)
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
var location1 = Math.floor((Math.random() * deck.length));
|
||||
var location2 = Math.floor((Math.random() * deck.length));
|
||||
var tmp = deck[location1];
|
||||
|
||||
deck[location1] = deck[location2];
|
||||
deck[location2] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function blackJackHitCommand(command, params, client) {
|
||||
if (!isPlayerPlayingBlackJack(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayersTurnInBlackJack(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let hand = getPlayerData(client).casinoCardHand;
|
||||
|
||||
hand.push(deck.pop());
|
||||
|
||||
let tempHandValue = 0;
|
||||
|
||||
for (let i in hand) {
|
||||
if (hand[i].value == 1) {
|
||||
|
||||
if ((tempHandValue + 11) > 21) {
|
||||
tempHandValue += 1;
|
||||
} else {
|
||||
tempHandValue += 11;
|
||||
}
|
||||
} else {
|
||||
tempHandValue += hand[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
if (handValue > 21) {
|
||||
playerBustBlackJack(client);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function blackJackStandCommand(command, params, client) {
|
||||
if (!isPlayerPlayingBlackJack(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayersTurnInBlackJack(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function blackJackHit(hand, deck) {
|
||||
|
||||
|
||||
return handValue;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function dealPlayerBlackJackHand(deck, players) {
|
||||
// Alternate handing cards to each player, 2 cards each
|
||||
for (var i = 0; i < 2; i++) {
|
||||
for (var x = 0; x < players.length; x++) {
|
||||
var card = deck.pop();
|
||||
getPlayerData(players[i]).casinoCardHand.push(card);
|
||||
updateCasinoCardHand(players[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: chat.js
|
||||
// DESC: Provides chat functions and usage
|
||||
@@ -16,23 +17,23 @@ function initChatScript() {
|
||||
// ===========================================================================
|
||||
|
||||
function processPlayerChat(client, messageText) {
|
||||
if(!isConsole(client)) {
|
||||
if(!getPlayerData(client)) {
|
||||
if (!isConsole(client)) {
|
||||
if (!getPlayerData(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerLoggedIn(client)) {
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerSpawned(client)) {
|
||||
if (!isPlayerSpawned(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
@@ -61,7 +62,7 @@ function processPlayerChat(client, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function meActionCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -73,12 +74,12 @@ function meActionCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function doActionCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -90,12 +91,12 @@ function doActionCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function shoutCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -107,17 +108,17 @@ function shoutCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function megaphoneChatCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUseMegaphone(client)) {
|
||||
if (!canPlayerUseMegaphone(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantUseMegaphone"));
|
||||
return false;
|
||||
}
|
||||
@@ -129,12 +130,12 @@ function megaphoneChatCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function talkCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -146,12 +147,12 @@ function talkCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function whisperCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -163,12 +164,12 @@ function whisperCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function adminChatCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -179,12 +180,12 @@ function adminChatCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function clanChatCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -194,24 +195,77 @@ function clanChatCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function privateMessageCommand(command, params, client) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let splitParams = params.split(" ");
|
||||
let targetClient = getPlayerFromParams(splitParams[0]);
|
||||
let messageText = splitParams.slice(1).join(" ");
|
||||
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getPlayerData(targetClient).privateMessageReplyTo = client;
|
||||
messagePlayerPrivateMessage(targetClient, client, messageText);
|
||||
messagePlayerTip(client, getLocaleString(client, "PrivateMessageReplyCommandTip", "{ALTCOLOUR}/reply{MAINCOLOUR}"))
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function replyToLastPrivateMessageCommand(command, params, client) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getPlayerData(client).privateMessageReplyTo == null) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoPrivateMessageToReply"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getPlayerData(targetClient).privateMessageReplyTo = client;
|
||||
messagePlayerPrivateMessage(targetClient, client, messageText);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function talkToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerTalk(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendLocalChat) {
|
||||
messageDiscordChatChannel(`🗣️ ${getPlayerAccentInlineOutput(talkingClient)}${getClientSubAccountName(talkingClient)} says: ${messageText}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function phoneOutgoingToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to phone): {MAINCOLOUR}${messageText}`);
|
||||
}
|
||||
}
|
||||
@@ -222,9 +276,9 @@ function phoneOutgoingToNearbyPlayers(client, messageText) {
|
||||
|
||||
function phoneIncomingToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().phoneSpeakerDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().phoneSpeakerDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(from phone): {MAINCOLOUR}${messageText}`);
|
||||
}
|
||||
}
|
||||
@@ -235,91 +289,115 @@ function phoneIncomingToNearbyPlayers(client, messageText) {
|
||||
|
||||
function whisperToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().whisperDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().whisperDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerWhisper(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendLocalChat) {
|
||||
messageDiscordChatChannel(`🤫 ${getPlayerAccentInlineOutput(whisperingClient)}${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function shoutToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().shoutDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().shoutDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerShout(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendLocalChat) {
|
||||
messageDiscordChatChannel(`🗣️ ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function megaPhoneToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().megaphoneDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().megaphoneDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerMegaPhone(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendLocalChat) {
|
||||
messageDiscordChatChannel(`📢 ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} (megaphone): ${messageText}!`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function doActionToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().doActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().doActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerDoAction(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendAction) {
|
||||
messageDiscordChatChannel(`🙋 *${messageText} (${getCharacterFullName(client)})*`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function meActionToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().meActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().meActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerMeAction(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendAction) {
|
||||
messageDiscordChatChannel(`🙋 *${getCharacterFullName(client)} ${messageText}*`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function clanChat(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || arePlayersInSameClan(client, clients[i])) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || arePlayersInSameClan(client, clients[i])) {
|
||||
messagePlayerClanChat(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (getGlobalConfig().discord.sendClan) {
|
||||
// messageDiscordClanWebhook(getPlayerClan(client), getClanDiscordWebhookFlagValue("ClanChat"), fullString);
|
||||
//}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function canPlayerUseMegaphone(client) {
|
||||
if(getPlayerFirstItemSlotByUseType(client, VRR_ITEM_USETYPE_MEGAPHONE) != -1) {
|
||||
if(isPlayerActiveItemEnabled(client)) {
|
||||
if (getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_MEGAPHONE) != -1) {
|
||||
if (isPlayerActiveItemEnabled(client)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(getPlayerVehicle(client)) {
|
||||
if(doesVehicleHaveMegaphone(getPlayerVehicle(client))) {
|
||||
if (getPlayerVehicle(client)) {
|
||||
if (doesVehicleHaveMegaphone(getPlayerVehicle(client))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
195
scripts/server/client.js
Normal file
@@ -0,0 +1,195 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: client.js
|
||||
// DESC: Provides client communication and cross-endpoint operations
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Return-To types (for when a player is teleported)
|
||||
const AGRP_RETURNTO_TYPE_NONE = 0; // "Return to" data is invalid
|
||||
const AGRP_RETURNTO_TYPE_ADMINGET = 1; // "Return to" data is from admin teleporting
|
||||
const AGRP_RETURNTO_TYPE_SKINSELECT = 2; // "Return to" data is from skin select
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing extra data for a client
|
||||
*/
|
||||
class ClientData {
|
||||
constructor(client, accountData, subAccounts) {
|
||||
/** @member {AccountData} accountData */
|
||||
this.accountData = accountData;
|
||||
|
||||
/** @member {Array.<SubAccountData>} subAccounts */
|
||||
this.subAccounts = subAccounts; // Characters
|
||||
|
||||
// General Info
|
||||
this.client = client;
|
||||
this.currentSubAccount = -1;
|
||||
this.loggedIn = false;
|
||||
this.index = -1;
|
||||
this.connectTime = 0;
|
||||
this.clientVersion = "0.0.0";
|
||||
this.afk = false;
|
||||
this.spawned = false;
|
||||
this.sessionId = 0;
|
||||
|
||||
// Security
|
||||
this.passwordResetState = AGRP_RESETPASS_STATE_NONE;
|
||||
this.passwordResetCode = "";
|
||||
this.twoFactorAuthenticationState = AGRP_2FA_STATE_NONE;
|
||||
this.twoFactorAuthenticationCode = 0;
|
||||
this.loginTimeout = null;
|
||||
this.loginAttemptsRemaining = 3;
|
||||
|
||||
// Job Stuff
|
||||
this.jobEquipmentCache = [];
|
||||
this.jobUniform = 0;
|
||||
this.jobRoute = -1;
|
||||
this.jobRouteLocation = -1;
|
||||
this.jobRouteVehicle = false;
|
||||
this.returnToJobVehicleTick = 0;
|
||||
this.returnToJobVehicleTimer = null;
|
||||
|
||||
this.rentingVehicle = false;
|
||||
this.buyingVehicle = false;
|
||||
this.lastVehicle = false;
|
||||
|
||||
this.switchingCharacter = false;
|
||||
|
||||
this.tutorialStep = -1;
|
||||
this.tutorialItem = null;
|
||||
this.tutorialVehicle = null;
|
||||
|
||||
// Items
|
||||
this.tempLockerCache = new Array(9).fill(-1);
|
||||
this.tempLockerType = AGRP_TEMP_LOCKER_TYPE_NONE;
|
||||
this.hotBarItems = new Array(9).fill(-1);
|
||||
this.activeHotBarSlot = -1;
|
||||
this.toggleUseItem = false;
|
||||
this.itemActionState = AGRP_ITEM_ACTION_NONE;
|
||||
this.itemActionItem = -1;
|
||||
this.paintBallItemCache = [];
|
||||
|
||||
// Ordering for business
|
||||
this.businessOrderAmount = 0;
|
||||
this.businessOrderBusiness = -1;
|
||||
this.businessOrderItem = -1;
|
||||
this.businessOrderValue = -1;
|
||||
|
||||
// For Non-Server Elements
|
||||
this.syncPosition = null;
|
||||
this.syncHeading = null;
|
||||
this.syncVehicle = null;
|
||||
this.syncVehicleSeat = null;
|
||||
|
||||
// Payday
|
||||
this.payDayAmount = 0;
|
||||
this.payDayTickStart = 0;
|
||||
|
||||
// Creating Character
|
||||
//this.creatingCharacter = false;
|
||||
//this.creatingCharacterSkin = -1;
|
||||
|
||||
// Radio
|
||||
this.streamingRadioStation = -1;
|
||||
this.streamingRadioElement = false;
|
||||
|
||||
// Return To (when being teleported)
|
||||
this.returnToPosition = null;
|
||||
this.returnToHeading = null;
|
||||
this.returnToInterior = null;
|
||||
this.returnToDimension = null;
|
||||
this.returnToHouse = null;
|
||||
this.returnToBusiness = null;
|
||||
this.returnToType = AGRP_RETURNTO_TYPE_NONE;
|
||||
|
||||
// Animation
|
||||
this.currentAnimation = -1;
|
||||
this.currentAnimationPositionOffset = false;
|
||||
this.currentAnimationPositionReturnTo = false;
|
||||
this.animationStart = 0;
|
||||
this.animationForced = false;
|
||||
|
||||
// Misc
|
||||
this.changingCharacterName = false;
|
||||
this.currentPickup = false;
|
||||
this.usingSkinSelect = false;
|
||||
this.keyBinds = [];
|
||||
this.incomingDamageMultiplier = 1;
|
||||
this.weaponDamageEvent = AGRP_WEAPON_DAMAGE_EVENT_NORMAL;
|
||||
this.lastJobVehicle = null;
|
||||
this.health = 100;
|
||||
this.locale = 0;
|
||||
this.enteringVehicle = null;
|
||||
this.customDisconnectReason = "";
|
||||
this.interiorCutscene = -1;
|
||||
this.playerBlip = null;
|
||||
this.alcoholLevel = 0;
|
||||
this.pedState = AGRP_PEDSTATE_NONE;
|
||||
this.promptType = AGRP_PROMPT_NONE;
|
||||
this.privateMessageReplyTo = null;
|
||||
|
||||
// Paintball
|
||||
this.inPaintBall = false;
|
||||
this.paintBallBusiness = -1;
|
||||
this.paintBallDeaths = 0;
|
||||
this.paintBallKills = 0;
|
||||
|
||||
// Job Route Editing
|
||||
this.jobRouteEditNextLocationDelay = 0;
|
||||
this.jobRouteEditNextLocationArriveMessage = "";
|
||||
this.jobRouteEditNextLocationGotoMessage = "";
|
||||
this.jobRouteEditNextLocationType = AGRP_JOB_ROUTE_LOCATION_TYPE_NONE;
|
||||
|
||||
// Casino Stuff
|
||||
this.casinoChips = 0; // This might become an item with a useId of a business (for chips belonging to specific casinos)
|
||||
this.casinoCardHand = [];
|
||||
this.casinoPlayingGame = AGRP_CASINO_GAME_NONE;
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initClientScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Client]: Initializing client script ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.Client]: Client script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetClientStuff(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`);
|
||||
|
||||
if (!getPlayerData(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerOnJobRoute(client)) {
|
||||
stopJobRoute(client, false, false);
|
||||
}
|
||||
|
||||
if (getPlayerData(client).rentingVehicle) {
|
||||
stopRentingVehicle(client);
|
||||
}
|
||||
|
||||
deleteJobItems(client);
|
||||
deletePaintBallItems(client);
|
||||
//deletePlayerTemporaryLockerItems(client);
|
||||
|
||||
getPlayerData(client).lastVehicle = null;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function kickAllClients() {
|
||||
getClients().forEach((client) => {
|
||||
getPlayerData(client).customDisconnectReason = `Kicked - All clients are being disconnected`;
|
||||
disconnectPlayer(client);
|
||||
})
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: command.js
|
||||
// DESC: Provides command data, functions and usage
|
||||
@@ -69,8 +70,17 @@ function loadCommands() {
|
||||
new CommandData("notips", toggleNoRandomTipsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off random tips"),
|
||||
new CommandData("loginalert", toggleAccountLoginAttemptNotificationsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off email notifications for attempts to login to your account"),
|
||||
new CommandData("scrolllines", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
|
||||
new CommandData("chatscrolllines", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
|
||||
new CommandData("chatscroll", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
|
||||
new CommandData("chatautohide", setAccountChatAutoHideDelayCommand, "<time in seconds>", getStaffFlagValue("None"), true, false, "Sets how long to wait to hide the chatbox after last use (in seconds)"),
|
||||
|
||||
new CommandData("chattimestamp", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chattimestamps", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chattime", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chattimes", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chatfilter", toggleAccountProfanityFilterCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off profanity filter"),
|
||||
new CommandData("chatemoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
|
||||
new CommandData("emoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
|
||||
//new CommandData("noblood", toggleAccountHideBloodCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off blood in-game"),
|
||||
],
|
||||
ammunation: [],
|
||||
animation: [
|
||||
@@ -134,7 +144,8 @@ function loadCommands() {
|
||||
new CommandData("bizdefaultitems", giveDefaultItemsToBusinessCommand, "<item template>", getStaffFlagValue("ManageItems"), true, true, "Gives the business the default items based on template name"),
|
||||
new CommandData("bizdelflooritems", deleteBusinessFloorItemsCommand, "", getStaffFlagValue("ManageItems"), true, true, "Destroys all items on the business floor (for-sale items)"),
|
||||
new CommandData("bizdelstorageitems", deleteBusinessStorageItemsCommand, "", getStaffFlagValue("ManageItems"), true, true, "Destroys all items in the business's storage"),
|
||||
new CommandData("bizdealership", setBusinessEntranceLabelToDealershipCommand, "", getStaffFlagValue("ManageBusinesses"), true, true, "Sets the business's door label to vehicle dealership"),
|
||||
new CommandData("bizdealership", setBusinessDealershipCommand, "", getStaffFlagValue("None"), true, true, "Sets the business's door label to vehicle dealership"),
|
||||
//new CommandData("bizpaintball", setBusinessPaintBallCommand, "", getStaffFlagValue("None"), true, true, "Sets the business to a paintball arena"),
|
||||
],
|
||||
chat: [
|
||||
new CommandData("me", meActionCommand, "<message>", getStaffFlagValue("None"), true, false, "Shows a custom action message in chat"),
|
||||
@@ -153,6 +164,10 @@ function loadCommands() {
|
||||
new CommandData("a", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
|
||||
new CommandData("achat", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
|
||||
new CommandData("m", megaphoneChatCommand, "<message>", getStaffFlagValue("None"), true, true, "Shouts a message over a megaphone (portable bullhorn/loudspeaker)"),
|
||||
new CommandData("pm", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
|
||||
new CommandData("dm", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
|
||||
new CommandData("msg", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
|
||||
new CommandData("reply", replyToLastPrivateMessageCommand, "<message>", getStaffFlagValue("None"), true, true, "Replies to the last private message you received"),
|
||||
],
|
||||
clan: [
|
||||
new CommandData("clans", listClansCommand, "[search text]", getStaffFlagValue("None"), true, true, "List clans (search by partial name, if provided)"),
|
||||
@@ -250,6 +265,8 @@ function loadCommands() {
|
||||
email: [
|
||||
new CommandData("testemail", testEmailCommand, "<email address>", getStaffFlagValue("Developer"), true, true),
|
||||
],
|
||||
fishing: [],
|
||||
forensics: [],
|
||||
gate: [
|
||||
new CommandData("gate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
@@ -258,8 +275,8 @@ function loadCommands() {
|
||||
new CommandData("bizgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("businessgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("door", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("closegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
//new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
//new CommandData("closegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("opendoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("closedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("garagedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
@@ -302,6 +319,7 @@ function loadCommands() {
|
||||
new CommandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("ManageHouses"), true, true, "Moves a house's exit (inside/interior location to exit the house)"),
|
||||
new CommandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("ManageHouses"), true, true, "Sets a house's interior to a pre-defined type"),
|
||||
],
|
||||
insurance: [],
|
||||
item: [
|
||||
new CommandData("i", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("None"), true, false, "Switches to the item in the specified slot of your inventory."),
|
||||
new CommandData("item", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("None"), true, false, "Switches to the item in the specified slot of your inventory."),
|
||||
@@ -334,9 +352,17 @@ function loadCommands() {
|
||||
new CommandData("additemtype", createItemTypeCommand, "<name>", getStaffFlagValue("ManageItems"), true, false, "Adds a new item type"),
|
||||
new CommandData("itemtypeusetype", setItemTypeUseTypeCommand, "<item type> <use type>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-type (what kind of action is performed when using it)"),
|
||||
new CommandData("itemtypeuseval", setItemTypeUseValueCommand, "<item type> <use value>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-value (how much gets subtracted when using it)"),
|
||||
new CommandData("itemtypeorderprice", setItemTypeOrderPriceCommand, "<item type> <price>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's order price (base price when ordering for a business"),
|
||||
new CommandData("itemtypeorderprice", setItemTypeOrderPriceCommand, "<item type> <order price>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's order price (base price when ordering for a business"),
|
||||
new CommandData("itemtyperiskmult", setItemTypeRiskMultiplierCommand, "<item type> <risk multiplier>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's risk multiplayer (higher value for more dangerous or rare illegal items)"),
|
||||
new CommandData("itemtypeenabled", toggleItemTypeEnabledCommand, "<item type>", getStaffFlagValue("ManageItems"), true, false, "Toggles an item type on or off (if off, any items with that type can't be interacted with)"),
|
||||
new CommandData("itemtypedroppos", setItemTypeDropPositionCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the offset position for the object of an item type when dropped"),
|
||||
new CommandData("itemtypedroprot", setItemTypeDropRotationCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the rotation for the object of an item type when dropped"),
|
||||
new CommandData("itemtypedropscale", setItemTypeDropScaleCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the scale for the object of an item type when dropped"),
|
||||
new CommandData("itemtypedropfrontdistance", setItemTypeDropFrontDistanceCommand, "<item type> <distance>", getStaffFlagValue("ManageItems"), true, false, "Sets how far in front of a player an item type will be dropped"),
|
||||
new CommandData("itemtypemaxval", setItemTypeMaxValueCommand, "<item type> <max value>", getStaffFlagValue("ManageItems"), true, false, "Sets the maximum value an item type can have"),
|
||||
new CommandData("itemtypeorderval", setItemTypeOrderValueCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets the initial value of an item type when ordered by a business"),
|
||||
new CommandData("itemtypesize", setItemTypeSizeCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets the item type's size"),
|
||||
new CommandData("itemtypecapacity", setItemTypeSizeCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's capacity (how much it can hold)"),
|
||||
|
||||
new CommandData("delplritem", deleteItemInPlayerInventoryCommand, "<player name/id> <item slot>", getStaffFlagValue("ManageItems"), true, false, "Removes an item by slot from a player's personal inventory"),
|
||||
new CommandData("delplritems", deleteAllItemsInPlayerInventoryCommand, "<player name/id>", getStaffFlagValue("ManageItems"), true, false, "Removes all items from a player's personal inventory"),
|
||||
@@ -390,11 +416,14 @@ function loadCommands() {
|
||||
new CommandData("jobroutepay", setJobRoutePayCommand, "<amount>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutestartmsg", setJobRouteStartMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutefinishmsg", setJobRouteFinishMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocarrivemsg", setJobRouteLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocnextmsg", setJobRouteLocationNextMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutearrivemsg", setJobRouteDefaultLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutenextmsg", setJobRouteDefaultLocationNextMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocarrivemsg", setJobRouteNextLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocnextmsg", setJobRouteNextLocationGotoMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobrouteenabled", toggleJobRouteEnabledCommand, "", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutevehcolours", setJobRouteVehicleColoursCommand, "<colour 1> <colour 2>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutedelays", setJobRouteAllLocationDelaysCommand, "<time in milliseconds>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocdelay", setJobRouteNextLocationDelayCommand, "<time in milliseconds>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobcolour", setJobColourCommand, "<job id/name> <red> <green> <blue>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobblip", setJobBlipCommand, "<job id/name> <blip id/name>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobpickup", setJobPickupCommand, "<job id/name> <pickup id/name>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
@@ -441,7 +470,13 @@ function loadCommands() {
|
||||
new CommandData("gps", gpsCommand, "[item or place name]", getStaffFlagValue("None"), true, false, "Shows you locations for special places or where to buy items"),
|
||||
new CommandData("speak", playerPedSpeakCommand, "<speech name>", getStaffFlagValue("None"), true, false, "Makes your ped say something in their game voice (IV only)"),
|
||||
new CommandData("lock", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
|
||||
new CommandData("locks", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
|
||||
new CommandData("doorlock", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
|
||||
new CommandData("lockdoor", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
|
||||
new CommandData("lights", lightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights for your vehicle, house, or business"),
|
||||
new CommandData("light", lightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights for your vehicle, house, or business"),
|
||||
new CommandData("kill", suicideCommand, "", getStaffFlagValue("None"), true, false, "Kills yourself"),
|
||||
new CommandData("suicide", suicideCommand, "", getStaffFlagValue("None"), true, false, "Kills yourself"),
|
||||
],
|
||||
npc: [
|
||||
new CommandData("addnpc", createNPCCommand, "<skin id/name>", getStaffFlagValue("ManageNPCs"), true, false, "Creates an NPC with the specified skin"),
|
||||
@@ -453,6 +488,7 @@ function loadCommands() {
|
||||
//new CommandData("npcrespawnall", respawnAllNPCsCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns all NPCs"),
|
||||
//new CommandData("npcrespawn", respawnNPCCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns the nearest NPC"),
|
||||
],
|
||||
paintball: [],
|
||||
race: [
|
||||
// Unfinished!
|
||||
//new CommandData("addrace", createRaceCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race"),
|
||||
@@ -462,14 +498,18 @@ function loadCommands() {
|
||||
//new CommandData("delracestart", deleteRaceStartPositionCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest starting position for a race"),
|
||||
//new CommandData("delracecp", deleteRaceCheckPointCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest race checkpoint"),
|
||||
//new CommandData("racename", setRaceNameCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Sets a race's name"),
|
||||
//new CommandData("racestart", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
|
||||
//new CommandData("startrace", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
|
||||
//new CommandData("racestop", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
|
||||
//new CommandData("stoprace", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
|
||||
//new CommandData("stopAllRacesCommand", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops a race"),
|
||||
//new CommandData("racestopall", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops all active races"),
|
||||
//new CommandData("stopallraces", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops all active races"),
|
||||
],
|
||||
radio: [
|
||||
new CommandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("None"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"),
|
||||
new CommandData("radiostations", showRadioStationListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all available radio stations"),
|
||||
new CommandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."),
|
||||
new CommandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level 0-100>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."),
|
||||
new CommandData("radiovol", setStreamingRadioVolumeCommand, "<volume level 0-100>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."),
|
||||
new CommandData("radioreloadall", reloadAllRadioStationsCommand, "", getStaffFlagValue("ManageServer"), true, false, "Reloads all radio stations from database (use after making changes)"),
|
||||
],
|
||||
security: [],
|
||||
@@ -503,18 +543,25 @@ function loadCommands() {
|
||||
new CommandData("int", playerInteriorCommand, "<player name/id> [interior id]", getStaffFlagValue("BasicModeration"), true, true, "Gets or sets a player's game interior."),
|
||||
new CommandData("vw", playerVirtualWorldCommand, "<player name/id> [virtual world id]", getStaffFlagValue("BasicModeration"), true, true, "Gets or sets a player's virtual world/dimension."),
|
||||
new CommandData("addplrstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
|
||||
new CommandData("addplayerstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
|
||||
new CommandData("addstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
|
||||
new CommandData("delplrstaffflag", removePlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Takes a player's staff flag by name (this server only)."),
|
||||
new CommandData("plrstaffflags", getPlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all staff flags a player has (this server only)."),
|
||||
new CommandData("clearstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
|
||||
new CommandData("delstaffflag", removePlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Takes a player's staff flag by name (this server only)."),
|
||||
new CommandData("getplrstaffflags", getPlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all staff flags a player has (this server only)."),
|
||||
new CommandData("delplrstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
|
||||
new CommandData("delstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
|
||||
new CommandData("allstaffflags", getStaffFlagsCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all valid staff flag names."),
|
||||
new CommandData("staffflags", getStaffFlagsCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all valid staff flag names."),
|
||||
new CommandData("plrstafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
|
||||
new CommandData("playerstafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
|
||||
new CommandData("stafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
|
||||
new CommandData("givemoney", givePlayerMoneyCommand, "<player name/id> <amount>", getStaffFlagValue("serverManager"), true, true),
|
||||
new CommandData("nonrpname", forceCharacterNameChangeCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to change their current character's name."),
|
||||
new CommandData("setname", setCharacterNameCommand, "<player name/id> <first name> <last name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's name directly."),
|
||||
new CommandData("setskin", setPlayerSkinCommand, "<player name/id> <skin id/name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's skin."),
|
||||
new CommandData("setaccent", setPlayerAccentCommand, "<player name/id> <accent name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's accent."),
|
||||
//new CommandData("setfightstyle", setPlayerFightStyleCommand, "<player name/id> <fight style name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's fight style."),
|
||||
new CommandData("setstars", setPlayerWantedLevelCommand, "<player name/id> <wanted level>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to have a wanted level"),
|
||||
new CommandData("setname", forceCharacterNameCommand, "<player name/id> <first name> <last name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's name directly."),
|
||||
new CommandData("setskin", forcePlayerSkinCommand, "<player name/id> <skin id/name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's skin."),
|
||||
new CommandData("setaccent", forcePlayerAccentCommand, "<player name/id> <accent name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's accent."),
|
||||
new CommandData("setfightstyle", forcePlayerFightStyleCommand, "<player name/id> <fight style name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's fight style."),
|
||||
new CommandData("setstars", forcePlayerWantedLevelCommand, "<player name/id> <wanted level>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to have a wanted level"),
|
||||
new CommandData("plrinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"),
|
||||
new CommandData("playerinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"),
|
||||
new CommandData("getplrhouses", getHousesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all houses owned by the player"),
|
||||
@@ -529,13 +576,20 @@ function loadCommands() {
|
||||
new CommandData("getplayervehicles", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
|
||||
new CommandData("geoip", getPlayerGeoIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves GeoIP information on a player (country & city)"),
|
||||
new CommandData("ip", getPlayerIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves IP information on a player"),
|
||||
new CommandData("getgeoip", getPlayerGeoIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves GeoIP information on a player (country & city)"),
|
||||
new CommandData("getip", getPlayerIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves IP information on a player"),
|
||||
new CommandData("plrsync", toggleSyncForElementsSpawnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Sets whether elements spawned by a player are synced (traffic, peds, etc)"),
|
||||
new CommandData("health", setPlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
|
||||
new CommandData("armour", setPlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
|
||||
new CommandData("health", forcePlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
|
||||
new CommandData("armour", forcePlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
|
||||
new CommandData("sethealth", forcePlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
|
||||
new CommandData("setarmour", forcePlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
|
||||
new CommandData("infiniterun", setPlayerInfiniteRunCommand, "<player name/id> <state>", getStaffFlagValue("BasicModeration"), true, true, "Toggles a player's infinite sprint"),
|
||||
new CommandData("atbiz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
|
||||
new CommandData("atbusiness", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
|
||||
new CommandData("athouse", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
|
||||
new CommandData("biz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
|
||||
new CommandData("business", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
|
||||
new CommandData("house", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
|
||||
],
|
||||
startup: [],
|
||||
subAccount: [
|
||||
@@ -655,6 +709,9 @@ function addAllCommandHandlers() {
|
||||
}
|
||||
}
|
||||
|
||||
removeCommandHandler("help");
|
||||
addCommandHandler("help", helpCommand);
|
||||
|
||||
logToConsole(LOG_INFO, `[VRR.Command] ${commandCount} command handlers added!`);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: config.js
|
||||
// DESC: Provides server configuration
|
||||
@@ -35,6 +36,8 @@ class ServerConfigData {
|
||||
this.characterSelectInterior = 0;
|
||||
this.characterSelectDimension = 0;
|
||||
|
||||
this.name = "";
|
||||
this.password = "";
|
||||
this.hour = 0;
|
||||
this.minute = 0
|
||||
this.minuteDuration = 1000;
|
||||
@@ -49,7 +52,8 @@ class ServerConfigData {
|
||||
this.showLogo = true;
|
||||
this.inflationMultiplier = 1;
|
||||
this.testerOnly = false;
|
||||
this.settings = 0;
|
||||
this.devServer = false;
|
||||
this.nameTagDistance = 50.0;
|
||||
|
||||
this.antiCheat = {
|
||||
enabled: false,
|
||||
@@ -78,12 +82,9 @@ class ServerConfigData {
|
||||
this.realTimeZone = 0;
|
||||
|
||||
this.discordConfig = {
|
||||
eventChannelWebHookURL: "",
|
||||
chatChannelWebHookURL: "",
|
||||
adminChannelWebHookURL: "",
|
||||
sendEvents: true,
|
||||
sendChat: true,
|
||||
sendAdminEvents: true,
|
||||
sendAdmin: true,
|
||||
};
|
||||
|
||||
if (dbAssoc) {
|
||||
@@ -94,34 +95,54 @@ class ServerConfigData {
|
||||
money: dbAssoc["svr_newchar_money"],
|
||||
bank: dbAssoc["svr_newchar_bank"],
|
||||
skin: dbAssoc["svr_newchar_skin"],
|
||||
},
|
||||
this.settings = toInteger(dbAssoc["svr_settings"]);
|
||||
};
|
||||
|
||||
this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]);
|
||||
this.connectCameraLookAt = toVector3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]);
|
||||
|
||||
this.name = toInteger(dbAssoc["svr_name"]);
|
||||
this.password = toInteger(dbAssoc["svr_password"]);
|
||||
this.hour = toInteger(dbAssoc["svr_start_time_hour"]);
|
||||
this.minute = toInteger(dbAssoc["svr_start_time_min"]);
|
||||
this.minuteDuration = toInteger(dbAssoc["svr_time_min_duration"]);
|
||||
this.weather = toInteger(dbAssoc["svr_start_weather"]);
|
||||
this.fallingSnow = intToBool(toInteger(dbAssoc["svr_snow_falling"]));
|
||||
this.groundSnow = intToBool(toInteger(dbAssoc["svr_snow_ground"]));
|
||||
this.useGUI = intToBool(toInteger(dbAssoc["svr_gui"]));
|
||||
this.showLogo = intToBool(toInteger(dbAssoc["svr_logo"]));
|
||||
this.createJobPickups = intToBool(toInteger(dbAssoc["svr_job_pickups"]));
|
||||
this.createBusinessPickups = intToBool(toInteger(dbAssoc["svr_biz_pickups"]));
|
||||
this.createHousePickups = intToBool(toInteger(dbAssoc["svr_house_pickups"]));
|
||||
this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips"]));
|
||||
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips"]));
|
||||
this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips"]));
|
||||
this.createPlayerBlips = intToBool(toInteger(dbAssoc["svr_player_blips"]));
|
||||
this.guiColourPrimary = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])];
|
||||
this.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])];
|
||||
this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])];
|
||||
//this.guiTextColourSecondary = [toInteger(dbAssoc["svr_gui_textcol2_r"]), toInteger(dbAssoc["svr_gui_textcol2_g"]), toInteger(dbAssoc["svr_gui_textcol2_b"])];
|
||||
this.inflationMultiplier = toFloat(dbAssoc["svr_inflation_multiplier"]);
|
||||
|
||||
this.nameTagDistance = toFloat(dbAssoc["svr_nametag_distance"]);
|
||||
this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]);
|
||||
this.introMusicURL = dbAssoc["svr_intro_music"];
|
||||
this.realTimeZone = dbAssoc["svr_time_realtime_timezone"];
|
||||
|
||||
this.discordConfig = {
|
||||
eventChannelWebHookURL: dbAssoc["svr_discord_event_webhook"],
|
||||
chatChannelWebHookURL: dbAssoc["svr_discord_chat_webhook"],
|
||||
adminChannelWebHookURL: dbAssoc["svr_discord_admin_webhook"],
|
||||
sendEvents: true,
|
||||
sendChat: true,
|
||||
sendAdminEvents: true,
|
||||
//this.useRealTime = intToBool(toInteger(dbAssoc["svr_real_time_enabled"]));
|
||||
//this.realTimeZone = dbAssoc["svr_real_time_timezone"];
|
||||
|
||||
this.discord = {
|
||||
sendEvents: intToBool(dbAssoc["svr_discord_send_events"]),
|
||||
sendChat: intToBool(dbAssoc["svr_discord_send_chat"]),
|
||||
sendAdmin: intToBool(dbAssoc["svr_discord_send_admin"]),
|
||||
};
|
||||
|
||||
this.economy = {
|
||||
inflationMultiplier: toFloat(dbAssoc["svr_inflation_multiplier"]),
|
||||
incomeTaxRate: toFloat(dbAssoc["svr_income_tax_rate"]),
|
||||
passiveIncome: toFloat(dbAssoc["svr_passive_income"]),
|
||||
}
|
||||
|
||||
this.devServer = intToBool(toInteger(server.getCVar("agrp_devserver")));
|
||||
this.testerOnly = intToBool(toInteger(server.getCVar("agrp_testeronly")));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -177,18 +198,18 @@ let globalConfig = {
|
||||
geoIPCityDatabaseFilePath: "geoip-city.mmdb",
|
||||
randomTipInterval: 600000,
|
||||
weaponEquippableTypes: [
|
||||
VRR_ITEM_USETYPE_WEAPON,
|
||||
VRR_ITEM_USETYPE_TAZER,
|
||||
VRR_ITEM_USETYPE_EXTINGUISHER,
|
||||
VRR_ITEM_USETYPE_SPRAYPAINT,
|
||||
VRR_ITEM_USETYPE_PEPPERSPRAY,
|
||||
AGRP_ITEM_USE_TYPE_WEAPON,
|
||||
AGRP_ITEM_USE_TYPE_TAZER,
|
||||
AGRP_ITEM_USE_TYPE_EXTINGUISHER,
|
||||
AGRP_ITEM_USE_TYPE_SPRAYPAINT,
|
||||
AGRP_ITEM_USE_TYPE_PEPPERSPRAY,
|
||||
],
|
||||
onFootOnlyItems: [
|
||||
VRR_ITEM_USETYPE_VEHREPAIR,
|
||||
VRR_ITEM_USETYPE_VEHCOLOUR,
|
||||
VRR_ITEM_USETYPE_VEHUPGRADE_PART,
|
||||
VRR_ITEM_USETYPE_VEHLIVERY,
|
||||
VRR_ITEM_USETYPE_VEHTIRE,
|
||||
AGRP_ITEM_USE_TYPE_VEHREPAIR,
|
||||
AGRP_ITEM_USE_TYPE_VEHCOLOUR,
|
||||
AGRP_ITEM_USE_TYPE_VEHUPGRADE_PART,
|
||||
AGRP_ITEM_USE_TYPE_VEHLIVERY,
|
||||
AGRP_ITEM_USE_TYPE_VEHTIRE,
|
||||
],
|
||||
vehicleInactiveRespawnDelay: 1800000, // 20 minutes
|
||||
chatSectionHeaderLength: 96,
|
||||
@@ -206,6 +227,8 @@ let globalConfig = {
|
||||
houseBlipStreamOutDistance: 120,
|
||||
jobBlipStreamInDistance: -1,
|
||||
jobBlipStreamOutDistance: -1,
|
||||
playerStreamInDistance: -1,
|
||||
playerStreamOutDistance: -1,
|
||||
playerBlipStreamInDistance: -1,
|
||||
playerBlipStreamOutDistance: -1,
|
||||
handcuffPlayerDistance: 3,
|
||||
@@ -216,6 +239,13 @@ let globalConfig = {
|
||||
passwordRequiredSymbols: 0,
|
||||
minChatLines: 1,
|
||||
maxChatLines: 6,
|
||||
vehicleTrunkDistance: 2.0,
|
||||
fishingSpotDistance: 10.0,
|
||||
atmDistance: 1.5,
|
||||
loginTimeout: 60000,
|
||||
fishingCastMaxStrength: 100,
|
||||
fishingCastMinStrength: 30,
|
||||
jobRouteLocationSphereRadius: 3,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
@@ -303,6 +333,26 @@ function loadServerConfigFromGameAndPort(gameId, port) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadServerConfigFromGame(gameId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
if (dbQuery.numRows > 0) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return tempServerConfigData;
|
||||
}
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadServerConfigFromId(tempServerId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
@@ -1077,7 +1127,12 @@ function getDatabaseConfig() {
|
||||
function loadServerConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading server configuration");
|
||||
try {
|
||||
serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort());
|
||||
if (toInteger(server.getCVar("agrp_devserver")) == 1) {
|
||||
serverConfig = loadServerConfigFromGame(getGame());
|
||||
} else {
|
||||
serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort());
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort}`);
|
||||
thisResource.stop();
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: core.js
|
||||
// DESC: Provides core data structures, function, and operations
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let scriptVersion = "1.1";
|
||||
let scriptVersion = "1.2";
|
||||
let serverStartTime = 0;
|
||||
let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE; // LOG_ERROR|LOG_WARN;
|
||||
let logLevel = LOG_INFO | LOG_DEBUG | LOG_VERBOSE; // LOG_ERROR|LOG_WARN;
|
||||
|
||||
let playerResourceReady = new Array(server.maxClients).fill(false);
|
||||
let playerResourceStarted = new Array(server.maxClients).fill(false);
|
||||
let playerInitialized = new Array(server.maxClients).fill(false);
|
||||
let playerGUI = new Array(server.maxClients).fill(false);
|
||||
let defaultNoAccountId = 479;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -28,15 +30,19 @@ let playerGUI = new Array(server.maxClients).fill(false);
|
||||
* @property {Array.<ItemData>} items
|
||||
* @property {Array.<ItemTypeData>} itemTypes
|
||||
* @property {Array.<ClanData>} clans
|
||||
* @property {Array} localeStrings
|
||||
* @property {Array.<TriggerData>} triggers
|
||||
* @property {Array.<NPCData>} npcs
|
||||
* @property {Array.<RaceData>} races
|
||||
* @property {Array.<JobData>} jobs
|
||||
* @property {Array.<Gates>} gates
|
||||
* @property {Array.<GateData>} gates
|
||||
* @property {Array.<RadioStationData>} radioStations
|
||||
* @property {Array} locales
|
||||
* @property {Array} localeStrings
|
||||
* @property {Array} groundItemCache
|
||||
* @property {Array} groundPlantCache
|
||||
* @property {Array} purchasingVehicleCache
|
||||
* @property {Array} rentingVehicleCache
|
||||
* @property {Array} atmLocationCache
|
||||
*/
|
||||
let serverData = {
|
||||
vehicles: [],
|
||||
@@ -47,26 +53,26 @@ let serverData = {
|
||||
items: [],
|
||||
itemTypes: [],
|
||||
clans: [],
|
||||
localeStrings: {},
|
||||
cachedTranslations: [],
|
||||
cachedTranslationFrom: [],
|
||||
//triggers: [],
|
||||
triggers: [],
|
||||
npcs: [],
|
||||
races: [],
|
||||
jobs: [],
|
||||
gates: [],
|
||||
radioStations: [],
|
||||
localeStrings: {},
|
||||
groundItemCache: [],
|
||||
groundPlantCache: [],
|
||||
purchasingVehicleCache: [],
|
||||
rentingVehicleCache: [],
|
||||
atmLocationCache: [],
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {ServerData}
|
||||
*
|
||||
* @return {ServerData} serverData
|
||||
*/
|
||||
function getServerData() {
|
||||
return serverData;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: crime.js
|
||||
// DESC: Provides crime data structures, functions, and operations
|
||||
@@ -10,7 +11,7 @@
|
||||
/**
|
||||
* @class Representing a crime's data. Loaded and saved in the database
|
||||
*/
|
||||
class CrimeData {
|
||||
class CrimeData {
|
||||
constructor(suspectId, crimeType, reporterId = 0) {
|
||||
this.crimeType = crimeType;
|
||||
this.suspectId = suspectId;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: database.js
|
||||
// DESC: Provides database handling, functions and usage
|
||||
@@ -24,13 +25,13 @@ function createDatabaseInsertQuery(tableName, data) {
|
||||
let fields = [];
|
||||
let values = [];
|
||||
|
||||
for(let i in data) {
|
||||
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') {
|
||||
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
|
||||
for (let i in data) {
|
||||
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') {
|
||||
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
|
||||
fields.push(data[i][0]);
|
||||
|
||||
if(typeof data[i][1] == "string") {
|
||||
if(data[i][1] == "{UNIXTIMESTAMP}") {
|
||||
if (typeof data[i][1] == "string") {
|
||||
if (data[i][1] == "{UNIXTIMESTAMP}") {
|
||||
values.push("UNIX_TIMESTAMP()");
|
||||
} else {
|
||||
values.push(`'${data[i][1]}'`);
|
||||
@@ -51,11 +52,11 @@ function createDatabaseInsertQuery(tableName, data) {
|
||||
function createDatabaseUpdateQuery(tableName, data, whereClause) {
|
||||
let values = [];
|
||||
|
||||
for(let i in data) {
|
||||
if(data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') {
|
||||
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
|
||||
if(typeof data[i][1] == "string") {
|
||||
if(data[i][1] == "{UNIXTIMESTAMP}") {
|
||||
for (let i in data) {
|
||||
if (data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') {
|
||||
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
|
||||
if (typeof data[i][1] == "string") {
|
||||
if (data[i][1] == "{UNIXTIMESTAMP}") {
|
||||
values.push(`${data[i][0]}=UNIX_TIMESTAMP()`);
|
||||
} else {
|
||||
values.push(`${data[i][0]}='${data[i][1]}'`);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: developer.js
|
||||
// DESC: Provides developer operation, commands, functions and usage
|
||||
@@ -120,12 +121,12 @@ function pvd(params) {
|
||||
// ===========================================================================
|
||||
|
||||
function addLogLevelCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(toLowerCase(params)) {
|
||||
switch (toLowerCase(params)) {
|
||||
case "debug":
|
||||
logLevel = logLevel | LOG_DEBUG;
|
||||
break;
|
||||
@@ -151,9 +152,7 @@ function addLogLevelCommand(command, params, client) {
|
||||
}
|
||||
|
||||
sendPlayerLogLevel(null, logLevel);
|
||||
|
||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -162,40 +161,39 @@ function addLogLevelCommand(command, params, client) {
|
||||
function getLogLevelCommand(command, params, client) {
|
||||
let logLevels = [];
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_DEBUG)) {
|
||||
if (hasBitFlag(logLevel, LOG_DEBUG)) {
|
||||
logLevels.push("debug");
|
||||
}
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_WARN)) {
|
||||
if (hasBitFlag(logLevel, LOG_WARN)) {
|
||||
logLevels.push("warn");
|
||||
}
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_ERROR)) {
|
||||
if (hasBitFlag(logLevel, LOG_ERROR)) {
|
||||
logLevels.push("error");
|
||||
}
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_INFO)) {
|
||||
if (hasBitFlag(logLevel, LOG_INFO)) {
|
||||
logLevels.push("info");
|
||||
}
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_VERBOSE)) {
|
||||
if (hasBitFlag(logLevel, LOG_VERBOSE)) {
|
||||
logLevels.push("verbose");
|
||||
}
|
||||
|
||||
messagePlayerAlert(`{MAINCOLOUR}Current log levels: {ALTCOLOUR}${toLowerCase(logLevels.join(", "))}`);
|
||||
|
||||
messagePlayerAlert(client, `{MAINCOLOUR}Current log levels: {ALTCOLOUR}${toLowerCase(logLevels.join(", "))}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function removeLogLevelCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(toLowerCase(params)) {
|
||||
switch (toLowerCase(params)) {
|
||||
case "debug":
|
||||
logLevel = logLevel & ~LOG_DEBUG;
|
||||
break;
|
||||
@@ -221,28 +219,26 @@ function removeLogLevelCommand(command, params, client) {
|
||||
}
|
||||
|
||||
sendPlayerLogLevel(null, logLevel);
|
||||
|
||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function simulateCommandForPlayerCommand(command, params, client) {
|
||||
if(getCommand(command).requireLogin) {
|
||||
if(!isPlayerLoggedIn(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))) {
|
||||
if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
messagePlayerError(client, "You do not have permission to use this command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
|
||||
if (areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -252,12 +248,12 @@ function simulateCommandForPlayerCommand(command, params, client) {
|
||||
tempCommand.replace("/", "");
|
||||
let tempParams = splitParams.slice(2).join(" ");
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, "Invalid player name or ID");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getCommand(tempCommand)) {
|
||||
if (!getCommand(tempCommand)) {
|
||||
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
|
||||
return false;
|
||||
}
|
||||
@@ -270,19 +266,19 @@ function simulateCommandForPlayerCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function simulateCommandForAllPlayersCommand(command, params, client) {
|
||||
if(getCommand(command).requireLogin) {
|
||||
if(!isPlayerLoggedIn(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))) {
|
||||
if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
messagePlayerError(client, "You do not have permission to use this command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
|
||||
if (areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -291,14 +287,14 @@ function simulateCommandForAllPlayersCommand(command, params, client) {
|
||||
tempCommand.replace("/", "");
|
||||
let tempParams = splitParams.slice(1).join(" ");
|
||||
|
||||
if(!getCommand(tempCommand)) {
|
||||
if (!getCommand(tempCommand)) {
|
||||
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(!clients[i].console) {
|
||||
for (let i in clients) {
|
||||
if (!clients[i].console) {
|
||||
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, clients[i]);
|
||||
}
|
||||
}
|
||||
@@ -309,7 +305,7 @@ function simulateCommandForAllPlayersCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function executeServerCodeCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -317,7 +313,7 @@ function executeServerCodeCommand(command, params, client) {
|
||||
let returnValue = "Nothing";
|
||||
try {
|
||||
returnValue = eval("(" + params + ")");
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
messagePlayerError(client, "The code could not be executed!");
|
||||
return false;
|
||||
}
|
||||
@@ -332,7 +328,7 @@ function executeServerCodeCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function executeClientCodeCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -341,12 +337,12 @@ function executeClientCodeCommand(command, params, client) {
|
||||
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
|
||||
let targetCode = splitParams.slice(1).join(" ");
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(targetCode == "") {
|
||||
if (targetCode == "") {
|
||||
messagePlayerError(client, "You didn't enter any code!");
|
||||
return false;
|
||||
}
|
||||
@@ -361,19 +357,19 @@ function executeClientCodeCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setPlayerTesterStatusCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
|
||||
if (!hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
|
||||
getPlayerData(targetClient).accountData.flags.moderation = addBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
|
||||
} else {
|
||||
getPlayerData(targetClient).accountData.flags.moderation = removeBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
|
||||
@@ -388,14 +384,14 @@ function setPlayerTesterStatusCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function testPromptGUICommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
@@ -407,14 +403,14 @@ function testPromptGUICommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function testInfoGUICommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
@@ -426,14 +422,14 @@ function testInfoGUICommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function testErrorGUICommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
@@ -456,8 +452,8 @@ function saveServerDataCommand(command, params, client) {
|
||||
function testEmailCommand(command, params, client) {
|
||||
try {
|
||||
messagePlayerAlert(client, `Sending test email to ${params}`);
|
||||
sendEmail(params, "Player", "Test email", "Just testing the SMTP module for the server!");
|
||||
} catch(error) {
|
||||
sendEmail(params, "Player", "Test email", "Just testing the SMTP module for the server!");
|
||||
} catch (error) {
|
||||
messagePlayerError(client, "The email could not be sent! Error: ${error}");
|
||||
return false;
|
||||
}
|
||||
@@ -477,7 +473,7 @@ function restartGameModeCommand(command, params, client) {
|
||||
|
||||
function clientRunCodeFail(client, returnTo, error) {
|
||||
let returnClient = getClientFromIndex(returnTo);
|
||||
if(!returnClient) {
|
||||
if (!returnClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -488,7 +484,7 @@ function clientRunCodeFail(client, returnTo, error) {
|
||||
|
||||
function clientRunCodeSuccess(client, returnTo, returnVal) {
|
||||
let returnClient = getClientFromIndex(returnTo);
|
||||
if(!returnClient) {
|
||||
if (!returnClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -500,19 +496,25 @@ function clientRunCodeSuccess(client, returnTo, returnVal) {
|
||||
// ===========================================================================
|
||||
|
||||
function submitIdea(client, ideaText) {
|
||||
let position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
|
||||
let heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
|
||||
let position = toVector3(0.0, 0.0, 0.0);
|
||||
let heading = 0.0;
|
||||
let session = 0;
|
||||
let databaseId = 0;
|
||||
|
||||
if(isConsole(client)) {
|
||||
databaseId = -1;
|
||||
if (client != null) {
|
||||
if (isConsole(client)) {
|
||||
databaseId = -1;
|
||||
} else {
|
||||
databaseId = getPlayerData(client).accountData.databaseId;
|
||||
position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
|
||||
heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
|
||||
}
|
||||
} else {
|
||||
databaseId = getPlayerData(client).accountData.databaseId;
|
||||
databaseId = defaultNoAccountId;
|
||||
}
|
||||
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let safeIdeaMessage = escapeDatabaseString(dbConnection, ideaText);
|
||||
queryDatabase(dbConnection, `INSERT INTO idea_main (idea_server, idea_script_ver, idea_who_added, idea_when_added, idea_message, idea_pos_x, idea_pos_y, idea_pos_z, idea_rot_z, idea_svr_start, idea_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeIdeaMessage}',${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
|
||||
}
|
||||
@@ -521,19 +523,25 @@ function submitIdea(client, ideaText) {
|
||||
// ===========================================================================
|
||||
|
||||
function submitBugReport(client, bugText) {
|
||||
let position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
|
||||
let heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
|
||||
let position = toVector3(0.0, 0.0, 0.0);
|
||||
let heading = 0.0;
|
||||
let session = 0;
|
||||
let databaseId = 0;
|
||||
|
||||
if(isConsole(client)) {
|
||||
databaseId = -1;
|
||||
if (client != null) {
|
||||
if (isConsole(client)) {
|
||||
databaseId = -1;
|
||||
} else {
|
||||
databaseId = getPlayerData(client).accountData.databaseId;
|
||||
position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
|
||||
heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
|
||||
}
|
||||
} else {
|
||||
databaseId = getPlayerData(client).accountData.databaseId;
|
||||
databaseId = defaultNoAccountId;
|
||||
}
|
||||
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let safeBugMessage = escapeDatabaseString(dbConnection, bugText);
|
||||
queryDatabase(dbConnection, `INSERT INTO bug_main (bug_server, bug_script_ver, bug_who_added, bug_when_added, bug_message, bug_pos_x, bug_pos_y, bug_pos_z, bug_rot_z, bug_svr_start, bug_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeBugMessage}', ${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
|
||||
}
|
||||
@@ -551,14 +559,14 @@ function migrateSubAccountsToPerServerData() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
let dbAssoc = false;
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM sacct_main`);
|
||||
if(dbQuery) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
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) {
|
||||
if (dbQuery2) {
|
||||
freeDatabaseQuery(dbQuery2);
|
||||
}
|
||||
}
|
||||
@@ -573,10 +581,10 @@ function resetAllAccountsHotkeysToDefault() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
let dbAssoc = false;
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT acct_id FROM acct_main`);
|
||||
if(dbQuery) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
if (dbQuery) {
|
||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
createDefaultKeybindsForAccount(dbAssoc["acct_id"]);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
@@ -595,9 +603,9 @@ function togglePauseSavingToDatabaseCommand(command, params, client) {
|
||||
function createAccountDataForNewServer(serverId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_main`);
|
||||
if(dbQuery) {
|
||||
if (dbQuery) {
|
||||
let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accountDatabaseId}, ${serverId})`;
|
||||
quickDatabaseQuery(dbQueryString);
|
||||
}
|
||||
@@ -607,7 +615,7 @@ function createAccountDataForNewServer(serverId) {
|
||||
// ===========================================================================
|
||||
|
||||
function streamAudioURLToAllPlayersCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -621,7 +629,7 @@ function streamAudioURLToAllPlayersCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function streamAudioNameToAllPlayersCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -685,28 +693,28 @@ function showLocalePickerTestCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function executeDatabaseQueryCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, "That player was not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(targetCode == "") {
|
||||
if (targetCode == "") {
|
||||
messagePlayerError(client, "You didn't enter any code!");
|
||||
return false;
|
||||
}
|
||||
|
||||
let success = quickDatabaseQuery(params);
|
||||
let results = quickDatabaseQueryWithResults(params);
|
||||
|
||||
if(!success) {
|
||||
if (results == false || results == null || results == undefined) {
|
||||
messagePlayerAlert(client, `Database query failed to execute: {ALTCOLOUR}${query}`);
|
||||
} else if(typeof success != "boolean") {
|
||||
messagePlayeSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
|
||||
messagePlayerInfo(client, `Returns: ${success}`);
|
||||
} else if (typeof results == "boolean") {
|
||||
messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
|
||||
messagePlayerInfo(client, `Returns: ${getTrueFalseFromBool(results)}`);
|
||||
} else {
|
||||
messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: discord.js
|
||||
// DESC: Provides discord bridging and connection functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Discord Webhook Types
|
||||
const AGRP_DISCORD_WEBHOOK_NONE = 0;
|
||||
const AGRP_DISCORD_WEBHOOK_LOG = 1;
|
||||
const AGRP_DISCORD_WEBHOOK_ADMIN = 2;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initDiscordScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Discord]: Initializing discord script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Discord]: Discord script initialized successfully!");
|
||||
@@ -102,7 +110,8 @@ function messageDiscordChatChannel(messageString) {
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
|
||||
messageString = replaceProfanityInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -121,7 +130,8 @@ function messageDiscordEventChannel(messageString) {
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
|
||||
messageString = replaceProfanityInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -140,12 +150,35 @@ function messageDiscordAdminChannel(messageString) {
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_ADMIN);
|
||||
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_ADMIN);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function triggerDiscordWebHook(messageString, serverId = getServerId(), type = VRR_DISCORD_WEBHOOK_LOG) {
|
||||
function messageDiscordClanWebhook(clanIndex, requiredFlagValue, messageString) {
|
||||
if (getServerConfig().devServer == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getGlobalConfig().discord.sendClan) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getServerConfig().discord.sendClan) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!hasBitFlag(getClanData(clanIndex).discordWebhookFlags, requiredFlagValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
triggerClanDiscordWebHook(clanIndex, messageString);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function triggerDiscordWebHook(messageString, serverId = getServerId(), type = AGRP_DISCORD_WEBHOOK_LOG) {
|
||||
if (!getGlobalConfig().discord.webhook.enabled) {
|
||||
return false;
|
||||
}
|
||||
@@ -167,4 +200,32 @@ function triggerDiscordWebHook(messageString, serverId = getServerId(), type = V
|
||||
);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function triggerClanDiscordWebHook(clanIndex, messageString) {
|
||||
if (!getGlobalConfig().discord.webhook.enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
let webhookURL = getClanData(clanIndex).discordWebhookURL;
|
||||
|
||||
let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL;
|
||||
tempURL = tempURL.replace("{0}", encodeURI(messageString));
|
||||
tempURL = tempURL.replace("{1}", serverId);
|
||||
tempURL = tempURL.replace("{2}", type);
|
||||
tempURL = tempURL.replace("{3}", getGlobalConfig().discord.webhook.pass);
|
||||
|
||||
httpGet(
|
||||
tempURL,
|
||||
"",
|
||||
function (data) {
|
||||
|
||||
},
|
||||
function (data) {
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: economy.js
|
||||
// DESC: Provides economy/financial utils, functions and usage
|
||||
@@ -187,19 +188,19 @@ function repossessFirstAsset(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getAllVehiclesOwnedByPlayer(client) {
|
||||
return getServerData().vehicles.filter((v) => v.ownerType == VRR_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
return getServerData().vehicles.filter((v) => v.ownerType == AGRP_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAllBusinessesOwnedByPlayer(client) {
|
||||
return getServerData().businesses.filter((b) => b.ownerType == VRR_BIZOWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
return getServerData().businesses.filter((b) => b.ownerType == AGRP_BIZ_OWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAllHousesOwnedByPlayer(client) {
|
||||
return getServerData().houses.filter((h) => h.ownerType == VRR_HOUSEOWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
return getServerData().houses.filter((h) => h.ownerType == AGRP_HOUSE_OWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: email.js
|
||||
// DESC: Provides email handling, functions and usage
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: event.js
|
||||
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
|
||||
@@ -18,11 +19,7 @@ function initEventScript() {
|
||||
function addAllEventHandlers() {
|
||||
addEventHandler("onResourceStart", onResourceStart);
|
||||
addEventHandler("onResourceStop", onResourceStop);
|
||||
addEventHandler("onServerStop", onResourceStop);
|
||||
|
||||
addEventHandler("onProcess", onProcess);
|
||||
addEventHandler("onEntityProcess", onEntityProcess);
|
||||
|
||||
addEventHandler("onPlayerConnect", onPlayerConnect);
|
||||
addEventHandler("onPlayerJoin", onPlayerJoin);
|
||||
addEventHandler("onPlayerJoined", onPlayerJoined);
|
||||
@@ -30,15 +27,12 @@ function addAllEventHandlers() {
|
||||
addEventHandler("onPlayerQuit", onPlayerQuit);
|
||||
addEventHandler("onElementStreamIn", onElementStreamIn);
|
||||
addEventHandler("onElementStreamOut", onElementStreamOut);
|
||||
|
||||
addEventHandler("onPedSpawn", onPedSpawn);
|
||||
addEventHandler("onPedEnterVehicle", onPedEnteringVehicle);
|
||||
addEventHandler("onPedExitVehicle", onPedExitingVehicle);
|
||||
|
||||
addEventHandler("onPedEnteringVehicle", onPedEnteringVehicle);
|
||||
addEventHandler("onPedExitingVehicle", onPedExitingVehicle);
|
||||
|
||||
//addEventHandler("OnPlayerCommand", onPlayerCommand);
|
||||
addEventHandler("onPedEnteredVehicleEx", onPedEnteredVehicle);
|
||||
addEventHandler("onPedExitedVehicleEx", onPedExitedVehicle);
|
||||
addEventHandler("onPedEnteredSphereEx", onPedEnteredSphere);
|
||||
addEventHandler("onPedExitedSphereEx", onPedExitedSphere);
|
||||
addEventHandler("OnPickupPickedUp", onPedPickupPickedUp);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -56,9 +50,9 @@ function onPlayerConnect(event, ipAddress, port) {
|
||||
function onPlayerJoin(event, client) {
|
||||
logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`);
|
||||
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
//if (isFadeCameraSupported()) {
|
||||
// fadeCamera(client, true, 1.0);
|
||||
//}
|
||||
|
||||
//if(isCustomCameraSupported()) {
|
||||
// showConnectCameraToPlayer(client);
|
||||
@@ -78,7 +72,7 @@ function onPlayerJoin(event, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function onPlayerJoined(event, client) {
|
||||
|
||||
//initClient(client);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -115,31 +109,52 @@ function onPlayerQuit(event, client, quitReasonId) {
|
||||
}
|
||||
}
|
||||
|
||||
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
|
||||
|
||||
getClients().forEach(forClient => {
|
||||
let reasonText = getGroupedLocaleString(forClient, "DisconnectReasons", quitReasonId);
|
||||
messagePlayerNormal(forClient, getLocaleString(forClient, "PlayerLeftServer", getPlayerName(client), reasonText));
|
||||
});
|
||||
//messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
|
||||
|
||||
//if (isPlayerFishing(client)) {
|
||||
// stopFishing(client);
|
||||
//}
|
||||
|
||||
if (isPlayerInPaintBall(client)) {
|
||||
stopPaintBall(client);
|
||||
}
|
||||
|
||||
if (isPlayerOnJobRoute(client)) {
|
||||
stopJobRoute(client);
|
||||
}
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
|
||||
if (isPlayerLoggedIn(client)) {
|
||||
savePlayerToDatabase(client);
|
||||
resetClientStuff(client);
|
||||
getServerData().clients[getPlayerId(client)] = null;
|
||||
}
|
||||
|
||||
if (getPlayerData(client).loginTimeout != null) {
|
||||
clearTimeout(getPlayerData(client).loginTimeout);
|
||||
}
|
||||
|
||||
playerResourceReady[client.index] = false;
|
||||
playerResourceStarted[client.index] = false;
|
||||
playerInitialized[client.index] = false;
|
||||
playerGUIReady[client.index] = false;
|
||||
|
||||
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
|
||||
getClients().forEach(forClient => {
|
||||
let reasonText = getGroupedLocaleString(forClient, "DisconnectReasons", quitReasonId);
|
||||
messagePlayerNormal(forClient, getLocaleString(forClient, "PlayerLeftServer", getPlayerName(client), reasonText));
|
||||
});
|
||||
|
||||
getServerData().clients[getPlayerId(client)] = null;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function onPlayerChat(event, client, messageText) {
|
||||
processPlayerChat(client, messageText);
|
||||
event.preventDefault();
|
||||
processPlayerChat(client, messageText);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -163,7 +178,7 @@ function onEntityProcess(event, entity) {
|
||||
function onPedEnteringVehicle(event, ped, vehicle, seat) {
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_ENTERINGVEHICLE;
|
||||
|
||||
if (!getVehicleData(vehicle)) {
|
||||
return false;
|
||||
@@ -172,12 +187,12 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) {
|
||||
if (getVehicleData(vehicle).locked) {
|
||||
if (doesPlayerHaveVehicleKeys(client, vehicle)) {
|
||||
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) {
|
||||
messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`);
|
||||
messagePlayerTip(client, getLocaleString(client, "VehicleLockedCommandTip", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))}{MAINCOLOUR}`));
|
||||
} else {
|
||||
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
|
||||
messagePlayerTip(client, getLocaleString(client, "VehicleLockedCommandTip", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}/lock{MAINCOLOUR}`));
|
||||
}
|
||||
} else {
|
||||
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
|
||||
messagePlayerNormal(client, messagePlayerTip(client, getLocaleString(client, "VehicleLockedCantUnlock", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`)));
|
||||
}
|
||||
|
||||
//getPlayerData(client).enteringVehicle = null;
|
||||
@@ -198,7 +213,7 @@ function onPedExitingVehicle(event, ped, vehicle) {
|
||||
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_EXITINGVEHICLE;
|
||||
}
|
||||
|
||||
if (!getVehicleData(vehicle).spawnLocked) {
|
||||
@@ -230,230 +245,138 @@ function onResourceStop(event, resource) {
|
||||
if (resource == thisResource) {
|
||||
kickAllClients();
|
||||
saveServerDataToDatabase();
|
||||
disconnectFromDatabase(persistentDatabaseConnection, true);
|
||||
collectAllGarbage();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPlayerEnteredSphere(client, sphere) {
|
||||
function onPedEnteredSphere(event, ped, sphere) {
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPlayerExitedSphere(client, sphere) {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
|
||||
if (client == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicle = null;
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
vehicle = getVehicleFromIVNetworkId(clientVehicle);
|
||||
} else {
|
||||
if (getPlayerPed(client) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
await waitUntil(() => client != null && getPlayerPed(client) != null && getPlayerVehicle(client) != null);
|
||||
|
||||
vehicle = getPlayerVehicle(client);
|
||||
}
|
||||
|
||||
if (!getVehicleData(vehicle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("agrp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
|
||||
|
||||
getPlayerData(client).lastVehicle = vehicle;
|
||||
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
|
||||
|
||||
if (getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) {
|
||||
vehicle.engine = getVehicleData(vehicle).engine;
|
||||
|
||||
if (getVehicleData(vehicle).buyPrice > 0) {
|
||||
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
|
||||
resetVehiclePosition(vehicle);
|
||||
} else if (getVehicleData(vehicle).rentPrice > 0) {
|
||||
if (getVehicleData(vehicle).rentedBy != client) {
|
||||
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
|
||||
resetVehiclePosition(vehicle);
|
||||
} else {
|
||||
messagePlayerAlert(client, `You are renting this ${getVehicleName(vehicle)} for {ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute. {MAINCOLOUR}Use {ALTCOLOUR}/stoprent {MAINCOLOUR}if you want to stop renting it.`);
|
||||
}
|
||||
} else {
|
||||
let ownerName = "Nobody";
|
||||
let ownerType = "None";
|
||||
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
|
||||
switch (getVehicleData(vehicle).ownerType) {
|
||||
case VRR_VEHOWNER_CLAN:
|
||||
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
|
||||
ownerType = "clan";
|
||||
break;
|
||||
|
||||
case VRR_VEHOWNER_JOB:
|
||||
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
|
||||
ownerType = "job";
|
||||
break;
|
||||
|
||||
case VRR_VEHOWNER_PLAYER:
|
||||
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
|
||||
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
|
||||
ownerType = "player";
|
||||
break;
|
||||
|
||||
case VRR_VEHOWNER_BIZ:
|
||||
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
|
||||
ownerType = "business";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`);
|
||||
}
|
||||
|
||||
if (!getVehicleData(vehicle).engine) {
|
||||
if (getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
|
||||
if (doesPlayerHaveVehicleKeys(client, vehicle)) {
|
||||
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
|
||||
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
|
||||
} else {
|
||||
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
|
||||
}
|
||||
} else {
|
||||
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
|
||||
|
||||
}
|
||||
}
|
||||
resetVehiclePosition(vehicle);
|
||||
}
|
||||
|
||||
let currentSubAccount = getPlayerCurrentSubAccount(client);
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
|
||||
if (getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
|
||||
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
|
||||
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
if (isPlayerOnJobRoute(client)) {
|
||||
if (vehicle == getPlayerJobRouteVehicle(client)) {
|
||||
stopReturnToJobVehicleCountdown(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getVehicleData(vehicle).streamingRadioStation != -1) {
|
||||
if (getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) {
|
||||
playRadioStreamForPlayer(client, getServerData().radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
|
||||
}
|
||||
// Handled client-side since server spheres aren't showing on GTAC atm (bug)
|
||||
//if (isPlayerOnJobRoute(client)) {
|
||||
// if (sphere == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) {
|
||||
// playerArrivedAtJobRouteLocation(client);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPlayerExitedVehicle(client, vehicle) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
||||
|
||||
stopRadioStreamForPlayer(client);
|
||||
|
||||
if (!getVehicleData(vehicle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
if (isPlayerOnJobRoute(client)) {
|
||||
if (vehicle == getPlayerJobRouteVehicle(client)) {
|
||||
startReturnToJobVehicleCountdown(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("agrp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
|
||||
function onPedExitedSphere(event, ped, sphere) {
|
||||
//if (ped.isType(ELEMENT_PLAYER)) {
|
||||
// let client = getClientFromPlayerElement(ped);
|
||||
//}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPlayerDeath(client, position) {
|
||||
function onPedPickupPickedUp(event, ped, pickup) {
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
|
||||
//if (isPlayerOnJobRoute(client)) {
|
||||
// if (pickup == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) {
|
||||
// playerArrivedAtJobRouteLocation(client);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPedWasted(event, ped, killerPed, weapon, pedPiece) {
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let killerClient = null;
|
||||
if (killerPed != null && killerPed.type == ELEMENT_PLAYER) {
|
||||
killerClient = getClientFromPlayerElement(killerPed);
|
||||
}
|
||||
onPlayerWasted(getClientFromPlayerElement(ped), killerClient, weapon, pedPiece);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPlayerDeath(client, killer, weapon, pedPiece) {
|
||||
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`);
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_DEAD;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_DEAD;
|
||||
updatePlayerSpawnedState(client, false);
|
||||
setPlayerControlState(client, false);
|
||||
setPlayerRenderLabelsState(client, false);
|
||||
setTimeout(function () {
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, false, 1.0);
|
||||
}
|
||||
setTimeout(function () {
|
||||
if (getPlayerCurrentSubAccount(client).inJail) {
|
||||
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
|
||||
despawnPlayer(client);
|
||||
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
|
||||
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
|
||||
if (isPlayerInPaintBall(client)) {
|
||||
getPlayerData(killer).paintBallKills++;
|
||||
getPlayerData(client).paintBallDeaths++;
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
if (getPlayerData(killer).paintBallDeaths >= getGlobalConfig().paintBallMaxKills) {
|
||||
let paintBallPlayers = getAllPlayersInBusiness(getPlayerData(client).paintBallBusiness);
|
||||
let winner = paintBallPlayers[i];
|
||||
for (let i in paintBallPlayers) {
|
||||
if (getPlayerData(paintBallPlayers[i]).paintBallKills > getPlayerData(winner).paintBallKills) {
|
||||
winner = paintBallPlayers[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_MAFIA_ONE) {
|
||||
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestJail.position, closestJail.heading);
|
||||
for (let i in paintBallPlayers) {
|
||||
showSmallGameMessage(paintBallPlayers[i], `${getLocaleString(paintBallPlayers[i], "PaintBallEnded")} ${getLocaleString(paintBallPlayers[i], "Winners", `${getCharacterFullName(winner)}`)}`);
|
||||
stopPaintBall(paintBallPlayers[i]);
|
||||
}
|
||||
} else {
|
||||
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||
respawnPlayerForPaintBall(client);
|
||||
}
|
||||
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
updatePlayerSpawnedState(client, true);
|
||||
makePlayerStopAnimation(client);
|
||||
setPlayerControlState(client, true);
|
||||
resetPlayerBlip(client);
|
||||
setPlayerRenderLabelsState(client, true);
|
||||
} else {
|
||||
let closestHospital = getClosestHospital(getPlayerPosition(client));
|
||||
despawnPlayer(client);
|
||||
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
|
||||
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
|
||||
if (getPlayerCurrentSubAccount(client).inJail) {
|
||||
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
|
||||
despawnPlayer(client);
|
||||
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
|
||||
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
|
||||
if (getGame() == VRR_GAME_MAFIA_ONE) {
|
||||
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestHospital.position, closestHospital.heading);
|
||||
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
updatePlayerSpawnedState(client, true);
|
||||
makePlayerStopAnimation(client);
|
||||
setPlayerControlState(client, true);
|
||||
resetPlayerBlip(client);
|
||||
} else {
|
||||
let closestHospital = getClosestHospital(getPlayerPosition(client));
|
||||
despawnPlayer(client);
|
||||
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
|
||||
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
|
||||
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||
}
|
||||
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
|
||||
updatePlayerSpawnedState(client, true);
|
||||
makePlayerStopAnimation(client);
|
||||
setPlayerControlState(client, true);
|
||||
resetPlayerBlip(client);
|
||||
setPlayerRenderLabelsState(client, true);
|
||||
updatePlayerSpawnedState(client, true);
|
||||
makePlayerStopAnimation(client);
|
||||
setPlayerControlState(client, true);
|
||||
resetPlayerBlip(client);
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
|
||||
/*
|
||||
let queryData = [
|
||||
["log_death_server", getServerId()]
|
||||
["log_death_who_died", getPlayerCurrentSubAccount(client).databaseId],
|
||||
@@ -464,6 +387,7 @@ function onPlayerDeath(client, position) {
|
||||
];
|
||||
let queryString = createDatabaseInsertQuery("log_death", queryData);
|
||||
addToQueryQueue(queryString);
|
||||
*/
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -490,7 +414,7 @@ async function onPlayerSpawn(client) {
|
||||
await waitUntil(() => client != null && getPlayerPed(client) != null);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
|
||||
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
|
||||
if (!getPlayerData(client)) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
|
||||
getPlayerData(targetClient).customDisconnectReason = `Kicked - Spawn bug. Data invalid.`;
|
||||
@@ -498,7 +422,7 @@ async function onPlayerSpawn(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
|
||||
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
|
||||
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without logging in.`;
|
||||
@@ -506,7 +430,7 @@ async function onPlayerSpawn(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
|
||||
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
|
||||
if (getPlayerData(client).currentSubAccount == -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
|
||||
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without selecting a character.`;
|
||||
@@ -516,26 +440,23 @@ async function onPlayerSpawn(client) {
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
|
||||
|
||||
if (getGame() == VRR_GAME_GTA_IV) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
|
||||
setEntityData(getPlayerPed(client), "agrp.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
|
||||
setEntityData(getPlayerPed(client), "agrp.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
|
||||
if (isGameFeatureSupported("pedScale")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
|
||||
setEntityData(getPlayerPed(client), "agrp.scale", getPlayerCurrentSubAccount(client).pedScale, true);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
|
||||
setEntityData(getPlayerPed(client), "agrp.scale", getPlayerCurrentSubAccount(client).pedScale, true);
|
||||
//if (isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
|
||||
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if (isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isCustomCameraSupported()) {
|
||||
if (isCustomCameraSupported() && getGame() != AGRP_GAME_GTA_IV && getGame() != AGRP_GAME_GTA_IV_EFLC) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Restoring ${getPlayerDisplayForConsole(client)}'s camera`);
|
||||
restorePlayerCamera(client);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
|
||||
if (areServerElementsSupported()) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
|
||||
getPlayerData(client).ped = getPlayerPed(client);
|
||||
}
|
||||
|
||||
@@ -544,14 +465,18 @@ async function onPlayerSpawn(client) {
|
||||
//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"));
|
||||
|
||||
if (getGame() == VRR_GAME_MAFIA_ONE) {
|
||||
setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition);
|
||||
setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading);
|
||||
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
|
||||
}
|
||||
// Tried this. Doesn't work for some reason.
|
||||
// Mafia Connected needs fixed to set position on spawn.
|
||||
//if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
// setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition);
|
||||
// setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading);
|
||||
// setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
|
||||
//}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
|
||||
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
|
||||
if (isGameFeatureSupported("interior")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
|
||||
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
|
||||
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
|
||||
@@ -563,30 +488,37 @@ async function onPlayerSpawn(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
|
||||
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
|
||||
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
|
||||
if (isGameFeatureSupported("pedArmour")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
|
||||
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
|
||||
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
|
||||
setPlayer2DRendering(client, true, true, true, true, true, true);
|
||||
if (isGameFeatureSupported("rendering2D")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
|
||||
setPlayer2DRendering(client, true, true, true, true, true, true);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
|
||||
if (isSnowSupported()) {
|
||||
if (isGameFeatureSupported("snow")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
|
||||
updatePlayerSnowState(client);
|
||||
}
|
||||
|
||||
if (areServerElementsSupported() && getGame() == VRR_GAME_GTA_SA) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
|
||||
if (areServerElementsSupported() && isGameFeatureSupported("walkStyle")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walking style for ${getPlayerDisplayForConsole(client)}`);
|
||||
setEntityData(getPlayerPed(client), "agrp.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
|
||||
}
|
||||
|
||||
if (isGameFeatureSupported("fightStyle")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player fighting style for ${getPlayerDisplayForConsole(client)}`);
|
||||
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
|
||||
if (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
|
||||
updatePlayerShowLogoState(client, true);
|
||||
if (isGameFeatureSupported("rendering2D")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
|
||||
updatePlayerShowLogoState(client, (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)));
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
|
||||
@@ -626,7 +558,7 @@ async function onPlayerSpawn(client) {
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
|
||||
if (areServerElementsSupported()) {
|
||||
syncPlayerProperties(client);
|
||||
@@ -638,11 +570,10 @@ async function onPlayerSpawn(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
|
||||
updatePlayerCash(client);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
|
||||
updateAllPlayerNameTags();
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`);
|
||||
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
|
||||
if (isGameFeatureSupported("customNametag")) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`);
|
||||
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
|
||||
}
|
||||
|
||||
if (!areServerElementsSupported()) {
|
||||
sendAllBusinessesToPlayer(client);
|
||||
@@ -657,27 +588,44 @@ async function onPlayerSpawn(client) {
|
||||
|
||||
getPlayerData(client).payDayTickStart = sdl.ticks;
|
||||
|
||||
// Locales are handled via resource files now. No need to send anymore, but kept in case revert is needed.
|
||||
//sendPlayerLocaleStrings(client);
|
||||
|
||||
// Stop playing intro music and any other radio
|
||||
stopRadioStreamForPlayer(client);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
|
||||
updateAllPlayerNameTags();
|
||||
|
||||
setPlayerRenderLabelsState(client, true);
|
||||
setPlayerWeaponDamageEvent(client, AGRP_WEAPON_DAMAGE_EVENT_NORMAL);
|
||||
|
||||
// Start playing business/house radio if in one
|
||||
let businessId = getPlayerBusiness(client);
|
||||
let houseId = getPlayerHouse(client);
|
||||
if (businessId != -1) {
|
||||
if (getBusinessData(businessId).streamingRadioStation != -1) {
|
||||
playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(businessId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
|
||||
}
|
||||
} else if (houseId != -1) {
|
||||
if (getHouseData(houseId).streamingRadioStation != -1) {
|
||||
playRadioStreamForPlayer(client, getRadioStationData(getHouseData(houseId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
|
||||
if (areServerElementsSupported()) {
|
||||
if (getGlobalConfig().playerStreamInDistance == -1 || getGlobalConfig().playerStreamOutDistance == -1) {
|
||||
getPlayerPed(client).netFlags.distanceStreaming = false;
|
||||
} else {
|
||||
setElementStreamInDistance(getPlayerPed(client), getServerConfig().playerStreamInDistance);
|
||||
setElementStreamOutDistance(getPlayerPed(client), getServerConfig().playerStreamOutDistance);
|
||||
}
|
||||
|
||||
resetPlayerBlip(client);
|
||||
}
|
||||
|
||||
resetPlayerBlip(client)
|
||||
// Radio stuff must be last thing sent to client because it hangs the client for a second, which blocks processing of other incoming packets
|
||||
// Start playing business/house radio if in one
|
||||
if (getPlayerCurrentSubAccount(client).interior != getGameConfig().mainWorldInterior[getGame()] || getPlayerCurrentSubAccount(client).dimension != getGameConfig().mainWorldDimension[getGame()]) {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
let houseId = getPlayerHouse(client);
|
||||
if (businessId != -1) {
|
||||
if (getBusinessData(businessId).streamingRadioStation != -1) {
|
||||
playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(businessId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
|
||||
}
|
||||
} else if (houseId != -1) {
|
||||
if (getHouseData(houseId).streamingRadioStation != -1) {
|
||||
playRadioStreamForPlayer(client, getRadioStationData(getHouseData(houseId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
|
||||
}
|
||||
} else {
|
||||
stopRadioStreamForPlayer(client);
|
||||
}
|
||||
} else {
|
||||
stopRadioStreamForPlayer(client);
|
||||
}
|
||||
|
||||
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
|
||||
}
|
||||
@@ -690,4 +638,169 @@ function onPlayerCommand(event, client, command, params) {
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPedExitedVehicle(event, ped, vehicle, seat) {
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
if (client != null) {
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
|
||||
stopRadioStreamForPlayer(client);
|
||||
|
||||
if (!getVehicleData(vehicle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
if (isPlayerOnJobRoute(client)) {
|
||||
if (vehicle == getPlayerJobRouteVehicle(client)) {
|
||||
startReturnToJobVehicleCountdown(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("agrp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPedEnteredVehicle(event, ped, vehicle, seat) {
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
if (client != null) {
|
||||
if (getPlayerData(client) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
vehicle = getVehicleFromIVNetworkId(clientVehicle);
|
||||
}
|
||||
|
||||
if (!getVehicleData(vehicle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("agrp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
|
||||
|
||||
getPlayerData(client).lastVehicle = vehicle;
|
||||
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
|
||||
|
||||
if (getPlayerVehicleSeat(client) == AGRP_VEHSEAT_DRIVER) {
|
||||
vehicle.engine = getVehicleData(vehicle).engine;
|
||||
|
||||
if (getVehicleData(vehicle).buyPrice > 0) {
|
||||
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
|
||||
resetVehiclePosition(vehicle);
|
||||
} else if (getVehicleData(vehicle).rentPrice > 0) {
|
||||
if (getVehicleData(vehicle).rentedBy != client) {
|
||||
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
|
||||
resetVehiclePosition(vehicle);
|
||||
} else {
|
||||
messagePlayerAlert(client, getLocaleString(client, "CurrentlyRentingThisVehicle", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}`, `{ALTCOLOUR}/stoprent{MAINCOLOUR}`));
|
||||
}
|
||||
} else {
|
||||
let ownerName = "Nobody";
|
||||
let ownerType = getLocaleString(client, "NotOwned");
|
||||
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
|
||||
switch (getVehicleData(vehicle).ownerType) {
|
||||
case AGRP_VEHOWNER_CLAN:
|
||||
ownerName = getClanData(getClanIndexFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
|
||||
ownerType = getLocaleString(client, "Clan");
|
||||
break;
|
||||
|
||||
case AGRP_VEHOWNER_JOB:
|
||||
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
|
||||
ownerType = getLocaleString(client, "Job");
|
||||
break;
|
||||
|
||||
case AGRP_VEHOWNER_PLAYER:
|
||||
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
|
||||
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
|
||||
ownerType = getLocaleString(client, "Player");
|
||||
break;
|
||||
|
||||
case AGRP_VEHOWNER_BIZ:
|
||||
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
|
||||
ownerType = getLocaleString(client, "Business");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
messagePlayerAlert(client, getLocaleString(client, "VehicleBelongsTo", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}${ownerName}{MAINCOLOUR}`, `{ALTCOLOUR}${ownerType}{MAINCOLOUR}`));
|
||||
}
|
||||
|
||||
if (!getVehicleData(vehicle).engine) {
|
||||
if (getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
|
||||
if (doesPlayerHaveVehicleKeys(client, vehicle)) {
|
||||
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
|
||||
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
|
||||
} else {
|
||||
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
|
||||
}
|
||||
} else {
|
||||
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
|
||||
|
||||
}
|
||||
}
|
||||
resetVehiclePosition(vehicle);
|
||||
}
|
||||
|
||||
let currentSubAccount = getPlayerCurrentSubAccount(client);
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
if (getVehicleData(vehicle).ownerType == AGRP_VEHOWNER_JOB) {
|
||||
if (getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
|
||||
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
|
||||
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
if (isPlayerOnJobRoute(client)) {
|
||||
if (vehicle == getPlayerJobRouteVehicle(client)) {
|
||||
stopReturnToJobVehicleCountdown(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let radioStationIndex = getVehicleData(vehicle).streamingRadioStationIndex;
|
||||
if (radioStationIndex != -1) {
|
||||
if (getPlayerData(client).streamingRadioStation != radioStationIndex) {
|
||||
playRadioStreamForPlayer(client, getRadioStationData(radioStationIndex).url, true, getPlayerStreamingRadioVolume(client));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPedEnteringVehicle(event, ped, vehicle, seat) {
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
if (client != null) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function onPedExitingVehicle(event, ped, vehicle, seat) {
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
if (client != null) {
|
||||
onPlayerExitingVehicle(client, vehicle, seat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,15 +1,209 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: fishing.js
|
||||
// DESC: Provides fishing functions and commands
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Fishing Catch Types (Probably not going to be used, in favor of items and their use type)
|
||||
const AGRP_FISHING_CATCH_TYPE_NONE = 0;
|
||||
const AGRP_FISHING_CATCH_TYPE_FISH = 1;
|
||||
const AGRP_FISHING_CATCH_TYPE_JUNK = 2;
|
||||
|
||||
// Fishing Line States
|
||||
const AGRP_FISHING_LINE_STATE_NONE = 0;
|
||||
const AGRP_FISHING_LINE_STATE_READY = 1;
|
||||
const AGRP_FISHING_LINE_STATE_CASTING = 2;
|
||||
const AGRP_FISHING_LINE_STATE_CASTED = 3;
|
||||
const AGRP_FISHING_LINE_STATE_REELING = 4;
|
||||
const AGRP_FISHING_LINE_STATE_HOOKED = 5;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let fishingCollectables = [
|
||||
// Fish
|
||||
["Salmon", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Tuna", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Crab", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Trout", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Sea Bass", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Shark", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Turtle", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Manta Ray", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Cat Fish", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Blue Marlin", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
|
||||
// Junk
|
||||
["Rusty Can", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Old Pants", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Old Shoes", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Garbage", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Baby Diaper", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Old Tire", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Old Car Battery", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Horse Hoove", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Soggy Log", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Soggy Dildo", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Clump of Seaweed", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let fishingAnimations = {
|
||||
[AGRP_GAME_GTA_III]: {
|
||||
"fishingLineCasting": "bathit1",
|
||||
"fishingLineReeling": "aimdown",
|
||||
},
|
||||
[AGRP_GAME_GTA_VC]: {
|
||||
"fishingLineCasting": "frontpunch",
|
||||
"fishingLineReeling": "aimdown",
|
||||
},
|
||||
[AGRP_GAME_GTA_SA]: {
|
||||
"fishingLineCasting": "none",
|
||||
"fishingLineReeling": "none",
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let fishingParticleEffects = {
|
||||
[AGRP_GAME_GTA_III]: {
|
||||
"fishingLineCast": [
|
||||
"MediumSprayingWater",
|
||||
0.2,
|
||||
500
|
||||
],
|
||||
"fishingLineReel": [
|
||||
"MediumSprayingWater",
|
||||
0.2,
|
||||
500
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initFishingScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Fishing]: Initializing fishing script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Fishing]: Fishing script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function castFishingLineCommand(command, params, client) {
|
||||
if (!isPlayerInFishingSpot(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantFishHere"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveItemOfUseTypeEquipped(client, AGRP_ITEM_USE_TYPE_FISHINGROD)) {
|
||||
messagePlayerError(client, getLocaleString(client, "NeedFishingRod"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveFishingLineCast(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "FishingLineAlreadyCast"));
|
||||
return false;
|
||||
}
|
||||
|
||||
let maxStrength = getGlobalConfig().fishingCastMaxStrength;
|
||||
let minStrength = getGlobalConfig().fishingCastMinStrength;
|
||||
let keyDuration = getPlayerData(client).keyBindDuration;
|
||||
|
||||
let strength = Math.round((maxStrength - minStrength) * (keyDuration / getGlobalConfig().fishingLineCastDuration));
|
||||
|
||||
castPlayerFishingLine(client, strength);
|
||||
|
||||
let messageText = getLocaleString(client, "FishingCastCommandHelp");
|
||||
if (doesPlayerHaveKeyBindForCommand(client, "fish")) {
|
||||
messageText = getLocaleString(client, "FishingCastKeyPressHelp");
|
||||
}
|
||||
showSmallGameMessage(client, messageText);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetFishingLineCommand(client) {
|
||||
if (doesPlayerHaveFishingLineCast(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "FishingLineNotCast"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveItemOfUseTypeEquipped(client, AGRP_ITEM_USE_TYPE_FISHINGROD)) {
|
||||
messagePlayerError(client, getLocaleString(client, "NeedFishingRod"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isPlayerInFishingSpot(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantFishHere"));
|
||||
return false;
|
||||
}
|
||||
|
||||
makePedStopAnimation(getPlayerPed(client));
|
||||
|
||||
let messageText = getLocaleString(client, "FishingCastCommandHelp");
|
||||
if (doesPlayerHaveKeyBindForCommand(client, "fish")) {
|
||||
messageText = getLocaleString(client, "FishingCastKeyPressHelp");
|
||||
}
|
||||
|
||||
showSmallGameMessage(client, messageText);
|
||||
|
||||
getPlayerData(client).fishingLineState = AGRP_FISHING_LINE_STATE_NONE;
|
||||
getPlayerData(client).fishingLineCastStart = 0;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveFishingLineCast(client) {
|
||||
return getPlayerData(client).fishingLineCastStart != 0;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function castPlayerFishingLine(client, strength) {
|
||||
let frontPosition = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), strength * 2);
|
||||
|
||||
makePlayerPlayAnimation(client, getAnimationFromParams(fishingAnimations[getGame()]["fishingLineCasting"]));
|
||||
|
||||
setTimeout(function () {
|
||||
let particleEffectName = fishingParticleEffects[getGame()].fishingLineCast[1];
|
||||
showParticleEffect(frontPosition, getGameConfig().particleEffects[getGame()][particleEffectName], fishingParticleEffects[getGame()].fishingLineCast[1], fishingParticleEffects[getGame()].fishingLineCast[2]);
|
||||
|
||||
getPlayerData(client).fishingLineCastPosition = frontPosition;
|
||||
getPlayerData(client).fishingLineState = AGRP_FISHING_LINE_STATE_CASTED;
|
||||
}, strength * 10);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerInFishingSpot(client) {
|
||||
if (isPlayerOnBoat(client)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let closestFishingLocation = getClosestFishingLocation(getPlayerPosition(client));
|
||||
if (closestFishingLocation != false) {
|
||||
if (getDistance(getPlayerPosition(client), closestFishingLocation) < getGlobalConfig().fishingSpotDistance) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerFishing(client) {
|
||||
return (getPlayerData(client).fishingLineState != AGRP_FISHING_LINE_STATE_NONE);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerFishing(client) {
|
||||
return (getPlayerData(client).fishingLineState != AGRP_FISHING_LINE_STATE_NONE);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: forensics.js
|
||||
// DESC: Provides forensics functions and commands (bullet casings, blood, etc)
|
||||
@@ -8,13 +9,13 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Forensic Types
|
||||
const VRR_FORENSICS_NONE = 0;
|
||||
const VRR_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
|
||||
const VRR_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit when somebody is shot
|
||||
const VRR_FORENSICS_BODY = 3; // Body. A dead body lol
|
||||
const VRR_FORENSICS_HAIR = 4; // Hair. Automatically applied to
|
||||
const VRR_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
|
||||
const VRR_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank
|
||||
const VRR_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)
|
||||
const AGRP_FORENSICS_NONE = 0;
|
||||
const AGRP_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
|
||||
const AGRP_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit and outfit worn when somebody is shot
|
||||
const AGRP_FORENSICS_BODY = 3; // Body. A dead body lol
|
||||
const AGRP_FORENSICS_HAIR = 4; // Hair.
|
||||
const AGRP_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
|
||||
const AGRP_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank and unfinished food items when eaten
|
||||
const AGRP_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: gate.js
|
||||
// DESC: Provides gate functions and commands
|
||||
@@ -8,14 +9,14 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Gate Owner Types
|
||||
const VRR_GATEOWNER_NONE = 0; // Not owned
|
||||
const VRR_GATEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
|
||||
const VRR_GATEOWNER_JOB = 2; // Owned by a job
|
||||
const VRR_GATEOWNER_CLAN = 3; // Owned by a clan
|
||||
const VRR_GATEOWNER_FACTION = 4; // Owned by a faction
|
||||
const VRR_GATEOWNER_PUBLIC = 5; // Public gate. Technically not owned. This probably won't be used.
|
||||
const VRR_GATEOWNER_BUSINESS = 6; // Owned by a business. Back lots, unloading areas, and other stuff like that
|
||||
const VRR_GATEOWNER_HOUSE = 7; // Owned by a house. Like for mansions with closed private areas.
|
||||
const AGRP_GATEOWNER_NONE = 0; // Not owned
|
||||
const AGRP_GATEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
|
||||
const AGRP_GATEOWNER_JOB = 2; // Owned by a job
|
||||
const AGRP_GATEOWNER_CLAN = 3; // Owned by a clan
|
||||
const AGRP_GATEOWNER_FACTION = 4; // Owned by a faction
|
||||
const AGRP_GATEOWNER_PUBLIC = 5; // Public gate. Technically not owned. This probably won't be used.
|
||||
const AGRP_GATEOWNER_BUSINESS = 6; // Owned by a business. Back lots, unloading areas, and other stuff like that
|
||||
const AGRP_GATEOWNER_HOUSE = 7; // Owned by a house. Like for mansions with closed private areas.
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -27,7 +28,7 @@ class GateData {
|
||||
this.enabled = false;
|
||||
this.position = toVector3(0.0, 0.0, 0.0);
|
||||
this.locked = true;
|
||||
this.ownerType = VRR_GATEOWNER_NONE;
|
||||
this.ownerType = AGRP_GATEOWNER_NONE;
|
||||
this.ownerId = 0;
|
||||
|
||||
if (dbAssoc) {
|
||||
@@ -54,17 +55,17 @@ function initGateScript() {
|
||||
function doesPlayerHaveGateKeys(client, vehicle) {
|
||||
let gateData = getGateData(vehicle);
|
||||
|
||||
if (gateData.ownerType == VRR_GATEOWNER_PUBLIC) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_PUBLIC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (gateData.ownerType == VRR_GATEOWNER_PLAYER) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_PLAYER) {
|
||||
if (gateData.ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (gateData.ownerType == VRR_GATEOWNER_CLAN) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_CLAN) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -76,7 +77,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
|
||||
}
|
||||
}
|
||||
|
||||
if (gateData.ownerType == VRR_GATEOWNER_FACTION) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_FACTION) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageFactions"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -88,7 +89,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
|
||||
}
|
||||
}
|
||||
|
||||
if (gateData.ownerType == VRR_GATEOWNER_JOB) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_JOB) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -98,7 +99,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
|
||||
}
|
||||
}
|
||||
|
||||
if (gateData.ownerType == VRR_GATEOWNER_BUSINESS) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_BUSINESS) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -108,7 +109,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
|
||||
}
|
||||
}
|
||||
|
||||
if (gateData.ownerType == VRR_GATEOWNER_HOUSE) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_HOUSE) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: gps.js
|
||||
// DESC: Provides GPS functions and commands
|
||||
@@ -8,36 +9,36 @@
|
||||
// ===========================================================================
|
||||
|
||||
// GPS State Types
|
||||
const VRR_GPS_TYPE_NONE = 0; // None (invalid)
|
||||
const VRR_GPS_TYPE_BUSINESS = 1; // Business
|
||||
const VRR_GPS_TYPE_POLICE = 2; // Police Station
|
||||
const VRR_GPS_TYPE_HOSPITAL = 3; // Hospital
|
||||
const VRR_GPS_TYPE_JOB = 4; // Job
|
||||
const VRR_GPS_TYPE_GAMELOC = 5; // Game Location
|
||||
const AGRP_GPS_TYPE_NONE = 0; // None (invalid)
|
||||
const AGRP_GPS_TYPE_BUSINESS = 1; // Business
|
||||
const AGRP_GPS_TYPE_POLICE = 2; // Police Station
|
||||
const AGRP_GPS_TYPE_HOSPITAL = 3; // Hospital
|
||||
const AGRP_GPS_TYPE_JOB = 4; // Job
|
||||
const AGRP_GPS_TYPE_GAMELOC = 5; // Game Location
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function gpsCommand(command, params, client) {
|
||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessList")));
|
||||
|
||||
let locationType = VRR_GPS_TYPE_NONE;
|
||||
let useType = VRR_ITEM_USETYPE_NONE;
|
||||
let locationType = AGRP_GPS_TYPE_NONE;
|
||||
let useType = AGRP_ITEM_USE_TYPE_NONE;
|
||||
let blipColour = "white";
|
||||
|
||||
switch(toLowerCase(params)) {
|
||||
switch (toLowerCase(params)) {
|
||||
case "police":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_POLICE;
|
||||
locationType = AGRP_GPS_TYPE_POLICE;
|
||||
break;
|
||||
|
||||
case "hospital":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_HOSPITAL;
|
||||
locationType = AGRP_GPS_TYPE_HOSPITAL;
|
||||
break;
|
||||
|
||||
case "job":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_JOB;
|
||||
locationType = AGRP_GPS_TYPE_JOB;
|
||||
break;
|
||||
|
||||
case "skin":
|
||||
@@ -45,8 +46,8 @@ function gpsCommand(command, params, client) {
|
||||
case "clothes":
|
||||
case "player":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_SKIN;
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_SKIN;
|
||||
break;
|
||||
|
||||
case "gun":
|
||||
@@ -56,29 +57,29 @@ function gpsCommand(command, params, client) {
|
||||
case "wep":
|
||||
case "weps":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_WEAPON;
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_WEAPON;
|
||||
break;
|
||||
|
||||
case "food":
|
||||
case "eat":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_FOOD;
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_FOOD;
|
||||
break;
|
||||
|
||||
case "drink":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_DRINK;
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_DRINK;
|
||||
break;
|
||||
|
||||
case "alcohol":
|
||||
case "booze":
|
||||
case "bar":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_ALCOHOL;
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_ALCOHOL;
|
||||
break;
|
||||
|
||||
case "repair":
|
||||
@@ -87,8 +88,8 @@ function gpsCommand(command, params, client) {
|
||||
case "spray":
|
||||
case "fix":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_VEHREPAIR;
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_VEHREPAIR;
|
||||
break;
|
||||
|
||||
case "vehiclecolour":
|
||||
@@ -96,53 +97,53 @@ function gpsCommand(command, params, client) {
|
||||
case "carcolour":
|
||||
case "colour":
|
||||
blipColour = "businessBlue"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_VEHCOLOUR;
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_VEHCOLOUR;
|
||||
break;
|
||||
|
||||
default: {
|
||||
let itemTypeId = getItemTypeFromParams(params);
|
||||
if(getItemTypeData(itemTypeId) != false) {
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
blipColour = "businessBlue";
|
||||
if (getItemTypeData(itemTypeId) != false) {
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
blipColour = "businessBlue";
|
||||
useType = getItemTypeData(itemTypeId).useType;
|
||||
} else {
|
||||
let gameLocationId = getGameLocationFromParams(params);
|
||||
if(gameLocationId != false) {
|
||||
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
|
||||
}
|
||||
}
|
||||
let gameLocationId = getGameLocationFromParams(params);
|
||||
if (gameLocationId != false) {
|
||||
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(locationType == VRR_GPS_TYPE_NONE) {
|
||||
if (locationType == AGRP_GPS_TYPE_NONE) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidGPSLocation"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(locationType == VRR_GPS_TYPE_BUSINESS) {
|
||||
if (locationType == AGRP_GPS_TYPE_BUSINESS) {
|
||||
let businessId = getClosestBusinessWithBuyableItemOfUseType(useType);
|
||||
if(!businessId) {
|
||||
if (!businessId) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getBusinessData(businessId)) {
|
||||
if (!getBusinessData(businessId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
|
||||
return false;
|
||||
}
|
||||
|
||||
hideAllBlipsForPlayerGPS(client);
|
||||
hideAllBlipsForPlayerGPS(client);
|
||||
blinkGenericGPSBlipForPlayer(client, getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getColourByType(blipColour), 10);
|
||||
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
|
||||
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
|
||||
}
|
||||
|
||||
if(locationType == VRR_GPS_TYPE_GAMELOC) {
|
||||
hideAllBlipsForPlayerGPS(client);
|
||||
blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10);
|
||||
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
|
||||
return true;
|
||||
}
|
||||
if (locationType == AGRP_GPS_TYPE_GAMELOC) {
|
||||
hideAllBlipsForPlayerGPS(client);
|
||||
blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10);
|
||||
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: gui.js
|
||||
// DESC: Provides GUI functions and usage
|
||||
@@ -8,9 +9,15 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Prompts (used for client GUI prompt responses)
|
||||
const VRR_PROMPT_NONE = 0;
|
||||
const VRR_PROMPT_CREATEFIRSTCHAR = 1;
|
||||
const VRR_PROMPT_BIZORDER = 2;
|
||||
const AGRP_PROMPT_NONE = 0;
|
||||
const AGRP_PROMPT_CREATEFIRSTCHAR = 1;
|
||||
const AGRP_PROMPT_BIZORDER = 2;
|
||||
const AGRP_PROMPT_GIVEVEHTOCLAN = 3;
|
||||
const AGRP_PROMPT_GIVEBIZTOCLAN = 4;
|
||||
const AGRP_PROMPT_GIVEHOUSETOCLAN = 5;
|
||||
const AGRP_PROMPT_BUYBIZ = 6;
|
||||
const AGRP_PROMPT_BUYHOUSE = 7;
|
||||
const AGRP_PROMPT_RESETKEYBINDS = 8;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -22,21 +29,21 @@ function initGUIScript() {
|
||||
// ===========================================================================
|
||||
|
||||
function playerPromptAnswerNo(client) {
|
||||
if (getPlayerData(client).promptType == VRR_PROMPT_NONE) {
|
||||
if (getPlayerData(client).promptType == AGRP_PROMPT_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
|
||||
|
||||
switch (getPlayerData(client).promptType) {
|
||||
case VRR_PROMPT_CREATEFIRSTCHAR:
|
||||
case AGRP_PROMPT_CREATEFIRSTCHAR:
|
||||
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");
|
||||
getPlayerData(targetClient).customDisconnectReason = `Kicked - Didn't create a character`;
|
||||
setTimeout(function () { disconnectPlayer(client); }, 5000);
|
||||
break;
|
||||
|
||||
case VRR_PROMPT_BIZORDER:
|
||||
case AGRP_PROMPT_BIZORDER:
|
||||
if (getPlayerData(client).businessOrderAmount > 0) {
|
||||
if (canPlayerUseGUI(client)) {
|
||||
showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled");
|
||||
@@ -53,25 +60,25 @@ function playerPromptAnswerNo(client) {
|
||||
break;
|
||||
}
|
||||
|
||||
getPlayerData(client).promptType = VRR_PROMPT_NONE;
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_NONE;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function playerPromptAnswerYes(client) {
|
||||
if (getPlayerData(client).promptType == VRR_PROMPT_NONE) {
|
||||
if (getPlayerData(client).promptType == AGRP_PROMPT_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
|
||||
|
||||
switch (getPlayerData(client).promptType) {
|
||||
case VRR_PROMPT_CREATEFIRSTCHAR: {
|
||||
case AGRP_PROMPT_CREATEFIRSTCHAR: {
|
||||
showPlayerNewCharacterGUI(client);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_BIZORDER: {
|
||||
case AGRP_PROMPT_BIZORDER: {
|
||||
if (getPlayerData(client).businessOrderAmount > 0) {
|
||||
if (getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`);
|
||||
@@ -83,7 +90,7 @@ function playerPromptAnswerYes(client) {
|
||||
} else {
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`);
|
||||
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, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount);
|
||||
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, AGRP_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount);
|
||||
cacheBusinessItems(getPlayerData(client).businessOrderBusiness);
|
||||
getBusinessData(getPlayerData(client).businessOrderBusiness).till -= getPlayerData(client).businessOrderCost;
|
||||
updateBusinessPickupLabelData(getPlayerData(client).businessOrderBusiness);
|
||||
@@ -98,7 +105,7 @@ function playerPromptAnswerYes(client) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_GIVEVEHTOCLAN: {
|
||||
case AGRP_PROMPT_GIVEVEHTOCLAN: {
|
||||
if (!isPlayerInAnyVehicle(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeInVehicle"));
|
||||
return false;
|
||||
@@ -109,7 +116,7 @@ function playerPromptAnswerYes(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getVehicleData(getPlayerVehicle(client)).ownerType != VRR_VEHOWNER_PLAYER) {
|
||||
if (getVehicleData(getPlayerVehicle(client)).ownerType != AGRP_VEHOWNER_PLAYER) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
|
||||
return false;
|
||||
}
|
||||
@@ -119,21 +126,21 @@ function playerPromptAnswerYes(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getVehicleData(getPlayerVehicle(client)).ownerType = VRR_VEHOWNER_CLAN;
|
||||
getVehicleData(getPlayerVehicle(client)).ownerType = AGRP_VEHOWNER_CLAN;
|
||||
getVehicleData(getPlayerVehicle(client)).ownerId = getPlayerCurrentSubAccount(client).clan;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "GaveVehicleToClan", getVehicleName(getPlayerVehicle(client))));
|
||||
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_GIVEHOUSETOCLAN: {
|
||||
case AGRP_PROMPT_GIVEHOUSETOCLAN: {
|
||||
let houseId = getPlayerHouse(client);
|
||||
if (!houseId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) {
|
||||
if (getHouseData(houseId).ownerType != AGRP_VEHOWNER_PLAYER) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
|
||||
return false;
|
||||
}
|
||||
@@ -143,21 +150,21 @@ function playerPromptAnswerYes(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_CLAN;
|
||||
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_CLAN;
|
||||
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).clan;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "GaveHouseToClan"));
|
||||
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_GIVEBIZTOCLAN: {
|
||||
case AGRP_PROMPT_GIVEBIZTOCLAN: {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if (!businessId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getBusinessData(businessId).ownerType != VRR_VEHOWNER_PLAYER) {
|
||||
if (getBusinessData(businessId).ownerType != AGRP_VEHOWNER_PLAYER) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
|
||||
return false;
|
||||
}
|
||||
@@ -167,14 +174,14 @@ function playerPromptAnswerYes(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_CLAN;
|
||||
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).clan;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "GaveBusinessToClan"));
|
||||
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_BUYHOUSE: {
|
||||
case AGRP_PROMPT_BUYHOUSE: {
|
||||
let houseId = getPlayerHouse(client);
|
||||
if (!houseId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
|
||||
@@ -191,7 +198,7 @@ function playerPromptAnswerYes(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_PLAYER;
|
||||
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_PLAYER;
|
||||
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
|
||||
getHouseData(houseId).buyPrice = 0;
|
||||
getHouseData(houseId).needsSaved = true;
|
||||
@@ -202,7 +209,7 @@ function playerPromptAnswerYes(client) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_BUYBIZ: {
|
||||
case AGRP_PROMPT_BUYBIZ: {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if (!businessId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
|
||||
@@ -219,7 +226,7 @@ function playerPromptAnswerYes(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_PLAYER;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_PLAYER;
|
||||
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
|
||||
getBusinessData(businessId).buyPrice = 0;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
@@ -230,13 +237,21 @@ function playerPromptAnswerYes(client) {
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROMPT_RESETKEYBINDS: {
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROMPT_COPYKEYBINDSTOSERVER: {
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
submitBugReport(client, `[AUTOMATED REPORT] Unknown prompt type: ${getPlayerData(client).promptType}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getPlayerData(client).promptType = VRR_PROMPT_NONE;
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_NONE;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||