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 03-13-2007, 07:24 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
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.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #2  
Old 03-13-2007, 08:58 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
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
Reply With Quote
  #3  
Old 03-13-2007, 03:56 PM
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 killerogue View Post
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

__________________

Last edited by cbk1994; 03-13-2007 at 03:59 PM.. Reason: typo
Reply With Quote
  #4  
Old 03-13-2007, 08:13 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Quote:
Originally Posted by cbkbud View Post
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.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #5  
Old 03-13-2007, 09:04 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
add a 'this.currentoutfits' array so you go about editing some outfits rather then just adding to the string
Reply With Quote
  #6  
Old 03-13-2007, 09:35 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld
Reply With Quote
  #7  
Old 03-13-2007, 11:27 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Skyld View Post
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 .
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 10:57 PM.


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