Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Trigger Server for another player (https://forums.graalonline.com/forums/showthread.php?t=134268984)

sssssssssss 01-11-2014 08:16 PM

Trigger Server for another player
 
I could have sworn I've done this before, but maybe I'm wrong. pl.triggerServer just throws the error
Quote:

Script: Function Player Indalecio_Azmaveth.triggerServer not found in function doPlayerSword in script of Weapon -System/Movement
I have to trigger the server to use findplayer with the params, then pl.triggerclient, then trigger back to the server with the player that got hurt so I can subtract the health server side. Isn't there a better way? I've already tried adding in a function to a class that's joined to the player and it was useless as well.

PHP Code:

for (temp.pltemp.closePlayers) {
    if (
pl == player || pl.guild == player.guild || pl.isdead || pl.ispause) continue;
    
    if ((
pl.1.5in |myx1myx2| && (pl.2in |myy1myy2|) {
      
pl.triggerServer("weapon"this.name"hurtPlayer"plkillerkillerg);
    }
  } 


fowlplay4 01-11-2014 08:22 PM

It's just triggerserver. also since you're looping go through and add the players to an array and send that to the serverside instead of 1 or more triggers.

In theory all you should need is:

PHP Code:

for (temp.pltemp.closePlayers) {
  if (
pl == player || pl.guild == player.guild || pl.isdead || pl.ispause) continue; 
  if ((
pl.1.5in |myx1myx2| && (pl.2in |myy1myy2|) { 
    
temp.hurt.add(temp.pl.account);
  }
}
if (
temp.hurt.size() > 0) {
  
triggerserver("gui"this.name"hurtplayers"temp.hurt);


then on the server-side:

PHP Code:

temp.hurtplayers params[1];
for (
temp.pltemp.hurtplayers) {
  
temp.pl findplayer(temp.pl);
  if (
temp.pl == NULL || !(temp.pl in players)) continue;
  if (
pl == player || pl.guild == player.guild || pl.isdead || pl.ispause) continue;
  
temp.dist vectordist({temp.pl.xtemp.pl.y0},{player.xplayer.y0});
  if (
temp.dist 5) {
    
temp.pl.hp--;
    
temp.pl.setani("hurt""");
    
temp.pl.triggerclient("gui""-System/Damage""washurt");
  }



sssssssssss 01-11-2014 08:26 PM

does vectordist kill the need for my to calculate the xy for the sword distance and if the other player is in it?

Not sure why it's there to be honest.

Also I'm using clientr.vars for the hp, so wouldn't I have to trigger a weapon function for each player hurt to update that, since it's not accessible for anything like pl.clientr.hp?

sssssssssss 01-12-2014 02:14 AM

I got it triggering back to the client for the pl again, then back serverside to change the clientr.vars, then back clientside to handle death or anything else. If there's a better way someone please let me know.

Thanks!

fowlplay4 01-12-2014 02:24 AM

Quote:

Originally Posted by sssssssssss (Post 1724980)
does vectordist kill the need for my to calculate the xy for the sword distance and if the other player is in it?

Not sure why it's there to be honest.

Also I'm using clientr.vars for the hp, so wouldn't I have to trigger a weapon function for each player hurt to update that, since it's not accessible for anything like pl.clientr.hp?

Serverside positions aren't always going to match with the clientside so it does a proximity check.

Replace temp.pl.hp--; with your own variable or whatever you do to 'damage' the player. You shouldn't have to trigger the client then back to the server again.

sssssssssss 01-12-2014 03:01 AM

I would just be taking out of clientr.hp, but it's not accessible by pl.clientr.hp correct?

cbk1994 01-12-2014 03:54 AM

Quote:

Originally Posted by sssssssssss (Post 1724988)
I would just be taking out of clientr.hp, but it's not accessible by pl.clientr.hp correct?

Yes, that's exactly how you should access it. Serverside you can use findPlayer to get another player object. The only difference between "temp.pl" and "player" in this case is that player is available automatically. They're both TServerPlayer objects, and you can do the same things to etiher of them. There's no reason to trigger clientside and then back.

It might help to remember that clientr.hp is really the same thing as player.clientr.hp. So you can also do findPlayer("fowlplay4").clientr.hp.

If you want to do it properly you should move this into a player class so you can just do findPlayer("fowlplay4").attack(9999, player) or whatever and not have to recycle the same logic everywhere you need to do damage.

sssssssssss 01-12-2014 04:10 AM

thanks for the help you guys. :)


All times are GMT +2. The time now is 09:14 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.