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 06-02-2009, 06:55 PM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
this is what I came up with so far but it doesn't want to work.

PHP Code:
function onCreated()
{
  
this.emoticons = {
  {
65"emoticon_AFK_stay.mng"},
  {
66"emoticon_BRB_stay.mng"},
  {
67"emoticon_conf.png"}
  };
  
  
//player.chat = this.emoticons[this.emoticons.index(65)][1];
  //this.chat = this.emoticons.index("emoticon_conf.png");
}

function 
onPlayerChats()
{
  
/*if (player.guild != "Events Team")
  {
    return;
  }*/
  
  
if (player.chat in {":start"":stop"})
  {
    
this.(player.chat == ":start""startEvent""stopEvent")();
  }
}
  
function 
startEvent()
{
  
this.chat "Event starting, get ready!";
  
serverr.emoticon "";
  
scheduleEvent(3"onPickEmoticon""first");
}

function 
stopEvent()
{
  
serverr.emoticon "";
  
serverr.emoticonevent false;
}

function 
onPickEmoticon()
{
  if (
params[0] == "first")
  {
    
serverr.emoticonevent true;
  }
  
  if (
serverr.emoticonevent == false)
  {
    return;
  }
  
  
serverr.emoticonevent true;
  
kickPlayers();
  
serverr.emoticon int(random(6567));
  
this.chat serverr.emoticon;
  
  
//showimg stuff here, didn't do it yet.
  
  
scheduleEvent(3"onPickEmoticon""");
}

function 
kickPlayers()
{
  if (
serverr.emoticon == "")
  {
    return;
  }
  
  for (
plplayers)
  {
    if (
pl.guild != "Events Team")
    {
      
level.playercount ++;
    }
    if (
level.playercount == 1)
    {
      
stopEvent();
    }
    
    if (
pl.client.emoticon != serverr.emoticon)
    {
      
player.chat "you lose!";
    }
  }
}
  
//#CLIENTSIDE
function GraalControl.onKeyDown()
{
  if (
serverr.emoticonevent == false)
  {
    
client.emoticon "";
    return;
  }
  
  if (
params[0in |577602|)
  {
    
client.emoticon emoticonchar;
  }

I also found out that array.index doesn't work when you have an array inside of an array -.-
__________________
*Sum41Freeeeek
*Frankie
Reply With Quote
  #2  
Old 06-02-2009, 11:42 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Frankie View Post
this is what I came up with so far but it doesn't want to work.

PHP Code:
stuff 
I also found out that array.index doesn't work when you have an array inside of an array -.-
Like I said, you should use a triggeraction and should be setting a this. variable for the emoticon variable, not using a client. variable. client. variables only really should be used when you need to save something to the player, not for something temporary (doesn't matter after you logoff) like this. Same thing with the serverr variable. While nice, it's kind of a waste of memory as the npc's scope shouldn't have to leave the level it self so there's no reason it can't use variables scoped to it self (this.).

If you are using the serverr variable to say tell the server the event is going on, then maybe that's a viable solution but personally, I would just trigger() or call a function of some core events WNPC for setting such a thing.

The real bane I find with classic servers (where I feel they fall short) is that scripters attach a million and a half client. and clientr. variables to the player which can really slow down the loading time of the server (3/4 of the variables aren't even needed to be saved). server. and serverr. aren't so bad but I still tend to avoid them unless I have to use them. There's almost always a better method

Anyways back to your script, the triggeractions will tell the serverside script when a player has a new emoticon. You could do like:

PHP Code:
function onActionGotEmoticon() {
  
temp.this.list.accounts.index(player.account);
  if (
== -1) {
    
this.list.accounts.add(player.account);
    
this.list.emoticons.add(params[0]);
  }
  else 
this.list.emoticons.replace(iparams[0]);

Then using your scheduleevent serverside: once the time has run out, do something like:

PHP Code:
for (temp.players) {
  
temp.this.list.accounts.index(p.account);
  if (
== -|| this.list.emoticons[i] != currentemoticonkick();

If currentemoticon never is NULL or 0 when you get to this point, you can just remove the i == -1 part since this.list.emoticons[-1] will give you those results.

That help?

Also, how does array.index not work in an array? I've never found it not to work unless I'm using it wrong.
__________________
Do it with a DON!
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 04:01 PM.


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