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 07-04-2011, 03:37 AM
xuntasi xuntasi is offline
Registered User
xuntasi's Avatar
Join Date: Jun 2011
Location: Deadaccountsville, Internet
Posts: 14
xuntasi is on a distinguished road
How to script chat-operated weapons?

Ok, so I am deeply confused about how to script weapons that are affected by player chat. I made this script, and it is operated by chat commands, but when I make it a weapon it doesn't work. I've literally been sitting at my computer for over 2 hours now stuck on this one script. It works perfectly when made into a regular NPC, but it doesn't do jack as a weapon. I'm not asking for anyone to give me any script, I just need advice on what commands I should change to make this a weapon (or just a script that will work in all levels, not necessarily a weapon. Really the only problem now is that it only works in the room with the NPC.)

Here is my script:
PHP Code:
function onPlayerChats() {
  if(
player.chat.starts("/shonmessage ") && player.account=="Graal780973") {
    
shon.mess player.chat.substring("/shonmessage ".length());
    echo(
"Shonspeak message set to "@shon.mess);
  }
  if(
player.chat.starts("/shonaccount ") && player.account=="Graal780973") {
    
shon.acc findplayer(player.chat.substring("/shonaccount ".length()));
    echo(
"Shonspeak target set to "@shon.acc.account);
  }
  if(
player.chat=="/shonspeak" && player.account=="Graal780973") {
  
shon.acc.chat shon.mess;
  }

Any advice as to what I should do?
__________________
This account is DEAD!
Reply With Quote
  #2  
Old 07-04-2011, 03:40 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
In a weapon, onPlayerChats() is only invoked on the clientside.

Tip: echo() will be sent to your F2 window on the clientside.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 07-04-2011, 03:44 AM
xuntasi xuntasi is offline
Registered User
xuntasi's Avatar
Join Date: Jun 2011
Location: Deadaccountsville, Internet
Posts: 14
xuntasi is on a distinguished road
I know about the echo this, that was intentional, but what of the clientside thing? Do I just add //#CLIENTSIDE to the script and it will work?
__________________
This account is DEAD!
Reply With Quote
  #4  
Old 07-04-2011, 03:45 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Yes, it will work to an extent. I'm assuming you've defined "shon" to be some object somewhere else on the serverside, so, in order to get the complete desired effect, you will most likely have to use triggerserver() to send the information to the serverside.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #5  
Old 07-04-2011, 03:47 AM
xuntasi xuntasi is offline
Registered User
xuntasi's Avatar
Join Date: Jun 2011
Location: Deadaccountsville, Internet
Posts: 14
xuntasi is on a distinguished road
Thanks man! lol Though I think I should read more GS2 tutorials before I do any more on that script, cause Idk what the serverside or clientside are, let alone how to access them.
__________________
This account is DEAD!
Reply With Quote
  #6  
Old 07-04-2011, 03:50 AM
xuntasi xuntasi is offline
Registered User
xuntasi's Avatar
Join Date: Jun 2011
Location: Deadaccountsville, Internet
Posts: 14
xuntasi is on a distinguished road
Wait do I just put this in the script?
PHP Code:
function onCreated() {
  
triggerserver()

Cause that'd be pretty easy lol.
__________________
This account is DEAD!
Reply With Quote
  #7  
Old 07-04-2011, 03:52 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
I'll do this one for you as an example, consider this your freebie.
PHP Code:
function onActionServerside(commandparameter) {
  switch (
command) {
    case 
"mess":
      
shon.mess parameter;
      echo(
"Shonspeak message set to "shon.mess);
    break;

    case 
"acc":
      
shon.acc findplayer(parameter);
      echo(
"Shonspeak target set to "@shon.acc.account);
    break;

    case 
"accchat":
      
shon.acc.chat shon.mess;
    break;
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("/shonmessage ") && player.account=="Graal780973") {
    
temp.mess player.chat.substring("/shonmessage ".length());
    
triggerserver("weapon"this.name"mess"temp.mess);
  }
  if (
player.chat.starts("/shonaccount ") && player.account=="Graal780973") {
    
temp.acc player.chat.substring("/shonaccount ".length());
    
triggerserver("weapon"this.name"acc"temp.acc);
  }
  if (
player.chat=="/shonspeak" && player.account=="Graal780973") {
    
triggerserver("weapon"this.name"accchat");
  }

__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #8  
Old 07-04-2011, 03:57 AM
xuntasi xuntasi is offline
Registered User
xuntasi's Avatar
Join Date: Jun 2011
Location: Deadaccountsville, Internet
Posts: 14
xuntasi is on a distinguished road
Oh wow thanks dude! I'm gonna study this a lot, I need to figure out how to do this myself! Thank you very much for all your help!
__________________
This account is DEAD!
Reply With Quote
  #9  
Old 07-04-2011, 09:26 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
you can also use if (player.account == "Graal780973") { above your if statements,
instead of repeating if (... && player.account == "Graal780973") { for every if condition you make that is "account locked".

e.g;
PHP Code:
if (player.account == "acc") {
  if (
player.chat == "something") { // only "acc" can call doStuffs(); by saying "something"
    
doStuffs();
  }
  if (
player.chat == "stuff") { // same here
    
doOtherStuffs();
  }

__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
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:52 AM.


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