Quote:
|
Originally Posted by falco10291029
I basically know how to use the new for function but I have a question.
It's supposed to replace the with command but I am not sure exactly how one is supposed to actually do a function with it, though setting variables i an do.
I think it is something like this:
NPC Code:
for (pl: players) {
pl.setlevel2(level,x,y);
}
But I am not sure if that's right. I ahve been trying it like that but my results are inconclusive, can someone tell me if this is right, and if not, the proper way to do it?
|
don't even bother reading Gambet's post, it's not helpful at all
you have it correct, you prefix the command/variable with the player's object
by default it uses player so these two commands are equal
NPC Code:
setlevel2(level,x,y);
player.setlevel2(level,x,y);
if you want to get a variable of another player, i think you should be able to figure it out, you have it correct in your example, but here's an example of getting a player's object then using it
NPC Code:
pobj = findplayer("Evil_Trunks");
pobj.hp = pobj.maxhp;
pobj.setlevel2(player.level,player.x,player.y);
it would heal Evil_Trunks to max hp, then bring him to wherever the active player is
in your example, you are getting each item of the "players" array, which contains an object for each player in the level