Stryke is correct, but I would do something like
PHP Code:
temp.npc = putnpc2(player.x + 1.5 + vecx(player.dir) * 2, player.y + 2 + vecy(player.dir) * 2, "");
npc.join("classname");
though you'd have to play with the coordinates.
As far as the script, you create a new class called 'classname' or whatever you specify it as in the other script, and put in your script as (for example)
PHP Code:
function onCreated() {
setimg("bomb.png");
for (temp.i = 3; i > 0; i --) {
sleep(1);
}
putexplosion(2, this.x, this.y);
destroy();
}
When you use putnpc2, you create a new NPC. I'll explain the rest in comments.
PHP Code:
putnpc2(32, 32, ""); // third param is the script, you can also do
putnpc2(32, 32, "this.x = 10;"); // or any other script you want, but it's really annoying to script like that, and is considered bad practice.
// normally, you should join a class; there are a few ways to do this.
putnpc2(32, 32, "join classname;"); // this isn't preferred since it's using GS1
// the following class joining examples are all GS2
putnpc2(32, 32, "join(\"classname\");"); // notice the confusing escape slashes; the other ones are much easier.
// or ...
with (putnpc2(32, 32, "")) {
join("classname");
}
// or ...
temp.npc = putnpc(32, 32, "");
npc.join("classname"); // I prefer this way, because it keeps the stuff in scope, which means you can do
npc.dropper = player.account; // this
// Since NPCs are objects, you can access them from the laying script.
echo(npc.x); // would echo 32
echo("Chat:" SPC npc.chat); // would echo "Chat:" because there is no chat. If there was chat, it would be "Chat: Hello, world!" or whatever the chat is
// you can also perform functions on the npc or call events
npc.warpto("level.name", 30, 29);
npc.chat = "Hello, world!";
npc.trigger("Test"); // calls the event "onTest()" in the script.
npc.destroy(); // removes the NPC; make sure to do this when done with it, or within the class (which is preferred)