![]() |
Beginner Scripting is GS2
Okay I have loads of questions but I'll try reading all of the Graal Bible thoroughly before I unload them all on you guys/gals.
First off, I am busy converting many of the predefined objects I use. I 'converted' Stefan's light NPC, basically searching for the functions in Graal Bible and pasting them in, but I'm not sure if I have it correct, nor do I think it is as efficient as it could be. HTML Code:
function onCreated() { EDIT: I meant "in GS2" and not "is GS2". Someone might read that and get insulted :3 EDIT: Is there a server open to a Classic subscriber where I could test my scripts for trial and error, rather than me asking each question? EDIT: What is the difference between onCreated and onPlayerEnters? Does the NPC server process an NPC that uses onCreated immediately, without the player being in the level? If I used onCreated clientside would it be treated differently, more like onPlayerEnters? |
Quote:
|
First, I suggest posting code on the forums inbetween [php][/php] tags. At least we have some syntax highlighting then.
Second, you got a small but important error in your code. You have to place quotation marks around strings, like light2.png in your case. This should work: PHP Code:
|
Quote:
|
Quote:
|
Quote:
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
How about this script? If placed in a level it would put the imagepart at the selected location, correct? Would there be any unexpected behavior (this is why I need a place to test :() PHP Code:
|
Correct. To be a bit more specific, it would move the npc this is in to the specified position, then set the image. Unexpected behavior? Depends on what you want this to be. Just a simple lamp? Nothing unexpected. Though this will block by default. But you should already know this ;D
|
Quote:
|
Quote:
|
if you put a timeout in if(created):
Serverside: it's a lot like playerenters, because created's called once Ever for the Entire Server - which is often also when a player enters - but it could hypothetically start a script for an empty room. I guess it's useful if that's what you're going for - this event's going to happen whether anyone's here to see it or not - but generally it's good practice to, if a timeout happens when playerscount<1, do nothing until playerenters. Clientside: dangerous, as it starts the loop only once per session; if you leave the room, the timeout stalls, and when you return it doesn't re-start. |
Quote:
Quote:
|
All times are GMT +2. The time now is 07:26 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.