Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-11-2014, 08:16 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
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);
    }
  } 
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #2  
Old 01-11-2014, 08:22 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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");
  }

__________________
Quote:
Reply With Quote
  #3  
Old 01-11-2014, 08:26 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
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?
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #4  
Old 01-12-2014, 02:14 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
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!
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #5  
Old 01-12-2014, 02:24 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by sssssssssss View Post
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.
__________________
Quote:
Reply With Quote
  #6  
Old 01-12-2014, 03:01 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I would just be taking out of clientr.hp, but it's not accessible by pl.clientr.hp correct?
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #7  
Old 01-12-2014, 03:54 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by sssssssssss View Post
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.
__________________
Reply With Quote
  #8  
Old 01-12-2014, 04:10 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
thanks for the help you guys.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:25 AM.


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