Question on Server... again ...
PHP Code:
I know I could go reading 10 in the array, and I think to pull it out i'd need a for(), but I tried. I've been out of this for 4 years. Sorry guys. |
Yes, you can use a loop instead:
PHP Code:
|
Should have known. Forgot to do the if match is i. xD
Like I said, been to long, thanks gambet. |
Quote:
1. Can you explain why the temp. is not required or that just the way it is and I better accept it? 2. Also, does it only apply to temp.variables? 3. Are there any exceptions to this rule? I've noticed that you can use pc[0....10] or whatever to access variables created with temp.pc = player.chat.tokenize(); |
Quote:
If I do this: PHP Code:
Now, with regards to temporary variables, you only need to use the temp. prefix when first defining them and then all other instances after that you don't need to. It's similar to the whole parameter naming I mentioned above where at first you just need to tell the engine that you're defining a temporary variable for the function, once you have defined it, you no longer need to use a prefix to access it. So: PHP Code:
PHP Code:
This doesn't work with this. vars., since this. vars can be accessed throughout the entire script whereas temp. vars are restricted to the function they are created in. |
Quote:
2) If you mean using a for() loop, no, but in most cases you'll want to unless you plan to loop through an array of things, find something specific, and use the data somewhere else. 3) player.chat.tokenize() separates the player's chat at every space (" ") and put it in an array (tokenize() can also separate at other points by using a string inside the ()). Using that in temp.pc just makes it so you can access that data using temp.pc (needed when defining it) or pc (any time after defining it) and can only be called inside the function it was defined in. Array sizes start at 0 for the first param and end at the number 1 less than the last param (in normal counting). Params are accessed using [#]. As an example: PHP Code:
|
I knew how to access function parameters using said defined names. I think I took what you said the wrong way, but thanks for your clarifications. One more question though;
What should I expect this to output? This? [foo] FOOED [temp.foo] foostring [bar] BARRED [temp.bar] barstring || This? [foo] foostring [temp.foo] foostring [bar] barstring [temp.bar] barstring PHP Code:
EDIT to s^11: Sorry to jack your thread |
Quote:
PHP Code:
|
Quote:
|
Quote:
|
Ok. The forum I started was for this script.
PHP Code:
Im just lost. Don't know where to go next, at all. help :( |
probably not supposed to do this but all. bump
|
Among other things, player.dies is not a variable I am aware of existing. There is a GS1 event called playerdies.
If you plan on using that, it should be in a timeout rather than created so it gets checked more than once. Your serverside warping functions don't have a player to warp. I believe it is currently warping the NPC itself to another level if it's even being hit. Take other peoples suggestions from before and create something to clean up the say2, creating a string with a loop. "if (player.account == serverr.sdematch1[0] " is particularly confusing because you'll only ever warp that particular player in element of the array rather than all the match strings. |
NPC Code:function onActionSetMatchServer(match, vplayer, splayer) { Why not this instead: NPC Code:function onActionSetMatchServer(match, vplayer, splayer) { Don't make a loop if you don't have to ;) This looks even sexier: NPC Code:function onActionSetMatchServer(i, v, s) serverr.(@"sdematch" @ i) = {v, s}; serverr. and server. are the devil though. |
Quote:
|
Quote:
Actually the loop idea is much better than your idea because your idea is insecure in that a player would have the potential of creating an unlimited number of serverr. vars. If you want to go the route of not using a loop, you would have to add an extra check to prevent the above from happening, something like: PHP Code:
|
I stick with loop, and ya, server is annoying but thats what i was choosing to use.
What im stuck at is getting the matches to start, warp the player in, when they die, warp both out, and warp match 2 in. I just need to know how ot approach it, dont have to give me codes or anything. |
Well the basic idea is:
Have a player queue script, when the queue is full, create the matches, warp the players in, have a loop scan the players until one of them is dead, add the winner to a list, warp the loser to OSL, the winner to spar waiting room or whatever, then continue with next match, continue till there are no matches, then re-create the matches with winners, continue the same process till the winners list is down to just one. Of course you'll have to add some other things to make for a better player experience, to prevent AFK people and so forth. Should probably draw a diagram/flowchart, to get a better idea of the "big picture." MS' Visio is good for that. |
Thanks. :)
It probably would be easier for me to use this. scripts with all that wouldn it? And just do them serverside? I guess that would be alot on serverr flags wouldnt it? And also, I've tried to do a triggeraction for warping players on a level npc, since actionserverside will not work on a level npc. Could I get a talk through on how or a sample on that? |
Well I'd have a DBNPC for this called SparBot, or something.
It would hold all the data, spar locations, matches, etc. You wouldn't need to use serverr flags at all. In a DB-NPC you could have: DB NPC Name: SlaveBot PHP Code:
PHP Code:
On the serverside you can do things in NPCs like: PHP Code:
|
I don't have access to the server this is going up on. I also cant make a wep for it. :(
ive done regular trigger actions to serverside script, then a setlevel2("levl.nw",x,y); but it wouldnt seem to work at all. also, this.commands work just fine serverside for this stuff right? |
Quote:
If you're deadset on always having a 16 man tourney, that's cool, but if you use a DB NPC to manage vars, it would be easier to allow for an adjustable size spar tourney. |
unfortunately, Im actually doing this for a guildhouse on a server, so I have no access to a DB NPC, and they wont let me. That would actually be easier on me than this for some reason. So this.flags will work fine for this too though correct?
And also, on the server warp, how do you get it to go on a level npc? I cant get it to work. :/ |
Quote:
As for setlevel2, it can be used on the serverside in any NPC as long as you have an object (typically a player) you are sending. I believe people have already posted examples of this but if you want a function purely for warping players to a waiting room or spar room, you could write a function sending a player and another param (with the level name, an int, whatever) to warp the player. PHP Code:
|
ty.
btw, this.var is safe, as long as you dont get the level updated, as stated earlier. reconnecting, changing levels, it all stays. If i update level on rc, its erased. Tried on testbed. But, that works for me, because I wont be updating the level in the middle of a spar tournament. |
fowl beat me to it, but I would also recommend that the case statement would be the best choice in what you are trying to do, less load on the server, and you will get the fastest response time.
|
Just want to say first, I thank everyone for their help. I can do more than most, but I learn best through someone correct my mistakes, and at times showing me whats wrong. With that said:
PHP Code:
|
Quote:
also, in your script, you are only getting the say2 to display for the array sdematch1 rather than cycling through. try replacing it with PHP Code:
|
odd, now it wont show anything except blank matches. before it at least showed the first one.
Just did a test with this.chat putting after the say2, its saying the this.var is there. |
Quote:
PHP Code:
|
xD i just did that and was posting as fixed. Ty.
|
Quote:
|
Its for the same code, so I'm going to keep posting the same problems with it here.
PHP Code:
An example, or even just an explanation of what code to use. Tried everything I can remember, been 4 years since I touched this stuff. :( |
Why are you putting @'s in the middle of no where lol.
I.e: this.whatmatch = @ this.(@"sdematch" @ i) @; Should just be: this.whatmatch = this.(@"sdematch" @ i); You generally use @ when you want to append things together. I.e: PHP Code:
PHP Code:
|
It didnt change a thing. Coding at 3am, that was my fault, I already understand how that works.
|
Ok, so it got it to at least start one match, having a problem setting the area when the player dies. This was my last attempt. Ive already tried using the function onPlayerDies() as well, instead of the player.hp part, neither worked at all. Any obvious thing Im missing?
PHP Code:
|
I see you're using triggers to call functions on the serverside, from the serverside. You can just call them directly:
onActionSetMatchServer(temp.match, temp.vplayer, temp.splayer); instead of triggeraction(this.x + 0.5, this.y + 0.5, "SetMatchServer", temp.match, temp.vplayer,temp.splayer); Generally triggeraction is used to go from client to server, and vice versa. Personally I'd have a loop watch the players health. I.e: PHP Code:
|
Quote:
So, I guess i could use what you did, and put the timer, and check for sparring, and then go through and look for the hearts, but, in a spar, the only people that should be dying are the people sparring, and checking for a tie, winner 1, or winner 2, and all that is a bit redundant compared to just using a serverside function onPlayerDies() to check the level for any player that dies, then warp them both back, eh? First code in 4 years btw, not first code. Anywho, changed it a bit, no results. Im trying to set it where when it starts the match, it finds the players by comm name, then sets a this.array to hold it in, so that way, if the playerdies, it can check if any account in the level is in that array, then warp them out of the spar. This is what i have thus far. PHP Code:
|
Quote:
"I want this, I want that!" god |
um, no crap?
People bomb on the way I do things, so if i do to someone else he is now my "butler"? geeze. |
All times are GMT +2. The time now is 04:52 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.