Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-26-2009, 12:52 AM
littlekinky littlekinky is offline
Registered User
littlekinky's Avatar
Join Date: Sep 2007
Posts: 185
littlekinky has a little shameless behaviour in the past
dunno no the name ?

Well i was wondering how to do this when a player enters and levels and image appears would that jsut be simply something like

PHP Code:
//#CLIENTSIDE

function Playerenters.onShow() {
  
   
showimg1"imagename"
player.- -1.5player.1.8 );

Reply With Quote
  #2  
Old 08-26-2009, 01:01 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
There's onPlayerEnters, that is called when the player enters a level.

PHP Code:
//#CLIENTSIDE
function onPlayerEnters() {
  
// Show Image Script here

__________________
Quote:
Reply With Quote
  #3  
Old 08-26-2009, 03:00 AM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
if (playerenters) can be used if you've already called a function.

PHP Code:
//#CLIENTSIDE
function onCreated() {
 if (
playerenters) {
   
//Stuff
 
}

Reply With Quote
  #4  
Old 08-26-2009, 03:03 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by cyan3 View Post
if (playerenters) can be used if you've already called a function.

PHP Code:
//#CLIENTSIDE
function onCreated() {
 if (
playerenters) {
   
//Stuff
 
}

Don't do this, just use onPlayerEnters() to detect if a player has entered a level.
Reply With Quote
  #5  
Old 08-26-2009, 03:04 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by cyan3 View Post
if (playerenters) can be used if you've already called a function.

PHP Code:
//#CLIENTSIDE
function onCreated() {
 if (
playerenters) {
   
//Stuff
 
}

That's mixing GS1 and GS2, which is bad.

Also for future note you shouldn't have to call onCreated or onPlayerEnters unless you're re-initializing your script for whatever reason.

I.e:

PHP Code:
function whatever() {
  
// whatever "calls" onCreated();
  
onCreated();

Edit: lol, two negative verdicts.
__________________
Quote:
Reply With Quote
  #6  
Old 08-26-2009, 03:04 AM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Quote:
Originally Posted by Mark Sir Link View Post
Don't do this, just use onPlayerEnters() to detect if a player has entered a level.
Wouldn't that not work if it's called under another function?

Quote:
Originally Posted by fowlplay4 View Post
That's mixing GS1 and GS2, which is bad.
I know it was used in GS1 but somebody told me a while back that it works in GS2 if it's called under a function.
Reply With Quote
  #7  
Old 08-26-2009, 03:09 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by cyan3 View Post
Wouldn't that not work if it's called under another function?
I don't understand your question. the action onPlayerEnters is called every time a player enters a level.
Quote:
I know it was used in GS1 but somebody told me a while back that it works in GS2 if it's called under a function.
I haven't done a whole lot of work lately so I can't say this for sure but onCreated() may not always be called when a player enters if they have entered previously (instances of a class maybe?)
Reply With Quote
  #8  
Old 08-26-2009, 03:15 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by cyan3 View Post
I know it was used in GS1 but somebody told me a while back that it works in GS2 if it's called under a function.
Well I believe that would be useless to put in there, because I assume you want to be called when you do both onCreated and onPlayerEnters.

If you need it to update/do script every time you enter a level you can get away with only using onPlayerEnters(), if it's only a one time thing use onCreated().

Anyway the whole reason onPlayerEnters() exists is so you don't have to use "if (playerenters)" ever again.
__________________
Quote:
Reply With Quote
  #9  
Old 08-26-2009, 03:15 AM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Quote:
Originally Posted by Mark Sir Link View Post
I haven't done a whole lot of work lately so I can't say this for sure but onCreated() may not always be called when a player enters if they have entered previously (instances of a class maybe?)
Maybe because was a bad example, this is the script somebody said will work.

PHP Code:
function onTimeout() {
 if (
playerenters) {
  
setTimer(0.5);
   
setani("sit",NULL);
 }

Quote:
Originally Posted by fowlplay4 View Post
Well I believe that would be useless to put in there, because I assume you want to be called when you do both onCreated and onPlayerEnters.

If you need it to update/do script every time you enter a level you can get away with only using onPlayerEnters(), if it's only a one time thing use onCreated().
My example was bad, you would call both as a different function. It would work exactly the same if you used function onPlayerEnters() instead of calling it under onCreated().
Reply With Quote
  #10  
Old 08-26-2009, 03:20 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by cyan3 View Post
Maybe that was a bad example, this is the script somebody said will work.

PHP Code:
function onTimeout() {
 if (
playerenters) {
  
setTimer(0.5);
   
setani("sit",NULL);
 }



My example was bad, you would call both as a different function if it's onCreated()
I don't mean to be rude, but you should definitely not be giving advice like that when you don't know quite what you're talking about.

Stuff like "if (playerenters)" is GS1, and makes no sense. The idea of coding is creating readable code that flows smoothly. Using stuff like that in combination with GS2 leads to messy code that is hard to follow.
__________________
Reply With Quote
  #11  
Old 08-26-2009, 03:20 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by cyan3 View Post
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();

Reply With Quote
  #12  
Old 08-26-2009, 03:30 AM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
I don't mean to be rude, but you should definitely not be giving advice like that when you don't know quite what you're talking about.
I shouldn't have taken any notice of the person who told me it works because they probably didn't know either.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.