I've designed a custom sword/fighting system for my server, and can't seem to work out the only real problem. I use findnearestplayers to recognize the closest player, and tokenize it, however this sometimes turns out in client.hurt[1] being my own account, and not the nearest account besides my own. in theory, client.hurt[0] should be my own account, and the second closest player to me besides myself is client.hurt[1]...however it's sporadic and i'm not sure why.
Anyways. I tried to make it so if it recognizes client.hurt[1] as the player's account it changes it to client.hurt[0] but this is not working. Any suggestions?
PHP Code:
//#CLIENTSIDE
function activePlayers()
{
temp.x = player.x;
temp.y = player.y;
client.acc = player.account;
client.hurt= findnearestplayers(temp.x, temp.y);
client.hurt.tokenize(",");
if (client.hurt[1] == player.account) {
client.hurt[1] = client.hurt[0];
}
Attack(client.type, player.dir); //next function which would calculate
//if the player is close enough to client.hurt[1]
//to hurt him.
}
with this script, after it does the attack function, it moves serverside to distribute health loss. Here's what it echos to show you how it screws up client.hurt[1] and client.hurt[0]:
PHP Code:
Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
Weapon/GUI-script +Fighting added/updated by BrianD
Weapon/GUI-script +Fighting added/updated by BrianD
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt Graal778318 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt Graal778318 for 2
<b>Fighting:Graal778318 hurt Graal778318 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt Graal778318 for 2
<b>Fighting:Graal778318 hurt Graal778318 for 2
<b>Fighting:Graal778318 hurt Graal778318 for 2
<b>Fighting:Graal778318 hurt pc:5390521 for 2
<b>Fighting:Graal778318 hurt Graal778318 for 2
<b>Fighting:Graal778318 hurt Graal778318 for 2
Forgive my sloppiness by the way haha, i'm not a neat scripter.