Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Player Levels (https://forums.graalonline.com/forums/showthread.php?t=77160)

TSAdmin 10-14-2007 08:36 AM

Player Levels
 
I have this weapon that allows me to use chat to trigger occurances upon myself or specified players. Things like :osl Account to send someone to OSL immediately. Anyway, I got toying with doing it with all players in the same level as myself and hit a brick wall. To test, I merely used chat rather than jumping right to setLevel2. I stood in a level with around 20 players in it and triggered it with the :test command and it's only finding 1 or 2 people in the same level as me. Basically, could someone check this out and see if I'm missing something. I sought help from kinetaro, and he added the temp stuff to it as he said for messes with player.account sometimes, but even he was unable to figure out why it wasn't working.

PHP Code:

else if (toks[0] == ":test") {
      if (
player.account in this.allowedFull) {
      
this.tempacc player.account;
        for (
plallplayers) {
          if (
pl.level.name == findPlayer(thiso.tempacc).level.name && pl.level != null) {
            
pl.chat pl.account;
            return;
          }
        }
      }
    } 

Any clues?

xXziroXx 10-14-2007 08:40 AM

findPlayer(thiso.tempacc).level.name is obselete, try replacing it with player.level.name - you never, ever, use findPlayer() to access the current player.

TSAdmin 10-14-2007 08:41 AM

Quote:

Originally Posted by xXziroXx (Post 1352777)
findPlayer(thiso.tempacc).level.name is obselete, try replacing it with player.level.name - you never, ever, use findPlayer() to access the current player.

player.level.name was what I had originally, that thiso was something kine threw in. Neither worked.

xXziroXx 10-14-2007 08:43 AM

&& pl.level.name != null instead of && pl.level != null? I probably wont be making much sense, as I havent slept for over a day.

TSAdmin 10-14-2007 08:48 AM

Quote:

Originally Posted by xXziroXx (Post 1352779)
&& pl.level.name != null instead of && pl.level != null? I probably wont be making much sense, as I havent slept for over a day.

You should get some sleep, then. Anyway, this is basically what I had before I got kine to check it out:

PHP Code:

else if (toks[0] == ":test") {
      if (
player.account in this.allowedFull) {
        for (
plallplayers) {
          if (
pl.level.name == player.level.name && pl.level.name != null) {
            
pl.chat pl.account;
            return;
          }
        }
      }
    } 

Which, going by what you have told me, should work as expected, which is why when it didn't I sought such help :s It hates me, rofl.

xXziroXx 10-14-2007 08:54 AM

If you want to access people in the current level, why not use players instead of allplayers?


PHP Code:

else if (toks[0] == ":test") {
  if (
player.account in this.allowedFull) {
    for (
plplayers) {
      
pl.chat pl.account;
      return;
    }
  }


And yes, sleep is next on today's schedule.. I think.

TSAdmin 10-14-2007 09:01 AM

Sadly, I also thought of that :( Still nothing.

xXziroXx 10-14-2007 09:04 AM

I told Novo to take a look at the thread, I'm too tired for coding right now. Hopefully he'll help you out.

TSAdmin 10-14-2007 09:06 AM

Quote:

Originally Posted by xXziroXx (Post 1352783)
I told Novo to take a look at the thread, I'm too tired for coding right now. Hopefully he'll help you out.

Alright, thanks :) Sleep well

Novo 10-14-2007 09:08 AM

The return causes the function to terminate. :)

Novo 10-14-2007 09:10 AM

PHP Code:

if (toks[0] == ":test")
  {
//      if (player.account in this.allowedFull) { 
        
for (plallplayers) { 
          if (
pl.level.name != player.level.name )
            continue;

          
pl.chat pl.account
        } 
//      } 
    


This is what I'd use for testing.

TSAdmin 10-14-2007 09:29 AM

NOVO WINS, lmao... stupid me, actually was using : as the initiating symbol in this example, and it was meant to be /

Thanks, rofl <3

xAndrewx 10-14-2007 09:50 AM

although, since you're only wanting to find a specific player I wouldn't use players/allplayers...

HTML Code:

//pars = [0-action]
if (temp.action == "summon") {
  findPlayer(params.substring(temp.action.length() + 1)).setlevel2(player.level.name, player.x, player.y);
}

oh, just re-read my bad

HTML Code:

if (temp.action == "summon") {
  for (temp.i: players) {
    temp.i.setlevel2(player.level.name, player.x, player.y);
  }
}

this will cause everyone in your level to be warped to that position

zokemon 10-14-2007 10:41 AM

return: Leaves the function and returns parameters to the function caller.
break: Immediately ends the loop or switch and jumps to the end of it.
continue: Ends the current step of the while/for loop and continues with the next one.

Make sure you remember which is which :)

xXziroXx 10-14-2007 07:49 PM

Geez, would have thought I'd notice such a thing even when tired like hell. :whatever:


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

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