You need to pass the player data serverside. On the serverside your player is not the only player object, thus you need to give the script scope.
PHP Code:
function onActionServerSide(){
for(temp.p:allplayers){
temp.pl = findplayer(p);
temp.mypl = findplayer(params[0]);
if (pl.x in | mypl.x -5, mypl.x + 5 | && pl.y in | mypl.y-5,mypl.y +5 | ) {
pl.chat = pl.account;
}
}
}
//#CLIENTSIDE
function onKeyPressed(){
if(keydown(6)){
triggerserver("gui", name,player.account);
}
}
Also, you can instead on the clientside use findnearestplayers(x,y), loop through, find the players you wish to send the chat and send the array to the serverside, instead of letting the server handle the loop.