Quote:
Originally Posted by Deas_Voice
tirggeraction sounds about right
|
To cover an 8x4 section of tiles. Hell no.
Best plan of action would be to...
1. Loop through the players on clientside and check if they're in the '8x4' section
2. Send the list of players in the section to the server-side
3. Double-check that they're in the square (perhaps with some leniency)
4. Triggerclient each person in the square, or even just change their animation and chat if that's all that's necessary.
It looks like this:
PHP Code:
function onActionServerSide() {
if (params[0] == "hitpeople") {
// Do the same check up here, or maybe even a radius check like cbk suggested.
for (temp.pl: players) {
if (temp.pl.x in |tx,tx+dw| && temp.pl.y in |ty,ty+dh|) {
temp.pl.chat = "Ow!";
temp.pl.setani("hurt", "");
}
}
}
}
//#CLIENTSIDE
function hitPeople() {
// Determine the 8x4 Section
// tx = topleft x
// ty = topleft y
// dw = width of section
// dh = height of section
// Find Players
for (temp.pl: players) {
// Check if Player is in Section
if (temp.pl.x in |tx,tx+dw| && temp.pl.y in |ty,ty+dh|) {
// Add Account to the List of those being Hit
temp.hitting.add(temp.pl.account);
}
}
// Check if Hitting Anyone
if (temp.hitting.size() > 0) {
// Trigger the server
triggerserver("gui", this.name, "hitpeople", temp.hitting);
}
}