Use INT and VW in closest NPC util
This commit is contained in:
@@ -19,7 +19,7 @@ function initNPCScript() {
|
|||||||
* @return {NPCData} The NPC's data (class instancee)
|
* @return {NPCData} The NPC's data (class instancee)
|
||||||
*/
|
*/
|
||||||
function getNPCData(npcId) {
|
function getNPCData(npcId) {
|
||||||
if(typeof getServerData().npcs[npcId] != "undefined") {
|
if (typeof getServerData().npcs[npcId] != "undefined") {
|
||||||
return getServerData().npcs[npcId];
|
return getServerData().npcs[npcId];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -28,14 +28,14 @@ function getNPCData(npcId) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function createNPCCommand(command, params, client) {
|
function createNPCCommand(command, params, client) {
|
||||||
if(areParamsEmpty(params)) {
|
if (areParamsEmpty(params)) {
|
||||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let skinIndex = getSkinModelIndexFromParams(params);
|
let skinIndex = getSkinModelIndexFromParams(params);
|
||||||
|
|
||||||
if(!skinIndex) {
|
if (!skinIndex) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidSkin"));
|
messagePlayerError(client, getLocaleString(client, "InvalidSkin"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -53,11 +53,11 @@ function loadNPCsFromDatabase() {
|
|||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
let tempNPCs = [];
|
let tempNPCs = [];
|
||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
if(dbConnection) {
|
if (dbConnection) {
|
||||||
let dbQueryString = `SELECT * FROM npc_main WHERE npc_server = ${getServerId()} AND npc_enabled = 1`;
|
let dbQueryString = `SELECT * FROM npc_main WHERE npc_server = ${getServerId()} AND npc_enabled = 1`;
|
||||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||||
if(dbQuery) {
|
if (dbQuery) {
|
||||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
let tempNPCData = new NPCData(dbAssoc);
|
let tempNPCData = new NPCData(dbAssoc);
|
||||||
tempNPCData.triggers = loadNPCTriggersFromDatabase(tempNPCData.databaseId);
|
tempNPCData.triggers = loadNPCTriggersFromDatabase(tempNPCData.databaseId);
|
||||||
tempNPCs.push(tempNPCData);
|
tempNPCs.push(tempNPCData);
|
||||||
@@ -78,11 +78,11 @@ function loadNPCTriggersFromDatabase(npcDatabaseId) {
|
|||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
let tempNPCTriggers = [];
|
let tempNPCTriggers = [];
|
||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
if(dbConnection) {
|
if (dbConnection) {
|
||||||
let dbQueryString = `SELECT * FROM npc_trig WHERE npc_trig_npc = ${npcDatabaseId} AND npc_trig_enabled = 1`;
|
let dbQueryString = `SELECT * FROM npc_trig WHERE npc_trig_npc = ${npcDatabaseId} AND npc_trig_enabled = 1`;
|
||||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||||
if(dbQuery) {
|
if (dbQuery) {
|
||||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
let tempNPCTriggerData = new NPCTriggerData(dbAssoc);
|
let tempNPCTriggerData = new NPCTriggerData(dbAssoc);
|
||||||
tempNPCTriggerData.conditions = loadNPCTriggerConditionsFromDatabase(tempNPCTriggerData.databaseId);
|
tempNPCTriggerData.conditions = loadNPCTriggerConditionsFromDatabase(tempNPCTriggerData.databaseId);
|
||||||
tempNPCTriggerData.responses = loadNPCTriggerResponsesFromDatabase(tempNPCTriggerData.databaseId);
|
tempNPCTriggerData.responses = loadNPCTriggerResponsesFromDatabase(tempNPCTriggerData.databaseId);
|
||||||
@@ -104,11 +104,11 @@ function loadNPCTriggerConditionsFromDatabase(npcTriggerDatabaseId) {
|
|||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
let tempNPCTriggerConditions = [];
|
let tempNPCTriggerConditions = [];
|
||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
if(dbConnection) {
|
if (dbConnection) {
|
||||||
let dbQueryString = `SELECT * FROM npc_cond WHERE npc_cond_trig = ${npcTriggerDatabaseId} AND npc_cond_enabled = 1`;
|
let dbQueryString = `SELECT * FROM npc_cond WHERE npc_cond_trig = ${npcTriggerDatabaseId} AND npc_cond_enabled = 1`;
|
||||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||||
if(dbQuery) {
|
if (dbQuery) {
|
||||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
let tempNPCTriggerConditionData = new NPCTriggerConditionData(dbAssoc);
|
let tempNPCTriggerConditionData = new NPCTriggerConditionData(dbAssoc);
|
||||||
tempNPCTriggerConditions.push(tempNPCTriggerConditionData);
|
tempNPCTriggerConditions.push(tempNPCTriggerConditionData);
|
||||||
}
|
}
|
||||||
@@ -128,11 +128,11 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
|
|||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
let tempNPCTriggerResponses = [];
|
let tempNPCTriggerResponses = [];
|
||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
if(dbConnection) {
|
if (dbConnection) {
|
||||||
let dbQueryString = `SELECT * FROM npc_resp WHERE npc_resp_trig = ${npcTriggerDatabaseId} AND npc_resp_enabled = 1`;
|
let dbQueryString = `SELECT * FROM npc_resp WHERE npc_resp_trig = ${npcTriggerDatabaseId} AND npc_resp_enabled = 1`;
|
||||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||||
if(dbQuery) {
|
if (dbQuery) {
|
||||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
let tempNPCTriggerResponseData = new NPCTriggerResponseData(dbAssoc);
|
let tempNPCTriggerResponseData = new NPCTriggerResponseData(dbAssoc);
|
||||||
tempNPCTriggerResponses.push(tempNPCTriggerResponseData);
|
tempNPCTriggerResponses.push(tempNPCTriggerResponseData);
|
||||||
}
|
}
|
||||||
@@ -148,11 +148,11 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function saveAllNPCsToDatabase() {
|
function saveAllNPCsToDatabase() {
|
||||||
if(getServerConfig().devServer) {
|
if (getServerConfig().devServer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let i in getServerData().npcs) {
|
for (let i in getServerData().npcs) {
|
||||||
saveNPCToDatabase(i);
|
saveNPCToDatabase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,34 +160,34 @@ function saveAllNPCsToDatabase() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function saveNPCToDatabase(npcDataId) {
|
function saveNPCToDatabase(npcDataId) {
|
||||||
if(getServerConfig().devServer) {
|
if (getServerConfig().devServer) {
|
||||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} can't be saved because server is running as developer only. Aborting save ...`);
|
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} can't be saved because server is running as developer only. Aborting save ...`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getNPCData(npcDataId) == false) {
|
if (getNPCData(npcDataId) == false) {
|
||||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} data is invalid. Aborting save ...`);
|
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} data is invalid. Aborting save ...`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let tempNPCData = getNPCData(npcDataId);
|
let tempNPCData = getNPCData(npcDataId);
|
||||||
|
|
||||||
if(tempNPCData.databaseId == -1) {
|
if (tempNPCData.databaseId == -1) {
|
||||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} is a temp NPC. Aborting save ...`);
|
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} is a temp NPC. Aborting save ...`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tempNPCData.needsSaved) {
|
if (!tempNPCData.needsSaved) {
|
||||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} hasn't changed data. Aborting save ...`);
|
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} hasn't changed data. Aborting save ...`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saving NPC ${tempNPCData.databaseId} to database ...`);
|
logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saving NPC ${tempNPCData.databaseId} to database ...`);
|
||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
if(dbConnection) {
|
if (dbConnection) {
|
||||||
if(tempNPCData.ped != false) {
|
if (tempNPCData.ped != false) {
|
||||||
if(!tempNPCData.spawnLocked) {
|
if (!tempNPCData.spawnLocked) {
|
||||||
if(areServerElementsSupported()) {
|
if (areServerElementsSupported()) {
|
||||||
tempNPCData.position = tempNPCData.ped.position;
|
tempNPCData.position = tempNPCData.ped.position;
|
||||||
tempNPCData.heading = tempNPCData.ped.heading;
|
tempNPCData.heading = tempNPCData.ped.heading;
|
||||||
} else {
|
} else {
|
||||||
@@ -224,7 +224,7 @@ function saveNPCToDatabase(npcDataId) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let dbQuery = null;
|
let dbQuery = null;
|
||||||
if(tempNPCData.databaseId == 0) {
|
if (tempNPCData.databaseId == 0) {
|
||||||
let queryString = createDatabaseInsertQuery("npc_main", data);
|
let queryString = createDatabaseInsertQuery("npc_main", data);
|
||||||
dbQuery = queryDatabase(dbConnection, queryString);
|
dbQuery = queryDatabase(dbConnection, queryString);
|
||||||
tempNPCData.databaseId = getDatabaseInsertId(dbConnection);
|
tempNPCData.databaseId = getDatabaseInsertId(dbConnection);
|
||||||
@@ -247,19 +247,19 @@ function saveNPCToDatabase(npcDataId) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function setNPCDataIndexes() {
|
function setNPCDataIndexes() {
|
||||||
for(let i in getServerData().npcs) {
|
for (let i in getServerData().npcs) {
|
||||||
getServerData().npcs[i].index = i;
|
getServerData().npcs[i].index = i;
|
||||||
|
|
||||||
for(let j in getServerData().npcs[i].triggers) {
|
for (let j in getServerData().npcs[i].triggers) {
|
||||||
getServerData().npcs[i].triggers[j].index = j;
|
getServerData().npcs[i].triggers[j].index = j;
|
||||||
getServerData().npcs[i].triggers[j].npcIndex = i;
|
getServerData().npcs[i].triggers[j].npcIndex = i;
|
||||||
|
|
||||||
for(let k in getServerData().npcs[i].triggers[j].conditions) {
|
for (let k in getServerData().npcs[i].triggers[j].conditions) {
|
||||||
getServerData().npcs[i].triggers[j].conditions[k].index = k;
|
getServerData().npcs[i].triggers[j].conditions[k].index = k;
|
||||||
getServerData().npcs[i].triggers[j].conditions[m].triggerIndex = j;
|
getServerData().npcs[i].triggers[j].conditions[m].triggerIndex = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let m in getServerData().npcs[i].triggers[j].responses) {
|
for (let m in getServerData().npcs[i].triggers[j].responses) {
|
||||||
getServerData().npcs[i].triggers[j].responses[m].index = m;
|
getServerData().npcs[i].triggers[j].responses[m].index = m;
|
||||||
getServerData().npcs[i].triggers[j].responses[m].triggerIndex = j;
|
getServerData().npcs[i].triggers[j].responses[m].triggerIndex = j;
|
||||||
}
|
}
|
||||||
@@ -272,12 +272,12 @@ function setNPCDataIndexes() {
|
|||||||
function spawnNPC(npcIndex) {
|
function spawnNPC(npcIndex) {
|
||||||
let npcData = getNPCData(npcIndex);
|
let npcData = getNPCData(npcIndex);
|
||||||
let ped = createGamePed(npcData.skin, npcData.position, npcData.rotation.z);
|
let ped = createGamePed(npcData.skin, npcData.position, npcData.rotation.z);
|
||||||
if(ped) {
|
if (ped) {
|
||||||
getNPCData(npcIndex).ped = ped;
|
getNPCData(npcIndex).ped = ped;
|
||||||
setEntityData(ped, "vrr.dataIndex", npcIndex, false);
|
setEntityData(ped, "vrr.dataIndex", npcIndex, false);
|
||||||
if(npcData.animationName != "") {
|
if (npcData.animationName != "") {
|
||||||
let animationId = getAnimationFromParams(npcData.animationName);
|
let animationId = getAnimationFromParams(npcData.animationName);
|
||||||
if(animationId != false) {
|
if (animationId != false) {
|
||||||
setEntityData(ped, "vrr.anim", animationId, true);
|
setEntityData(ped, "vrr.anim", animationId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,7 @@ function spawnNPC(npcIndex) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function spawnAllNPCs() {
|
function spawnAllNPCs() {
|
||||||
for(let i in getServerData().npcs) {
|
for (let i in getServerData().npcs) {
|
||||||
spawnNPC(i);
|
spawnNPC(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,9 +297,9 @@ function spawnAllNPCs() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function deleteNPCCommand(command, params, client) {
|
function deleteNPCCommand(command, params, client) {
|
||||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||||
|
|
||||||
if(!getNPCData(closestNPC)) {
|
if (!getNPCData(closestNPC)) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -315,8 +315,8 @@ function deleteNPCCommand(command, params, client) {
|
|||||||
function deleteNPC(npcId) {
|
function deleteNPC(npcId) {
|
||||||
quickDatabaseQuery(`DELETE FROM npc_main WHERE npc_id=${getNPCData(npcId).databaseId}`);
|
quickDatabaseQuery(`DELETE FROM npc_main WHERE npc_id=${getNPCData(npcId).databaseId}`);
|
||||||
|
|
||||||
if(getNPCData(npcId)) {
|
if (getNPCData(npcId)) {
|
||||||
if(getNPCData(npcId).ped != false) {
|
if (getNPCData(npcId).ped != false) {
|
||||||
deleteEntity(getNPCData(npcId).ped);
|
deleteEntity(getNPCData(npcId).ped);
|
||||||
}
|
}
|
||||||
getServerData().npcs.splice(npcId, 1);
|
getServerData().npcs.splice(npcId, 1);
|
||||||
@@ -328,27 +328,27 @@ function deleteNPC(npcId) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function setNPCAnimationCommand(command, params, client) {
|
function setNPCAnimationCommand(command, params, client) {
|
||||||
if(areParamsEmpty(params)) {
|
if (areParamsEmpty(params)) {
|
||||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||||
let animationId = getAnimationFromParams(getParam(params, " ", 1));
|
let animationId = getAnimationFromParams(getParam(params, " ", 1));
|
||||||
let animationPositionOffset = 1;
|
let animationPositionOffset = 1;
|
||||||
|
|
||||||
if(!getNPCData(closestNPC)) {
|
if (!getNPCData(closestNPC)) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getAnimationData(animationId)) {
|
if (!getAnimationData(animationId)) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
|
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(areThereEnoughParams(params, 2, " ")) {
|
if (areThereEnoughParams(params, 2, " ")) {
|
||||||
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
|
if (toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
|
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -365,15 +365,15 @@ function setNPCAnimationCommand(command, params, client) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function setNPCNameCommand(command, params, client) {
|
function setNPCNameCommand(command, params, client) {
|
||||||
if(areParamsEmpty(params)) {
|
if (areParamsEmpty(params)) {
|
||||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||||
let name = params;
|
let name = params;
|
||||||
|
|
||||||
if(!getNPCData(closestNPC)) {
|
if (!getNPCData(closestNPC)) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -389,9 +389,9 @@ function setNPCNameCommand(command, params, client) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function toggleNPCLookAtClosestPlayerCommand(command, params, client) {
|
function toggleNPCLookAtClosestPlayerCommand(command, params, client) {
|
||||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||||
|
|
||||||
if(!getNPCData(closestNPC)) {
|
if (!getNPCData(closestNPC)) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -406,14 +406,14 @@ function toggleNPCLookAtClosestPlayerCommand(command, params, client) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function getNPCInfoCommand(command, params, client) {
|
function getNPCInfoCommand(command, params, client) {
|
||||||
if(areParamsEmpty(params)) {
|
if (areParamsEmpty(params)) {
|
||||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
||||||
|
|
||||||
if(!getNPCData(closestNPC)) {
|
if (!getNPCData(closestNPC)) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -422,7 +422,7 @@ function getNPCInfoCommand(command, params, client) {
|
|||||||
|
|
||||||
let ownerName = "Nobody";
|
let ownerName = "Nobody";
|
||||||
let ownerType = "None";
|
let ownerType = "None";
|
||||||
switch(npcData.ownerType) {
|
switch (npcData.ownerType) {
|
||||||
case VRR_NPCOWNER_CLAN:
|
case VRR_NPCOWNER_CLAN:
|
||||||
ownerName = getClanData(getClanIdFromDatabaseId(npcData.ownerId)).name;
|
ownerName = getClanData(getClanIdFromDatabaseId(npcData.ownerId)).name;
|
||||||
ownerType = "clan";
|
ownerType = "clan";
|
||||||
@@ -464,22 +464,19 @@ function getNPCInfoCommand(command, params, client) {
|
|||||||
|
|
||||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderNPCInfo")));
|
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderNPCInfo")));
|
||||||
let chunkedList = splitArrayIntoChunks(stats, 6);
|
let chunkedList = splitArrayIntoChunks(stats, 6);
|
||||||
for(let i in chunkedList) {
|
for (let i in chunkedList) {
|
||||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function getClosestNPC(position) {
|
function getClosestNPC(position, interior, dimension) {
|
||||||
let npcs = getServerData().npcs;
|
let npcs = getServerData().npcs;
|
||||||
|
|
||||||
let interior = getPlayerInterior(client);
|
|
||||||
let dimension = getPlayerDimension(client);
|
|
||||||
|
|
||||||
let closest = 0;
|
let closest = 0;
|
||||||
for(let i in npcs) {
|
for (let i in npcs) {
|
||||||
if(getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position) && npcs[closest].interior == interior && npcs[closest].dimension == dimension) {
|
if (getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position) && npcs[closest].interior == interior && npcs[closest].dimension == dimension) {
|
||||||
closest = i;
|
closest = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -502,9 +499,9 @@ function createNPC(skinIndex, position, heading, interior, dimension) {
|
|||||||
let npcIndex = getServerData().npcs.push(tempNPCData);
|
let npcIndex = getServerData().npcs.push(tempNPCData);
|
||||||
setNPCDataIndexes();
|
setNPCDataIndexes();
|
||||||
|
|
||||||
spawnNPC(npcIndex-1);
|
spawnNPC(npcIndex - 1);
|
||||||
|
|
||||||
return npcIndex-1;
|
return npcIndex - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user