![]() |
for
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: 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? |
I'll give you some examples, hopefully this helps:
NPC Code: NPC Code: NPC Code: I believe these are all the player-level manipulations you can do: player.level - object, read only player.x - floating point value player.y - floating point value player.z - floating point value |
Quote:
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); 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: 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 |
Thank you Evil_trunks for your help, Good to know I'm doing something right ;). And Also thanks for the examples of having it do something based on two players, I can now finmd my scripts that use multiple with or fors and the variable thiso.work and thiso.level=h.nw ect ect :).
|
Actually, my post is helpful. I didnt give him the script myself, instead I showed some examples on how to use each of those commands correctly. He should be able to do the rest from there. Its the best way of learning, by viewing examples, instead of just scripting things for the person.
|
Not really, your post said I was wrong and that I should use with and the old for command. Also Evil_trunks did give me examples by showing the prefix commands and the example of setting another player's values through a different ones. Also i now know from that that IU dont need to use for in an instance like:
NPC Code: |
I didnt say your post was wrong. I was giving examples on how to use the with, for, and setlevel commands with the new engine. You shouldve picked up from there. If I needed to further elaborate, then I'm sorry. But Evil pretty much summed it all up.
|
Well I didnt need wioth examples i'm fine with that command You may have misread my only question was if I used that for command correctly and from your post it seemed like you were saying that it was only usable with the values you supplied.
|
Ah, my mistake then.
|
Quote:
PHP Code:
It is essentially the same as: PHP Code:
|
Actually the for-each command can replace with, and the for loop cant without using with, so yes i believe it can, plus stefan said himself that it's meant to.
|
Quote:
|
yes I suppose it actually replaces for with combo if you need to use for-each.
What i mean by this is: NPC Code: replaces: NPC Code: |
Quote:
PHP Code:
you still have to do: PHP Code:
You can also just aswell do: PHP Code:
|
NPC Code: like that, no with. |
Quote:
|
Well then the prefix of pl or whatever then acts as a replacement for with.
|
Quote:
|
Quote:
with() is what you use so you don't have to use the prefix. |
Quote:
|
The "with" command is kinda changing the environment - by default variables and functions without prefix are either mapped onto the current npc or the current player. With "with" you can change the current npc or current player, so that functions without prefix are mapped onto other objects, in old scripting engine this was the only way to warp another player because "setlevel2" is always warping the "current" player.
Only a few variables were accessible with prefix (players[index].x etc.) in the old engine. In the new engine everything is accessible directly, so you can access numeric attributes like "x" or "y", string attributes like "account" or "nick", built-in functions like "setlevel2" or "setani" or even script functions of other objects, e.g. StatsDatabase.addStatsForPlayer(player), if you declare a function as "public function". So the with-command is not really needed anymore, but often very useful if you want to do a lot of operations on an object, also it can sometimes be faster, although some script optimizations are disabled inside with-blocks (because the lookup of this. numeric variables is changed, this is different to old scripting engine). |
Quote:
allplayers is an object of some sort that acts as an array of all of the players online. By using the foreach syntax of with, you are merely just cycling through every element of that object array and setting each instance at a specific point in time to a specific player. There is no REPLACING. It is just another method to do it. |
Quote:
By acting as a replacement (For those of you who don't know english, acting as means purposely having similar traits of such, but not actually being it) it means that you can use it as one, though it isn't necessary. Thank you for taking my post and messing it up with your *****ic "thinking". No, really. |
Quote:
|
Quote:
|
Quote:
Think before you post. |
Quote:
Think. |
Quote:
Quote:
Quote:
Quote:
|
Quote:
|
Here:
Quote:
Quote:
|
Quote:
|
Quote:
|
Quote:
|
WHO cares if it is a replacement or an alternative. You can do things with prefixes that before where only possible with the with command.
|
| All times are GMT +2. The time now is 06:32 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.