| DustyPorViva |
08-26-2009 03:20 AM |
Quote:
Originally Posted by cyan3
(Post 1518509)
if (playerenters) can be used if you've already called a function.
PHP Code:
//#CLIENTSIDE
function onCreated() {
if (playerenters) {
//Stuff
}
}
|
onPlayerEnters was originally an event. Something that is called in response to an action(in this case, the player entering). However, in GS1, events were checked in if statements just like conditions(1 == 1), hence why it might be possible to do if (playerenters).
Regardless, onCreated is an event as well(as such, in GS2 both are functions and are called upon their respective actions), so the equivalent in GS1 would have been:
if (playerenters && created) {}
Which is impossible(I'm assuming) because it would be attempting to check if the NPC was created AND the player entered at the exact same moment.
Simply, the player entering the room is not a condition(which are what if checks are for) and shouldn't be treated as such. It is not a true or false situation, but instead an action.
Fowlplay got it right in his first post. However, to do something similar to what your post is implying would be something like this:
PHP Code:
function onCreated() {
// do stuff
}
function onPlayerEnters() {
onCreated();
}
|