Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Error changing body,head,shield (https://forums.graalonline.com/forums/showthread.php?t=78786)

Mark Sir Link 02-20-2008 02:27 AM

Error changing body,head,shield
 
The idea here is to use a DB NPC to keep track of data for statues so players without RC can change statues has they see fit without frequently having to have staff update levels for them. This also prevents update levels/level overwrites/not being in the level for an extended amount of time from changing how the class looks.

However, right now, only the colors, hat, nick, and AP change effectively.

The bodyimg, headimg, and shieldimg stay at head0.png, shield1.png, and body.png.

Any ideas as to why?

Class "statue"
PHP Code:

function onCreated()
{
  
showcharacter();
  
this.+= .5;
  
this.shieldpower 1;
}

function 
reload(pars)
  {
  
this.chat pars// this is for diagnostics.
  
for(0<= 4i++)
    {
    
this.colors[i] = pars[i];
  }
  
this.headimg pars[5];
  
this.shieldimg pars[6];
  
this.bodyimg pars[7];
  
this.nick pars[8];
  
this.ap pars[9];
  
this.attr[1] = pars[10];
}
function 
copyPlayer(pobj)
{
  
this.shieldimg pobj.shieldimg;
  for(
0pobj.colors.size(); i++)
    
this.colors[i] = pobj.colors[i];
  
this.headimg pobj.headimg;
  
this.nick pobj.nick;
  
this.ap pobj.ap;
  
this.attr[1] = pobj.attr[1];
  
this.bodyimg pobj.bodyimg;
  
this.sprite 0;
}

function 
updateLook()
{
  
DB_Statues.(this.level "_" this.acc) = {this.colors[0], this.colors[1], this.colors[2], this.colors[3], this.colors[4], this.headimgthis.shieldimg,this.bodyimgthis.nickthis.ap,this.attr[1]};
}

function 
getLook()
{
  return 
DB_Statues.(this.level "_" this.acc);
}
function 
reset()
{
  
showcharacter();


Level NPC
PHP Code:

function onCreated()
  {
  
join("statue");
  
this.acc "Mark Sir Link";
  
reload(getLook());
}

function 
onPlayerChats()
  {
  if(
player.account == this.acc && player.chat.starts("copy"))
    {
    
copyPlayer(findplayer(player.account));
    
this.nick "";
    
updateLook();
  }


DB_Statue flags:
PHP Code:

guildrommiel_sumi_spar.nw_Mark Sir Link=orange,white,black,black,black,classichead-ghosthawk.png,classicshield-ghosthawk.png,body.png,"",81,hat104.png 


Chompy 02-20-2008 03:46 AM

Well, instead of this.level you should use this.level.name

Mark Sir Link 02-20-2008 03:48 AM

this.level works fine and it would still generate unique keys, and seeing as the NPCs are returning the proper array when setting it to their chat, I don't see where this is going

The issue is not with the identifier itself, it's with passing the params into images

TSAdmin 02-20-2008 03:53 AM

I made something similar for a gang on Era. Generally just 'giving' a script to someone to solve their problem isn't always helpful, but see if this helps you:

DB_NPC Flags (Named: "TSAdmin_Functions"):
PHP Code:

BlackHolstBody=body.png
BlackHolstChat
=You can set my chathere!
BlackHolstColours0=orange
BlackHolstColours1
=darkred
BlackHolstColours2
=darkred
BlackHolstColours3
=darkred
BlackHolstColours4
=black
BlackHolstHat
=
BlackHolstHead=head26.png
BlackHolstShield
=shield1.png 

Level NPC:
PHP Code:

function onCreated() {
  
this.join("tsadmin_bhholo-new");


Class (named: "tsadmin_bhholo-new"):
PHP Code:

//Class-Script made by TSAdmin (All rights reserved, lol)

function onPlayerEnters() {
  
doUpdateHolo();
}

function 
onPlayerChats() {
  if ((
player.guild in {"Black Holst"} && clientr.gangrank in {"Boss""Leader""Head Chief"}) || (player.guild in {"Working"} && player.account in {"TSAdmin"})) {
  
    
nbhh findNPC("TSAdmin_Functions");
    
    if (
player.chat.starts(":holohead")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstHead") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holobody")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstBody") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holohat")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstHat") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holoshield")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstShield") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holochat")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstChat") = player.chat.substring(10player.chat.length());
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holoskin")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstColours0") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holocoat")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstColours1") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holosleeves")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstColours2") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holoshoes")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstColours3") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holobelt")) {
      
