Many improvements.

This commit is contained in:
Vortrex
2020-12-04 02:48:16 -06:00
parent a7cc0bce7c
commit 33f8c4615a
110 changed files with 3680 additions and 923 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.vs/
.git/

View File

46
files/html/login.html Normal file
View File

@@ -0,0 +1,46 @@
<html>
<head>
<title>Asshat Gaming: Login</title>
<style type="text/css" rel="stylesheet">
body {
background-color: #1B1B1B;
overflow: hidden;
}
.login_name {
font-family: "Arial";
color: #B1B1B1;
font-size: 12px;
padding: 5px 0px;
width: 200px;
}
.login_password {
font-family: "Arial";
color: #B1B1B1;
font-size: 12px;
padding: 5px 0px;
width: 200px;
}
.login_submit {
font-family: "Arial";
color: #B1B1B1;
font-size: 12px;
padding: 5px 0px;
width: 200px;
text-align: center;
border-style: solid;
border-color: #B1B1B1;
}
</style>
</head>
<body>
<div class="container">
<img src="main-logo.png" />
<input type="text" class="login_name" placeholder="Username" />
<input type="password" class="login_password" placeholder="Password" />
<button class="login_submit" id="login_submit">Login</button>
</div>
</body>
</html>

239
ideas.txt
View File

