Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Outift Save - Opinions? (https://forums.graalonline.com/forums/showthread.php?t=72796)

killerogue 03-13-2007 07:24 AM

Outift Save - Opinions?
 
This isn't really a general question looking for help or such but rather what you think so far as I have been learning to script.

The general idea of this script is to be able to save your current outfit with a specified name using the command, "/save oufit "name"" as well as load it later using the command, "/load outfit "name"". It's not finished but tell me what you think.

PHP Code:


public function test() {

}

function 
onCreated () {

  
client.head "";
  
client.body "";
  
client.shield "";
  
client.sword "";

}

function 
onPlayerChats () {

if (
player.chat.starts("/save outfit")) {
  
player.chat.tokenize();
  
this.outfitname tokens[2];
  
client.head.add(player.head);
  
client.body.add(player.body);
  
client.shield.add(player.shield);
  
client.sword.add(player.sword) ;
  }

if (
player.chat.starts("/load outfit")) {
  
player.chat.tokenize();
    for(
i=0;i<client.size();i++) {
    
player.head[i] = client.head[i];
    
player.body[i] = client.body[i];
    
player.shield[i] = client.shield[i];
    
player.sword[i] = client.sword[i];
    }
  }



P.S. I'm considering creating functions for each part. But Hell Raven has taught me it's best to make independent functions. Tho, I have not done so here.

Chandler 03-13-2007 08:58 AM

HTML Code:

function onPlayerChats ()
  {
  if (player.chat.starts("/save outfit"))
    {
    temp.styleName = player.chat.substring("/save outfit".length()); //I got lazy!
    for (temp.i = 0; temp.i < 5; temp.i++)
      client.(@"outfits_"@ temp.styleName).add(player.colors[temp.i]);
    client.(@"outfits_"@ temp.styleName).add({player.headimg, player.bodyimg, player.shieldimg. player.swordimg});
    }
  elseif (player.chat.starts("/load outfit"))
    {
    temp.styleName = player.chat.substring("/save outfit".length()); //I got lazy!
    temp.outfitInfo = client.(@"outfits_"@ temp.styleName);
    temp.outfitParts = {"head", "body", "shield", "sword"};
    for (temp.currentPart: temp.outfitParts)
      player.(@temp.currentPart @"img") = temp.outfitInfo[temp.outfitParts.index(temp.currentPart) + 5];   
    for (temp.i = 0; temp.i < 5; temp.i++)
      player.colors[temp.i] = temp.outfitInfo[temp.i];
    }
}

I have no idea if it'll work

cbk1994 03-13-2007 03:56 PM

Quote:

Originally Posted by killerogue (Post 1288072)
P.S. I'm considering creating functions for each part. But Hell Raven has taught me it's best to make independent functions. Tho, I have not done so here.

Independant functions are nice because they can be reused. Public functions in DB NPCs are also extremely useful.

Very nice script, though a little long for what it is. Also, I notice 'client.length'? Not quite sure what that is supposed to do, but I'm pretty sure that won't return anything.

Also, the onCreated function ... there's no need to delete the outfits, unless you were testing. And to delete an array it is best to use obj.clear();

And lastly, as far as I can tell, player.chat.tokenize(); I'm not sure how you'd get that to work. You need to assign that to something ...
NPC Code:

tokens = player.chat.tokenize(); // tokens is an array ... tokens[0], tokens[1], etc


killerogue 03-13-2007 08:13 PM

Quote:

Originally Posted by cbkbud (Post 1288164)
Independant functions are nice because they can be reused. Public functions in DB NPCs are also extremely useful.

Yeah, I'm using a public function here.

Quote:

Very nice script, though a little long for what it is. Also, I notice 'client.length'? Not quite sure what that is supposed to do, but I'm pretty sure that won't return anything.
I'm didn't use 'client.length'? Unless you're reffering to my 'client.size' variable.

[QUOTE]
Also, the onCreated function ... there's no need to delete the outfits, unless you were testing. And to delete an array it is best to use obj.clear();
[QUOTE]

I'm pretty sure that using ' "" ' rather than 'NULL' would not delete the array. I was scripting something similar to this and while using NULL it deleted the array but with the quotations it didn't. :o

Quote:

And lastly, as far as I can tell, player.chat.tokenize(); I'm not sure how you'd get that to work. You need to assign that to something ...
NPC Code:

tokens = player.chat.tokenize(); // tokens is an array ... tokens[0], tokens[1], etc


Yeah, I've long since fixed that thing you're reffering to about the assigning tokenize to something. :)


Thanks.

Rapidwolve 03-13-2007 09:04 PM

add a 'this.currentoutfits' array so you go about editing some outfits rather then just adding to the string

Skyld 03-13-2007 09:35 PM

Things like this I sometimes feel are better stored on the clientside (in scriptfiles, par exemple) but I guess that means that if someone loses their Graal installation, their outfits go with it.

Twinny 03-13-2007 11:27 PM

Quote:

Originally Posted by Skyld (Post 1288242)
Things like this I sometimes feel are better stored on the clientside (in scriptfiles, par exemple) but I guess that means that if someone loses their Graal installation, their outfits go with it.

That's cool ^^. People on N-Pulse can have like 200 outfits at some points :\.


All times are GMT +2. The time now is 11:54 PM.

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