I see you're using triggers to call functions on the serverside, from the serverside. You can just call them directly:
onActionSetMatchServer(temp.match, temp.vplayer, temp.splayer);
instead of
triggeraction(this.x + 0.5, this.y + 0.5, "SetMatchServer", temp.match, temp.vplayer,temp.splayer);
Generally triggeraction is used to go from client to server, and vice versa.
Personally I'd have a loop watch the players health.
I.e:
PHP Code:
function onCreated() {
setTimer(0.5);
}
function onTimeout() {
// Only watch if there's an actual spar.
if (this.sparring) {
onWatchSpar();
setTimer(0.5);
}
}
// Variables used for sake of example.
// this.player_a = findplayer("whoever");
// this.player_b = findplayer("someoneelse");
function onWatchSpar() {
// Both players dead?
if (this.player_a.hearts <= 0 && this.player_b.hearts <= 0) onTie();
// Player A Alive, and B dead?
else if (this.player_a.hearts > 0 && this.player_b.hearts <= 0) onWin(this.player_a);
// Player B Alive, and A dead?
else if (this.player_b.hearts > 0 && this.player_a.hearts <= 0) onWin(this.player_b);
}
Personally I think this may be a bit complicated for one of your first scripts :P