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 04-02-2011, 10:11 PM
mrnothersan mrnothersan is offline
Owner of MrNothersan
Join Date: Mar 2011
Location: On the Computer
Posts: 97
mrnothersan is an unknown quantity at this point
Send a message via AIM to mrnothersan Send a message via MSN to mrnothersan
Adding Scripts to NPC

Hi,

How do I add commands to the NPC user?
For example if someone chats to the npc user and says "/eventsapp" they get sent back the events team staff application automatically?

Thanks
__________________

Regards
MrNothersan - Playerworld owner


Staff Hirings Thread for MrNothersan: http://forums.graalonline.com/forums....php?p=1639180

Reply With Quote
  #2  
Old 04-02-2011, 10:16 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
A combination of these two functions, you could have just looked through the starting guide in the wiki and figured it out.
PHP Code:
onPlayerChats()
sendpm() 
Reply With Quote
  #3  
Old 04-02-2011, 10:26 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
For a weapon:

PHP Code:
function onActionServerSide(){
 if(
params[0] == "Getets"){
  
player.sendpm("put message here");
 }
}
//#CLIENTSIDE
function onPlayerChats(){
 if(
player.chat == "/eventsapp"){
  
triggerserver("gui",name,"Getets");
 }

__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #4  
Old 04-02-2011, 10:30 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
If you want to add more than one 'command' which i'm sure you will instead of doing elseif or else you can also use the switch statement. There's a post that Zero(zokemon) did explaining it. I think it was called spoils of the switch statement.
Reply With Quote
  #5  
Old 04-04-2011, 07:48 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
...i think he means pm'ing the NPC-Server
__________________
.
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
  #6  
Old 04-04-2011, 09:26 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
In that case, in Control-NPC:

PHP Code:
function onCreated() {
  
this.setPM(""); // reset the reply PM
}

function 
onInitialized() {
  
this.trigger("created"); // if the server restarts
}

// the parameters are lines
function onPM(p0p1p2p3) { // first parameter isn't used
  
if (p1 == "eventsapp") {
    
player.sendPM("Events Application:\nStuff here!");
  }

__________________

Last edited by cbk1994; 04-04-2011 at 10:00 PM.. Reason: fixed, thanks jer
Reply With Quote
  #7  
Old 04-04-2011, 09:33 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
It's actually lines.

I.e:
Quote:
Hello World
This is a pm.
Results in...

PHP Code:
params = {
  
""// Some sort of reference, useless though since player. is accessible.
  
"Hello World",
  
"This is a pm."
}; 
Therefore...

PHP Code:
function onPM(p0p1) {
  
// If you need the whole message in a string (delete this otherwise)
  // you can put it together like this:
  
for (temp.lineparams.subarray(1)) {
    
temp.message @= temp.line NL "";
  }
  
// Or just check the first line
  
if (p1 == "eventsapp") {
    
player.sendPM("Events Application:\nStuff here!");
  }

__________________
Quote:
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 08:27 AM.


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