toks player.chat.tokenize();
      
nbhh.("BlackHolstColours4") = toks[1];
      
doUpdateHolo();
    }
    
    if (
player.chat == ":resetholo") {
      
nbhh.("BlackHolstHead") = "head26.png";
      
nbhh.("BlackHolstBody") = "body.png";
      
nbhh.("BlackHolstShield") = "shield1.png";
      
nbhh.("BlackHolstHat") = "";
      
nbhh.("BlackHolstColours0") = "orange";
      
nbhh.("BlackHolstColours1") = "darkred";
      
nbhh.("BlackHolstColours2") = "darkred";
      
nbhh.("BlackHolstColours3") = "darkred";
      
nbhh.("BlackHolstColours4") = "black";
      
nbhh.("BlackHolstChat") = "";
      
doUpdateHolo();
    }
    
    if (
player.chat == ":holome") {
      
nbhh.("BlackHolstHead") = player.headimg;
      
nbhh.("BlackHolstBody") = player.bodyimg;
      
nbhh.("BlackHolstShield") = player.shieldimg;
      
nbhh.("BlackHolstHat") = player.attr[1];
      
nbhh.("BlackHolstColours0") = player.colors[0];
      
nbhh.("BlackHolstColours1") = player.colors[1];
      
nbhh.("BlackHolstColours2") = player.colors[2];
      
nbhh.("BlackHolstColours3") = player.colors[3];
      
nbhh.("BlackHolstColours4") = player.colors[4];
      
doUpdateHolo();
    }
    
    if (
player.chat.starts(":holoplayer")) {
      
toks player.chat.tokenize();
      
pl findPlayer(toks[1]);
      if (
pl == null) {
        
player.addMessage(_("Player not online!"),"b",1);
        return;
      }
      
nbhh.("BlackHolstHead") = pl.headimg;
      
nbhh.("BlackHolstBody") = pl.bodyimg;
      
nbhh.("BlackHolstShield") = pl.shieldimg;
      
nbhh.("BlackHolstHat") = pl.attr[1];
      
nbhh.("BlackHolstColours0") = pl.colors[0];
      
nbhh.("BlackHolstColours1") = pl.colors[1];
      
nbhh.("BlackHolstColours2") = pl.colors[2];
      
nbhh.("BlackHolstColours3") = pl.colors[3];
      
nbhh.("BlackHolstColours4") = pl.colors[4];
      
doUpdateHolo();
    }
    if (
player.chat == ":holohelp") {
      
player.sendPM("Commands for the Hologram:
:holohead [head file]
:holobody [body file]
:holoshield [shield file]
:holohat [hat file]
:holoskin [colour]
:holocoat [colour]
:holoshoes [colour]
:holosleeves [colour]
:holobelt [colour]
:resetholo
:holome - Copies yourself to the hologram
:holoplayer [account] - Sets the holo to the account specified."
);
    }
  }
}

function 
doUpdateHolo() {
  
nbhh findNPC("TSAdmin_Functions");
  
this.showCharacter();
  
this.headimg nbhh.("BlackHolstHead");
  
this.bodyimg nbhh.("BlackHolstBody");
  
this.shieldimg nbhh.("BlackHolstShield");
  
this.attr[1] = nbhh.("BlackHolstHat");
  
  
this.colors[0] = nbhh.("BlackHolstColours0");
  
this.colors[1] = nbhh.("BlackHolstColours1");
  
this.colors[2] = nbhh.("BlackHolstColours2");
  
this.colors[3] = nbhh.("BlackHolstColours3");
  
this.colors[4] = nbhh.("BlackHolstColours4");
  
  
this.chat nbhh.("BlackHolstChat");
}

