Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Npc Message (https://forums.graalonline.com/forums/showthread.php?t=61341)

alissalee 09-22-2005 03:00 AM

Npc Message
 
how can i make the npc server send out another message when the player pms it saying a word like "Nat Applacation"

ForgottenLegacy 09-22-2005 03:23 AM

Quote:

Originally Posted by alissalee
how can i make the npc server send out another message when the player pms it saying a word like "Nat Applacation"

(These go into the Control-NPC)

There's a function, onPM(), that is called when the player PMs the NPCServer. Fiddle around with the params, I think the first one is the account and the second one is the text. Using some crazy if-statements, you can find a way to check if the text is equal to something. Then, you can use the sendpm(text) function to send the reply. Note, this is serverside, yanno.

napo_p2p 09-22-2005 07:13 AM

If you are using GS1, instead of onPM(), use:
PHP Code:

if (pm) {
  
//stuff



Velox Cruentus 09-22-2005 07:31 AM

In GS2, you'd have something pretty close to this:
PHP Code:

function onPM(something,text){
  if (
text == "Nat Application")
   
sendPM("Sorry; We aren't seeking assistance in NPCs currently! Thanks anyways.");



Torankusu_2002 09-22-2005 07:37 AM

Just curious, is it possible to leave the account part blank?

napo_p2p 09-22-2005 07:59 AM

Quote:

Originally Posted by Torankusu_2002
Just curious, is it possible to leave the account part blank?

You mean in the onPM() parameters?

If so, I think you can probably do:
PHP Code:

function onPM(" "message) {



I don't know why you would though.

Velox Cruentus 09-22-2005 10:28 AM

Quote:

Originally Posted by Torankusu_2002
Just curious, is it possible to leave the account part blank?

PHP Code:

function onPM()
{
  echo(
"Someone said :" params[1]);


Works just as well.. It's just hard clearing the first param and identifying the second.

Silent 09-22-2005 01:45 PM

Quote:

Originally Posted by napo_p2p
Quote:

Originally Posted by Torankusu_2002
Just curious, is it possible to leave the account part blank?

I think you can probably do:
PHP Code:

function onPM(" "message) {




A space isn't a nothing o.O

("",message)

napo_p2p 09-22-2005 06:24 PM

Quote:

Originally Posted by Silent
A space isn't a nothing o.O

("",message)

Heh, just noticied that I put a space.

But then again, does it have to be nothing?

Skyld 09-22-2005 07:16 PM

  • The first parameter is not the account name.
  • Why are you putting "" in place of a variable?
  • Velox Cruentus is right. If you're only going to use one parameter, then why are you wasting your time with a new variable when params[1] works just as well?

calani 09-23-2005 01:32 AM

Quote:

Originally Posted by napo_p2p
PHP Code:

function onPM(" "message) { 




hahaha bad idea


and as for the params, use all or none.
also, adding variables there doesn't tell the function what to put where, it just gives names for things. the first variable will always be the first paramater, and the second variable will always be the second.

Quote:

function onKeypressed(key,code)
function onKeypressed(code,key)
function onKeypressed(code)
function onKeypressed(key)
if you do things like this, you're bound to get yourself confused.

ForgottenLegacy 09-23-2005 02:23 AM

Quote:

Originally Posted by calani
if you do things like this, you're bound to get yourself confused.

PHP Code:

onKeyPressed(code,key) {


'code' is the asciival of the key
'key' is the key

Memorize that Ashy. :P

napo_p2p 09-23-2005 02:32 AM

lol, I didn't know how to bypass a param. I guess the " " isn't a good idea then >_<.

Torankusu_2002 09-23-2005 06:55 PM

what's the syntax for omPM() then?

napo_p2p 09-23-2005 07:54 PM

try this (GS2):

PHP Code:

function onPM() {



params[1] is the message that the NPC server recieved in the PM.


All times are GMT +2. The time now is 10:10 AM.

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