Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Resetting Player Attributes (https://forums.graalonline.com/forums/showthread.php?t=68959)

xAndrewx 09-25-2006 08:08 PM

Resetting Player Attributes
 
Create a new database called
'Control_PlayerReset'
Inside that database, add in this script:

HTML Code:

public function doPlayerReset(playerAccount, resetNumber)
{
  if (temp.playerAccount in this.(@ "v" @ temp.resetNumber @ "-accounts"))
  {
    return false;
  }

  this.(@ "v" @ temp.resetVersion @ "-accounts").add(temp.playerAccount);
  sendtorc("/reset " @ temp.playerAccount);
 
  this.trigger("update", "");
}

Once you've added both of those two in, add in the Control-NPC [Or in a player-login sequence if there is one!] this script

HTML Code:

//Change the second value to the reset value for a quick reset
Control_PlayerReset.doPlayerReset(player.account, 1);


Yen 09-25-2006 09:07 PM

function onPlayerLogin() is called on DBs at log in :O

xAndrewx 09-25-2006 09:56 PM

Quote:

Originally Posted by Yen (Post 1222206)
function onPlayerLogin() is called on DBs at log in :O

Via a class etc :p

KuJi 09-25-2006 10:08 PM

Uhh.. I make it save into a textfile via savevars (with the version + account)

MAINLY due to npc restart.. /savenpcs doesn't always work and people end up getting double-reset0rized =o

xXziroXx 09-26-2006 01:57 AM

Quote:

Originally Posted by Yen (Post 1222206)
function onPlayerLogin() is called on DBs at log in :O

Isnt it only called in the Control-NPC?

KuJi 09-26-2006 02:26 AM

Quote:

Originally Posted by xXziroXx (Post 1222336)
Isnt it only called in the Control-NPC?

PHP Code:

function onPlayerLogin(temp.plyr)
{


would work in any database npc.. and even in weapons/scripts. (clientsided aswell)
ex:

PHP Code:

function onPlayerLogin(temp.plyr)
{
  if (
temp.plyr != NULL)
  {
    
player.chat format("%s has logged on!"temp.plyr); // I think?
  
}



xXziroXx 09-26-2006 02:39 AM

Well look at that! I learned something new!

xAndrewx 09-26-2006 08:30 AM

Quote:

Originally Posted by KuJi (Post 1222263)
Uhh.. I make it save into a textfile via savevars (with the version + account)

MAINLY due to npc restart.. /savenpcs doesn't always work and people end up getting double-reset0rized =o

''this.trigger("update", "");''
I've heard that this actually saves the database. Well, that's what I saw in an Era Database NPC :p

ApothiX 09-26-2006 04:34 PM

Quote:

Originally Posted by KuJi (Post 1222343)
PHP Code:

function onPlayerLogin(temp.plyr)
{


would work in any database npc.. and even in weapons/scripts. (clientsided aswell)
ex:

PHP Code:

function onPlayerLogin(temp.plyr)
{
  if (
temp.plyr != NULL)
  {
    
player.chat format("%s has logged on!"temp.plyr); // I think?
  
}



PHP Code:

function onPlayerLogin(pl) {
  if(
pl.account != NULL) {
    
player.chat format("%s has logged on!"pl.account);
  }


is the proper way to do it

KuJi 09-26-2006 09:03 PM

Quote:

Originally Posted by ApothiX (Post 1222483)
PHP Code:

function onPlayerLogin(pl) {
  if(
pl.account != NULL) {
    
player.chat format("%s has logged on!"pl.account);
  }


is the proper way to do it

o hmm..


All times are GMT +2. The time now is 02:56 PM.

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