Fix get player by id/name/char name util
This commit is contained in:
@@ -764,15 +764,15 @@ function getClientFromPlayer(player) {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function getPlayerFromParams(params, isServer) {
|
function getPlayerFromParams(params) {
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
if(isNaN(params)) {
|
if(isNaN(params)) {
|
||||||
for(let i in clients) {
|
for(let i in clients) {
|
||||||
if(toLowerCase(clients[i].name).indexOf(toLowerCase(params)) != -1) {
|
if(toLowerCase(clients[i].name).indexOf(toLowerCase(params)) != -1) {
|
||||||
return clients[i].player;
|
return clients[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
let charName = `${getClientCurrentSubAccount(clients[i]).firstName} ${getClientCurrentSubAccount(clients[i]).lastName}`;
|
let charName = getCharacterFullName(clients[i]);
|
||||||
if(toLowerCase(charName).indexOf(toLowerCase(clientName)) != -1) {
|
if(toLowerCase(charName).indexOf(toLowerCase(clientName)) != -1) {
|
||||||
return clients[i];
|
return clients[i];
|
||||||
}
|
}
|
||||||
@@ -787,29 +787,6 @@ function getPlayerFromParams(params, isServer) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function getClientFromParams(checkParams) {
|
|
||||||
let clients = getClients();
|
|
||||||
if(isNaN(checkParams)) {
|
|
||||||
checkParams = toLowerCase(checkParams);
|
|
||||||
for(let i in clients) {
|
|
||||||
let clientName = toLowerCase(clients[i].name);
|
|
||||||
if(clientName.indexOf(checkParams) != -1) {
|
|
||||||
return clients[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let clientId = toInteger(checkParams) || 0;
|
|
||||||
if(typeof clients[clientId] != "undefined") {
|
|
||||||
return clients[clientId];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function getFirstEmptyEffectSlot(isServer = false) {
|
function getFirstEmptyEffectSlot(isServer = false) {
|
||||||
@@ -1801,4 +1778,3 @@ function resetClientStuff(client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user