![]() |
players in room
hey i wanna make a event house where the people dont need ET to play events. I wanna make the doors will open automatic when there are enough players in the room. Can anyone help me with this?
|
Use a for loop and the playercount variable.
|
Wasnt there a command like
if (playerscount == 2){..} Bla, But i'd listen to kiirar, the loop is the best direction to go :) |
Quote:
Quote:
|
No. I mean a for loop.
Edit: I re-read what they wanted, a timeout loop would be more useful in this case. |
ok... i'm no scripting genius, heck, i can barelly make a door ;)
but wouldn't it look like this? NPC Code: but I don't know, i've never used player count, and heck, i suck at scripting.. |
Quote:
|
Well. The timeout is too infrequent. A timeout of 0.05 would do.
The variable is playerscount I believe. Not to mention it doesn't conform to KSI-GS standards. |
Quote:
|
not the standards!? NO!!! *cuts hand off* it was an example, sheesh, and what's wrong with doing that? (give me a good reason and i'll never do it again)
[edit] sorry about the timeout I always do that.. I don't even know why, I meant 0.05 tho. [/edit] |
Quote:
It is neater. Read KSI-GS standards thread. |
meh, I guess I'll fall to the wrain of kai...
so would it be like this? NPC Code: atleast that's how I understood it... |
Quote:
|
than like this!?
NPC Code: !? |
Quote:
|
Lol, finally he got it, still chance for you zero:p.
Anywho you could of done if (playerenters || timeout){ } lol, Anywho :p |
I knew how to make it work, I just didn't know how to do it propperly.
|
Quote:
|
Just a side note:
playerscount includes NPCs when used clientside. |
Quote:
|
Quote:
Although there is an easy fix to determine whether it’s an NPC or player. |
Quote:
One line of two related checks (an event and a condition) and splitting them up one to each line is the same code - so you can't really argue efficiency or optimization, but only a stylistic choice. (Additionally, the standards thread does not mention putting an event and a condition on separate lines. :) |
I'm not a script head, so.. these rules would not be worth remembering, nor practicing.
|
Quote:
|
Quote:
|
Quote:
|
you can solve the problem of it counting npc characters by doing a for statement that includes the playerscount and a check if players[i].id>=0; as -1 = npc character. then if it's true add to a variable. this, however, would require resetting the string every time the event is called. I would go right out and post the script, but I fear it is against the rules of the NPC Scripting Forums
|
Quote:
Very easily? I don't go around putting '&& otherflag==true' for every check I add, but it is arguably easier to type two ampersands than 'if ( ) { }'. That does not make it better, but you are incorrect in saying it's easier. :) |
It depends on Graal's inner workings. If you're using a literal compiler/interpreter that doesn't make a distinction between & and && then it's more efficient to split up the checks - if you combine them then it'll happily evaluate the whole condition without stopping to check if it's already invalidated itself.
|
Quote:
if (event && flag=true) { compared to: if (event) { if (flag==true) { type situation - if the event occurs, how could it invalidate itself in either? Or, are you talking about if the event doesn't occur at all? That's the only way I can think that it could be invalidated... |
Ah, yes, in that case you are correct. I tend to favour separation of event checks from normal conditional statements, but that's just a stylistic thing. Wouldn't affect efficiency.
|
NPC Code: Also note if you have showcharacter NPCS (the ones which stefan put in.. that have heads, bodies and stuff counts as players to, so if you got lets say 2 of them, change the 5 to 7. |
//#CLIENTSIDE
if ((playerenters && strequals(#L,levelname.nw)) || timeout){ for(i=0; i<playerscount; i++;){ stuff here :o } timeout=0.05; } Isnt that one way? I dont think it is.. not sure tho :o.. |
Snake, no need for the level thing, playerscount is the players in the level, allplayers is players in the server.
|
I see, Thanks for mensioning:D
|
the npc character's problem can be solved like this
NPC Code: of course the "this.players" variable would have to be reset to zero before called. and the variable "this.players" everytime would equal to the amount of "real players" in the room. |
Quote:
|
Quote:
|
I prefer Tsengs way actually, because if you ask me its alot easier to see all the checks at once instead of making new brackets for each one
just so you know it's not jut Tseng whose crazy ;) |
Quote:
Stylistic. choice. :) |
| All times are GMT +2. The time now is 09:38 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.