Raised This Month: $ Target: $400
 0% 

Spawning NPC Ents


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
awpticaL
Member
Join Date: Jul 2004
Location: EAST US
Old 05-14-2007 , 07:00   Spawning NPC Ents
Reply With Quote #1

I've edited, changed and added to many plugins in the past, but when it comes to creating my own, I'm completely friggin scrub. I figured it was time to start learning, 'cause there isn't any other way of getting what I need out of quick-editing other plugins.

So anyway, I'm trying to spawn Solid NPC's that do nothing besides their idle animation. Here's what I have so far:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <engine> #define PLUGIN "NPC's" #define VERSION "1.0" #define AUTHOR "nub coder lawl" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR) } public fakenpc1(id) {     new ent = create_entity("ts_model")     entity_set_string(ent, EV_SZ_classname, "fakenpc1")     entity_set_model(ent, "models/mecklenburg/refr2.mdl")     new Float:Vec[3] = {-2376.0, 1219.0, -411.0}     entity_set_origin(ent, Vec)     entity_set_int(ent, EV_INT_solid, 1)     entity_set_int(ent, EV_INT_movetype, 6) }

Now of course, something is seriously wrong with this, cause it didn't work.
I was going to use Fakemeta, but since it is my first plugin, I went with Engine for now.

I'm trying to get the basics down before I move anywhere else.



Also, if anyone could post any other tutorials/helpful info that isn't in the stickies and whatnot, that'd be great.

Thanks in advance
__________________
[img]http://img247.**************/img247/1166/userbar414943lj2.gif[/img]
[img]http://img116.**************/img116/527/ownage39ch.jpg[/img]
awpticaL is offline
Send a message via AIM to awpticaL Send a message via MSN to awpticaL
Drak
Veteran Member
Join Date: Jul 2005
Old 05-14-2007 , 15:03   Re: Spawning NPC Ents
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?t=11756
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
awpticaL
Member
Join Date: Jul 2004
Location: EAST US
Old 05-14-2007 , 15:07   Re: Spawning NPC Ents
Reply With Quote #3

I saw that, but I want it to spawn NPC's at the given coords, and do this every map load, so I don't have to redo it when the map restarts.

I can also leave out the precache, since it is already in the map.
__________________
[img]http://img247.**************/img247/1166/userbar414943lj2.gif[/img]
[img]http://img116.**************/img116/527/ownage39ch.jpg[/img]
awpticaL is offline
Send a message via AIM to awpticaL Send a message via MSN to awpticaL
pRED*
Join Date: Dec 2006
Old 05-14-2007 , 16:11   Re: Spawning NPC Ents
Reply With Quote #4

I havn't bothered checking your ent creation code but the most obvious problem is that fakenpc1 is never called.

The plugin_init function is run automatically when the plugin is loaded.

Remove id from fakenpc1 becuase it isn't called for a particular player.

Make it "public fakenpc1() {..."

Then in plugin_init add the line "fakenpc1()" and see if it works..
pRED* is offline
awpticaL
Member
Join Date: Jul 2004
Location: EAST US
Old 05-14-2007 , 18:35   Re: Spawning NPC Ents
Reply With Quote #5

Quote:
Originally Posted by pRED* | NZ View Post
I havn't bothered checking your ent creation code but the most obvious problem is that fakenpc1 is never called.

The plugin_init function is run automatically when the plugin is loaded.

Remove id from fakenpc1 becuase it isn't called for a particular player.

Make it "public fakenpc1() {..."

Then in plugin_init add the line "fakenpc1()" and see if it works..
I thought that was the problem, it's basically a line of code that is never executed. I tried looking to execute it a few seconds after map load, but couldn't figure it out. Now that I finally got some sleep I'll have another go at it



Alright, I managed to get it to spawn and work. Now I'm having a problem when I try to do multiple NPC's...


Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     new Float:maxs[3] = {16.0, 16.0, 36.0}     new Float:mins[3] = {-16.0, -16.0, -32.0}     new Float:Vec[3] = {-2376.0, 1219.0, -411.0}         new ent = create_entity("ts_model")     entity_set_string(ent, EV_SZ_classname, "fakenpc")     entity_set_model(ent, "models/mecklenburg/chef.mdl")     entity_set_origin(ent, Vec)     entity_set_size(ent,mins,maxs)     entity_set_int(ent,EV_INT_solid, 2)     entity_set_float(ent,EV_FL_animtime,2.0)     entity_set_float(ent,EV_FL_framerate,1.0)     entity_set_int(ent,EV_INT_sequence,1);     entity_set_byte(ent,EV_BYTE_controller1,125);     entity_set_byte(ent,EV_BYTE_controller2,125);     entity_set_byte(ent,EV_BYTE_controller3,125);     entity_set_byte(ent,EV_BYTE_controller4,125);         new ent1 = create_entity("ts_model")     entity_set_string(ent1, EV_SZ_classname, "fakenpc1")     entity_set_model(ent1, "models/mecklenburg/chef.mdl")     Vec[3] = {-70.0, -448.0, -379.0}     entity_set_origin(ent1, Vec)     entity_set_size(ent1,mins,maxs)     entity_set_int(ent1,EV_INT_solid, 2)     entity_set_float(ent, EV_FL_animtime,2.0)     entity_set_float(ent,EV_FL_framerate,1.0)     entity_set_int(ent1,EV_INT_sequence,1)     entity_set_byte(ent,EV_BYTE_controller1,125);     entity_set_byte(ent,EV_BYTE_controller2,125);     entity_set_byte(ent,EV_BYTE_controller3,125);     entity_set_byte(ent,EV_BYTE_controller4,125);

The part that is screwing up is the
Code:
new Float:Vec[3] = {-2376.0, 1219.0, -411.0}

I defined and used it in the first one, but when it comes to the second one, I don't know how to "re-use" Vec and reset it's coordinates.

I don't think I need 500 new Float:Vec's for all my NPC's.. There has to be another way.


I'm trying to catch my mistakes early, so if anyone can help me, it'd be great.

Error:
Code:
Error: Array index out of bounds (variable "Vec") on line 36
__________________
[img]http://img247.**************/img247/1166/userbar414943lj2.gif[/img]
[img]http://img116.**************/img116/527/ownage39ch.jpg[/img]

Last edited by awpticaL; 05-14-2007 at 20:29.
awpticaL is offline
Send a message via AIM to awpticaL Send a message via MSN to awpticaL
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 -4. The time now is 07:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode