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, 01:05 AM
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
emoticons event

having some trouble here. I haven't scripted in quite a long time and I'm trying to make an event but I'm not sure where to start.

basically I'm trying to make the emoticons event, where an NPC does an emoticon and the players have to replicate the exact emoticon in a certain amount of time or else they get kicked.

basically what I did, I put everything in a class. every time the player in the level used an emoticon, it set a client string with "emoticonchar"

the NPC ran a 3 second loop using schedule event and every 3 seconds it would choose a random number between 65 and 90? (not sure if it was 90) since emoticonchar is basically just a value 65 - 90.

when it picked the number it would add to a string. basically after 3 seconds it tries to match up the last emoticon value with your client string value. if it was different, it would kick you (I never really got to code this without it being buggy..)

I don't have the code right now, but what I did seemed messy and it was quite buggy. the 3 second loop wasn't even working for some reason. is there a better way to do what I'm trying to accomplish?

I'll try to re-do the code and show it here in a bit.
__________________
*Sum41Freeeeek
*Frankie
Reply With Quote
  #2  
Old 06-02-2009, 04:11 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Hmm....
Why save every player's emoticons that are pressed in a client string?

You can just check everytime the player makes an emoticon if it's the correct one and if yes, add them to an array. at the end you loop throught the players and kick the ones that are not in that array
Reply With Quote
  #3  
Old 06-02-2009, 05:19 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
Did you do this all serverside or clientside?

emoticonchar I don't think is serverside and if the check was made clientside, there's no need to check anyone else's emoticonchar other then the main player's (player variable) since everyone player will have their own instance of the clientside script running on their own computer (very nature of clientside scripting).

You could just do a simple 0.05 timeout that checks player.emoticonchar against the npcs and it triggeraction's the result to the serverside if emoticonchar isn't either a null value (or whatever the value is when the player has no emoicon) or this.lastemoticon. Make sure to set this.lastemoticon = player.emoticonchar if the check is successful too to avoid spamming the npcserver with emoticons.

The actual selecting of the emoticon should be done serverside (so everyone gets the same emoticon as well as picking who gets kept and who gets kicked (which is convenient since you can only warp players serverside).

Hope this makes sense and helps you.
__________________
Do it with a DON!
Reply With Quote
  #4  
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
  #5  
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
  #6  
Old 06-03-2009, 12:09 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
You should've read my post :[
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 01:53 PM.


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