Overhaul of "client" to "player"

This commit is contained in:
Vortrex
2020-12-29 04:26:15 -06:00
parent eeff21929c
commit 1c7532523c
34 changed files with 920 additions and 911 deletions

View File

@@ -22,7 +22,7 @@ function initEventScript() {
addEventHandler("OnPlayerConnect", function(event, ipAddress, port) {
console.log(`[Asshat.Event] Client connecting (IP: ${ipAddress})`);
if(isIpAddressBanned(ipAddress)) {
messageClientError(client, "You are banned from this server!");
messagePlayerError(client, "You are banned from this server!");
return false;
}
});
@@ -36,7 +36,7 @@ addEventHandler("OnPlayerJoined", function(event, client) {
// ---------------------------------------------------------------------------
addEventHandler("OnPlayerQuit", function(event, client, quitReasonId) {
console.log(`[Asshat.Event] ${getClientDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
savePlayerToDatabase(client);
resetClientStuff(client);
@@ -50,7 +50,7 @@ addEventHandler("OnPlayerQuit", function(event, client, quitReasonId) {
addEventHandler("onPlayerChat", function(event, client, messageText) {
event.preventDefault();
if(!getPlayerData(client).loggedIn) {
messageClientError(client, "You need to login before you can chat!");
messagePlayerError(client, "You need to login before you can chat!");
return false;
}
@@ -78,26 +78,26 @@ addEventHandler("OnProcess", function(event, deltaTime) {
if(getPlayerData(clients[i]).buyingVehicle) {
if(getPlayerVehicle(clients[i]) == getPlayerData(clients[i]).buyingVehicle) {
if(getDistance(getVehiclePosition(getPlayerData(clients[i]).buyingVehicle), getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
if(getClientCurrentSubAccount(clients[i]).cash < getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice) {
messageClientError(client, "You don't have enough money to buy this vehicle!");
if(getPlayerCurrentSubAccount(clients[i]).cash < getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice) {
messagePlayerError(client, "You don't have enough money to buy this vehicle!");
respawnVehicle(getPlayerData(clients[i]).buyingVehicle);
getPlayerData(clients[i]).buyingVehicle = false;
return false;
}
createNewDealershipVehicle(getVehicleData(getPlayerData(clients[i]).buyingVehicle).model, getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnPosition, getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnRotation, getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice, getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerId);
getClientCurrentSubAccount(clients[i]).cash -= getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice;
getPlayerCurrentSubAccount(clients[i]).cash -= getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice;
updatePlayerCash(clients[i]);
getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerId = getClientCurrentSubAccount(clients[i]).databaseId;
getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerId = getPlayerCurrentSubAccount(clients[i]).databaseId;
getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerType = AG_VEHOWNER_PLAYER;
getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice = 0;
getVehicleData(getPlayerData(clients[i]).buyingVehicle).rentPrice = 0;
getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnLocked = false;
getPlayerData(clients[i]).buyingVehicle = false;
messageClientSuccess(clients[i], "This vehicle is now yours! It will save wherever you leave it.");
messagePlayerSuccess(clients[i], "This vehicle is now yours! It will save wherever you leave it.");
}
} else {
messageClientError(client, "You canceled the vehicle purchase by exiting the vehicle!");
messagePlayerError(client, "You canceled the vehicle purchase by exiting the vehicle!");
respawnVehicle(getPlayerData(clients[i]).buyingVehicle);
getPlayerData(clients[i]).buyingVehicle = false;
}
@@ -126,12 +126,12 @@ addEventHandler("OnPedEnterVehicle", function(event, ped, vehicle, seat) {
if(getVehicleData(vehicle).locked) {
if(doesClientHaveVehicleKeys(client, vehicle)) {
messageClientNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
if(doesPlayerHaveKeyBindForCommand(client, "lock")) {
messageClientTip(client, `You can also press [#AAAAAA]${sdl.getKeyName(getPlayerKeyBindForCommand(client, "lock").key)} [#FFFFFF]to lock and unlock vehicles.`);
messagePlayerTip(client, `You can also press [#AAAAAA]${sdl.getKeyName(getPlayerKeyBindForCommand(client, "lock").key)} [#FFFFFF]to lock and unlock vehicles.`);
}
} else {
messageClientNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
}
}
}
@@ -151,7 +151,7 @@ async function playerEnteredVehicle(client) {
return false;
}
console.log(`[Asshat.Event] ${getClientDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
getPlayerData(client).lastVehicle = vehicle;
@@ -159,33 +159,33 @@ async function playerEnteredVehicle(client) {
vehicle.engine = getVehicleData(vehicle).engine;
if(getVehicleData(vehicle).buyPrice > 0) {
messageClientAlert(client, `This ${getVehicleName(vehicle)} is for sale! Cost: [#AAAAAA]$${getVehicleData(vehicle).buyPrice}`);
messageClientTip(client, `Use /vehbuy if you want to buy it.`);
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for sale! Cost: [#AAAAAA]$${getVehicleData(vehicle).buyPrice}`);
messagePlayerTip(client, `Use /vehbuy if you want to buy it.`);
} else if(getVehicleData(vehicle).rentPrice > 0) {
messageClientAlert(client, `This ${getVehicleName(vehicle)} is for rent! Cost: [#AAAAAA]$${getVehicleData(vehicle).rentPrice} per minute`);
messageClientTip(client, `Use /vehrent if you want to rent it.`);
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for rent! Cost: [#AAAAAA]$${getVehicleData(vehicle).rentPrice} per minute`);
messagePlayerTip(client, `Use /vehrent if you want to rent it.`);
} else {
if(!getVehicleData(vehicle).engine) {
if(doesClientHaveVehicleKeys(client, vehicle)) {
messageClientAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
if(doesPlayerHaveKeyBindForCommand(client, "engine")) {
messageClientTip(client, `You can also press [#AAAAAA]${sdl.getKeyName(getPlayerKeyBindForCommand(client, "engine").key)} [#FFFFFF]to start and stop the engine.`);
messagePlayerTip(client, `You can also press [#AAAAAA]${sdl.getKeyName(getPlayerKeyBindForCommand(client, "engine").key)} [#FFFFFF]to start and stop the engine.`);
}
} else {
messageClientAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
}
triggerNetworkEvent("ag.control", client, false, false);
}
}
let currentSubAccount = getClientCurrentSubAccount(client);
let currentSubAccount = getPlayerCurrentSubAccount(client);
if(isPlayerWorking(client)) {
if(getVehicleData(vehicle).ownerType == AG_VEHOWNER_JOB) {
if(getVehicleData(vehicle).ownerId == getClientCurrentSubAccount(client).job) {
if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
//if(seat == 0) {
getClientCurrentSubAccount(client).lastJobVehicle = vehicle;
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
//}
}
}
@@ -210,7 +210,7 @@ function playerExitedVehicle(client) {
return false;
}
console.log(`[Asshat.Event] ${getClientDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
@@ -232,11 +232,11 @@ function processPlayerDeath(client) {
triggerNetworkEvent("ag.fadeCamera", client, false, 1.0);
setTimeout(function() {
client.despawnPlayer();
if(getClientCurrentSubAccount(client).inJail) {
if(getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestJail(getPlayerPosition(client));
spawnPlayer(client, closestJail.position, closestJail.heading, getClientCurrentSubAccount(client).skin);
spawnPlayer(client, closestJail.position, closestJail.heading, getPlayerCurrentSubAccount(client).skin);
} else {
spawnPlayer(client, closestHospital.position, closestHospital.heading, getClientCurrentSubAccount(client).skin);
spawnPlayer(client, closestHospital.position, closestHospital.heading, getPlayerCurrentSubAccount(client).skin);
}
setTimeout(function() {
setEntityData(client.player, "ag.spawned", true, true);