Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-23-2008, 10:41 PM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
Exclamation Scripting an NPC Server

Ive been having trouble scripting an NPC server, and really need help. i dont mean script it for me, i'm asking for some basic guidelines for doing functions via NPC Server. i am having trouble on these areas (and yes i searched the wiki, didnt help):

Adding Weapons
Reseting players
__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #2  
Old 07-23-2008, 10:59 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
There are two ways to add a weapon... one, is initializing it on the serverside. That's as simple as doing...
PHP Code:
findplayer("DustyPorViva").addweapon("Bomb"); 
The other method involves triggering the serverside and adding it... which is more common.
PHP Code:
function onActionserverside() { // when the server is triggered, via triggerserver
  
if (params[0] == "addbomb") { // Check to see what 'command' is being sent
    // params[0] will be the first parameter you sent through the trigger... assuming you know how triggers and parameters work
    
findplayer(params[1]).addweapon("Bomb"); 
    
// findplayer() will pinpoint an account and addweapon to the player.
    // findplayer() is very important serverside, as a server holds the data of ALL players, you need to be specific.
  
}
}
//#CLIENTSIDE
// ^ That means everything under this line is on the clientside
function onPlayerchats() {
  if (
player.chat=="/addbomb") { // if the player says /addbomb
    
triggerserver("gui",name,"addbomb",player.account);
    
/* trigger the server
       GUI simply means you are triggering a weapon... don't change that
       NAME means you're triggering THIS weapon... you can change that to another weapon if you want to trigger another
       "ADDBOMB" will be used as a command of sort, so you can interpret it on the serverside as what you're doing
       player.account -- we need to send this info so the server knows which player to add the weapon to
    */
  
}

Reply With Quote
  #3  
Old 07-23-2008, 11:27 PM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
thank you dusty. and for the
PHP Code:
 findplayer("account").addweapon("bomb"
would i make this as my NPC Script for adding weapons?


PHP Code:
function onCreated()
{
  
findplayer(player.account).addweapon("bomb")

or could i do this?

PHP Code:
function onCreated()
{
  
this.startweapons = { "-System""-reconnect""-Messages"};
  
findplayer(player.account).addweapon(this.startweapons);

__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #4  
Old 07-23-2008, 11:32 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Knightmare1 View Post
PHP Code:
function onCreated()
{
  
findplayer(player.account).addweapon("bomb")

Which player?
Reply With Quote
  #5  
Old 07-23-2008, 11:37 PM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
Quote:
Originally Posted by Loriel View Post
Which player?
im trying to make it find all players. or would i do that with
PHP Code:
function onLogin()
//or function onPlayerEnters()? 
__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #6  
Old 07-23-2008, 11:38 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
onLogin sounds like a better plan. No idea. Go ahead and try it?
Reply With Quote
  #7  
Old 07-23-2008, 11:42 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 the control NPC script, something like this:

PHP Code:
function onActionPlayerOnline()
{
  
temp.weapons = { "weapon1""weapon2" };
  
  for ( 
temp.weapon weapons )
  {
    
player.addweaponweapon );
  }

I recommend using my control-npc I released, it will do most of this for you. (http://forums.graalonline.com/forums...ad.php?t=77750)
__________________
Reply With Quote
  #8  
Old 07-23-2008, 11:42 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Ya... for adding weapons to all players, do so on login...
or:

PHP Code:
for (i:allplayers) {
  
findplayer(i).addweapon("weaponname");

If you want to do so whenever you please.
Reply With Quote
  #9  
Old 07-23-2008, 11:48 PM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
and, when i try to reset players, it resets them every time they login. how do i add a flag to the NPC server?


would this work?
PHP Code:
function onActionPlayerOnline()
{
  
temp.weapons = { "-System/Main""-reconnect" };

  
sendPM("
  Welcome to Final Resort!
  we are under construction!
  please, if you are not here to help,
  come back later, to se if there is updates.
  "
);
   
  for ( 
temp.weapon weapons )
  {
    
player.addweaponweapon );
  }
  
  if(
clientr.reset 0)
  {
    
sendtoRC("/reset" SPC player.account);
    for (
1:allplayers)
    {
      
findplayer.(i).addflag("client.reset = 1");
    }
  }

__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #10  
Old 07-23-2008, 11:50 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
Quote:
Originally Posted by Knightmare1 View Post
and, when i try to reset players, it resets them every time they login. how do i add a flag to the NPC server?
http://forums.graalonline.com/forums...ad.php?t=69096

A quick search reveals this.
__________________
Reply With Quote
Reply

Tags
nightmare, npcserver, scripting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:39 AM.


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