Move get player util to shared

This commit is contained in:
Vortrex
2021-02-20 20:09:24 -06:00
parent d501e00092
commit 7475c9d7ee
2 changed files with 30 additions and 26 deletions

View File

@@ -759,31 +759,6 @@ function getClientFromPlayer(player) {
// ---------------------------------------------------------------------------
function getPlayerFromParams(params) {
let clients = getClients();
if(isNaN(params)) {
for(let i in clients) {
if(!clients[i].console) {
if(toLowerCase(clients[i].name).indexOf(toLowerCase(params)) != -1) {
return clients[i];
}
if(toLowerCase(getCharacterFullName(clients[i])).indexOf(toLowerCase(params)) != -1) {
return clients[i];
}
}
}
} else {
if(typeof clients[toInteger(params)] != "undefined") {
return clients[toInteger(params)];
}
}
return false;
}
// ---------------------------------------------------------------------------
function getFirstEmptyEffectSlot(isServer = false) {
if(isServer) {
for(let i in effects) {
@@ -1982,4 +1957,8 @@ function showConnectCameraToPlayer(client) {
setPlayerCameraLookAt(client, getServerConfig().connectCameraPosition, getServerConfig().connectCameraLookAt);
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function doesGameHaveSnow(gameId) {
return (getServerGame() != GAME_GTA_IV);
}

View File

@@ -301,4 +301,29 @@ function getConsoleClient() {
}
}
// ---------------------------------------------------------------------------
function getPlayerFromParams(params) {
let clients = getClients();
if(isNaN(params)) {
for(let i in clients) {
if(!clients[i].console) {
if(toLowerCase(clients[i].name).indexOf(toLowerCase(params)) != -1) {
return clients[i];
}
if(toLowerCase(getCharacterFullName(clients[i])).indexOf(toLowerCase(params)) != -1) {
return clients[i];
}
}
}
} else {
if(typeof clients[toInteger(params)] != "undefined") {
return clients[toInteger(params)];
}
}
return false;
}
// ---------------------------------------------------------------------------