Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   spar script. (https://forums.graalonline.com/forums/showthread.php?t=134257197)

sssssssssss 12-05-2009 03:43 AM

spar script.
 
This code had been working fine for months, and now it just up and stopped working. nothing has been changed whatsoever as far as i know. any ideas?

PHP Code:

function onCreated()
{
  
this.attr[10] = false;

  
this.spar_list "";

  
UpdateList();
  
this.setshape(13232);
}
function 
onPlayerEnters()
{
  
CheckSparList();

  if (
InSpar(player))
  {
    
player.30.5;
    
player.47;
  }
}
function 
onPlayerLeaves()
{
  if (
GetSparNumber() < 2)
    
this.attr[10] = false;
}
function 
onPlayerChats()
{
  if (
player.chat.starts("/join"))
  {
    if (!(
player.account in this.spar_list))
    {
      if (!
InSpar(player))
      {
        
this.spar_list.add(player.account);

        
CheckSparList();
      }
    }
  }
  if (
player.chat == "/leave")
  {
    if (
InSpar(player))
    {
      if (
this.attr[10] == false)
      {
        
player.30.5;
        
player.47;

        
CheckSparList();
      }
    }
  }
  if (
player.chat == "start")
  {
    if (
GetSparNumber() == 2)
    {
      if (
this.attr[10] == false)
      {
        if (
InSpar(player))
        {
          for (
pl:players)
          {
            
pl.hearts 20;
            if (
pl.account != player.account && InSpar(pl))
            {
              if (
pl.chat == "start")
                
BeginSpar();
            }
          }
        }
      }
    }
  }
  if (
player.chat == "end")
  {
    if (
GetSparNumber() == 2)
    {
      if (
this.attr[10] == true)
      {
        if (
InSpar(player))
        {
          for (
pl:players)
          {
            if (
pl.account != player.account && InSpar(pl))
            {
              if (
pl.chat == "end")
                
this.attr[10] = false;
            }
          }
        }
      }
    }
    else
      
this.attr[10] = false;
  }
}
function 
BeginSpar()
{
  
this.attr[10] = "starting";

  
putbomb(13125);

  
sleep(3);

  
this.attr[10] = true;
}
function 
onPlayerDies()
{
  for(
pl:players)
    
pl.hearts 20;

  if (
InSpar(player))
  {
    
this.attr[10] = false;

    
player.hearts 20;

    
player.30.5;
    
player.47;

    
CheckSparList();
  }
}
function 
CheckSparList()
{
  if (
this.spar_list.size() > 0)
  {
    if (
GetSparNumber() < 2)
    {
      
findplayer(this.spar_list[0]).30.5;
      
findplayer(this.spar_list[0]).24;

      
findplayer(this.spar_list[0]).ap 50;

      
findplayer(this.spar_list[0]).hearts 20;

      
this.spar_list.delete(0);

      
CheckSparList();
    }
  }
  
UpdateList();
}
function 
GetSparNumber()
{
  
temp.spar_p 0;

  for(
pl:players)
  {
    if (
InSpar(pl))
      
temp.spar_p ++;
  }

  return 
temp.spar_p;
}
function 
InSpar(pl)
{
  if (
pl.x+1.5 in |1747| && pl.y+2 in |1537|)
    return 
true;
  else
    return 
false;
}
function 
UpdateList()
{
  if (
this.spar_list.size() > 0)
    
this.chat "Line: " this.spar_list;
  else
    
this.chat "No Line!";
}
//#CLIENTSIDE
function onCreated()
{
  
enablefeatures(allfeatures-0x80);
  
disableweapons();
  
setTimer(.05);
  
this.setshape(13232);
}
function 
onPlayerDies()
  
freezeplayer(.5);
function 
onTimeout()
{
  
enableweapons();
  
disablemap();
  if (
player.x+1.5 in |1747| && player.y+2 in |1537|)
  {
    if (
this.attr[10] == true)
    {
      
enablefeatures(allfeatures-1-2-4-0x10-0x20-0x80);
    }
    else{
      
enablefeatures(allfeatures-0x80);
      
disableweapons();
    }
  }
  else{
    
enablefeatures(allfeatures-0x80);
    
disableweapons();
  }
  
setTimer(.05);



fowlplay4 12-05-2009 03:58 AM

lol that's GScript for ya.

Could you be more specific?

Side note: You should probably make functions for joining, leaving, ending to trim off the fat in playerchats. Also commenting your code doesn't hurt either.

sssssssssss 12-05-2009 04:02 AM

Sorry, I meant to say its not showing the line. Ive tried this.chat and message(), doesnt do anything. Used to last I checked though... kind of weird.

fowlplay4 12-05-2009 04:09 AM

Quote:

Originally Posted by sssssssssss (Post 1542549)
Sorry, I meant to say its not showing the line. Ive tried this.chat and message(), doesnt do anything. Used to last I checked though... kind of weird.

The issue:

PHP Code:

Script compiler output for Class asdf:
error: function onCreated redefined at line 170: function onCreated()
error: function onPlayerDies redefined at line 177: function onPlayerDies()
Script asdf updated by fowlplay4 

Alright that's a little weird but..

PHP Code:

function onCreated() 

  
this.attr[10] = false

  
this.spar_list ""

  
UpdateList(); 
  
this.setshape(13232); 

function 
onPlayerEnters() 

  
CheckSparList(); 

  if (
InSpar(player)) 
  { 
    
player.30.5
    
player.47
  } 

function 
onPlayerLeaves() 

  if (
GetSparNumber() < 2
    
this.attr[10] = false

function 
onPlayerChats() 

  if (
player.chat.starts("/join")) 
  { 
    if (!(
player.account in this.spar_list)) 
    { 
      if (!
InSpar(player)) 
      { 
        
this.spar_list.add(player.account); 

        
CheckSparList(); 
      } 
    } 
  } 
  if (
player.chat == "/leave"
  { 
    if (
InSpar(player)) 
    { 
      if (
this.attr[10] == false
      { 
        
player.30.5
        
player.47

        
CheckSparList(); 
      } 
    } 
  } 
  if (
player.chat == "start"
  { 
    if (
GetSparNumber() == 2
    { 
      if (
this.attr[10] == false
      { 
        if (
InSpar(player)) 
        { 
          for (
pl:players
          { 
            
pl.hearts 20
            if (
pl.account != player.account && InSpar(pl)) 
            { 
              if (
pl.chat == "start"
                
BeginSpar(); 
            } 
          } 
        } 
      } 
    } 
  } 
  if (
player.chat == "end"
  { 
    if (
GetSparNumber() == 2
    { 
      if (
this.attr[10] == true
      { 
        if (
InSpar(player)) 
        { 
          for (
pl:players
          { 
            if (
pl.account != player.account && InSpar(pl)) 
            { 
              if (
pl.chat == "end"
                
this.attr[10] = false
            } 
          } 
        } 
      } 
    } 
    else 
      
this.attr[10] = false
  } 

function 
BeginSpar() 

  
this.attr[10] = "starting"

  
putbomb(13125); 

  
sleep(3); 

  
this.attr[10] = true

function 
onPlayerDies() 

  for(
pl:players
    
pl.hearts 20

  if (
InSpar(player)) 
  { 
    
this.attr[10] = false

    
player.hearts 20

    
player.30.5
    
player.47

    
CheckSparList(); 
  } 

function 
CheckSparList() 

  if (
this.spar_list.size() > 0
  { 
    if (
GetSparNumber() < 2
    { 
      
findplayer(this.spar_list[0]).30.5
      
findplayer(this.spar_list[0]).24

      
findplayer(this.spar_list[0]).ap 50

      
findplayer(this.spar_list[0]).hearts 20

      
this.spar_list.delete(0); 

      
CheckSparList(); 
    } 
  } 
  
UpdateList(); 

function 
GetSparNumber() 

  
temp.spar_p 0

  for(
pl:players
  { 
    if (
InSpar(pl)) 
      
temp.spar_p ++; 
  } 

  return 
temp.spar_p


function 
InSpar(pl

  if (
pl.x+1.5 in |1747| && pl.y+2 in |1537|) 
    return 
true
  else 
    return 
false


function 
UpdateList() 

  if (
this.spar_list.size() > 0
    
this.chat "Line: " this.spar_list
  else 
    
this.chat "No Line!"
}
 
//#CLIENTSIDE
 
function onCreated() 

  
enablefeatures(allfeatures-0x80); 
  
disableweapons(); 
  
setTimer(.05); 
  
this.setshape(13232); 

function 
onPlayerDies() 
{
  
freezeplayer(.5); 
}

function 
onTimeout() 

  
enableweapons(); 
  
disablemap(); 
  if (
player.x+1.5 in |1747| && player.y+2 in |1537|) 
  { 
    if (
this.attr[10] == true
    { 
      
enablefeatures(allfeatures-1-2-4-0x10-0x20-0x80); 
    } 
    else{ 
      
enablefeatures(allfeatures-0x80); 
      
disableweapons(); 
    } 
  } 
  else{ 
    
enablefeatures(allfeatures-0x80); 
    
disableweapons(); 
  } 
  
setTimer(.05); 


Works fine, but you need to have a blank line after the clientside or else it doesn't compile it properly. Neat huh?

For the sake of the future scripts on your server, I'd recommend having all enablefeatures/showstats get done in a weapon-script system, so you can actually keep track of it before it's too late.

ffcmike 12-05-2009 04:09 AM

Wouldn't NPC chat be disabled if text is disabled via the 0x80 feature?

sssssssssss 12-05-2009 04:37 AM

It should just be player chat, being the player vs player, and player streak is showing up fine.

Also, it may not be loading for me properly, b/c sometimes gmaps take like a day to load for me for some reason on here, but its still not working.

ffcmike 12-05-2009 04:53 AM

I've just tested it, the feature does also hide NPC chat aswell as players, and by the looks of the script is being used regardless of whether the player is sparring or not.

If your intention was for chat to only be disabled while you are sparring you should only be including the - 0x80 part here -

PHP Code:

if (player.x+1.5 in |1747| && player.y+2 in |1537|)  
  {  
    if (
this.attr[10] == true)  
    {  
      
enablefeatures(allfeatures-1-2-4-0x10-0x20-0x80);  
    } 

Though I personally don't think default chat is a decent method of displaying a queue line, could probably get messy if it became big, with Classics arena system I have the queue stored as an Attr value (tokenized and processed whenever it changes), front 2 sparrers with their heads + names displayed as a showimg on screen, and your position within the queue displayed by showtext if behind the front 2.

sssssssssss 12-05-2009 04:57 AM

well we have a custom chat sys, so its not just for the spar, ill have to put it in a wep, no biggie.

thanks for the test, and the advice. :)

Switch 12-05-2009 10:39 PM

Quote:

Originally Posted by sssssssssss (Post 1542559)
Also, it may not be loading for me properly, b/c sometimes gmaps take like a day to load for me for some reason on here, but its still not working.

You mean when just updated? Use "/updatelevel gmapname.gmap" in RC.

sssssssssss 12-06-2009 01:47 AM

That doesnt always work. its weird, gmaps just take like a day to load, and its not just for me. I dunno why. tried the rc /updatelevel. no biggie tho.


All times are GMT +2. The time now is 08:30 PM.

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