Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Removing weapons on login? (https://forums.graalonline.com/forums/showthread.php?t=134266421)

Fysez 05-12-2012 01:01 AM

Removing weapons on login?
 
How can I remove player weapons on login?
This is what I have, and it doesn't work:

PHP Code:

 function onActionServerSide() {
    
findPlayer.removeWeapon("bow");



ffcmike 05-12-2012 01:06 AM

Quote:

Originally Posted by Fysez (Post 1694405)
How can I remove player weapons on login?
This is what I have, and it doesn't work:

PHP Code:

 function onActionServerSide() {
    
findPlayer.removeWeapon("bow");



The login function is:

PHP Code:

function onActionPlayerOnline(){



within the Control-NPC.

'findplayer("account")' is a function which takes the specified account string parameter and returns the player object if it exists, it is not necessary within onActionPlayerOnline however as there is already the 'player' object to use.

I would also imagine the parameter for removeweapon is case sensitive, which probably means you should have 'removeweapon("Bow");'.

Fysez 05-12-2012 01:19 AM

Quote:

Originally Posted by ffcmike (Post 1694406)
The login function is:

PHP Code:

function onActionPlayerOnline(){



within the Control-NPC.

'findplayer("account")' is a function which takes the specified account string parameter and returns the player object if it exists, it is not necessary within onActionPlayerOnline however as there is already the 'player' object to use.

I would also imagine the parameter for removeweapon is case sensitive, which probably means you should have 'removeweapon("Bow");'.

PHP Code:

 function onActionPlayerOnline(){ 
removeweapon("Bow");


This does not work.
I've tried it in (even though they don't need to be) Class, NPC-Database, Level NPC, and Weapon (though weapon won't help) and it does not work.

ffcmike 05-12-2012 01:27 AM

It specifically has to be the Control-NPC, which is listed among database NPCs.

Try:

PHP Code:

function onActionPlayerOnline(){ 
  
player.removeweapon("Bow");
  echo(
player.account SPC "logged in");


in order to determine whether the function is even occurring.

Fysez 05-12-2012 01:32 AM

Quote:

Originally Posted by ffcmike (Post 1694409)
It specifically has to be the Control-NPC, which is listed among database NPCs.

Try:

PHP Code:

function onActionPlayerOnline(){ 
  
player.removeweapon("Bow");
  echo(
player.account SPC "logged in");


in order to determine whether the function is even occurring.

Did not work either.

ffcmike 05-12-2012 01:35 AM

Quote:

Originally Posted by Fysez (Post 1694411)
Did not work either.

Then I imagine you're putting it in the wrong place or else if the function was at least occurring a message would be shown within RC. The Control-NPC is listed at the bottom of the database NPCs list.

Fysez 05-12-2012 01:39 AM

Quote:

Originally Posted by ffcmike (Post 1694412)
Then I imagine you're putting it in the wrong place or else if the function was at least occurring a message would be shown within RC. The Control-NPC is listed at the bottom of the database NPCs list.

It goes:
Classes
Database-NPC
Weapons

I put it in "Classes" and "Database-NPC".
Also, I see nothing named specifically "Control-NPC"

Fysez 05-12-2012 01:40 AM

Quote:

Originally Posted by Fysez (Post 1694413)
It goes:
Classes
Database-NPC
Weapons

I put it in "Classes" and "Database-NPC".
Also, I see nothing named specifically "Control-NPC"

Nevermind... I completely looked over it.

Fysez 05-12-2012 01:42 AM

Still does not work.
Even in the correct area.
I see it works for other items, I found. But not the bow...?

BlueMelon 05-12-2012 03:34 AM

public function onPlayerLogin(pl)
{
pl.removeweapon("weaponname");
}

Emera 05-12-2012 10:25 AM

Might be a little easier to put them all in an array instead of using multiple removeweapon() functions. It doesn't really make a difference, but it looks nicer.

PHP Code:

function onCreated() {
  
this.weapons_rem = {
    
"-System",
    
"-Other",
    
"Weapons/Here"
  
};
}

function 
onActionPlayerOnline() {
  for (
weapons this.weapons_rem) {
    
player.removeweapon(weapons);
  }



xXziroXx 05-12-2012 11:11 AM

Quote:

Originally Posted by Emera (Post 1694447)
Might be a little easier to put them all in an array instead of using multiple removeweapon() functions. It doesn't really make a difference, but it looks nicer.

PHP Code:

function onCreated() {
  
this.weapons_rem = {
    
"-System",
    
"-Other",
    
"Weapons/Here"
  
};
}

function 
onActionPlayerOnline() {
  for (
weapons this.weapons_rem) {
    
player.removeweapon(weapons);
  }



I don't see the need to permanently store the weapons array, and you should *REALLY* give your weapons string a temp header.


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

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