Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Problems with onwall (https://forums.graalonline.com/forums/showthread.php?t=134262153)

Starfire2001 02-19-2011 11:52 AM

Problems with onwall
 
The following script is part of a weapon, that when fired pushes any player in front of the player who fired the weapon a certain distance depending on how far away they are. Everything is working fine except for detecting a wall and stopping the player from going through it when they are hit. In this script I made it so my chat would say "onwall" if its detecting that the player is onwall and "good" if they are not, but regardless of where I fire the weapon wall present or not my chat always shows as "onwall", which leads me to believe I had no idea how to use onwall, but I haven't been able to find anything to help me with it. So yeah, as always, any help/advice would be greatly appreciated.

PHP Code:

function onActionServerSide(this.face, this.firex, this.firey){
  for (
temp.pl: players){
    if (
player.communityname != pl.communityname){
      
// Attack came from the bottom
      
if (face == 0){
        if(
pl.y in | firey - 2, firey -.1 |) {
          if(
pl.x in | firex - 1, firex + 1 |) {
            
pl.hearts = 0;
          }
        }
        if(
pl.y in | firey - 3, firey - 2.1 |) {
          if(
pl.x in | firex - 1.5, firex + 1.5 |) {
            
temp.strength = 12;
            for (
strength = 12; strength > 0; strength --){
              
sleep (.05);
              
pl.y = pl.y - .5;
              if (
onwall(pl.x,pl.y-1.5)){
                
player.chat = "onwall";
              }
              else{
                
player.chat = "good";
              }
            }
          }
        }
      }
      if(
pl.y in | firey - 4, firey - 3.1 |) {
        if(
pl.x in | firex - 2, firex + 2 |) {
          
temp.strength = 8;
          for (
strength = 8; strength > 0; strength --){
            
sleep (.05);
            
pl.y = pl.y - .5;
            if (
onwall(pl.x,pl.y-1.5)){
              
player.chat = "onwall";
            }
            else{
              
player.chat = "good";
            }
          }
        }
      }
      if(
pl.y in | firey - 5, firey - 4.1 |) {
        if(
pl.x in | firex - 2.5, firex + 2.5 |) {
          
temp.strength = 4;
          for (
strength = 4; strength > 0; strength --){
            
sleep (.05);
            
pl.y = pl.y - .5;
            if (
onwall(pl.x,pl.y-1.5)){
              
player.chat = "onwall";
            }
            else{
              
player.chat = "good";
            }
          }
        }
      }
    }
  }
} 


xAndrewx 02-19-2011 02:52 PM

Ahhh- you're doing this on the serverside.

What you should do is trigger to the clientside and move the player clientside with a similar function- it will be lassy laggy on your server.

HTML Code:


function onActionServerSide(this.face, this.firex, this.firey){
  for (temp.pl: findnearestplayers(this.firex, this.firey)){
    if (temp.pl == player) continue;

    //Do your HP checks here [to kill the player]
    temp.pl.triggerclient("weaponname for the function", "moveplayer", {this.face, this.firex, this.firey});
  }
}

in the weapon you trigger:
HTML Code:

//#CLIENTSIDE
function onActionClientside(option) {
  if (temp.option == "moveplayer") this.onmovePlayer(params[1]);
}

function onMovePlayer(data) {
  temp.face = temp.data[0];
  temp.firex = temp.data[1];
  temp.firey = temp.data[2];
  //Do your movement stuff
}


cbk1994 02-19-2011 07:46 PM

This line is incorrect:
Quote:

Originally Posted by xAndrewx (Post 1631821)
PHP Code:

    if (temp.pl == player.account) continue; 


You're comparing the player object to the player's account. It might work through some quirk in GScript, but the proper way to do it is

PHP Code:

     if (temp.pl == player) continue; 


xAndrewx 02-19-2011 09:16 PM

oh yeah- returns object hehe

(fixed) rep++ @ chris

Starfire2001 02-20-2011 03:47 PM

Thanks to you both, this fixed problem for me.


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

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