//#CLIENTSIDE

//This is to set a 'flicker' effect as if it were an actual hologram (optional)

function onPlayerEnters() {
  
setTimer(0.05);
}

function 
onTimeOut() {
  
temp.viseffect = {0.4,0.5,0.6,0.7,0.8};
  if (
lighteffectsenabled) {
    
this.setColorEffect(111randomstring(temp.viseffect));
  }
  else {
    
this.alpha 1;
  }
  
setTimer(0.05);


You can reference it/use it if you wish.

Mark Sir Link 02-20-2008 04:00 AM

Quote:

Originally Posted by TSAdmin (Post 1375843)
..

I get the approach but it's too cumbersome to manage every statue on the server, hence one line creating unique IDs based on level and the set acc.

I'm just confused as to why pars[5] clearly says classichead-ghosthawk.png yet setting this.headimg = pars[5]; fails to have the desired effect.

Inverness 02-20-2008 04:09 AM

You should be using variables head, body, and shield instead of headimg, bodyimg, and shieldimg.

Those ones ending in img are for compatability.

And perhaps try echoing pars[5] the line before you set the head to it so you can see what the value is at the time?

Mark Sir Link 02-20-2008 04:20 AM

I had already tried using body/head/shield with no results.

checking the pars[5] (and the whole pars array as I did earlier, which is why I felt doing this wouldn't help debug) still shows the proper head, so I'm still vastly confused as to why this doesn't work.

Inverness 02-20-2008 04:48 AM

I use it for the player just fine, it should be no different for npcs.

Mark Sir Link 02-20-2008 04:51 AM

still isn't fixing the issue :\

Mark Sir Link 02-20-2008 02:13 PM

managed to fix this by moving the call to reload into the class itself.

Odd.

xAndrewx 02-20-2008 08:03 PM

PHP Code:

function onPlayerEnters() {
  
doUpdateHolo();
}

function 
onPlayerChats() { 
  
temp.db findNPC("TSAdmin_Functions");

  
temp.modes = {"head""body""shield""hat""chat""skin""coat""sleeves""shoes""belt"}; 
  
temp.playerschat player.chat.tokenize(); 

  if (
player.chat.starts(":halo")) {
    for (
temp.itemp.modes) {
      if (
temp.playerschat[0].substring(5).starts(temp.i)) {
        
temp.chat player.chat.substring((temp.i.length());
        if (
temp.modes.index(temp.i) > 4) {
          
temp.part = (temp.modes.index(temp.i) - 5);
          
temp.db.("BlackHolstColours" temp.part) = temp.chat;
          
this.colors[temp.part] = temp.chat;
        } else {
          if (
temp.== "chat") {
            
this.chat temp.chat;
          } else if (
temp.== "hat") {
            
this.attr[1] = temp.chat;
          } else {
            
this.(temp."img") = temp.chat;
          }
          
temp.db.("BlackHolst" temp.i) = temp.chat;
        }
        break;
      }
    }
  } 
}

function 
doUpdateHolo() {
  
temp.db findNPC("TSAdmin_Functions");
  
this.showCharacter();

  
this.headimg temp.db.("BlackHolsthead");
  
this.bodyimg temp.db.("BlackHolstbody");
  
this.shieldimg temp.db.("BlackHolstshield");
  
this.attr[1] = temp.db.("BlackHolsthat");
  
  for (
temp.0temp.5temp.i++) {
    
this.colors[temp.i] = temp.db.("BlackHolstColours" temp.i);
  }
  
  
this.chat temp.db.("BlackHolstchat");


TSA.

Mark Sir Link 02-20-2008 10:47 PM

Uh, sure.


All times are GMT +2. The time now is 06:43 PM.

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