@@ -1,239 +0,0 @@
Ideas for Asshat Gaming RP!
NOTICE: Most of these ideas are totally random and some might be unrealistic. Every time I thought of something,
I immediately threw it into this file. There may be duplicates or similar entries spread out and unorganized.
Thanks for understanding,
- Vortrex
==============================================================================================================
- Businesses (some from GTA Online)
- Nightclubs
- Executive Offices
- Warehouses
- Hangars
- Houses
- Garages
- Casinos
- Interactive peds with each one having a background story, characteristics, certain people or groups they like/dislike.
- Procedurally generated?
- Nightclubs, bars, etc can employ "bouncer" peds that either prevent entry to certain people, or kick people out.
- Background ambience.
- Anonymous city traffic and pedestrians
- They come and go and aren't persistent.
- Police peds/traffic will pursue if player has 1+ stars and comes within range and line of sight.
- Police presence becomes more frequent in areas where crimes occur (default police spawn rate will be increased for the area)
- Random text bubble dialog above their heads.
- Complain about life, work, taxes, nearby shady establishments, rising crime rates, gangs, etc
- Praise nearby good establishments, lowered taxes, crime rates dropping, etc
- Named NPCs
- Persistent
- Move from place to place. Eat at restaurants, drive home, to work, get drunk at a bar, etc.
- Different personalities
- Relationship levels with each player and faction.
- If you piss them off, they won't do business with you.
- If you fuck them over, you have a chance of being greenlit under certain circumstances (peds will show up randomly and attempt to kill or subdue you)
- Faction/clans at war is basically kill on sight as long as cops aren't around
- Firefighter Job
- Vehicles catch on fire instead of blowing up.
- Random property fires can occur.
- Firetrucks can "spray" a fire, lowering the damage until it is extinguished (Aim detection).
- Streetsweeper Job
- Instead of checkpoints, show actual messes on the road.
- Drive over the messes with the right vehicle to "clean" the mess.
- Only show messes if at least one player is on duty.
- Garbageman Job
- Instead of checkpoints, have trashbag objects outside of properties or wherever.
- Allow the trashtruck drivers to "pickup" the trashbag, then "place" into the truck.
- If the truck is full, deliver the trashbags to the dump.
- Only show trashbags if at least one player is currently doing the job.
- Mailman Job
- Use a white solid van (Pony maybe) as a mail van.
- Load mail at the post office, and drive a specific route to "deliver" mail.
- Return the truck for payment.
- Vehicle Towing
- Use a Yankee or something to store the vehicle "inside" (just make the car disappear) until better sync options are built for GTA 3/VC.
- Universal command to tow/release a vehicle ( /tow ).
- Attach to nearest vehicle.
- Item System
- Several item types, including armour, skins, weapons, drugs, materials, and more.
- Items can be dropped and picked up.
- Items can be stored in a vehicle trunk or dash compartment.
- Items can be given, taken, or used.
- Payphones
- Make built in payphones usable (detect position, ring sound, etc)
- Payphones can be called, making them ring to nearby players.
- Multiple bed hospital.
- When one is taken, use the next one.
- If all are full, have a waiting list.
- Allow people to go in and lay on a bed to heal (or use a check-in system)
- Several NPC's
- 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.
- Admin abilities
- Moderation (muted/frozen/etc)
- LEO abilities
- Faction abilities
- etc
- For games with interiors, properties inside of properties (make it a sub-property, but using a "type" to define it) AKA a business inside a business (illegal back room gambling, perhaps?)
- Stealable clothes.
- Police uniforms can be stolen, and the cop will be reverted to his non-uniform skin.
- Clothes are items so the criminal can apply it immediately or store/drop/give/sell it
- Black market for anything.
- Smuggled drugs
- LEO items
- Weapons and weapon upgrades
- Illegal vehicle upgrades like NOS.
- Drug houses and weed farms.
- Make weed only plantable in certain areas.
- Drug houses aren't limited to the type of house, as anybody can deal or use in any place.
- Size-based inventories.
- Items should have a size and inventories can only hold so much.
- Items inside of items. This could be (but not limited to):
- Briefcases
- Wallets
- Safes
- Trashbags
- Boxes/crates
- Use the item sizes for storage capacity
- Weapons like DayZ.
- Multiple weapon types that issue different damages.
- Ammo clips that only fit a compatible weapon
- Different clip types hold different amounts of ammo in them (and specific ammo types)
- Hollow point and armor piercing round types
- Modifications. Flashlight, silencer, bigger clip, tracer, scope, etc.
- Crime scene investigations.
- Blood
- Fingerprints
- Ballistics/bullets on ground, in objects, walls, etc.
- Gunpowder traces
- Weapons
- Other crime scene stuff for investigation roleplay.
- These items should be visible on the ground (particle effects?)
- Can be cleaned up by anybody (including the murderer or suspects)
- Showering or swimming clears blood from body
- Rain washes away blood outside (if not under an object or bridge). Perhaps line of sight check with high up Z at same coord?
- Huge police interiors and garages.
- Multiple interrogation rooms with blocked sound (chat is localized to that room)
- Multiple offices for ranking members
- A large locker room
- Crime scene lab
- Cell block area (or multiple cell blocks)
- Elevators that can take you to multiple levels of the building (and roof/garage).
- Custom MDC.
- Arrest logs
- Past tickets
- Officer reports
- Investigation info
- APB list
- Admin panel.
- Reports
- Multiple actions for each
- Viewing info and past reports/actions on the reporter and the situation.
- Logs
- Chat
- Action
- Weapon/Kill/Death
- Others
- Log everything possible.
- Depending on type of injuries, have multiple results occur over time.
- Gunshots lead to bleeding which could lead to passing out for loss of blood.
- Post-treatment effects are also possible including siezures from blunt force trauma.
- Custom actions to have different results. Interactive-ness.
- Hotwiring a car could be successful or could also fail, depending on vehicle type and variance.
- The user has to go through each step in order to complete the task.
- Hotwiring could have things like splitting and joining wires to make the car start or the alarm stop.
- Include medical procedures in this idea.
- Require certain tools to perform different actions.
- Different vehicles have different wires to use to be successful.
- Limit weapons per person.
- Have a visible large weapon if they have one, and allow a concealable smaller weapon as well.
- Officers usually have a utility belt. Allow it to hold equipment as well.
- Trunks can hold players/peds (not visibly) and items and is size based.
- Get "inside" the back of trucks/trailers and store items inside.
- Use an interior for this and allow dropped items (including crates and boxes and etc).
- Ambulance, bus, delivery truck, semi truck trailer, etc.
- Shouts can be heard outside wherever the vehicle is at.
- Vehicle sink or explode while inside the back causes death and objects destroyed.
- Also for airplane interiors
- Impound
- Inaccessible parking garage. Spawn retrieved impound vehicles at the door.
- Or multi-space impound lot. When retrieving a car from impound, spawn it in the first empty space that isn't obstructed.
- Weapon wear and tear
- If not cared for, they can have decreased damage from shots, jam, misfire, etc.
- Cleaning weapons improves reliability
- Weapon ballistics and identity
- Barrel bores
- Serial numbers. Can be removed/rubbed off.
- GUI color schemes
- Settings page to switch them. Orange, red, blue, purple, etc.
- Police
- Stars
- 1 star
- Initial misdemeanor. Traffic violation, pedestrian crime, etc. Police will pursue to fine/ticket.
- 2 stars
- Any subsequent crimes, whether felony or misdeanor, after receiving one star and no action taken (if you don't pull over, evade, etc). Results in arrest.
- Any felony crime that isn't extremely violent or doesn't involve a deadly weapon
- 3 stars is basically a warrant. Police will attempt to arrest you on sight and may use heavier force than normal if you become a threat.
- 4 stars is SWAT and/or air support backup callout. Police presence will become more dense and they will really pursue you now.
- 5 stars (highest in the server) is all out manhunt. Police everywhere. They will most likely shoot to kill.
- NPC police will chase you if you have 1+ stars. If you lose them with 2 or less stars, they go away unless you are sighted by another officer before cooldown.
- Civilians can report crimes by calling police or informing nearby police. They will give them your description.
- Any traffic violation that takes place within LOS and range of police will cause them to chase you until you pull over.
- Failure to pull over within a timely manner, or breaking another law before pulling over adds a second star. They won't fine you at this level, only arrest or worse.
- NPC Ideas
- Bodyguards
- Biker gang formation
- Convoy Line
- Guard/Protect Properties
- Respond to enemy attacks at other locations
- Taxi Driver
- Personal Chauffeur
- Bus Driver
- Train Operator
- Gangs/Mafia Members
- Drug Dealers
- Weapons Dealers
- Mechanic
- Tweakers
- Bouncers

View File

@@ -1,5 +1,5 @@
<meta>
<info author="Asshat Gaming" version="1.0" description="Asshat Gaming RP" />
<info author="Vortrex, Asshat Gaming" version="1.0" description="Asshat-Gaming Roleplay" />
<!-- Server -->
<script src="scripts/server/class.js" type="server" language="javascript" />
@@ -26,6 +26,7 @@
<script src="scripts/server/misc.js" type="server" language="javascript" />
<script src="scripts/server/moderation.js" type="server" language="javascript" />
<script src="scripts/server/security.js" type="server" language="javascript" />
<script src="scripts/server/timers.js" type="server" language="javascript" />
<script src="scripts/server/translate.js" type="server" language="javascript" />
<script src="scripts/server/utilities.js" type="server" language="javascript" />
<script src="scripts/server/vehicle.js" type="server" language="javascript" />
@@ -58,7 +59,6 @@
<script src="scripts/server/startup.js" type="server" language="javascript" />
<!-- Client -->
<!-- Files -->
<file type="client" src="files/images/main-logo.png" />
<file type="client" src="files/fonts/roboto-regular.ttf" />
<file type="client" src="files/fonts/pricedown.ttf" />
@@ -67,7 +67,6 @@
<script src="scripts/client/gui.js" type="client" language="javascript" />
<script src="scripts/client/nametags.js" type="client" language="javascript" />
<!-- Skin Images -->
<file type="client" src="files/images/skins/gta3/Skin000.png" />
<file type="client" src="files/images/skins/gta3/Skin001.png" />
<file type="client" src="files/images/skins/gta3/Skin002.png" />
@@ -242,5 +241,5 @@
<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/Year.js" />
<script language="javascript" type="client" src="third-party/mexui/Core/Init.js" />
<script language="javascript" type="client" src="third-party/mexui/Core/Init.js" />
</meta>

View File

@@ -1 +0,0 @@
- Fix client data loggedIn for switchCharacterCommand

View File

@@ -1,3 +1,13 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: afk.js
// DESC: Provides AFK detection
// TYPE: Client (JavaScript)
// ===========================================================================
// ----------------------------------------------------------------------------
addEventHandler("OnLostFocus", function(event) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: main.js
// DESC: Main client script (will be reorganized into individual files later)
@@ -11,20 +11,38 @@
let allServerBlips = [];
let currentServerBlips = [];
let bigMessageFont = null;
let mainLogo = null;
let showLogo = true;
// ---------------------------------------------------------------------------
addNetworkHandler("ag.connectCamera", function(cameraPosition, cameraLookat) {
gta.fadeCamera(true);
gta.setCameraLookAt(cameraPosition, cameraLookat, true);
//if(gta.game < GAME_GTA_IV) {
gta.fadeCamera(true);
gta.setCameraLookAt(cameraPosition, cameraLookat, true);
//}
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.restoreCamera", function() {
//if(gta.game < GAME_GTA_IV) {
gta.restoreCamera(true);
//}
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.logo", function(state) {
showLogo = state;
});
// ---------------------------------------------------------------------------
addEventHandler("onPickupCollected", function(event, pickup, ped) {
console.log(`PICKUP COLLECTED: Ped ${ped.id}, ${pickup.id}`);
// This won't be needed in next GTAC update. onPickupCollccted has been added server side
if(ped == localPlayer) {
triggerNetworkEvent("ag.onPickupCollected", pickup);
}
});
// ---------------------------------------------------------------------------
@@ -41,6 +59,20 @@ addNetworkHandler("ag.giveWeapon", function(weaponId, ammo, active) {
// ---------------------------------------------------------------------------
addNetworkHandler("ag.showRegisterMessage", function() {
showRegisterMessage = true;
showLoginMessage = false;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.showLoginMessage", function() {
showLoginMessage = true;
showRegisterMessage = false;
});
// ---------------------------------------------------------------------------
function syncVehicle(vehicle) {
if(vehicle.getData("ag.lights") != null) {
let lights = vehicle.getData("ag.lights");
@@ -143,8 +175,27 @@ function attemptToShowBlipsOnSpawn(ped) {
// ---------------------------------------------------------------------------
addNetworkHandler("ag.skin", function(ped, skin) {
ped.skin = skin;
addNetworkHandler("ag.skin", function(skin) {
localPlayer.skin = skin;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.position", function(position) {
localPlayer.position = position;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.interior", function(interior) {
localPlayer.interior = interior;
cameraInterior = interior;
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.dimension", function(dimension) {
localPlayer.dimension = dimension;
});
// ---------------------------------------------------------------------------
@@ -156,26 +207,83 @@ addNetworkHandler("ag.removeFromVehicle", function() {
// ---------------------------------------------------------------------------
function initLocalPlayer(player) {
attemptToShowBlipsOnSpawn(player)
bindEventHandler("onEntityProcess", localPlayer, processLocalPlayerEntity);
attemptToShowBlipsOnSpawn(player);
if(gta.game < GAME_GTA_IV) {
addEventHandler("onProcess", processEvent);
}
}
// ---------------------------------------------------------------------------
function processLocalPlayerEntity(event, player) {
function processEvent(event, deltaTime) {
getElementsByType(ELEMENT_MARKER).forEach(function(sphere) {
if(player.position.distance(sphere.position) <= sphere.radius) {
if(player.getData("ag.inSphere") == null) {
player.setData("ag.inSphere", sphere);
if(localPlayer.position.distance(sphere.position) <= sphere.radius) {
if(localPlayer.getData("ag.inSphere") == null) {
localPlayer.setData("ag.inSphere", sphere);
triggerNetworkEvent("ag.onPlayerEnterSphere", sphere);
}
} else {
if(player.getData("ag.inSphere")) {
player.removeData("ag.inSphere", sphere);
if(localPlayer.getData("ag.inSphere")) {
localPlayer.removeData("ag.inSphere", sphere);
triggerNetworkEvent("ag.onPlayerExitSphere", sphere);
}
}
});
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
addEventHandler("OnDrawnHUD", function (event) {
if(bigMessageFont != null && mainLogo != null) {
/*
if(showLoginMessage) {
let logoPos = new Vec2(gta.width/2-128, gta.height/2-256);
let logoSize = new Vec2(256, 256);
drawing.drawRectangle(mainLogo, logoPos, logoSize);
let y = gta.height/2+10;
bigMessageFont.render(`Welcome back to Asshat Gaming, ${localClient.name}`, [gta.width/2, y], gta.width, 0.0, 0.0, bigMessageFont.size, COLOUR_WHITE, false, false, false, true);
y += 18;
bigMessageFont.render(`Please /login to access your account`, [gta.width/2, y], gta.width, 0.0, 0.0, bigMessageFont.size, COLOUR_WHITE, false, false, false, true);
}
if(showRegisterMessage) {
let logoPos = new Vec2(gta.width/2-128, gta.height/2-256);
let logoSize = new Vec2(256, 256);
drawing.drawRectangle(mainLogo, logoPos, logoSize);
let y = gta.height/2+10;
bigMessageFont.render(`Welcome to Asshat Gaming, ${localClient.name}`, [gta.width/2, y], gta.width, 0.0, 0.0, bigMessageFont.size, COLOUR_WHITE, false, false, false, true);
y += 18;
bigMessageFont.render(`Please /register to create an account`, [gta.width/2, y], gta.width, 0.0, 0.0, bigMessageFont.size, COLOUR_WHITE, false, false, false, true);
}
*/
}
// Draw logo in corner of screen
if(mainLogo != null && showLogo) {
let logoPos = new Vec2(gta.width-132, gta.height-132);
let logoSize = new Vec2(128, 128);
drawing.drawRectangle(mainLogo, logoPos, logoSize);
}
});
// ---------------------------------------------------------------------------
addEventHandler("OnResourceStart", function(event, resource) {
if(resource == thisResource) {
let fontStream = openFile("files/fonts/pricedown.ttf");
if(fontStream != null) {
bigMessageFont = lucasFont.createFont(fontStream, 28.0);
fontStream.close();
}
let logoStream = openFile("files/images/main-logo.png");
if(logoStream != null) {
mainLogo = drawing.loadPNG(logoStream);
logoStream.close();
}
}
});

View File

@@ -1,4 +1,12 @@
"use strict";
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: nametags.js
// DESC: Provides nametags for VRS
// TYPE: Client (JavaScript)
// ===========================================================================
// ----------------------------------------------------------------------------
@@ -20,22 +28,7 @@ addEventHandler("OnResourceReady", function(event, resource) {
// ----------------------------------------------------------------------------
function createColour(alpha, red, green, blue) {
return alpha << 24 | red << 16 | green << 8 | blue;
}
// ----------------------------------------------------------------------------
function getDistance(pos1, pos2) {
let dx = pos1[0] - pos2[0];
let dy = pos1[1] - pos2[1];
let dz = pos1[2] - pos2[2];
return Math.sqrt(dx*dx + dy*dy + dz*dz);
}
// ----------------------------------------------------------------------------
function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk) {
function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk, skin) {
if(nametagFont == null) {
return false;
}
@@ -49,18 +42,21 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
// -------------------------------------------
// Health Bar
if(skin == 109) {
y -= 20;
} else {
y -= 5;
}
if(gta.game == GAME_GTA_III) {
// Mickey Hamfists is ridiculously tall. Raise the nametag for him a bit
if(skin == 109) {
y -= 20;
} 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)
drawing.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB);
let colour = createColour(Math.floor(255.0*alpha), Math.floor(255.0-(health*255.0)), Math.floor(health*255.0), 0); // Health bar colour (varies, depending on health)
let colour = toColour(Math.floor(255.0*alpha), Math.floor(255.0-(health*255.0)), Math.floor(health*255.0), 0); // Health bar colour (varies, depending on health)
drawing.drawRectangle(null, [hx+2, hy+2], [(width-4)*health, 10-6], colour, colour, colour, colour);
}
@@ -71,9 +67,9 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
y -= 10;
let hx = x-width/2;
let hy = y-10/2;
let colourB = createColour(Math.floor(255.0*alpha), 0, 0, 0); // Background colour (black)
let colourB = toColour(Math.floor(255.0*alpha), 0, 0, 0); // Background colour (black)
drawing.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB);
let colour = createColour(Math.floor(255.0*alpha), 255, 255, 255); // Armour bar colour (white)
let colour = toColour(Math.floor(255.0*alpha), 255, 255, 255); // Armour bar colour (white)
drawing.drawRectangle(null, [hx+2, hy+2], [(width-4)*armour, 10-6], colour, colour, colour, colour);
}
@@ -82,7 +78,7 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
// Nametag
if(nametagFont != null) {
let size = nametagFont.measure(text, game.width, 0.0, 0.0, nametagFont.size, false, false);
let colourT = createColour(Math.floor(255.0*alpha), 255, 255, 255);
let colourT = toColour(Math.floor(255.0*alpha), 255, 255, 255);
nametagFont.render(text, [x-size[0]/2, y-size[1]/2], game.width, 0.0, 0.0, nametagFont.size, colour, false, false, false, true);
}
@@ -95,18 +91,7 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
let size = afkStatusFont.measure("PAUSED", game.width, 0.0, 0.0, afkStatusFont.size, false, false);
afkStatusFont.render("PAUSED", [x-size[0]/2, y-size[1]/2], game.width, 0.0, 0.0, afkStatusFont.size, toColour(255, 0, 0, 255), false, false, false, true);
}
}
// Go up another 50 pixels for the next part
//y -= 30;
//if(ping != -1) {
// if(pingFont != null) {
// let size2 = pingFont.measure(ping, game.width, 0.0, 0.0, pingFont.size, false, false);
// let colourT2 = createColour(Math.floor(255.0*alpha), 255, 255, 255);
// pingFont.render(ping, [x-size2[0]/2, y-size2[1]/2], game.width, 0.0, 0.0, pingFont.size, colourT2, false, false, false, true);
// }
//}
}
}
// ----------------------------------------------------------------------------
@@ -132,27 +117,26 @@ function updateNametags(element) {
armour = 1.0;
}
let distance = getDistance(playerPos, elementPos);
if(distance < nametagDistance) {
let distance = playerPos.distance(elementPos);
if(distance <= nametagDistance) {
if(element.type == ELEMENT_PLAYER) {
let name = element.name;
let colour = COLOUR_WHITE;
let afk = false;
if(element.getData("ag.name") != null) {
name = element.getData("ag.name");
if(client.getData("ag.name") != null) {
name = client.getData("ag.name");
}
if(element.getData("ag.afk") != null) {
if(client.getData("ag.afk") != null) {
afk = true;
}
if(element.getData("ag.colour") != null) {
colour = element.getData("ag.colour");
}
if(client.getData("ag.colour") != null) {
colour = client.getData("ag.colour");
}
drawNametag(screenPos[0], screenPos[1], health, armour, name, 0, 1.0-distance/nametagDistance, distance, colour, afk);
drawNametag(screenPos[0], screenPos[1], health, armour, name, 0, 1.0-distance/nametagDistance, distance, colour, afk, element.skin);
}
}
}
@@ -162,31 +146,23 @@ function updateNametags(element) {
// ----------------------------------------------------------------------------
function getClientFromPlayer(player) {
let clients = getClients();
for(let i in clients) {
if(clients[i].player == player) {
return clients[i];
getClients().forEach(function(client) {
if(client.player == player) {
return client;
}
}
});
}
// ----------------------------------------------------------------------------
addNetworkHandler("armour", function(client, ped, armour) {
if(ped != null) {
ped.armour = armour;
}
});
// ----------------------------------------------------------------------------
addEventHandler("OnDrawnHUD", function(event) {
let peds = getPeds();
for(let i in peds) {
if(peds[i] != localPlayer) {
updateNametags(peds[i]);
}
}
//if(gta.game >= GAME_GTA_IV) {
// return false;
//}
//getElementsByType(ELEMENT_PLAYER).forEach(function(player) {
// updateNametags(player)
//})
});
// ----------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: account.js
// DESC: Provides account functions and usage
@@ -57,13 +57,7 @@ function loginCommand(command, params, client) {
return false;
}
if(isAccountPasswordCorrect(getClientData(client).accountData, hashAccountPassword(client.name, params))) {
messageClientError(client, "Incorrect username or password!");
return false;
}
loginSuccess(client);
//messageClientSuccess(client, "You have been logged in! Press left CTRL to spawn.");
checkLogin(client, params);
return true;
}
@@ -99,20 +93,10 @@ function registerCommand(command, params, client) {
return false;
}
if(!doesPasswordMeetRequirements(params)) {
return false
}
let accountData = createAccount(client.name, params);
if(!accountData) {
messageClientError(client, "Something went wrong, and your account could not be created!");
messageClientAlert(client, "Asshat Gaming staff have been notified of the problem and will fix it shortly.");
return false;
}
getClientData(client).accountData = accountData;
messageClientSuccess(client, "Your account has been created!");
messageClientAlert(client, "To play on the server, you will need to make a character.");
checkRegistration(client, params);
//getClientData(client).accountData = accountData;
//messageClientSuccess(client, "Your account has been created!");
//messageClientAlert(client, "To play on the server, you will need to make a character.");
}
// ---------------------------------------------------------------------------
@@ -129,7 +113,7 @@ function changePasswordCommand(command, params, client) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
@@ -186,12 +170,77 @@ function switchCharacterCommand(command, params, client) {
getClientCurrentSubAccount(client).spawnPosition = client.player.position;
getClientCurrentSubAccount(client).spawnHeading = client.player.heading;
let tempSubAccount = getClientCurrentSubAccount(client);
saveSubAccountToDatabase(tempSubAccount);
saveSubAccountToDatabase(getClientCurrentSubAccount(client));
client.despawnPlayer();
triggerNetworkEvent("ag.connectCamera", client, serverConfig.connectCameraPosition[getServerGame()], serverConfig.connectCameraLookAt[getServerGame()]);
triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
showConnectCameraToPlayer(client);
showCharacterSelectToClient(client);
}
// ---------------------------------------------------------------------------
function newCharacterCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let firstName = splitParams[0];
let lastName = splitParams[1];
checkNewCharacter(client, firstName, lastName, "01/01/1901", "Liberty City", serverConfig.newCharacter.skin);
}
// ---------------------------------------------------------------------------
function useCharacterCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let characterId = Number(params) || 1;
selectCharacter(client, characterId-1);
}
// ---------------------------------------------------------------------------
@@ -317,7 +366,7 @@ function loadSubAccountsFromAccount(accountId) {
if(accountId > 0) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQueryString = `SELECT * FROM sacct_main WHERE sacct_acct = ${accountId};`;
let dbQueryString = `SELECT * FROM sacct_main WHERE sacct_acct = ${accountId} AND sacct_server = ${serverId}`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
@@ -394,7 +443,7 @@ function hashAccountPassword(name, password) {
// ---------------------------------------------------------------------------
function saltAccountInfo(name, password) {
return "asshat.gaming." + String(accountSaltHash) + "." + String(name) + "." + String(password);
return "ag.gaming." + String(accountSaltHash) + "." + String(name) + "." + String(password);
}
// ---------------------------------------------------------------------------
@@ -406,7 +455,9 @@ function loginSuccess(client) {
client.administrator = true;
}
triggerNetworkEvent("ag.loginSuccess", client);
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.loginSuccess", client);
}
}
// ---------------------------------------------------------------------------
@@ -461,6 +512,7 @@ function createAccount(name, password, email = "") {
// ---------------------------------------------------------------------------
function createSubAccount(accountId, firstName, lastName, skinId, dateOfBirth, placeOfOrigin) {
console.log(`[Asshat.Account] Attempting to create subaccount ${firstName} ${lastName} in database`);
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -468,7 +520,7 @@ function createSubAccount(accountId, firstName, lastName, skinId, dateOfBirth, p
let safeLastName = escapeDatabaseString(dbConnection, lastName);
let safePlaceOfOrigin = escapeDatabaseString(dbConnection, placeOfOrigin);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO sacct_main (sacct_acct, sacct_name_first, sacct_name_last, sacct_skin, sacct_origin, sacct_when_born, sacct_pos_x, sacct_pos_y, sacct_pos_z, sacct_cash) VALUES (${accountId}, '${safeFirstName}', '${safeLastName}', ${skinId}, '${safePlaceOfOrigin}', '${dateOfBirth}', ${serverConfig.newCharacter.spawnPosition.x}, ${serverConfig.newCharacter.spawnPosition.y}, ${serverConfig.newCharacter.spawnPosition.z}, ${serverConfig.newCharacter.money})`);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO sacct_main (sacct_acct, sacct_name_first, sacct_name_last, sacct_skin, sacct_origin, sacct_when_born, sacct_pos_x, sacct_pos_y, sacct_pos_z, sacct_angle, sacct_cash, sacct_server) VALUES (${accountId}, '${safeFirstName}', '${safeLastName}', ${skinId}, '${safePlaceOfOrigin}', '${dateOfBirth}', ${serverConfig.newCharacter.spawnPosition.x}, ${serverConfig.newCharacter.spawnPosition.y}, ${serverConfig.newCharacter.spawnPosition.z}, ${serverConfig.newCharacter.spawnHeading}, ${serverConfig.newCharacter.money}, ${serverId})`);
if(getDatabaseInsertId(dbConnection) > 0) {
return loadSubAccountFromId(getDatabaseInsertId(dbConnection));
}
@@ -480,97 +532,138 @@ function createSubAccount(accountId, firstName, lastName, skinId, dateOfBirth, p
// ---------------------------------------------------------------------------
addNetworkHandler("ag.checkLogin", function(client, password) {
function checkLogin(client, password) {
let loginAttemptsRemaining = client.getData("ag.loginAttemptsRemaining")-1;
if(isClientLoggedIn(client)) {
//messageClientError(client, "You are already logged in!");
triggerNetworkEvent("ag.loginSuccess", client);
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.loginSuccess", client);
} else {
messageClientError(client, "You are already logged in!");
}
return false;
}
if(!isClientRegistered(client)) {
//messageClientError(client, "Your name is not registered! Use /register to make an account.");
triggerNetworkEvent("ag.showRegistration", client);
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.showRegistration", client);
} else {
messageClientError(client, "Your name is not registered! Use /register to make an account.");
}
return false;
}
if(areParamsEmpty(password)) {
//messageClientError(client, "You must enter a password!");
triggerNetworkEvent("ag.loginFailed", client, "Invalid password! " + String(loginAttemptsRemaining) + " tries remaining.");
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
} else {
messageClientError(client, "You must enter a password!");
}
return false;
}
if(!isAccountPasswordCorrect(getClientData(client).accountData, hashAccountPassword(client.name, password))) {
//messageClientError(client, "Invalid password!");
triggerNetworkEvent("ag.loginFailed", client, "Invalid password! " + String(loginAttemptsRemaining) + " tries remaining.");
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
} else {
messageClientError(client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
}
return false;
}
loginSuccess(client);
if(getClientData(client).subAccounts.length == 0) {
triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No characters");
client.setData("ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No characters");
client.setData("ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
} else {
messageClientAlert(client, `You have no characters. Use /newchar to make one.`);
}
} else {
getClientData(client).currentSubAccount = 0;
let tempSubAccount = getClientData(client).subAccounts[0];
triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
showCharacterSelectToClient(client);
}
});
}
addNetworkHandler("ag.checkLogin", checkLogin);
// ---------------------------------------------------------------------------
addNetworkHandler("ag.checkRegistration", function(client, password, confirmPassword, emailAddress) {
function checkRegistration(client, password, confirmPassword = "", emailAddress = "") {
console.log("[Asshat.Account]: Checking registration for " + String(client.name));
if(isClientRegistered(client)) {
//messageClientError(client, "Your name is already registered!");
triggerNetworkEvent("ag.showLogin", client);
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.showLogin", client);
} else {
messageClientError(client, "Your name is already registered!");
}
return false;
}
if(isClientLoggedIn(client)) {
//messageClientError(client, "You are already logged in!");
triggerNetworkEvent("ag.loginSuccess", client);
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.loginSuccess", client);
} else {
messageClientError(client, "You are already logged in!");
}
return false;
}
if(areParamsEmpty(password)) {
triggerNetworkEvent("ag.registrationFailed", client, "Password cannot be blank!");
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.registrationFailed", client, "Password cannot be blank!");
} else {
messageClientError(client, "The password cannot be blank!");
}
return false;
}
if(areParamsEmpty(confirmPassword)) {
triggerNetworkEvent("ag.registrationFailed", client, "Password confirm cannot be blank!");
return false;
if(serverConfig.useGUI) {
if(areParamsEmpty(confirmPassword)) {
triggerNetworkEvent("ag.registrationFailed", client, "Password confirm cannot be blank!");
return false;
}
}
if(areParamsEmpty(emailAddress)) {
triggerNetworkEvent("ag.registrationFailed", client, "Email address cannot be blank!");
return false;
if(serverConfig.useGUI) {
if(areParamsEmpty(emailAddress)) {
triggerNetworkEvent("ag.registrationFailed", client, "Email address cannot be blank!");
return false;
}
}
if(password != confirmPassword) {
triggerNetworkEvent("ag.registrationFailed", client, "The passwords must match!");
return false;
if(serverConfig.useGUI) {
if(password != confirmPassword) {
triggerNetworkEvent("ag.registrationFailed", client, "The passwords must match!");
return false;
}
}
if(!doesPasswordMeetRequirements(password)) {
// Work on this later. Function should return true by default anyway for now.
triggerNetworkEvent("ag.registrationFailed", client, "Password doesn't meet requirements!");
if(serverConfig.useGUI) {
// Work on this later. Function should return true by default anyway for now.
triggerNetworkEvent("ag.registrationFailed", client, "Password doesn't meet requirements!");
} else {
messageClientError(client, "Password doesn't meet requirements!");
}
return false
}
if(!isValidEmailAddress(emailAddress)) {
// Work on this later. Function should return true by default anyway for now.
triggerNetworkEvent("ag.registrationFailed", client, "You must put a valid email!");
return false
if(serverConfig.useGUI) {
if(!isValidEmailAddress(emailAddress)) {
triggerNetworkEvent("ag.registrationFailed", client, "You must put a valid email!");
return false
}
}
let accountData = createAccount(client.name, password, emailAddress);
if(!accountData) {
triggerNetworkEvent("ag.registrationFailed", client, "Something went wrong. Your account could not be created!");
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.registrationFailed", client, "Something went wrong. Your account could not be created!");
} else {
messageClientAlert(client, "Something went wrong. Your account could not be created!");
}
messageClientAlert(client, "Asshat Gaming staff have been notified of the problem and will fix it shortly.");
return false;
}
@@ -580,15 +673,20 @@ addNetworkHandler("ag.checkRegistration", function(client, password, confirmPass
messageClientSuccess(client, "Your account has been created!");
messageClientAlert(client, "To play on the server, you will need to make a character.");
triggerNetworkEvent("ag.registrationSuccess", client);
triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No Characters");
client.setData("ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
});
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.registrationSuccess", client);
triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No Characters");
client.setData("ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
} else {
messageClientAlert(client, `You have no characters. Use /newchar to make one.`);
}
};
addNetworkHandler("ag.checkRegistration", checkRegistration);
// ---------------------------------------------------------------------------
addNetworkHandler("ag.checkNewCharacter", function(client, firstName, lastName, dateOfBirth, placeOfOrigin, skinId) {
function checkNewCharacter(client, firstName, lastName, dateOfBirth, placeOfOrigin, skinId) {
if(areParamsEmpty(firstName)) {
triggerNetworkEvent("ag.newCharacterFailed", client, "First name cannot be blank!");
return false;
@@ -618,18 +716,21 @@ addNetworkHandler("ag.checkNewCharacter", function(client, firstName, lastName,
let subAccountData = createSubAccount(getClientData(client).accountData.databaseId, firstName, lastName, skinId, dateOfBirth, placeOfOrigin);
if(!subAccountData) {
triggerNetworkEvent("ag.newCharacterFailed", client, "Something went wrong. Your character could not be created!");
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.newCharacterFailed", client, "Something went wrong. Your character could not be created!");
} else {
messageClientAlert(client, "Something went wrong. Your character could not be created!");
}
messageClientAlert(client, "Asshat Gaming staff have been notified of the problem and will fix it shortly.");
return false;
}
getClientData(client).subAccounts = loadSubAccountsFromAccount(getClientData(client).accountData.databaseId);
triggerNetworkEvent("ag.newCharacterSuccess", client);
getClientData(client).currentSubAccount = 0;
let tempSubAccount = getClientData(client).subAccounts[0];
triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
});
showCharacterSelectToClient(client);
}
addNetworkHandler("ag.checkNewCharacter", checkNewCharacter);
// ---------------------------------------------------------------------------
@@ -665,17 +766,26 @@ addNetworkHandler("ag.nextCharacter", function(client) {
// ---------------------------------------------------------------------------
addNetworkHandler("ag.selectCharacter", function(client) {
triggerNetworkEvent("ag.characterSelectSuccess", client);
function selectCharacter(client, characterId = -1) {
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.characterSelectSuccess", client);
}
let subAccountId = getClientData(client).currentSubAccount;
let tempSubAccount = getClientData(client).subAccounts[subAccountId];
if(characterId != -1) {
getClientData(client).currentSubAccount = characterId;
}
console.log(getClientData(client).currentSubAccount);
let tempSubAccount = getClientCurrentSubAccount(client);
spawnPlayer(client, tempSubAccount.spawnPosition, tempSubAccount.spawnHeading, tempSubAccount.skin);
messageClientNormal(client, "Welcome to Asshat Gaming Roleplay!", getColourByName("white"));
messageClientNormal(client, `You are playing as ${tempSubAccount.firstName} ${tempSubAccount.lastName}`, getColourByName("white"));
messageClientNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
messageClientNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
});
triggerNetworkEvent("ag.restoreCamera", client);
}
addNetworkHandler("ag.selectCharacter", selectCharacter);
// ---------------------------------------------------------------------------
@@ -721,7 +831,10 @@ function saveClientToDatabase(client) {
// ---------------------------------------------------------------------------
function initClient(client) {
triggerNetworkEvent("ag.connectCamera", client, serverConfig.connectCameraPosition[getServerGame()], serverConfig.connectCameraLookAt[getServerGame()]);
serverData.clients[client.index] = null;
triggerNetworkEvent("ag.logo", client, serverConfig.showLogo);
showConnectCameraToPlayer(client);
clearChatBox(client);
let tempAccountData = loadAccountFromName(client.name);
let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
@@ -729,14 +842,22 @@ function initClient(client) {
serverData.clients[client.index] = new serverClasses.clientData(client, tempAccountData, tempSubAccounts);
if(tempAccountData != false) {
triggerNetworkEvent("ag.showLogin", client);
//messageClient("Welcome back to Asshat Gaming RP, " + String(client.name) + "! Please /login to continue.", client, serverConfig.colour.byName["white"]);
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.showLogin", client);
} else {
messageClient(`Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, client, serverConfig.colour.byName.softGreen);
}
} else {
triggerNetworkEvent("ag.showRegistration", client);
//messageClient("Welcome to Asshat Gaming RP, " + String(client.name) + "! Please /register to continue.", client, serverConfig.colour.byName["white"]);
if(serverConfig.useGUI) {
triggerNetworkEvent("ag.showRegistration", client);
} else {
messageClient(`Welcome to Asshat Gaming RP, ${client.name}! Please /register to continue.`, client, serverConfig.colour.byName.softGreen);
}
}
sendAllBlips(client);
if(server.game < GAME_GTA_IV) {
sendAllBlips(client);
}
}
// ---------------------------------------------------------------------------
@@ -745,4 +866,22 @@ function getClientData(client) {
return serverData.clients[client.index];
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function showCharacterSelectToClient(client) {
if(serverConfig.useGUI) {
getClientData(client).currentSubAccount = 0;
let tempSubAccount = getClientData(client).subAccounts[0];
triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
} else {
//let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
//let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"];
messageClientNormal(client, `You have the following characters. Use /usechar <id> to select one:`, serverConfig.colour.byName.teal);
getClientData(client).subAccounts.forEach(function(subAccount, index) {
messageClientNormal(client, `${index+1} • [#CCCCCC]${subAccount.firstName} ${subAccount.lastName}`);
});
}
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: ammunation.js
// DESC: Provides ammunation functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bans.js
// DESC: Provides ban functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bitflags.js
// DESC: Provides bitwise operations, functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: business.js
// DESC: Provides business functions and usage
@@ -53,12 +53,40 @@ function loadBusinessesFromDatabase() {
disconnectFromDatabase(dbConnection);
}
console.log("[Asshat.Business]: " + String(tempBusinesses.length) + " businesses loaded from database successfully!");
console.log(`[Asshat.Business]: ${tempBusinesses.length} businesses loaded from database successfully!`);
return tempBusinesses;
}
// ---------------------------------------------------------------------------
function loadLocationsFromDatabase() {
console.log("[Asshat.Business]: Loading locations from database ...");
let tempLocations = [];
let dbConnection = connectToDatabase();
let dbQuery = null;
if(dbConnection) {
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `loc_main` WHERE `loc_server` = " + String(serverId));
if(dbQuery) {
if(dbQuery.numRows > 0) {
while(dbFetchAssoc = fetchQueryAssoc(dbQuery)) {
let tempLocationData = locationData(dbFetchAssoc);
tempLocations.push(tempLocationData);
console.log(`[Asshat.Business]: Location '${tempLocationData.name}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.Business]: ${tempBusinesses.length} locations loaded from database successfully!`);
return tempLocations;
}
// ---------------------------------------------------------------------------
function createBusinessCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
@@ -95,6 +123,45 @@ function createBusinessCommand(command, params, client) {
// ---------------------------------------------------------------------------
function createBusinessLocationCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
if(isClientSpawned(client)) {
messageClientError("You must be spawned to use this command!");
return false;
}
let locationType = String(splitParams[0]);
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
createBusinessLocation(locationType, businessId);
messageClientSuccess(client, "Business created in " + getAreaName(client.player.position) + " (" + params + ")");
}
// ---------------------------------------------------------------------------
function createBusiness(name, entrancePosition, interiorId, virtualWorld) {
let dbConnection = connectToDatabase();
let escapedName = name;
@@ -140,15 +207,48 @@ function deleteBusinessCommand(command, params, client) {
return false;
}
let businessId = Number(params);
let tempBusinessData = serverData.businesses.filter(b => b.databaseId == businessId)[0];
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
deleteBusiness(businessId);
messageClientSuccess(client, `Business '${tempBusinessData.name} deleted!`);
}
// ---------------------------------------------------------------------------
function deleteBusinessLocationCommand(command, params, client) {
messageClientError(client, "This command is under construction!");
return false;
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
//let businessId = Number(splitParams[1]);
//deleteBusinessLocation(businessId);
//messageClientSuccess(client, `Business '${tempBusinessData.name} deleted!`);
}
// ---------------------------------------------------------------------------
function setBusinessNameCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
@@ -177,12 +277,10 @@ function setBusinessNameCommand(command, params, client) {
let splitParams = params.split(" ");
let newBusinessName = String(splitParams[0]);
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position).databaseId;
let tempBusinessData = serverData.businesses.filter(b => b.databaseId == businessId)[0];
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
serverData.businesses[businessId].name = newBusinessName;
messageClientSuccess(client, `Business '${tempBusinessData.name}' renamed to '${newBusinessName}'!`);
messageClientSuccess(client, `Business '${serverData.businesses[businessId].name}' renamed to '${newBusinessName}'!`);
}
// ---------------------------------------------------------------------------
@@ -220,7 +318,7 @@ function setBusinessOwnerCommand(command, params, client) {
let splitParams = params.split(" ");
let newBusinessOwner = getClientFromParams(splitParams[0]);
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position).databaseId;
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
if(!newBusinessOwner) {
messageClientError("Player not found!");
@@ -270,7 +368,7 @@ function lockBusinessCommand(command, params, client) {
let splitParams = params.split(" ");
let businessId = Number(splitParams[0]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position).databaseId;
let businessId = Number(splitParams[0]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
serverData.businesses[businessId].locked = !serverData.businesses[businessId].locked;
messageClientSuccess(client, "Business " + serverData.businesses[businessId].name + " " + (serverData.businesses[businessId].locked) ? "locked" : "unlocked" + "!");
@@ -278,6 +376,164 @@ function lockBusinessCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setBusinessEntranceFeeCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let entranceFee = Number(splitParams[0]) || 0;
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
serverData.businesses[businessId].entranceFee = entranceFee;
messageClientSuccess(client, `Business '${serverData.businesses[businessId].name}' entrance fee to $'${entranceFee}'!`);
}
// ---------------------------------------------------------------------------
function withdrawFromBusinessCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let amount = Number(splitParams[0]) || 0;
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
let tempBusinessData = serverData.businesses.filter(b => b.databaseId == businessId)[0];
if(serverData.businesses[businessId].till < amount) {
messageClientError(client, `Business '${tempBusinessData.name}' doesn't have that much money! Use /bizbalance.`);
return false;
}
serverData.businesses[businessId].till -= amount;
getClientCurrentSubAccount(client).cash += amount;
updatePlayerCash(client);
messageClientSuccess(client, `You withdrew $${amount} from business '${tempBusinessData.name}''s till'`);
}
// ---------------------------------------------------------------------------
function depositIntoBusinessCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let amount = Number(splitParams[0]) || 0;
let businessId = Number(splitParams[1]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
if(getClientCurrentSubAccount(client).cash < amount) {
messageClientError(client, `You don't have that much money! You only have $${getClientCurrentSubAccount(client).cash}`);
return false;
}
serverData.businesses[businessId].till += amount;
getClientCurrentSubAccount(client).cash -= amount;
updatePlayerCash(client);
messageClientSuccess(client, `You deposited $${amount} into business '${tempBusinessData.name}''s till'`);
}
// ---------------------------------------------------------------------------
function viewBusinessTillAmountCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
//if(areParamsEmpty(params)) {
// messageClientSyntax(client, getCommandSyntaxText(command));
// return false;
//}
let splitParams = params.split(" ");
let businessId = Number(splitParams[0]) || (isPlayerInAnyBusiness(client.player)) ? getPlayerBusiness(client.player) : getClosestBusinessEntrance(client.player.position);
messageClientSuccess(client, `Business '${serverData.businesses[businessId].name}''s till has $'${serverData.businesses[businessId].till}'!`);
}
// ---------------------------------------------------------------------------
function getBusinessDataFromDatabaseId(databaseId) {
let matchingBusinesses = serverData.businesses.filter(b => b.databaseId == businessId)
if(matchingBusinesses.length == 1) {
@@ -315,7 +571,32 @@ function getPlayerBusiness(player) {
// ---------------------------------------------------------------------------
function saveAllBusinessesToDatabase() {
for(let i in serverData.businesses) {
saveBusinessToDatabase(i);
}
}
// ---------------------------------------------------------------------------
function saveBusinessToDatabase(businessId) {
let tempBusinessData = serverData.businesses[businessId]
console.log(`[Asshat.Business]: Saving business '${tempBusinessData.name}' to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
if(tempBusinessData.databaseId == 0) {
let dbQueryString = `INSERT INTO biz_main (biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw) VALUES ('${tempBusinessData.name}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePos.x}, ${tempBusinessData.entrancePos.y}, ${tempBusinessData.entrancePos.z}, ${tempBusinessData.entranceHeading}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPos.x}, ${tempBusinessData.exitPos.y}, ${tempBusinessData.exitPos.z}, ${tempBusinessData.exitHeading}, ${tempBusinessData.exitInterior}, ${tempBusinessData.exitDimension})`;
queryDatabase(dbConnection, dbQueryString);
serverData.businesses[businessId].databaseId = getDatabaseInsertId(dbConnection);
} else {
let dbQueryString = `UPDATE biz_main SET biz_name=${tempBusinessData.name}, biz_owner_type=${tempBusinessData.ownerType}, biz_owner_id=${tempBusinessData.ownerId}, biz_locked=${boolToInt(tempBusinessData.locked)}, biz_entrance_fee=${tempBusinessData.entranceFee}, biz_till=${tempBusinessData.till}, biz_entrance_pos_x=${tempBusinessData.entrancePos.x}, biz_entrance_pos_y=${tempBusinessData.entrancePos.y}, biz_entrance_pos_z=${tempBusinessData.entrancePos.z}, biz_entrance_rot_z=${tempBusinessData.entranceHeading}, biz_entrance_int=${tempBusinessData.entranceInterior}, biz_entrance_vw=${tempBusinessData.entranceDimension}, biz_exit_pos_x=${tempBusinessData.exitPos.x}, biz_exit_pos_y=${tempBusinessData.exitPos.y}, biz_exit_pos_z=${tempBusinessData.exitPos.z}, biz_exit_rot_z=${tempBusinessData.exitHeading}, biz_exit_int=${tempBusinessData.exitInterior}, biz_exit_vw=${tempBusinessData.exitDimension} WHERE biz_id=${tempBusinessData.databaseId}`;
queryDatabase(dbConnection, dbQueryString);
}
disconnectFromDatabase(dbConnection);
return true;
}
console.log(`[Asshat.Business]: Saved business '${tempBusinessData.name}' to database!`);
return false;
}
// ---------------------------------------------------------------------------
@@ -326,4 +607,71 @@ function createAllBusinessPickups() {
serverData.businesses[i].pickup.setData("ag.ownerType", AG_PICKUP_BUSINESS, true);
serverData.businesses[i].pickup.setData("ag.ownerId", i, true);
}
}
}
// ---------------------------------------------------------------------------
function deleteBusiness(businessId) {
let tempBusinessData = serverData.businesses[businessId];
let dbConnection = connectToDatabase();
let dbQuery = null;
if(dbConnection) {
dbQuery = queryDatabase(dbConnection, `UPDATE biz_main SET biz_deleted = 1 AND biz_who_deleted = ${getClientData(client).accountData.databaseId} AND biz_when_deleted = UNIX_TIMESTAMP() WHERE biz_id = ${tempBusinessData.databaseId} LIMIT 1`);
if(dbQuery) {
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
destroyElement(tempBusinessData.pickup);
removePlayersFromBusiness(businessId);
}
// ---------------------------------------------------------------------------
/*
function deleteBusiness(businessId) {
let tempBusinessData = serverData.businesses[businessId];
let dbConnection = connectToDatabase();
let dbQuery = null;
if(dbConnection) {
dbQuery = queryDatabase(dbConnection, `UPDATE biz_main SET biz_deleted = 1 AND biz_who_deleted = ${getClientData(client).accountData.databaseId} AND biz_when_deleted = UNIX_TIMESTAMP() WHERE biz_id = ${tempBusinessData.databaseId} LIMIT 1`);
if(dbQuery) {
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
destroyElement(tempBusinessData.pickup);
removePlayersFromBusiness(businessId);
}
*/
// ---------------------------------------------------------------------------
function removePlayersFromBusiness(businessId) {
getClients().forEach(function(client) {
if(client.getData("ag.inBusiness")) {
if(client.getData("ag.inBusiness") == businessId) {
exitBusiness(client);
}
}
});
}
// ---------------------------------------------------------------------------
function exitBusiness(client) {
let businessId = client.getData("ag.inBusiness");
if(client.player) {
triggerNetworkEvent("ag.interior", client, serverData.businesses[businessId].entranceInterior);
triggerNetworkEvent("ag.dimension", client, serverData.businesses[businessId].entranceDimension);
triggerNetworkEvent("ag.position", client, serverData.businesses[businessId].entrancePosition);
}
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bakery.js
// DESC: Provides bakery business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bar.js
// DESC: Provides bar/pub business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: burger.js
// DESC: Provides burger joint (McDonalds?) business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: clothing.js
// DESC: Provides clothing (skin) business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: club.js
// DESC: Provides club/nightclub business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: fuel.js
// DESC: Provides fuel/petrol business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: mechanic.js
// DESC: Provides mechanic/vehicle repair business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: pizza.js
// DESC: Provides pizza restaurant business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: restaurant.js
// DESC: Provides generic restaurant business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: vehicle.js
// DESC: Provides vehicle dealership business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: weapon.js
// DESC: Provides weapon (ammu) business functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: chat.js
// DESC: Provides chat functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: clan.js
// DESC: Provides clan functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: class.js
// DESC: Provides classes
@@ -92,12 +92,33 @@ function initClassTable() {
this.locked = businessAssoc("biz_locked");
this.entrancePosition = new Vec3(businessAssoc("biz_entrance_pos_x"), businessAssoc("biz_entrance_pos_y"), businessAssoc("biz_entrance_pos_z"));
this.entranceRotation = Number(businessAssoc["biz_entrance_rot_z"]);
this.entranceInterior = Number(businessAssoc["biz_entrance_int"]);
this.entranceDimension = Number(businessAssoc["biz_entrance_vw"]);
this.exitPosition = new Vec3(businessAssoc("biz_exit_pos_x"), businessAssoc("biz_exit_pos_y"), businessAssoc("biz_exit_pos_z"));
this.exitRotation = Number(businessAssoc["biz_exit_rot_z"]);
this.exitInterior = Number(businessAssoc["biz_exit_int"]);
this.exitDimension = Number(businessAssoc["biz_exit_vw"]);
this.till = Number(businessAssoc["biz_till"]);
}
},
locationData: class {
constructor(locationAssoc) {
if(!locationAssoc) {
return;
}
this.databaseId = locationAssoc("biz_id");
this.name = locationAssoc("loc_name");
this.type = locationAssoc("loc_type");
this.business = locationAssoc("loc_biz");
this.enabled = locationAssoc("loc_enabled");
this.position = new Vec3(businessAssoc("loc_pos_x"), businessAssoc("loc__pos_y"), businessAssoc("loc_pos_z"));
this.interior = Number(businessAssoc["loc_int"]);
this.dimension = Number(businessAssoc["loc_vw"]);
}
},
houseData: class {
@@ -117,6 +138,7 @@ function initClassTable() {
this.model = vehicle.modelIndex;
this.vehicle = vehicle;
this.tempVehicle = false;
this.streamedBy = false; // For IV only
// Ownership
this.ownerType = AG_VEHOWNER_NONE;

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: client.js
// DESC: Provides client communication and cross-endpoint operations

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: colour.js
// DESC: Provides colours, functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: command.js
// DESC: Provides command data, functions and usage
@@ -24,6 +24,8 @@ function loadCommandData() {
commandData("changepass", changePasswordCommand, "<password>", getStaffFlagValue("none"), true, false),
//commandData("setpass", changePasswordCommand, "<password>", getStaffFlagValue("none"), true, false),
commandData("switchchar", switchCharacterCommand, "", getStaffFlagValue("none"), true, false),
commandData("newchar", newCharacterCommand, "<first name> <last name>", getStaffFlagValue("none"), true, false),
commandData("usechar", useCharacterCommand, "<character id>", getStaffFlagValue("none"), true, false),
],
ammunation: [],
ban: [
@@ -33,8 +35,17 @@ function loadCommandData() {
],
bitFlag: [],
business: [
commandData("addbiz", createBusinessCommand, "<name>", getStaffFlagValue("manageBusinesses"), true, false),
commandData("addbiz", createBusinessCommand, "<name>", getStaffFlagValue("manageBusinesses"), true, false),
commandData("delbiz", deleteBusinessCommand, "[id]", getStaffFlagValue("manageBusinesses"), true, true),
commandData("addloc", createBusinessLocationCommand, "<type> <business id> <name>", getStaffFlagValue("manageBusinesses"), true, false),
commandData("delloc", deleteBusinessLocationCommand, "[id]", getStaffFlagValue("manageBusinesses"), true, false),
commandData("lockbiz", lockBusinessCommand, "", getStaffFlagValue("none"), true, true),
commandData("enterfee", setBusinessEntranceFeeCommand, "<amount>", getStaffFlagValue("none"), true, true),
commandData("till", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true),
commandData("bizwithdraw", withdrawFromBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true),
commandData("bizdeposit", depositIntoBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true),
commandData("bizname", setBusinessNameCommand, "<name>", getStaffFlagValue("none"), true, true),
commandData("bizowner", setBusinessOwnerCommand, "<player name/id>", getStaffFlagValue("none"), true, true),
],
chat: [
commandData("me", meActionCommand, "<message>", getStaffFlagValue("none"), true, false),
@@ -104,7 +115,12 @@ function loadCommandData() {
],
locale: [],
messaging: [],
misc: [],
misc: [
commandData("settime", setTimeCommand, "<hour> [minute]", getStaffFlagValue("manageServer"), true, true),
commandData("setweather", setWeatherCommand, "<weather id/name>", getStaffFlagValue("manageServer"), true, true),
commandData("setsnow", setSnowingCommand, "<falling snow> <ground snow>", getStaffFlagValue("manageServer"), true, true),
commandData("setlogo", toggleServerLogoCommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true),
],
moderation: [
commandData("kick", kickClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true),
commandData("mute", muteClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true),
@@ -179,6 +195,12 @@ function getCommandRequiredPermissions(command) {
// ---------------------------------------------------------------------------
function getCommandSyntaxText(command) {
return getCommand(command).syntaxString;
}
// ---------------------------------------------------------------------------
function isCommandAllowedOnDiscord(command) {
return getCommand(command).allowOnDiscord;
}

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: config.js
// DESC: Provides server configuration
@@ -9,6 +9,15 @@
// ===========================================================================
let serverConfig = {
useGUI: true,
name: "Asshat Gaming Roleplay",
password: "LockedForStartup*128",
hour: 0,
minute: 0,
weather: 1,
fallingSnow: 0,
groundSnow: 0,
showLogo: true,
colour: {
byType: {
talkMessage: toColour(200, 200, 200),
@@ -42,27 +51,16 @@ let serverConfig = {
burntYellow: toColour(210, 210, 0, 255),
burntOrange: toColour(210, 120, 0, 255),
bankGreen: toColour(0, 150, 0, 255),
softGreen: toColour(144, 255, 96, 255),
}
},
accountPasswordHash: "SHA512",
connectCameraPosition: [
false,
new Vec3(-1176.481, -17.694, 95.992),
false,
false,
false,
],
connectCameraLookAt: [
false,
new Vec3(-1175.726, -17.055, 95.847),
false,
false,
false,
],
connectCameraPosition: false,
connectCameraLookAt: false,
newCharacter: {
spawnPosition: new Vec3(1038.40, -666.70, 14.97),
spawnPosition: false,
spawnHeading: 0.0,
money: 1000,
money: 0,
},
npcFarProximity: 100,
npcMediumProximity: 40,
@@ -145,6 +143,58 @@ let serverConfig = {
vehicleLightsKey: SDLK_k,
vehicleLocksKey: SDLK_l,
},
discordBotToken: "",
discordEnabled: false,
};
// ----------------------------------------------------------------------------
function loadServerConfig() {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${server.game} AND svr_port = ${server.port} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
serverId = dbAssoc["svr_id"];
serverConfig.name = dbAssoc["svr_name"];
serverConfig.password = dbAssoc["svr_password"];
serverConfig.newCharacter.spawnPosition = new Vec3(dbAssoc["svr_newchar_pos_x"], dbAssoc["svr_newchar_pos_y"], dbAssoc["svr_newchar_pos_z"]);
serverConfig.newCharacter.spawnHeading = dbAssoc["svr_newchar_rot_z"];
serverConfig.newCharacter.money = dbAssoc["svr_newchar_money"];
serverConfig.newCharacter.bank = dbAssoc["svr_newchar_bank"];
serverConfig.newCharacter.skin = dbAssoc["svr_newchar_skin"];
serverConfig.connectCameraPosition = new Vec3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]);
serverConfig.connectCameraLookAt = new Vec3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]);
serverConfig.hour = dbAssoc["svr_start_time_hour"];
serverConfig.minute = dbAssoc["svr_start_time_min"];
serverConfig.weather = dbAssoc["svr_start_weather"];
serverConfig.fallingSnow = intToBool(dbAssoc["svr_start_snow_falling"]);
serverConfig.groundSnow = intToBool(dbAssoc["svr_start_snow_ground"]);
serverConfig.useGUI = intToBool(dbAssoc["svr_gui"]);
applyConfigToServer();
freeDatabaseQuery(dbQuery);
}
}
disconnectFromDatabase(dbConnection);
}
}
// ----------------------------------------------------------------------------
function applyConfigToServer() {
server.name = serverConfig.name;
server.password = serverConfig.password;
gta.time.hour = serverConfig.hour;
gta.time.minute = serverConfig.minute;
gta.forceWeather(serverConfig.weather);
updateServerRules();
}
// ----------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: const.js
// DESC: Provides constants
@@ -40,4 +40,26 @@ const AG_VEHOWNER_PLAYER = 1;
const AG_VEHOWNER_JOB = 2;
const AG_VEHOWNER_CLAN = 3;
const AG_VEHOWNER_FACTION = 4;
const AG_VEHOWNER_PUBLIC = 5;
const AG_VEHOWNER_PUBLIC = 5;
// Business Owner Types
const AG_BIZOWNER_NONE = 0;
const AG_BIZOWNER_PLAYER = 1;
const AG_BIZOWNER_JOB = 2;
const AG_BIZOWNER_CLAN = 3;
const AG_BIZOWNER_FACTION = 4;
const AG_BIZOWNER_PUBLIC = 5;
// House Owner Types
const AG_HOUSEOWNER_NONE = 0;
const AG_HOUSEOWNER_PLAYER = 1;
const AG_HOUSEOWNER_JOB = 2;
const AG_HOUSEOWNER_CLAN = 3;
const AG_HOUSEOWNER_FACTION = 4;
const AG_HOUSEOWNER_PUBLIC = 5;
// Business Location Types
const AG_BIZLOC_NONE = 0;
const AG_BIZLOC_FUEL = 1;
const AG_BIZLOC_DRIVETHRU = 2;
const AG_BIZLOC_VENDMACHINE = 3;

View File

@@ -1,14 +1,14 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: core.js
// DESC: Provides core data structures, function, and operations
// TYPE: Server (JavaScript)
// ===========================================================================
let serverId = server.game;
let serverId = 0;
// ----------------------------------------------------------------------------
@@ -260,16 +260,111 @@ let serverData = {
},
],
[ // GTA VC
{
position: new Vec3(399.77, -468.90, 11.73),
heading: 0.0,
blip: false,
name: "Washington Beach",
},
{
position: new Vec3(508.96, 512.07, 12.10),
heading: 0.0,
blip: false,
name: "Vice Point",
},
{
position: new Vec3(-657.43, 762.31, 11.59),
heading: 0.0,
blip: false,
name: "Downtown",
},
{
position: new Vec3(-885.08, -470.44, 13.11),
heading: 0.0,
blip: false,
name: "Little Havana",
},
],
[ // GTA SA
{
position: new Vec3(1545.53, -1675.64, 13.561),
heading: -1.575,
blip: false,
name: "Los Santos",
},
],
[ // GTA UG
],
[ // GTA IV
{
position: new Vec3(894.99, -357.39, 18.185),
heading: 2.923,
blip: false,
name: "Broker",
},
{
position: new Vec3(435.40, 1592.29, 17.353),
heading: 3.087,
blip: false,
name: "South Bohan",
},
{
position: new Vec3(974.93, 1870.45, 23.073),
heading: -1.621,
blip: false,
name: "Northern Gardens",
},
{
position: new Vec3(1233.25, -89.13, 28.034),
heading: 1.568,
blip: false,
name: "South Slopes",
},
{
position: new Vec3(50.12, 679.88, 15.316),
heading: 1.569,
blip: false,
name: "Middle Park East",
},
{
position: new Vec3(85.21, 1189.82, 14.755),
heading: 3.127,
blip: false,
name: "East Holland",
},
{
position: new Vec3(2170.87, 448.87, 6.085),
heading: 1.501,
blip: false,
name: "Francis International Airport",
},
{
position: new Vec3(213.12, -211.70, 10.752),
heading: 0.200,
blip: false,
name: "Chinatown",
},
{
position: new Vec3(-1714.95, 276.31, 22.134),
heading: 1.127,
blip: false,
name: "Acter",
},
{
position: new Vec3(-1220.73, -231.53, 3.024),
heading: 2.210,
blip: false,
name: "Port Tudor",
},
{
position: new Vec3(-927.66, 1263.63, 24.587),
heading: -0.913,
blip: false,
name: "Leftwood",
},
]
],
fireStations: [
@@ -304,8 +399,37 @@ let serverData = {
],
[ // GTA IV
]
{
position: new Vec3(953.13, 95.90, 35.004),
heading: 1.595,
blip: false,
name: "Broker",
},
{
position: new Vec3(-271.02, 1542.15, 20.420),
heading: -1.160,
blip: false,
name: "Northwood",
},
{
position: new Vec3(1120.47, 1712.36, 10.534),
heading: -0.682,
blip: false,
name: "Northern Gardens",
},
{
position: new Vec3(2364.87, 166.83, 5.813),
heading: 0.156,
blip: false,
name: "Francis International Airport",
},
{
position: new Vec3(295.40, -336.88, 4.963),
heading: 2.887,
blip: false,
name: "Chinatown",
},
]
],
hospitals: [
false,
@@ -339,7 +463,30 @@ let serverData = {
],
[ // GTA IV
{
position: new Vec3(1199.59, 196.78, 33.554),
heading: 1.633,
blip: false,
name: "Schottler",
},
{
position: new Vec3(980.71, 1831.61, 23.898),
heading: -0.049,
blip: false,
name: "Northern Gardens",
},
{
position: new Vec3(-1317.27, 1277.20, 22.370),
heading: 2.246,
blip: false,
name: "Leftwood",
},
{
position: new Vec3(-1538.43, 344.58, 20.943),
heading: -0.156,
blip: false,
name: "Acter",
},
]
],
payAndSprays: [
@@ -737,4 +884,11 @@ function getServerId() {
return serverId;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
function getServerGame() {
return server.game;
}
// ----------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: database.js
// DESC: Provides database handling, functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: developer.js
// DESC: Provides developer operation, commands, functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: discord.js
// DESC: Provides discord bridging and connection functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
@@ -10,24 +10,25 @@
addEventHandler("OnPlayerJoined", function(event, client) {
setTimeout(function() {
triggerNetworkEvent("ag.connectCamera", client, serverConfig.connectCameraPosition[getServerGame()], serverConfig.connectCameraLookAt[getServerGame()]);
initClient(client);
//triggerNetworkEvent("ag.connectCamera", client, serverConfig.connectCameraPosition[getServerGame()], serverConfig.connectCameraLookAt[getServerGame()]);
client.setData("ag.loginAttemptsRemaining", 3, false);
//client.setData("ag.loginAttemptsRemaining", 3, false);
let tempAccountData = loadAccountFromName(client.name);
let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
//let tempAccountData = loadAccountFromName(client.name);
//let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
serverData.clients[client.index] = new serverClasses.clientData(client, tempAccountData, tempSubAccounts);
//serverData.clients[client.index] = new serverClasses.clientData(client, tempAccountData, tempSubAccounts);
sendAllBlips(client);
//sendAllBlips(client);
if(tempAccountData != false) {
triggerNetworkEvent("ag.showLogin", client);
//messageClient("Welcome back to Asshat Gaming RP, " + String(client.name) + "! Please /login to continue.", client, serverConfig.colour.byName["white"]);
} else {
triggerNetworkEvent("ag.showRegistration", client);
//messageClient("Welcome to Asshat Gaming RP, " + String(client.name) + "! Please /register to continue.", client, serverConfig.colour.byName["white"]);
}
//if(tempAccountData != false) {
// triggerNetworkEvent("ag.showLogin", client);
// //messageClient("Welcome back to Asshat Gaming RP, " + String(client.name) + "! Please /login to continue.", client, serverConfig.colour.byName["white"]);
//} else {
// triggerNetworkEvent("ag.showRegistration", client);
// //messageClient("Welcome to Asshat Gaming RP, " + String(client.name) + "! Please /register to continue.", client, serverConfig.colour.byName["white"]);
//}
}, 500);
});
@@ -52,9 +53,17 @@ addEventHandler("OnPedSpawn", function(event, ped) {
// ---------------------------------------------------------------------------
addEventHandler("OnPedWasted", function(event, wastedPed, killerPed, weaponId, pedPiece) {
let closestHospital = getClosestHospital(wastedPed.position);
let client = getClientFromPedElement(wastedPed);
spawnPlayer(client, closestHospital.position, closestHospital.heading, getClientCurrentSubAccount(client).skin);
if(ped.isType(ELEMENT_PLAYER)) {
let closestHospital = getClosestHospital(wastedPed.position);
let client = getClientFromPedElement(wastedPed);
client.despawnPlayer();
if(getClientCurrentSubAccount(client).inJail) {
let closestJail = getClosestJail(wastedPed.position);
spawnPlayer(client, closestJail.position, closestJail.heading, getClientCurrentSubAccount(client).skin);
} else {
spawnPlayer(client, closestHospital.position, closestHospital.heading, getClientCurrentSubAccount(client).skin);
}
}
});
// ---------------------------------------------------------------------------
@@ -68,13 +77,7 @@ bindEventHandler("OnResourceStop", thisResource, function(event, resource) {
// ---------------------------------------------------------------------------
bindEventHandler("OnResourceStart", thisResource, function(event, resource) {
getClients().forEach(function(client) {
initClient(client);
});
//createAllLocationBlips();
//initAllClients();
});
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: faction.js
// DESC: Provides faction functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: help.js
// DESC: Provides update info, help commands, and documentation

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: house.js
// DESC: Provides house commands, functions, and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: item.js
// DESC: Provides item functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: job.js
// DESC: Provides job functions and usage
@@ -75,7 +75,7 @@ function sendAllJobSpheres() {
function createAllJobPickups() {
for(let i in serverData.jobs[getServerGame()]) {
serverData.jobs[getServerGame()][i].pickup = createPickup(serverData.jobs[getServerGame()][i].pickupModel, serverData.jobs[getServerGame()][i].position);
serverData.jobs[getServerGame()][i].pickup = gta.createPickup(serverData.jobs[getServerGame()][i].pickupModel, serverData.jobs[getServerGame()][i].position);
serverData.jobs[getServerGame()][i].pickup.setData("ag.ownerType", AG_PICKUP_JOB, true);
serverData.jobs[getServerGame()][i].pickup.setData("ag.ownerId", i, true);
@@ -323,7 +323,7 @@ function startWorking(client) {
getClientCurrentSubAccount(client).isWorking = true;
let jobId = getClientCurrentSubAccount(client).job;
switch(serverData.jobs[getServerGame()][jobId].jobType) {
switch(getJobType(jobId)) {
case AG_JOB_POLICE:
messageClientInfo(client, "Use /uniform and /equip to get your equipment.");
break;
@@ -370,7 +370,7 @@ function stopWorking(client) {
getClientCurrentSubAccount(client).isWorking = false;
triggerNetworkEvent("ag.skin", null, client.player, getClientCurrentSubAccount(client).skin);
triggerNetworkEvent("ag.skin", client, getClientCurrentSubAccount(client).skin);
let jobVehicle = getClientCurrentSubAccount(client).lastJobVehicle;
if(jobVehicle) {
@@ -394,7 +394,7 @@ function stopWorking(client) {
triggerNetworkEvent("ag.clearWeapons", client);
let jobId = getClientCurrentSubAccount(client).job;
switch(serverData.jobs[getServerGame()][jobId].jobType) {
switch(getJobType(jobId)) {
case AG_JOB_POLICE:
messageClientInfo(client, "Your uniform, equipment, and police car have been returned to the police station");
break;
@@ -456,41 +456,41 @@ function jobUniformCommand(command, params, client) {
let jobId = getClientCurrentSubAccount(client).job;
getClientCurrentSubAccount(client).jobUniform = uniformId-1;
switch(serverData.jobs[getServerGame()][jobId].jobType) {
switch(getJobType(jobId)) {
case AG_JOB_POLICE:
triggerNetworkEvent("ag.skin", null, client.player, serverData.policeJobSkins[getServerGame()][uniformId-1]);
triggerNetworkEvent("ag.skin", client, serverData.policeJobSkins[getServerGame()][uniformId-1]);
//client.player.modelIndex = serverData.policeJobSkins[getServerGame()][uniformId];
triggerNetworkEvent("ag.giveWeapon", client, 2, 200, false);
triggerNetworkEvent("ag.giveWeapon", client, 1, 1, false);
break;
case AG_JOB_MEDICAL:
triggerNetworkEvent("ag.skin", null, client.player, serverData.medicalJobSkins[getServerGame()][uniformId-1]);
triggerNetworkEvent("ag.skin", client, serverData.medicalJobSkins[getServerGame()][uniformId-1]);
//client.player.modelIndex = serverData.medicalJobSkins[getServerGame()][uniformId];
messageClientInfo(client, "Your uniform and ambulance have been returned to the hospital");
break;
case AG_JOB_FIRE:
triggerNetworkEvent("ag.skin", null, client.player, serverData.fireJobSkins[getServerGame()][uniformId-1]);
triggerNetworkEvent("ag.skin", client, serverData.fireJobSkins[getServerGame()][uniformId-1]);
//client.player.modelIndex = serverData.fireJobSkins[getServerGame()][uniformId];
messageClientInfo(client, "Your uniform and fire truck have been returned to the fire station");
break;
case AG_JOB_BUS:
triggerNetworkEvent("ag.skin", null, client.player, serverData.busJobSkins[getServerGame()][uniformId-1]);
triggerNetworkEvent("ag.skin", client, serverData.busJobSkins[getServerGame()][uniformId-1]);
//client.player.modelIndex = serverData.busJobSkins[getServerGame()][uniformId];
messageClientInfo(client, "Your bus has been returned to the bus depot");
break;
case AG_JOB_TAXI:
triggerNetworkEvent("ag.skin", null, client.player, serverData.taxiJobSkins[getServerGame()][uniformId-1]);
triggerNetworkEvent("ag.skin", client, serverData.taxiJobSkins[getServerGame()][uniformId-1]);
//client.player.modelIndex = serverData.taxiJobSkins[getServerGame()][uniformId];
messageClientInfo(client, "Your taxi has been returned to the taxi depot");
break;
case AG_JOB_GARBAGE:
triggerNetworkEvent("ag.skin", null, client.player, serverData.garbageJobSkins[getServerGame()][uniformId-1]);
triggerNetworkEvent("ag.skin", client, serverData.garbageJobSkins[getServerGame()][uniformId-1]);
//client.player.modelIndex = serverData.garbageJobSkins[getServerGame()][uniformId];
messageClientInfo(client, "Your trash truck has been returned to the city landfill");
break;

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bus.js
// DESC: Provides bus driver job functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: drug.js
// DESC: Provides drug runner/dealer job functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: fire.js
// DESC: Provides firefighter job functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: garbage.js
// DESC: Provides garbage collector job functions and usage

View File

@@ -1,9 +1,9 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: medic.js
// DESC: Provides medic job functions and usage
// DESC: Provides paramedic job functions and usage
// TYPE: Job (JavaScript)
// ===========================================================================

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: police.js
// DESC: Provides police officer job functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: taxi.js
// DESC: Provides taxi driver job functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2019 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: weapon.js
// DESC: Provides weapons dealer job functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: locale.js
// DESC: Provides locale structures, functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: messaging.js
// DESC: Provides messaging functions and usage
@@ -10,11 +10,28 @@
// ---------------------------------------------------------------------------
function messageAdminAction(messageText) {
message(`⚠️ ${messageText}`, getColourByName("orange"));
messageDiscord(`:warning: ${messageText}`);
}
// ---------------------------------------------------------------------------
function messageClientNormal(client, messageText, colour = COLOUR_WHITE) {
if(client instanceof Client) {
messageClient(`${messageText}`, client, colour);
} else {
messageDiscordUser(client, `:no_entry_sign: ${messageText}`);
}
}
// ---------------------------------------------------------------------------
function messageClientError(client, messageText) {
if(client instanceof Client) {
messageClientNormal(client, `🚫 ${messageText}`, getColourByType("errorMessage"));
} else {
messageDiscordUser(client, `🚫 ${messageText}`);
messageDiscordUser(client, `:no_entry_sign: ${messageText}`);
}
}
@@ -24,7 +41,7 @@ function messageClientSyntax(client, messageText) {
if(client instanceof Client) {
messageClientNormal(client, `⌨️ [#FFFFFF] ${messageText}`, getColourByType("syntaxMessage"));
} else {
messageDiscordUser(client, `⌨️ ${messageText}`);
messageDiscordUser(client, `:keyboard: ${messageText}`);
}
}
@@ -34,7 +51,7 @@ function messageClientAlert(client, messageText) {
if(client instanceof Client) {
messageClientNormal(client, `⚠️ [#FFFFFF] ${messageText}`, getColourByType("alertMessage"));
} else {
messageDiscordUser(client, `⚠️ ${messageText}`);
messageDiscordUser(client, `:warning: ${messageText}`);
}
}
@@ -44,7 +61,7 @@ function messageClientSuccess(client, messageText) {
if(client instanceof Client) {
messageClientNormal(client, `👍 [#FFFFFF] ${messageText}`, getColourByType("successMessage"));
} else {
messageDiscordUser(client, `👍 ${messageText}`);
messageDiscordUser(client, `:thumbsup: ${messageText}`);
}
}
@@ -54,7 +71,7 @@ function messageClientInfo(client, messageText) {
if(client instanceof Client) {
messageClientNormal(client, ` [#FFFFFF] ${messageText}`, getColourByType("successMessage"));
} else {
messageDiscordUser(client, ` ${messageText}`);
messageDiscordUser(client, `:information_source: ${messageText}`);
}
}

View File

@@ -1,11 +1,169 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: misc.js
// DESC: Provides any uncategorized functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// FUCK
// ---------------------------------------------------------------------------
function initBusinessScript() {
console.log("[Asshat.Misc]: Initializing misc script ...");
addMiscCommandHandlers();
console.log("[Asshat.Misc]: Misc script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addMiscCommandHandlers() {
console.log("[Asshat.Misc]: Adding misc commands!");
let businessCommands = serverCommands.misc;
for(let i in businessCommands) {
addCommandHandler(businessCommands[i].command, businessCommands[i].handlerFunction);
}
console.log("[Asshat.Misc]: Misc commands added!");
return true;
}
// ---------------------------------------------------------------------------
function setTimeCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split();
let hour = Number(splitParams[0]) || 0;
let minute = Number(splitParams[1]) || 0;
if(hour > 23 || hour < 0) {
messageClientError(client, "The hour must be between 0 and 23!");
return false;
}
if(minute > 59 || minute < 0) {
messageClientError(client, "The minute must be between 0 and 59!");
return false;
}
gta.time.hour = hour;
gta.time.minute = minute;
messageAdminAction(`${client.name} set the time to ${makeReadableTime(hour, minute)}`);
return true;
}
// ---------------------------------------------------------------------------
function setWeatherCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split();
let weatherId = getWeatherFromParams(splitParams[0]);
if(!weatherId) {
messageClientError(client, `That weather ID or name is invalid!`);
return false;
}
gta.forceWeather(weatherId);
messageAdminAction(`${client.name} set the weather to to ${weatherNames[server.game][weatherId]}`);
updateServerRules();
return true;
}
// ---------------------------------------------------------------------------
function setSnowingCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split();
let fallingSnow = Number(splitParams[0]) || 0;
let groundSnow = Number(splitParams[1]) || 0;
serverConfig.fallingSnow = 0;
messageAdminAction(`${client.name} turned falling snow ${getOnOffFromBool(intToBool(fallingSnow))} and ground snow ${getOnOffFromBool(intToBool(groundSnow))}`);
updateServerRules();
return true;
}
// ---------------------------------------------------------------------------
function toggleServerLogoCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split();
let logoState = Number(splitParams[0]) || 1;
serverConfig.useLogo = !!logoState;
messageAdminAction(`${client.name} turned the server logo image ${getOnOffFromBool(intToBool(fallingSnow))}`);
updateServerRules();
return true;
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: moderation.js
// DESC: Provides moderation commands, functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: native.js
// DESC: Provides util function to wrap mod-specific stuff

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: npc.js
// DESC: Provides NPC usage and functions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,9 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: police.js
// DESC: Provides police officer NPC interaction and functionality
// TYPE: Server (JavaScript)
// ===========================================================================

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: security.js
// DESC: Provides security functions and usage

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: startup.js
// DESC: Provides startup/shutdown procedures
@@ -9,6 +9,7 @@
// ===========================================================================
function initServerScripts() {
checkForAllRequiredModules();
initClassScript();
@@ -27,7 +28,13 @@ function initServerScripts() {
initVehicleScript();
initDeveloperScript();
serverData.saveDataIntervalTimer = setInterval(saveAllServerDataToDatabase, 600000);
initTimers();
//gta.time.hour = serverConfig.startup.hour;
//gta.time.minute = serverConfig.startup.minute;
//gta.forceWeather(serverConfig.startup.weather);
initAllClients();
}
// ---------------------------------------------------------------------------
@@ -52,26 +59,27 @@ function checkForMySQLModule() {
// ---------------------------------------------------------------------------
function checkForAllRequiredModules() {
console.log("[AsshatRP.Startup]: Checking for required modules ...");
console.log("[Asshat.Startup]: Checking for required modules ...");
if(!checkForHashingModule()) {
console.warn("[AsshatRP.Startup]: Hashing module is not loaded!");
console.warn("[AsshatRP.Startup]: This resource will now shutdown.");
console.warn("[Asshat.Startup]: Hashing module is not loaded!");
console.warn("[Asshat.Startup]: This resource will now shutdown.");
thisResource.stop();
}
if(!checkForMySQLModule()) {
console.warn("[AsshatRP.Startup]: MySQL module is not loaded!");
console.warn("[AsshatRP.Startup]: This resource will now shutdown.");
console.warn("[Asshat.Startup]: MySQL module is not loaded!");
console.warn("[Asshat.Startup]: This resource will now shutdown.");
thisResource.stop();
}
console.log("[AsshatRP.Startup]: All required modules loaded!");
console.log("[Asshat.Startup]: All required modules loaded!");
return true;
}
// ---------------------------------------------------------------------------
loadServerConfig();
initServerScripts();
// ----------------------------------------------------------------------------
// ---------------------------------------------------------------------------

36
scripts/server/timers.js Normal file
View File

@@ -0,0 +1,36 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: timers.js
// DESC: Provides timer functions and features
// TYPE: Server (JavaScript)
// ===========================================================================
let serverTimers = {};
// ---------------------------------------------------------------------------
function updateTimeRule() {
server.setRule("Time", makeReadableTime(gta.time.hour, gta.time.minute));
}
// ---------------------------------------------------------------------------
function saveAllServerDataToDatabase() {
console.log("[Asshat.Utilities]: Saving all server data to database ...");
saveAllClientsToDatabase();
saveAllVehiclesToDatabase();;
saveAllHousesToDatabase();
saveAllBusinessesToDatabase();
saveAllClansToDatabase();
console.log("[Asshat.Utilities]: Saved all server data to database!");
}
// ---------------------------------------------------------------------------
function initTimers() {
serverTimers.saveDataIntervalTimer = setInterval(saveAllServerDataToDatabase, 600000);
serverTimers.updateTimeRuleTimer = setInterval(updateTimeRule, 1000);
}

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: translate.js
// DESC: Provides translation functions

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: utilities.js
// DESC: Provides util functions and arrays with data
@@ -98,6 +98,18 @@ let gameData = {
"Sandstorm",
"Greenish/Foggy"
],
[ // GTA IV
"Extra Sunny",
"Sunny",
"Sunny/Windy",
"Cloudy",
"Rain",
"Light Rain",
"Foggy",
"Thunderstorm",
"Extra Sunny",
"Sunny/Windy",
],
],
gameNames: [
"Unknown",
@@ -1972,6 +1984,354 @@ let gameData = {
// More will be added soon!
],
],
gtaivSkinModels: [
//["Nico Bellic", 1862763509],
["Male Multiplayer", -2020305438],
["Female Multiplayer", -641875910],
["MODEL_SUPERLOD", -1370810922],
["Anna", 1853617247],
["Anthony", -1646893330],
["Badman", 1495769888],
["Bernie Crane", 1500493064],
["Bledar", 1731510984],
["Brian", 422305098],
["Brucie", -1729980128],
["Bulgarin", 237511807],
["Charise", 88667657],
["Charlie Undercover", -1328445565],
["Clarence", 1343144208],
["Dardan", 1468450703],
["Darko", 386513184],
["Derric", 1169442297],
["Dmitri", 237497537],
["Dwayne", -617264103],
["Eddie", -1600585231],
["Faustin", 57218969],
["Francis", 1710545037],
["French Tom", 1424670436],
["Gordon", 2129490787],
["Gracie", -357652594],
["Hossan", 980768434],
["Ilyena", -835225126],
["Issac", -479595866],
["Ivan", 1166762483],
["Jay", 364686627],
["Jason", 170756246],
["Jeff", 390357829],
["Jimmy", -366421228],
["Johnny Klebitz", -911507684],
["Kate", -773750838],
["Kenny", 995576506],
["Lil Jacob", 1487004273],
["Lil Jacob 2", -1275031987],
["Luca", -681942840],
["Luis", -492470690],
["Mallorie", -1040287406],
["Mam", -322700377],
["Manny", 1445589009],
["Marnie", 411185872],
["Mel", -807339118],
["Michael", 735211577],
["Michelle", -1080659212],
["Mickey", -636669566],
["Packie", 1690783035],
["Pathos", -165448092],
["Petrovic", -1947682830],
["Phil Bell", -1826458934],
["Playboy X", 1794146792],
["Ray Boccino", 954215094],
["Ricky", -587324132],
["Roman", -1992728631],
["Roman 2", 558221221],
["Sarah", -17823883],
["Tuna", 1384833284],
["Vinny Spaz", -1014976873],
["Vlad", 896408642],
["Black Street Thug 1", -301223260],
["Black Street Thug 2", -1143910864],
["Black Street OG 1", 869501081],
["Black Street OG 1", 632613980],
["Albanian Thug 1", -503930010],
["Albanian Thug 2", -235584669],
["Albanian Thug 3", 207714363],
["Albanian Thug 4", 514268366],
["Biker 1", 43005364],
["Biker 2", 1346668127],
["Biker 3", -1677255197],
["Biker 4", -1461281345],
["Biker 5", 1574850459],
["Biker 6", -1953289472],
["Irish Man 1", 280474699],
["Irish Man 2", -19263344],
["Irish Man 3", 1844702918],
["Jamaican OG 1", 1609755055],
["Jamaican OG 2", -330497431],
["Jamaican OG 3", 1117105909],
["Jamaican Thug 1", -1500397869],
["Jamaican Thug 2", -881358690],
["Asian Man 1", 1540383669],
["Asian Man 2", 764249904],
["Hispanic Man 1", 492147228],
["Hispanic Man 2", -1926041127],
["Hispanic Man 3", 1168388225],
["Hispanic Man 4", -1746774780],
["Fat Italian Mafia Boss", -302362397],
["Italian Mafia Boss", -1616890832],
["Italian Mafia Associate", 64730935],
["Fat Italian Mafia Associate", 510389335],
["Russian Thug 1", -1836006237],
["Russian Thug 2", -2088164056],
["Russian Thug 3", 1976502708],
["Russian Thug 4", 1543404628],
["Russian Thug 5", 1865532596],
["Russian Thug 6", 431692232],
["Russian Thug 7", 1724587620],
["Russian Thug 8", -1180674815],
["Triad Boss 1", 871281791],
["Triad Boss 2", 683712035],
["Triad Member 3", -1084007777],
["Triad Member 4", -164935626],
["Female Maid", -751071255],
["Female Binco Worker", -109247258],
["Female Bank Teller", 1366257926],
["Female Doctor", 346338575],
["Female Gym Worker", 1350216795],
["Female Burger Shot Worker", 924926104],
["Female Cluckin Bell Worker", -346378101],
["Female Rockstar Cafe Worker", -2104311883],
["Female TW@ Cafe Worker", 212900845],
["Female Well Stacked Pizza Worker", -290070895],
["Hooker", 552542187],
["Hooker 2", 996267216],
["Nurse", -1193778389],
["Stripper 1", 1113677074],
["Stripper 2", 1353709999],
["Waitress", 24233425],
["Alcoholic Man", -1761003415],
["Armoured Truck Driver", 1075583233],
["Bus Driver", 134077503],
["Generic Asian Man", 757349871],
["Black Crackhead", -1827421800],
["Doctor (Scrubs)", 219393781],
["Doctor", -1186940778],
["Doctor (Blood Covered Coat)", 375732086],
["Cook", 2105015949],
["Italian Mob Enforcer", -200234085],
["Factory Worker", 800131009],
["FIB Agent", -999506922],
["Fat Delivery Driver", -1993909080],
["Fire Chief", 610888851],
["Mercenary Soldier", 486302863],
["Helicopter Pilot", -778316080],
["Hotel Doorman", 624314380],
["Korean Cook", -1784833142],
["Lawyer 1", -1852976689],
["Lawyer 2", -1134712978],
["Loony Black Man", 379171768],
["Pilot", -1945168882],
["Generic Man", 807236245],
["Postal Worker", -284362863],
["Saxophone Player", -1188246269],
["Security Guard", -1870989171],
["Stadium Food Vendor", 420915580],
["Stadium Food Cook", 1878085135],
["Street Food Vendor", 142730876],
["Street Sweeper Driver", -690681764],
["Taxi Driver", 8772846],
["Telephone Company Worker", 1186270890],
["Tennis Player", -379234846],
["Train Conductor", 1159759556],
["Homeless Black Man", -142386662],
["Trucker", -46564867],
["Janitor", -1284047560],
["Hotel Doorman 2", 22944263],
["Mob Boss", 1178487645],
["Airport Worker", -1464712858],
["Bartender", -2139064254],
["Biker Bouncer", -1780698891],
["High End Club Bouncer", -409283472],
["Bowling Alley Worker", -799229885],
["Bowling Alley Worker 2", -434183225],
["Chinese Food Vendor", 768442188],
["Club Security", 676448572],
["Construction Worker", -722019798],
["Construction Worker 2", -1015957728],
["Construction Worker 3", -714220780],
["Police Officer", -183203150],
["Traffic Officer", -1518937979],
["Fat Police Officer", -370395528],
["Courier", -1371133859],
["Cowboy 1", -573788283],
["Drug Dealer 1", -1283406538],
["Drug Dealer 2", 1448755353],
["Male Burger Shot Worker", 989485],
["Male Cluckin Bell Worker", -1011530423],
["Male Rockstar Cafe Worker", 1979561477],
["Male TW@ Cafe Worker", -786449781],
["Male Well Stacked Pizza Worker", 206941425],
["Firefighter", -610224615],
["Garbage Collector", 1136499716],
["Goon", 897868981],
["Male Gym Worker", -1902758612],
["Mechanic 2", -356904519],
["Male Modo Worker", -1056268969],
["Helicopter Pilot", 1201610759],
["Perseus", -151000142],
["Generic Male 1", 501136335],
["Generic Male 2", 186619473],
["Generic Male 3", -111611196],
["Paramedic", -1175077216],
["Prisoner", -1676937780],
["Prisoner 2", 215190023],
["Roman's Taxi Service Driver", 1552970117],
["Male Runner", -1481923910],
["Male Shop Assistant 1", 357919731],
["State Trooper", -89302119],
["SWAT", -1004762946],
["Sword Swallower", -64233032],
["Thief", -1292254815],
["Valet", 271284208],
["Vendor", -186113957],
["French Tom", -2015686009],
["Jim Fitz", 1977784957],
["East European Woman", -203833294],
["East European Woman 2", 189853472],
["Woman", -349043578],
["Jersey Woman", -114937692],
["Oriental Woman", -1697333660],
["Rich Woman", 100706569],
["Business Woman 1", 155063868],
["Business Woman 2", 394310337],
["Chinatown Woman", 1375728805],
["Business Woman 3", -284229525],
["East European Woman 3", 677687516],
["Fat Black Woman", -1188238883],
["Jersey Woman 1", -2075220936],
["Jersey Woman 2", -1356924456],
["Fat Hispanic Woman 1", 812112483],
["Fat Hispanic Woman 2", -129242580],
["White Manhattan Woman", 852423121],
["Black Manhattan Woman", 76551508],
["Old Asian Woman", -2118501976],
["Old Rich Woman", 1616769823],
["Business Woman 4", 453889158],
["Asian Woman in Dress", 824245375],
["Fat Black Bronx Woman", -1362442041],
["Random White Woman", -1788328884],
["Random Hispanic Woman", -1523915823],
["Random Eastern European Woman", -949987237],
["Random Black Woman", -1926577323],
["Black Harlem Woman 1", 168065679],
["Fat Jersey Woman 1", 441464],
["Fat Hispanic Woman 3", 54114008],
["Hispanic Woman 1", -292713088],
["Hispanic Woman 2", 1743814728],
["Manhattan Woman 1", 1670568326],
["Manhattan Woman 2", 1354281938],
["Manhattan Woman 1", 1056837725],
["Asian Woman 1", -1193633577],
["Black Woman 2", 713691120],
["Rich White Woman 1", -1780385799],
["Asian Woman", -952185135],
["Female Shopper 1", 1586287288],
["Female Shopper 2", 1848013291],
["Female Shopper 3", -1702036227],
["Female Socialite 1", 1182843182],
["Street Woman 1", -900623157],
["Street Woman 2", 286007875],
["Street Woman 3", 1473654742],
["Street Woman 4", -1850743775],
["Street Woman 5", 1290755317],
["Street Woman 6", 1872110126],
["Tourist Woman 1", 1754440500],
["MODEL_F_Y_VILLBO_01", 761763258],
["Business Man 1", -636579119],
["Business Man 2", -1754526315],
["Street Criminal 1", -1516474414],
["Street Criminal 2", -1821258883],
["Obese Mafia Thug", 1952671026],
["Gay Man 1", -1991603022],
["Homeless Bum 1", -1080673049],
["Loony White Man 1", 495499562],
["MODEL_M_M_MIDTOWN_01", -1984134881],
["Business Man 2", 1063816580],
["Eastern European Man 1", 208763854],
["Fat Black Man 2", -1020237172],
["MODEL_M_M_PINDUS_02", 1782277836],
["Fat Italian Man 1", -1402442039],
["Italian Man 2", -1628417063],
["Hispanic Man 1", 1158569407],
["Hispanic Man 2", 1969438324],
["Hispanic Man 3", 1621955848],
["Tourist Man 1", -657489059],
["Black Business Man 1", -1307068958],
["Asian Man 3", 734334931],
["MODEL_M_M_PRICH_01", 1865082075],
["MODEL_M_O_EASTEURO_01", -432593815],
["Hasidic Jewish Man 1", -1639359785],
["Old Man 1", 1656087115],
["MODEL_M_O_PEASTEURO_02", 2034185905],
["MODEL_M_O_PHARBRON_01", 1316404726],
["MODEL_M_O_PJERSEY_01", 980990533],
["MODEL_M_O_STREET_01", -1298691925],
["Old Business Man", 243672348],
["MODEL_M_Y_BOHO_01", 2085884255],
["MODEL_M_Y_BOHOGUY_01", 221246143],
["MODEL_M_Y_BRONX_01", 52357603],
["Black Business Man 2", 1530937394],
["Black Business Man 3", 690281432],
["Asian Man 4", -1149743642],
["Chopshop Mechanic 1", -314369597],
["Chopshop Mechanic 2", -552829610],
["MODEL_M_Y_DODGY_01", -1097188138],
["MODEL_M_Y_DORK_02", -1775659292],
["MODEL_M_Y_DOWNTOWN_01", 1207402441],
["MODEL_M_Y_DOWNTOWN_02", 1500619449],
["MODEL_M_Y_DOWNTOWN_03", 594261682],
["MODEL_M_Y_GAYYOUNG", -747824291],
["MODEL_M_Y_GENSTREET_11", -677160979],
["MODEL_M_Y_GENSTREET_16", -1678614360],
["MODEL_M_Y_GENSTREET_20", 989044076],
["MODEL_M_Y_GENSTREET_34", 1180218190],
["MODEL_M_Y_HARDMAN_01", -1420592428],
["MODEL_M_Y_HARLEM_01", -1222963415],
["MODEL_M_Y_HARLEM_02", -1746153269],
["MODEL_M_Y_HARLEM_04", 2104499156],
["Hasidic Jewish Man 2", -1874580889],
["MODEL_M_Y_LEASTSIDE_01", -1055386282],
["MODEL_M_Y_PBRONX_01", 575808580],
["MODEL_M_Y_PCOOL_01", -71980543],
["MODEL_M_Y_PCOOL_02", -195159218],
["MODEL_M_Y_PEASTEURO_01", 697247370],
["MODEL_M_Y_PHARBRON_01", 670406267],
["MODEL_M_Y_PHARLEM_01", 26615298],
["MODEL_M_Y_PJERSEY_01", 1542927558],
["MODEL_M_Y_PLATIN_01", -1806886352],
["MODEL_M_Y_PLATIN_02", -1022920796],
["MODEL_M_Y_PLATIN_03", -1326394505],
["MODEL_M_Y_PMANHAT_01", 607901190],
["MODEL_M_Y_PMANHAT_02", 1968470106],
["MODEL_M_Y_PORIENT_01", -344136289],
["MODEL_M_Y_PQUEENS_01", 560413584],
["MODEL_M_Y_PRICH_01", 1352017873],
["MODEL_M_Y_PVILLBO_01", 223726252],
["MODEL_M_Y_PVILLBO_02", -1252681043],
["MODEL_M_Y_PVILLBO_03", -1562020391],
["MODEL_M_Y_QUEENSBRIDGE", 1223224881],
["MODEL_M_Y_SHADY_02", -1220737489],
["MODEL_M_Y_SKATEBIKE_01", 1755322862],
["MODEL_M_Y_SOHO_01", 386690478],
["MODEL_M_Y_STREET_01", 62496225],
["MODEL_M_Y_STREET_03", 523785438],
["MODEL_M_Y_STREET_04", 813889395],
["MODEL_M_Y_STREETBLK_02", -1552214124],
["MODEL_M_Y_STREETBLK_03", -650575089],
["Street Punk 1", -740078918],
["Street Punk 2", -1927496394],
["Street Punk 3", 1374242512],
["Tough Guy", -1139941790],
["Male Tourist", 809067472],
],
};
// ---------------------------------------------------------------------------
@@ -3281,6 +3641,7 @@ function sendAllPayAndSprayBlips(client) {
function sendAllFuelStationBlips(client) {
if(serverConfig.blipSprites[getServerGame()].fuelStation != -1) {
let tempBlips = [];
for(let i in serverData.fuelStations[getServerGame()]) {
tempBlips.push([
serverConfig.blipSprites[getServerGame()].fuelStation,
@@ -3359,15 +3720,7 @@ function canClientUseGuns(client) {
// ---------------------------------------------------------------------------
function saveAllServerDataToDatabase() {
console.log("[Asshat.Utilities]: Saving all server data to database ...");
saveAllClientsToDatabase();
saveAllVehiclesToDatabase();;
saveAllHousesToDatabase();
saveAllBusinessesToDatabase();
saveAllClansToDatabase();
console.log("[Asshat.Utilities]: Saved all server data to database!");
}
// ---------------------------------------------------------------------------
@@ -3458,7 +3811,7 @@ function processHoldVehicleEngineKey(client) {
function getClientChatColour(client) {
let tempJob = getClientCurrentSubAccount(client).job;
if(job != -1) {
if(tempJob != -1) {
if(getClientData(client).isWorking) {
return getJobData(tempJob).jobColour;
}
@@ -3466,4 +3819,67 @@ function getClientChatColour(client) {
return getColourByName("white");
}
// ---------------------------------------------------------------------------
function showConnectCameraToPlayer(client) {
triggerNetworkEvent("ag.connectCamera", client, serverConfig.connectCameraPosition, serverConfig.connectCameraLookAt);
//triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
}
// ---------------------------------------------------------------------------
function initAllClients() {
getClients().forEach(function(client) {
initClient(client);
});
}
// ---------------------------------------------------------------------------
function getYesNoFromBool(boolVal) {
return (boolVal) ? "Yes" : "No";
}
// ---------------------------------------------------------------------------
function updateServerRules() {
server.setRule("Time", makeReadableTime(serverConfig.hour, serverConfig.minute));
server.setRule("Weather", gameData.weatherNames[server.game][serverConfig.weather]);
server.setRule("Snowing", getYesNoFromBool(serverConfig.fallingSnow));
}
// ---------------------------------------------------------------------------
function getWeatherFromParams(params) {
if(isNaN(params)) {
for(let i in weatherNames[server.game]) {
if(weatherNames[server.game][i].toLowerCase().indexOf(params.toLowerCase()) != -1) {
return i;
}
}
return false;
} else {
if(typeof weatherNames[server.game][i] != "undefined") {
return i;
}
return false;
}
return false;
}
// ---------------------------------------------------------------------------
function updatePlayerCash(client) {
triggerNetworkEvent("ag.money", getClientCurrentSubAccount(client).cash);
}
// ---------------------------------------------------------------------------
function clearChatBox(client) {
//gta.messages.clear();
for(let i = 0; i <= 20; i++) {
messageClient(" ", client, COLOUR_WHITE);
}
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat Gaming RP
// http://asshatgaming.com
// © 2020 Asshat Gaming
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: vehicle.js
// DESC: Provides vehicle functions and usage
@@ -38,7 +38,7 @@ function loadVehiclesFromDatabase() {
let tempVehicles = [];
let dbAssoc;
if(dbConnection) {
let dbQueryString = `SELECT * FROM veh_main WHERE veh_server = ${serverId}`;
let dbQueryString = `SELECT * FROM veh_main WHERE veh_server = ${serverId} AND veh_deleted = 0`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
@@ -75,25 +75,12 @@ function saveVehicleToDatabase(vehicleData) {
if(dbConnection) {
// If vehicle hasn't been added to database, ID will be 0
if(vehicleData.databaseId == 0) {
//let dbQueryColourFields = "`veh_col1_id`, `veh_col2_id`, `veh_col3_id1, `veh_col4_id`";
//if(vehicleData.colourType == AH_VEH_COLOURTYPE_RGBA) {
// dbQueryColourFields = "`veh_col1_rgba`, `veh_col2_rgba`, `veh_col3_rgba`, `veh_col4_rgba`";
// dbQueryColourValues = vehicleData.colour1Red, `veh_col1_g`, `veh_col1_b`, `veh_col1_a`, `veh_col2_r`, `veh_col2_g`, `veh_col2_b`, `veh_col2_a`, `veh_col3_r`, `veh_col3_g`, `veh_col3_b`, `veh_col3_a`, `veh_col4_r`, `veh_col4_g`, `veh_col4_b`, `veh_col4_a`,";
//}
let dbQueryString = `INSERT INTO veh_main (veh_model, veh_pos_x, veh_pos_y, veh_pos_z, veh_rot_z, veh_owner_type, veh_owner_id) VALUES (${vehicleData.model}, ${vehicleData.spawnPosition.x}, ${vehicleData.spawnPosition.y}, ${vehicleData.spawnPosition.z}, ${vehicleData.spawnRotation}, ${vehicleData.ownerType}, ${vehicleData.ownerId})`;
let dbQueryString = `INSERT INTO veh_main (veh_model, veh_pos_x, veh_pos_y, veh_pos_z, veh_rot_z, veh_owner_type, veh_owner_id, veh_col1, veh_col2, veh_col3, veh_col4, veh_server) VALUES (${vehicleData.model}, ${vehicleData.spawnPosition.x}, ${vehicleData.spawnPosition.y}, ${vehicleData.spawnPosition.z}, ${vehicleData.spawnRotation}, ${vehicleData.ownerType}, ${vehicleData.ownerId}, ${vehicleData.colour1}, ${vehicleData.colour2}, ${vehicleData.colour3}, ${vehicleData.colour4}, ${serverId})`;
queryDatabase(dbConnection, dbQueryString);
//if(getDatabaseError(dbConnection)) {
// console.warn(`[Asshat.Vehicle]: There was a problem saving vehicle ${vehicleData.vehicle.id} to the database (INSERT). Error: ${getDatabaseError(dbConnection)}`);
// return false;
//}
getVehicleData(vehicleData.vehicle).databaseId = getDatabaseInsertId(dbConnection);
} else {
let dbQueryString = `UPDATE veh_main SET veh_model=${vehicleData.model}, veh_pos_x=${vehicleData.spawnPosition.x}, veh_pos_y=${vehicleData.spawnPosition.y}, veh_pos_z=${vehicleData.spawnPosition.z}, veh_rot_z=${vehicleData.spawnRotation}, veh_owner_type=${vehicleData.ownerType}, veh_owner_id=${vehicleData.ownerId} WHERE veh_id=${vehicleData.databaseId}`;
let dbQueryString = `UPDATE veh_main SET veh_model=${vehicleData.model}, veh_pos_x=${vehicleData.spawnPosition.x}, veh_pos_y=${vehicleData.spawnPosition.y}, veh_pos_z=${vehicleData.spawnPosition.z}, veh_rot_z=${vehicleData.spawnRotation}, veh_owner_type=${vehicleData.ownerType}, veh_owner_id=${vehicleData.ownerId}, veh_col1=${vehicleData.colour1}, veh_col2=${vehicleData.colour2}, veh_col3=${vehicleData.colour3}, veh_col4=${vehicleData.colour4} WHERE veh_id=${vehicleData.databaseId}`;
queryDatabase(dbConnection, dbQueryString);
//if(getDatabaseError(dbConnection)) {
// console.warn(`[Asshat.Vehicle]: There was a problem saving vehicle ${vehicleData.vehicle.id} to the database (UPDATE). Error: ${getDatabaseError(dbConnection)}`);
// return false;
//}
}
disconnectFromDatabase(dbConnection);
return true;
@@ -106,6 +93,10 @@ function saveVehicleToDatabase(vehicleData) {
// ---------------------------------------------------------------------------
function spawnAllVehicles() {
//if(gta.game == GAME_GTA_IV) {
// return false;
//}
for(let i in serverData.vehicles) {
let vehicle = gta.createVehicle(serverData.vehicles[i].model, serverData.vehicles[i].spawnPosition, serverData.vehicles[i].spawnRotation);
addToWorld(vehicle);
@@ -174,7 +165,7 @@ function createVehicleCommand(command, params, client) {
let frontPos = getPosInFrontOfPos(client.player.position, client.player.heading, serverConfig.spawnCarDistance);
let vehicle = createVehicle(modelId, frontPos, client.player.heading);
let vehicle = gta.createVehicle(modelId, frontPos, client.player.heading);
vehicle.heading = client.player.heading;
let tempVehicleData = new serverClasses.vehicleData(false, vehicle);
@@ -493,8 +484,8 @@ function setVehicleClanCommand(command, params, client) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
@@ -534,8 +525,8 @@ function setVehicleOwnerCommand(command, params, client) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
@@ -732,4 +723,23 @@ function toggleVehicleSpawnLockCommand(command, params, client) {
messageClientInfo(client, `This vehicle will now spawn ${(getVehicleData(vehicle).spawnLocked) ? "here" : "wherever a player leaves it."}`);
}
// ---------------------------------------------------------------------------
function sendAllVehiclesToClient(client) {
/*
let tempVehicles = [];
for(let i in serverData.vehicles) {
let thisVehicle = serverData.vehicles[i];
tempVehicles.push({
model: thisVehicle.model,
spawnPosition: thisVehicle.spawnPosition,
spawnHeading: thisVehicle.spawnHeading,
colours: [thisVehicle.colour1, thisVehicle.colour2, thisVehicle.colour3, thisVehicle.colour4],
locked: thisVehicle.locked,
});
}
*/
}
// ---------------------------------------------------------------------------

View File

@@ -1,20 +0,0 @@
{
"database": {
"host":"158.69.238.64",
"user":"db24053",
"pass":"G3At3d7BsA",
"name":"db24053",
"port":"3306"
},
"weather": {
"appKey":""
},
"discord": {
"token":"",
"logChannel":""
},
"security": {
"accountPasswordHashType":"SHA256",
"saltFormat":"asshat.gaming.{HASH}.{NAME}.{PASS}"
}
}

View File

@@ -21,12 +21,15 @@ mexui.Component.Control.defaultStyles = mexui.util.linkStyles(mexui.Entity.Style
// input
mexui.Component.Control.prototype.onMouseDown = function(e)
{
var hit = this.isCursorOverControl();
if(hit)
if(e.button == 0)
{
e.used = true;
e.clickedAControl = true;
mexui.focusedControl = this;
var hit = this.isCursorOverControl();
if(hit)
{
e.used = true;
e.clickedAControl = true;
mexui.focusedControl = this;
}
}
};

View File

@@ -45,7 +45,7 @@ mexui.Component.Window.defaultStyles = mexui.util.linkStyles(mexui.Entity.Stylea
// input
mexui.Component.Window.prototype.onMouseDown = function(e)
{
if(this.titleBarShown && this.titleBarIconShown && this.isCursorOverCloseIcon())
if(e.button == 0 && this.titleBarShown && this.titleBarIconShown && this.isCursorOverCloseIcon())
{
this.shown = false;
mexui.setInput(false);
@@ -240,7 +240,14 @@ mexui.Component.Window.prototype.triggerEvent = function(eventName, e, data, cal
{
this.controls[i][eventName].call(control, e, data);
if(e.used)
{
if(e.button == 0 && eventName == 'onMouseDown')
{
mexui.focusedControl = this.controls[i];
e.clickedAControl = true;
}
break;
}
if(mexui.Entity.Component.prototype[eventName])
{
@@ -360,6 +367,8 @@ mexui.Component.Window.prototype.minute = function(x, y, w, h, text, styles, c
mexui.Component.Window.prototype.month = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Month(this, x, y, w, h, text, styles, callback)); };
mexui.Component.Window.prototype.number = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Number(this, x, y, w, h, text, styles, callback)); };
mexui.Component.Window.prototype.password = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Password(this, x, y, w, h, text, styles, callback)); };
mexui.Component.Window.prototype.positiveInteger = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.PositiveInteger(this, x, y, w, h, text, styles, callback)); };
mexui.Component.Window.prototype.positiveNumber = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.PositiveNumber(this, x, y, w, h, text, styles, callback)); };
mexui.Component.Window.prototype.progressBar = function(x, y, w, h, text, styles) { return this.addControl(new mexui.Control.ProgressBar(this, x, y, w, h, text, styles)); };
mexui.Component.Window.prototype.radioButton = function(x, y, w, h, text, groupId, styles, callback) { return this.addControl(new mexui.Control.RadioButton(this, x, y, w, h, text, groupId, styles, callback)); };
mexui.Component.Window.prototype.rangedInteger = function(x, y, w, h, text, min, max, styles, callback) { return this.addControl(new mexui.Control.RangedInteger(this, x, y, w, h, text, min, max, styles, callback)); };
@@ -375,5 +384,6 @@ mexui.Component.Window.prototype.textInput = function(x, y, w, h, text, styles,
mexui.Component.Window.prototype.time = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Time(this, x, y, w, h, text, styles, callback)); };
mexui.Component.Window.prototype.tree = function(x, y, w, h, styles, callback) { return this.addControl(new mexui.Control.Tree(this, x, y, w, h, styles, callback)); };
mexui.Component.Window.prototype.week = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Week(this, x, y, w, h, text, styles, callback)); };
mexui.Component.Window.prototype.weekDay = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.WeekDay(this, x, y, w, h, text, styles, callback)); };
mexui.Component.Window.prototype.year = function(x, y, w, h, text, styles, callback) { return this.addControl(new mexui.Control.Year(this, x, y, w, h, text, styles, callback)); };

View File

@@ -11,7 +11,16 @@ mexui.util.linkBaseControlStyles('Button', {});
// input
mexui.Control.Button.prototype.onMouseDown = function(e)
{
if(this.isCursorOverControl())
if(e.button == 0 && this.isCursorOverControl())
{
e.used = true;
this.checkToCallCallback();
}
};
mexui.Control.Button.prototype.onKeyDown = function(e, key, mods)
{
if(this.isFocused() && (key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE))
{
e.used = true;
this.checkToCallCallback();
@@ -25,4 +34,7 @@ mexui.Control.Button.prototype.render = function()
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
mexui.native.drawText(pos, this.size, this.text, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};

View File

@@ -19,11 +19,22 @@ mexui.util.linkBaseControlStyles('CheckBox', {
// input
mexui.Control.CheckBox.prototype.onMouseDown = function(e)
{
if(this.isCursorOverControl())
if(e.button == 0 && this.isCursorOverControl())
{
e.used = true;
this.checked = !this.checked;
this.checkToCallCallback();
this.toggleChecked();
}
};
mexui.Control.CheckBox.prototype.onKeyDown = function(e, key, mods)
{
if(this.isFocused())
{
if(key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE)
{
e.used = true;
this.toggleChecked();
}
}
};
@@ -38,6 +49,9 @@ mexui.Control.CheckBox.prototype.render = function()
mexui.native.drawRectangle(mexui.util.addVec2(pos, new Vec2(1, 1)), new Vec2(this.size.x - 2, this.size.y - 2), this.getStyles('innerBox'));
mexui.native.drawText(mexui.util.addVec2(pos, new Vec2(this.size.x + this.textMarginLeft, 2)), this.size, this.text, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};
// model
@@ -45,4 +59,10 @@ mexui.Control.CheckBox.prototype.getSizeForInput = function()
{
var textWidth = mexui.native.getTextWidth(this.text, this.getStyles('main'));
return new Vec2(this.size.x + this.textMarginLeft + textWidth, this.size.y);
};
mexui.Control.CheckBox.prototype.toggleChecked = function()
{
this.checked = !this.checked;
this.checkToCallCallback();
};

View File

@@ -9,6 +9,11 @@ mexui.util.createControlConstructor('Date', false, function(window, x, y, w, h,
this.inputShown = false;
this.valueBoxSize = new Vec2(50, 30);
this.arrowBoxSize = new Vec2(25, 22);
this.maxYearOffset = 10;
this.minYearCallback = ()=>{ return 1900; };
this.maxYearCallback = ()=>{ return new Date().getFullYear() + this.maxYearOffset; }
this.twoDigitYearCapOffset = 10;
});
mexui.util.extend(mexui.Control.Date, mexui.Control.TextInput);
@@ -51,10 +56,12 @@ mexui.Control.Date.prototype.onMouseDown = function(e)
else if(this.month == 13)
this.month = 1;
if(this.year == 1899)
this.year = 1900;
else if(this.year == 2020)
this.year = 2019;
var minYear = this.minYearCallback();
var maxYear = this.maxYearCallback();
if(this.year < minYear)
this.year = minYear;
else if(this.year > maxYear)
this.year = maxYear;
this.generateText();
@@ -113,31 +120,44 @@ mexui.Control.Date.prototype.renderAfter = function()
// model
mexui.Control.Date.prototype.generateText = function()
{
this.text = (this.day < 10 ? '0'+this.day : this.day)
this.setText((this.day < 10 ? '0'+this.day : this.day)
+'/'+(this.month < 10 ? '0'+this.month : this.month)
+'/'+(this.year < 10 ? '0'+this.year : this.year);
+'/'+(this.year < 10 ? '0'+this.year : this.year));
};
mexui.Control.Date.prototype.validateInputCallback = function(e, character)
{
var text = this.getTextWithNewCharacter(character);
var parts = text.split(':');
return mexui.util.isPositiveIntChar(character) || mexui.util.isLetter(character) || character == '/';
};
mexui.Control.Date.prototype.validateValueCallback = function(e)
{
var parts = this.getText().split('/');
if(parts.length != 3)
return false;
for(var i in parts)
{
if(i == 3)
var partAsStr = parts[i];
if(partAsStr === '')
return false;
var part = parseInt(parts[i]);
if(isNaN(part))
return false;
if(part < 0)
return false;
if(part > (i == 0 ? 23 : 59))
return false;
if(i == 0)
{
if(!mexui.util.isDayIdWithOptionalSuffix(partAsStr))
return false;
}
else if(i == 1)
{
if(!mexui.util.isMonthIdOrName(partAsStr))
return false;
}
else if(i == 2)
{
if(!mexui.util.isYear(partAsStr, this.minYearCallback(), this.maxYearCallback(), this.twoDigitYearCapOffset))
return false;
}
}
return true;

View File

@@ -7,13 +7,10 @@ mexui.util.extend(mexui.Control.Day, mexui.Control.TextInput);
// model
mexui.Control.Day.prototype.validateInputCallback = function(e, character)
{
var _int = parseInt(character);
if(isNaN(_int))
return false;
if(_int < 0 || _int > 31)
return false;
return true;
return mexui.util.isPositiveIntChar(character) || mexui.util.isLetter(character);
};
mexui.Control.Day.prototype.validateValueCallback = function(e)
{
return mexui.util.isDayIdWithOptionalSuffix(this.getText());
};

View File

@@ -30,24 +30,25 @@ mexui.util.linkBaseControlStyles('DropDown', {
// input
mexui.Control.DropDown.prototype.onMouseDown = function(e)
{
if(this.axis.y.entries.length == 0)
return;
var hitButton = this.isCursorOverControl();
if(hitButton)
if(e.button == 0)
{
e.used = true;
this.setListShown(!this.axis.y.entriesShown);
}
else if(this.axis.y.entriesShown)
{
var selectedEntryIndex = this.axis.y.getEntryIndexByCursor();
if(selectedEntryIndex != null)
if(this.axis.y.entries.length == 0)
return;
var hitButton = this.isCursorOverControl();
if(hitButton)
{
e.used = true;
this.selectedEntryIndex = selectedEntryIndex;
this.checkToCallCallback();
this.setListShown(false);
this.setListShown(!this.axis.y.entriesShown);
}
else if(this.isListShown())
{
var selectedEntryIndex = this.axis.y.getEntryIndexByCursor();
if(selectedEntryIndex != null)
{
this.selectEntryByIndex(selectedEntryIndex);
e.used = true;
}
}
}
@@ -55,6 +56,27 @@ mexui.Control.DropDown.prototype.onMouseDown = function(e)
mexui.Entity.ControlWithEntries.prototype.onMouseDown.call(this, e);
};
mexui.Control.DropDown.prototype.onKeyDown = function(e, key, mods)
{
if(this.isFocused())
{
if(key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE)
{
var selectedEntryIndex = this.axis.y.getEntryIndexByCursor();
if(selectedEntryIndex == null)
{
this.setListShown(!this.isListShown());
e.used = true;
}
else
{
this.selectEntryByIndex(selectedEntryIndex);
e.used = true;
}
}
}
};
// render
mexui.Control.DropDown.prototype.render = function()
{
@@ -72,6 +94,9 @@ mexui.Control.DropDown.prototype.render = function()
}
mexui.Entity.ControlWithEntries.prototype.render.call(this);
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};
mexui.Control.DropDown.prototype.renderAfter = function()
@@ -79,10 +104,14 @@ mexui.Control.DropDown.prototype.renderAfter = function()
if(this.axis.y.entriesShown)
{
var pos = this.getScreenPosition();
var pos2 = new Vec2(pos.x, pos.y);
pos.x += this.entriesPositionOffset.x;
pos.y += this.entriesPositionOffset.y;
pos2.x += this.entriesPositionOffset.x;
pos2.y += this.entriesPositionOffset.y;
for(var i=this.axis.y.getEntryStartIndex(),j=this.axis.y.getEntryEndIndex(); i<j; i++)
{
var item = this.axis.y.entries[i];
@@ -96,6 +125,9 @@ mexui.Control.DropDown.prototype.renderAfter = function()
pos.y += this.entrySize.y;
}
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(new Vec2(this.entrySize.x,this.axis.y.getDisplayedEntriesLength()),new Vec2(3,3)), this.getStyles('focused'));
}
mexui.Entity.ControlWithEntries.prototype.renderAfter.call(this);
@@ -115,3 +147,14 @@ mexui.Control.DropDown.prototype.setListShown = function(shown)
this.axis.y.setScrollBarShown(shown);
};
mexui.Control.DropDown.prototype.isListShown = function()
{
return this.axis.y.entriesShown;
};
mexui.Control.DropDown.prototype.selectEntryByIndex = function(entryIndex)
{
this.selectedEntryIndex = entryIndex;
this.checkToCallCallback();
this.setListShown(false);
};

View File

@@ -77,6 +77,9 @@ mexui.Control.Grid.prototype.render = function()
startY += row.rowHeight;
mexui.native.drawAALine(new Vec2(pos.x, startY), new Vec2(pos.x + this.size.x, startY), this.getStyles('row'));
}
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};
// model

View File

@@ -7,12 +7,14 @@ mexui.util.extend(mexui.Control.Hour, mexui.Control.TextInput);
// model
mexui.Control.Hour.prototype.validateInputCallback = function(e, character)
{
var _int = parseInt(character);
return mexui.util.isPositiveIntChar(character);
};
mexui.Control.Hour.prototype.validateValueCallback = function(e)
{
var _int = parseInt(this.getText());
if(isNaN(_int))
return false;
if(_int < 0 || _int > 23)
if(_int < 1 || _int > 23)
return false;
return true;

View File

@@ -14,4 +14,7 @@ mexui.Control.Image.prototype.render = function()
var pos = this.getScreenPosition();
mexui.native.drawImage(pos, this.size, this.image, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};

View File

@@ -7,5 +7,10 @@ mexui.util.extend(mexui.Control.Integer, mexui.Control.TextInput);
// model
mexui.Control.Integer.prototype.validateInputCallback = function(e, character)
{
return !isNaN(parseInt(this.getTextWithNewCharacter(character)));
return mexui.util.isIntChar(character);
};
mexui.Control.Integer.prototype.validateValueCallback = function(e)
{
return mexui.util.isInt(this.getText());
};

View File

@@ -23,7 +23,7 @@ mexui.util.linkBaseControlStyles('List', {
// input
mexui.Control.List.prototype.onMouseDown = function(e)
{
if(this.isCursorOverControl())
if(e.button == 0 && this.isCursorOverControl())
{
this.activeRow = this.axis.y.getEntryByCursor();
this.checkToCallCallback();
@@ -34,6 +34,7 @@ mexui.Control.List.prototype.onMouseDown = function(e)
mexui.Control.List.prototype.render = function()
{
var pos = this.getScreenPosition();
var pos2 = new Vec2(pos.x, pos.y);
for(var i in this.axis.y.entries)
{
@@ -46,6 +47,9 @@ mexui.Control.List.prototype.render = function()
pos.y += this.rowHeight;
mexui.native.drawAALine(pos, new Vec2(pos.x + this.size.x, pos.y), this.getStyles('rowLine'));
}
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};
// model

View File

@@ -7,12 +7,14 @@ mexui.util.extend(mexui.Control.Minute, mexui.Control.TextInput);
// model
mexui.Control.Minute.prototype.validateInputCallback = function(e, character)
{
var _int = parseInt(character);
return mexui.util.isPositiveIntChar(character);
};
mexui.Control.Minute.prototype.validateValueCallback = function(e)
{
var _int = parseInt(this.getText());
if(isNaN(_int))
return false;
if(_int < 0 || _int > 59)
if(_int < 1 || _int > 59)
return false;
return true;

View File

@@ -7,13 +7,10 @@ mexui.util.extend(mexui.Control.Month, mexui.Control.TextInput);
// model
mexui.Control.Month.prototype.validateInputCallback = function(e, character)
{
var _int = parseInt(character);
if(isNaN(_int))
return false;
if(_int < 0 || _int > 11)
return false;
return true;
return mexui.util.isPositiveIntChar(character) || mexui.util.isLetter(character);
};
mexui.Control.Month.prototype.validateValueCallback = function(e)
{
return mexui.util.isMonthIdOrName(this.getText());
};

View File

@@ -7,5 +7,10 @@ mexui.util.extend(mexui.Control.Number, mexui.Control.TextInput);
// model
mexui.Control.Number.prototype.validateInputCallback = function(e, character)
{
return !isNaN(parseFloat(this.getTextWithNewCharacter(character)));
return mexui.util.isFloatChar(character);
};
mexui.Control.Number.prototype.validateValueCallback = function(e)
{
return mexui.util.isFloat(this.getText());
};

View File

@@ -0,0 +1,16 @@
mexui.util.createControlConstructor('PositiveInteger', false, function(window, x, y, w, h, text, styles, callback)
{
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('PositiveInteger', styles), callback, false, false);
});
mexui.util.extend(mexui.Control.PositiveInteger, mexui.Control.TextInput);
// model
mexui.Control.PositiveInteger.prototype.validateInputCallback = function(e, character)
{
return mexui.util.isPositiveIntChar(character);
};
mexui.Control.PositiveInteger.prototype.validateValueCallback = function(e)
{
return mexui.util.isPositiveInt(this.getText());
};

View File

@@ -0,0 +1,16 @@
mexui.util.createControlConstructor('PositiveNumber', false, function(window, x, y, w, h, text, styles, callback)
{
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('PositiveNumber', styles), callback, false, false);
});
mexui.util.extend(mexui.Control.PositiveNumber, mexui.Control.TextInput);
// model
mexui.Control.PositiveNumber.prototype.validateInputCallback = function(e, character)
{
return mexui.util.isPositiveFloatChar(character);
};
mexui.Control.PositiveNumber.prototype.validateValueCallback = function(e)
{
return mexui.util.isPositiveFloat(this.getText());
};

View File

@@ -20,13 +20,21 @@ mexui.util.linkBaseControlStyles('RadioButton', {
// input
mexui.Control.RadioButton.prototype.onMouseDown = function(e)
{
if(this.isCursorOverControl())
if(e.button == 0 && this.isCursorOverControl())
{
var checkedRadio = this.getCheckedRadio();
if(checkedRadio != this.checked)
checkedRadio.checked = false;
this.checked = !this.checked;
this.checkToCallCallback();
this.setChecked();
}
};
mexui.Control.RadioButton.prototype.onKeyDown = function(e, key, mods)
{
if(this.isFocused())
{
if(key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE)
{
e.used = true;
this.setChecked();
}
}
};
@@ -41,6 +49,9 @@ mexui.Control.RadioButton.prototype.render = function()
mexui.native.drawRectangle(mexui.util.addVec2(pos, new Vec2(2, 2)), new Vec2(this.size.x - 4, this.size.y - 4), this.getStyles('innerBox'));
mexui.native.drawText(mexui.util.addVec2(pos, new Vec2(this.size.x + this.textMarginLeft, 2)), this.size, this.text, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};
// model
@@ -85,4 +96,14 @@ mexui.Control.RadioButton.prototype.getCheckedRadio = function()
mexui.Control.RadioButton.prototype.isFirstRadioInGroup = function()
{
return this.getGroupRadios().length == 0;
};
mexui.Control.RadioButton.prototype.setChecked = function()
{
var checkedRadio = this.getCheckedRadio();
if(checkedRadio != this.checked)
checkedRadio.checked = false;
this.checked = !this.checked;
this.checkToCallCallback();
};

View File

@@ -10,13 +10,15 @@ mexui.util.extend(mexui.Control.RangedInteger, mexui.Control.TextInput);
// model
mexui.Control.RangedInteger.prototype.validateInputCallback = function(e, character)
{
var number = parseInt(this.getTextWithNewCharacter(character));
if(!isNaN(number))
return mexui.util.isIntChar(character);
};
mexui.Control.RangedInteger.prototype.validateValueCallback = function(e)
{
var text = this.getText();
if(!mexui.util.isInt(text))
return false;
if(number < this.min || number > this.max)
return false;
return true;
var _int = parseInt(text);
return _int >= this.min && _int <= this.max;
};

View File

@@ -10,13 +10,15 @@ mexui.util.extend(mexui.Control.RangedNumber, mexui.Control.TextInput);
// model
mexui.Control.RangedNumber.prototype.validateInputCallback = function(e, character)
{
var number = parseFloat(this.getTextWithNewCharacter(character));
if(!isNaN(number))
return mexui.util.isFloatChar(character);
};
mexui.Control.RangedNumber.prototype.validateValueCallback = function(e)
{
var text = this.getText();
if(!mexui.util.isFloat(text))
return false;
if(number < this.min || number > this.max)
return false;
return true;
var number = parseFloat(text);
return number >= this.min && number <= this.max;
};

View File

@@ -36,22 +36,25 @@ mexui.util.linkBaseControlStyles('ScrollBar', {
// input
mexui.Control.ScrollBar.prototype.onMouseDown = function(e)
{
if(mexui.util.isCursorInRectangle(this.getInnerBarPosition(), this.getInnerBarSize()))
if(e.button == 0)
{
e.used = true;
this.isScrolling = true;
}
else if(this.isCursorOverControl())
{
e.used = true;
this.scrolledRatio += this.getScrolledRatioOuterBarClickIncrease();
this.clampScrolledRatio();
if(mexui.util.isCursorInRectangle(this.getInnerBarPosition(), this.getInnerBarSize()))
{
e.used = true;
this.isScrolling = true;
}
else if(this.isCursorOverControl())
{
e.used = true;
this.scrolledRatio += this.getScrolledRatioOuterBarClickIncrease();
this.clampScrolledRatio();
}
}
};
mexui.Control.ScrollBar.prototype.onMouseUp = function(e)
{
if(this.isScrolling)
if(e.button == 0 && this.isScrolling)
{
this.isScrolling = false;
e.used = true;

View File

@@ -7,12 +7,14 @@ mexui.util.extend(mexui.Control.Second, mexui.Control.TextInput);
// model
mexui.Control.Second.prototype.validateInputCallback = function(e, character)
{
var _int = parseInt(character);
return mexui.util.isPositiveIntChar(character);
};
mexui.Control.Second.prototype.validateValueCallback = function(e)
{
var _int = parseInt(this.getText());
if(isNaN(_int))
return false;
if(_int < 0 || _int > 59)
if(_int < 1 || _int > 59)
return false;
return true;

View File

@@ -36,7 +36,7 @@ mexui.util.linkBaseControlStyles('Slider', {
// input
mexui.Control.Slider.prototype.onMouseDown = function(e)
{
if(this.isCursorOverInnerBar())
if(e.button == 0 && this.isCursorOverInnerBar())
{
this.sliding = true;
e.used = true;
@@ -45,7 +45,7 @@ mexui.Control.Slider.prototype.onMouseDown = function(e)
mexui.Control.Slider.prototype.onMouseUp = function(e)
{
if(this.sliding)
if(e.button == 0 && this.sliding)
{
this.sliding = false;
this.checkToCallCallback();
@@ -67,6 +67,7 @@ mexui.Control.Slider.prototype.onMouseMove = function(e, offset)
mexui.Control.Slider.prototype.render = function()
{
var pos = this.getScreenPosition();
var pos2 = new Vec2(pos.x, pos.y);
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
mexui.native.drawRectangle(this.getInnerBarPosition(), this.innerBarSize, this.getStyles('innerBar'));
@@ -81,6 +82,9 @@ mexui.Control.Slider.prototype.render = function()
pos.x += this.size.x - mexui.native.getTextWidth(this.maxText, this.getStyles('maxText'));
mexui.native.drawText(pos, this.size, this.maxText, this.getStyles('maxText'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};
// model

View File

@@ -26,30 +26,33 @@ mexui.util.linkBaseControlStyles('TabPanel', {
// input
mexui.Control.TabPanel.prototype.onMouseDown = function(e)
{
var pos = this.getScreenPosition();
var tabX = pos.x;
for(var i in this.axis.x.entries)
if(e.button == 0)
{
var tab = this.axis.x.entries[i];
var pos = this.getScreenPosition();
var tabPos = new Vec2(tabX, pos.y);
var tabSize = new Vec2(mexui.native.getTextWidth(tab.text, this.getStyles('tab')) + 10, 25);
if(mexui.util.isCursorInRectangle(tabPos, tabSize))
var tabX = pos.x;
for(var i in this.axis.x.entries)
{
tab.setActive();
break;
var tab = this.axis.x.entries[i];
var tabPos = new Vec2(tabX, pos.y);
var tabSize = new Vec2(mexui.native.getTextWidth(tab.text, this.getStyles('tab')) + 10, 25);
if(mexui.util.isCursorInRectangle(tabPos, tabSize))
{
tab.setActive();
break;
}
tabX += tabSize.x;
}
tabX += tabSize.x;
/*
var tab = this.axis.x.getEntryByCursor();
if(tab)
tab.setActive();
*/
}
/*
var tab = this.axis.x.getEntryByCursor();
if(tab)
tab.setActive();
*/
};
// render
@@ -71,6 +74,9 @@ mexui.Control.TabPanel.prototype.render = function()
tabX += tabSize.x;
}
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};
// model

View File

@@ -14,4 +14,7 @@ mexui.Control.Text.prototype.render = function()
var pos = this.getScreenPosition();
mexui.native.drawText(pos, this.size, this.text, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
};

View File

@@ -17,6 +17,8 @@ mexui.util.createControlConstructor('TextInput', false, function(window, x, y, w
this.caretShownForBlink = true;
this.lineHeight = 25;
this.maxLength = this.singleCharacter ? 1 : false;
this.validValue = true;
});
// default styles
@@ -34,10 +36,13 @@ mexui.util.linkBaseControlStyles('TextInput', {
// input
mexui.Control.TextInput.prototype.onMouseDown = function(e)
{
var hit = this.isCursorOverControl();
if(hit)
if(e.button == 0)
{
this.caretPosition = this.getCaretPositionByCursor();
var hit = this.isCursorOverControl();
if(hit)
{
this.caretPosition = this.getCaretPositionByCursor();
}
}
mexui.Component.Control.prototype.onMouseDown.call(this, e);
@@ -70,6 +75,7 @@ mexui.Control.TextInput.prototype.onCharacter = function(e, character)
}
this.checkToCallCallback();
this.validateValue(e);
}
};
@@ -193,12 +199,16 @@ mexui.Control.TextInput.prototype.onKeyDown = function(e, key, mods)
break;
}
}
this.validateValue(e);
};
// render
mexui.Control.TextInput.prototype.render = function()
{
var pos = this.getScreenPosition();
var pos2 = new Vec2(pos.x, pos.y);
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
if(this.isEmpty())
@@ -217,22 +227,31 @@ mexui.Control.TextInput.prototype.render = function()
}
}
if(mexui.focusedControl == this && this.caretShownForBlink)
var valueIsInvalid = !this.isEmpty() && !this.validValue;
if(this.isFocused())
{
var pos = this.getScreenPosition();
var text = this.lines[this.caretPosition.y].substr(0, this.caretPosition.x);
var displayedText = this.masked ? '*'.repeat(text.length) : text;
var textWidth = mexui.native.getTextWidth(displayedText, this.getStyles('main'));
var caretPosOffset = new Vec2(5 + textWidth, (this.caretPosition.y * this.lineHeight) + 1);
var caretPoint1 = mexui.util.addVec2(pos, caretPosOffset);
var caretPoint2 = new Vec2(caretPoint1.x, caretPoint1.y + 22);
mexui.native.drawAALine(caretPoint1, caretPoint2, this.getStyles('caret'));
if(!valueIsInvalid)
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
if(this.caretShownForBlink)
{
var pos = this.getScreenPosition();
var text = this.lines[this.caretPosition.y].substr(0, this.caretPosition.x);
var displayedText = this.masked ? '*'.repeat(text.length) : text;
var textWidth = mexui.native.getTextWidth(displayedText, this.getStyles('main'));
var caretPosOffset = new Vec2(5 + textWidth, (this.caretPosition.y * this.lineHeight) + 1);
var caretPoint1 = mexui.util.addVec2(pos, caretPosOffset);
var caretPoint2 = new Vec2(caretPoint1.x, caretPoint1.y + 22);
mexui.native.drawAALine(caretPoint1, caretPoint2, this.getStyles('caret'));
}
}
if(valueIsInvalid)
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('invalidValue'));
};
// model
mexui.Control.TextInput.prototype.getTextWithNewCharacter = function(character)
{
return this.lines[this.caretPosition.y].substr(0, this.caretPosition.x) + character + this.lines[this.caretPosition.y].substr(this.caretPosition.x);
@@ -335,6 +354,16 @@ mexui.Control.TextInput.prototype.deleteCharacter = function(charPos)
};
// text overall
mexui.Control.TextInput.prototype.setText = function(text)
{
this.lines = mexui.util.splitLines(text);
};
mexui.Control.TextInput.prototype.getText = function()
{
return this.lines.join("\r\n");
};
mexui.Control.TextInput.prototype.resetText = function()
{
this.lines = [''];
@@ -345,3 +374,8 @@ mexui.Control.TextInput.prototype.isEmpty = function()
return this.lines.length == 1 && this.lines[0] == '';
};
// validation
mexui.Control.TextInput.prototype.validateValue = function(e)
{
this.validValue = this.validateValueCallback ? this.validateValueCallback(e) : true;
};

View File

@@ -102,24 +102,35 @@ mexui.Control.Time.prototype.renderAfter = function()
// model
mexui.Control.Time.prototype.generateText = function()
{
this.text = (this.hour < 10 ? '0'+this.hour : this.hour)
this.setText((this.hour < 10 ? '0'+this.hour : this.hour)
+':'+(this.minute < 10 ? '0'+this.minute : this.minute)
+':'+(this.second < 10 ? '0'+this.second : this.second);
+':'+(this.second < 10 ? '0'+this.second : this.second));
};
mexui.Control.Time.prototype.validateInputCallback = function(e, character)
{
var text = this.getTextWithNewCharacter(character);
var parts = text.split(':');
return mexui.util.isPositiveIntChar(character) || character == ':';
};
mexui.Control.Time.prototype.validateValueCallback = function(e)
{
var parts = this.getText().split(':');
if(parts.length != 3)
return false;
for(var i in parts)
{
if(i == 3)
var partAsStr = parts[i];
if(partAsStr === '')
return false;
var part = parseInt(parts[i]);
var part = parseInt(partAsStr);
if(isNaN(part))
if(partAsStr.length == 2 && partAsStr.substr(0, 1) == '0')
partAsStr = partAsStr.substr(1);
if(!mexui.util.isPositiveInt(partAsStr))
return false;
if(part < 0)

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