![]() |
Classes help
I am having trouble placing classes, can someone give me a good example how to putnpc2? :confused:
function onCreated() { setimg("snicon_blank.gif") timeout = 2; } function ontimeout() { this.destroy(); } This is my class's script. I can't get putnpc2 to work on an NPC or weapon. |
First off, merge the posts.
Second, you need a weapon to link to the class. |
You don't -need- a weapon, you can use an NPC also >.> I'm having trouble with the "putnpc2" script.
|
True
I'm saying, you need something to connect to it. From what I've seen, putnpc2() is in the NPC/Weapon that connects to it. Also, go to the wiki and search putnpc2 or use search on the forums. |
First of all, you've missed a segfault after your "setimg("snicon_blank.gif")" :)
Here's an example on how to use putnpc2 (serverside, of course): temp.data = putnpc(x, y, "join(\"myclassname\");"); temp.data.chat = "I was just spawned!"; temp.data.setimg("snicon_blank.gif"); |
Quote:
A segmentation fault is where you try to access memory that isn't allocated to your program. |
function onActiongotsplaced()
{ temp.data = putnpc2(player.x, player.y, "join(\"object\");"); temp.data.chat = "I was just spawned!"; temp.data.setimg("sn_iconblank.gif"); } //#CLIENTSIDE function onweaponfired() { triggeraction(0, 0, "gotsplaced"); } Que? |
You need to have the shape of the npc set on serverside if you want it to be able to receive actions. Also you should be triggering the action on this.x and this.y not 0 and 0.
Though after looking at the script a second time I noticed its a weapon script, since you're using onWeaponFired(), in that case you need to do something different. This script is for doing it in a weapon. PHP Code:
PHP Code:
|
Thanks, got it to work, awesome.
Can you pass variables to the class? like putting: temp.data.myvar = 0; would make it accessable to the class? |
if you set what that variable/string is in the class and what it does, then yes, of course, you access it VIA the weapon and change it there, or link class to class and change it within them.
|
Quote:
PHP Code:
|
PHP Code:
|
Quote:
|
Quote:
|
Quote:
|
You can't set the ID for level npcs, its static and read-only. And I doubt its different for ones placed with putnpc().
|
| All times are GMT +2. The time now is 04:52 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.