Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   script help (https://forums.graalonline.com/forums/showthread.php?t=83730)

[email protected] 01-17-2009 06:59 AM

script help
 
Hello, i have a script. it basically makes the npc server reset someones attributes if they havnt been reset.

function onCreated()
{
this.resetver = 1;
}

function onActionPlayerOnline()
{
temp.rplayers.loadvars("resetlog.txt");

if (makevar("temp.rplayers.acct_" @ player.account) < this.resetver)
{
sendtorc(format("/reset %s", player.account));

makevar("temp.rplayers.acct_" @ player.account) = this.resetver;
temp.rplayers.savevars("resetlog.txt", 0);
return false;
}




It isnt working though

someone help me fix it please.

salesman 01-17-2009 07:15 AM

this might help you

http://forums.graalonline.com/forums...ad.php?t=77689

Seich 01-17-2009 07:15 AM

If you want to reset players as they login use something like this:

PHP Code:

function onActionPlayerOnline(){
    if(
client.reset != true){
        
temp.acc player.account;
        
sendtorc(format("/reset %s"temp.acc));
        
client.reset true;
    }


This should be added to the npc control.

I personally dislike that method, I would reset all accounts for once, instead of resetting them as players login as you requested.

Tigairius 01-17-2009 07:36 AM

Quote:

Originally Posted by Seich (Post 1457656)
PHP Code:

function onActionPlayerOnline(){
    if(
client.reset != true){
        
temp.acc player.account;
        
sendtorc(format("/reset s"temp.acc));
        
client.reset true;
    }



You shouldn't use client. variables for things like a reset since client. variables can be edited with a memory editor. You should use a clientr. variables and there's no need to use a temp variable you could just do sendtorc("/reset" SPC player.account);.

[email protected] 01-17-2009 07:44 AM

Is there a script that resets all accounts at once? I would prefere that.

please tell me seich =]

[email protected] 01-17-2009 07:46 AM

I personally dislike that method, I would reset all accounts for once, instead of resetting them as players login as you requested.

How could I do that? You know, resetting every player at once?

Please explain to me.

[email protected] 01-17-2009 07:51 AM

if (playerenters) {
sendtorc("/reset" SPC player.account);
}


Ok, that works, but it doesn't do it only once, It continues to reset. How do I stop this?

Tigairius 01-17-2009 07:54 AM

Quote:

Originally Posted by [email protected] (Post 1457662)
if (playerenters) {
sendtorc("/reset" SPC player.account);
}


Ok, that works, but it doesn't do it only once, It continues to reset. How do I stop this?

PHP Code:

function onActionPlayerOnline() {
  if (!(
player.account in this.reset)) {
    
this.reset.add(player.account);
    
sendtorc("/reset" SPC player.account);
  }


Put it in the DB NPC called Control-NPC.

[email protected] 01-17-2009 08:01 AM

Tig, you seem to have a good knowledge of scripting. Is there a script that when I update the npc server, it resets every account in the whole game? Like and it wont have to wait for them to log on and disconnect them?

Matt 01-17-2009 08:05 AM

I don't think that's possible. The closest thing you'll get, which should be good enough is that once that script that Tig gave you is in the Control-NPC, you can right click on that and select 'Reset'. That should make it so every play that logs in again will have their account reset automatically their next login onto your playerworld.

Twinny 01-17-2009 08:49 AM

I know Stefan has a handy serveroption for it but there is no way for a developer to do it. Unless you deleted all the account folders but there would probably be repercussions to that

DustyPorViva 01-17-2009 08:57 AM

The account folders/files also store staff data on them(like rights, IP/PCID access yada yada). I don't think there would be a direct repercussion if you delete all files other than staff, but giving the NPC server RW rights to account folders is risky, though not too risky if you remove the rights as soon as you're done.

Tigairius 01-17-2009 09:18 AM

As Dusty said above, you could delete the files in the accounts folder. I have done this before, but I haven't tested it multiple times, so I'm not sure if it's still working. If you give the NPC-Server rights to the accounts/ folder temporarily you could use a script to scan & delete the accounts folder. Also restart the GServer & NPC-Server once you're done for changes to take full effect. Your rights & everything will be gone though, so make sure the server owner is present to re-add your rights. This method is also highly unrecommended unless you have a great knowledge of what you're doing.

cbk1994 01-17-2009 03:56 PM

PHP Code:

function resetAll() {
  
temp.folder.loadFolder("accounts/*"true);
  
  for (
temp.file folder) {
    if (!
file.ends(".txt")) {
      continue;
    }
    
    
file file.substring(0file.length() - 4); // remove extension
    
temp.tokens file.tokenize("/"); // split between slashes
    
    
sendtorc("/reset" SPC tokens[tokens.size()]);
  }


I imagine something like this would work, but I've never tried anything like it. No rights should be needed; loadFolder works with no read rights as far as I know.

Crow 01-17-2009 10:53 PM

Quote:

Originally Posted by cbk1994 (Post 1457708)
PHP Code:

function resetAll() {
  
temp.folder.loadFolder("accounts/*"true);
  
  for (
temp.file folder) {
    if (!
file.ends(".txt")) {
      continue;
    }
    
    
file file.substring(0file.length() - 4); // remove extension
    
temp.tokens file.tokenize("/"); // split between slashes
    
    
sendtorc("/reset" SPC tokens[tokens.size()]);
  }


I imagine something like this would work, but I've never tried anything like it. No rights should be needed; loadFolder works with no read rights as far as I know.

As far as I know, a player has to be online to be reset.

Tigairius 01-17-2009 10:57 PM

Quote:

Originally Posted by cbk1994 (Post 1457708)

I imagine something like this would work, but I've never tried anything like it. No rights should be needed; loadFolder works with no read rights as far as I know.

Ah yes, I've done that before. It seems to work fine.

xXziroXx 01-18-2009 02:10 AM

Quote:

Originally Posted by Crow (Post 1457787)
As far as I know, a player has to be online to be reset.

Not to my knowledge.


All times are GMT +2. The time now is 09:36 PM.

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