Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Scripting an NPC Server (https://forums.graalonline.com/forums/showthread.php?t=80767)

Knightmare1 07-23-2008 10:41 PM

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

DustyPorViva 07-23-2008 10:59 PM

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
    */
  
}



Knightmare1 07-23-2008 11:27 PM

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);



Loriel 07-23-2008 11:32 PM

Quote:

Originally Posted by Knightmare1 (Post 1407511)
PHP Code:

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



Which player?

Knightmare1 07-23-2008 11:37 PM

Quote:

Originally Posted by Loriel (Post 1407513)
Which player?

im trying to make it find all players. or would i do that with
PHP Code:

function onLogin()
//or function onPlayerEnters()? 


Loriel 07-23-2008 11:38 PM

onLogin sounds like a better plan. No idea. Go ahead and try it?

cbk1994 07-23-2008 11:42 PM

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)

DustyPorViva 07-23-2008 11:42 PM

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.

Knightmare1 07-23-2008 11:48 PM

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");
    }
  }



cbk1994 07-23-2008 11:50 PM

Quote:

Originally Posted by Knightmare1 (Post 1407526)
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.


All times are GMT +2. The time now is 01:11 PM.

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