AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   adding model (https://forums.alliedmods.net/showthread.php?t=185376)

alvedro 05-16-2012 12:13

adding model
 
Hi,
How do the simplest addition model (entity) in the place where I stand now? For example, using the command: /add.

<VeCo> 05-16-2012 12:19

Re: adding model
 
PHP Code:

static ent
ent 
create_entity("info_target")
if(
ent)
{
entity_set_string(ent,EV_SZ_classname,"entity_classname"// put your entity classname here...
entity_set_model(ent,"models/..."// put your entity model path here (you should precache it first)
 
entity_set_int(ent,EV_INT_solid,SOLID_NOT// don't make it solid
entity_set_int(ent,EV_INT_movetype,MOVETYPE_NONE// don't move
 
static Float:origin[3]
entity_get_vector(id,EV_VEC_origin,origin// get origin of the player
 
entity_set_vector(ent,EV_VEC_origin,origin// set player origin to entity



alvedro 05-16-2012 14:23

Re: adding model
 
Is that correct? Where to download class_name of a model?

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>

#define PLUGIN "test"
#define VERSION "1.0"
#define AUTHOR "xxx"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /create","CreateEnt")
}

public 
plugin_precache() {
    
precache_model("models/chick.mdl")
    return 
PLUGIN_CONTINUE
}

public 
CreateEnt(id) {
    static 
ent
    ent 
create_entity("info_target")
    
entity_set_string(ent,EV_SZ_classname,"chick"// put your entity classname here...
    
entity_set_model(ent,"models/chick.mdl"// put your entity model path here (you should precache it first)

    
entity_set_int(ent,EV_INT_solid,SOLID_NOT// don't make it solid
    
entity_set_int(ent,EV_INT_movetype,MOVETYPE_NONE// don't move

    
static Float:origin[3]
    
entity_get_vector(id,EV_VEC_origin,origin// get origin of the player

    
entity_set_vector(ent,EV_VEC_origin,origin// set player origin to entity



<VeCo> 05-16-2012 15:33

Re: adding model
 
Test it.

You don't need to put return in plugin_precache().

alvedro 05-17-2012 11:33

Re: adding model
 
Well what does not work. Any ideas?

<VeCo> 05-17-2012 11:42

Re: adding model
 
I've tested it now - it works.

Btw, it's good to make a check like I've made:

PHP Code:

if(ent)
{
// entity has been created successfully (is valid)



alvedro 05-17-2012 12:34

Re: adding model
 
This code works for you? For me does not create the model.

PHP Code:

/* Plugin generated by AMXX-Studio */ 

#include <amxmodx> 
#include <amxmisc> 
#include <cstrike> 
#include <engine> 

#define PLUGIN "test" 
#define VERSION "1.0" 
#define AUTHOR "xxx" 

public plugin_init() { 
    
register_plugin(PLUGINVERSIONAUTHOR
    
    
register_clcmd("say /create","CreateEnt"


public 
plugin_precache() { 
    
precache_model("models/chick.mdl"


public 
CreateEnt(id) { 
    static 
ent 
    ent 
create_entity("info_target"
    if(
ent) {
        
entity_set_string(ent,EV_SZ_classname,"chick"// put your entity classname here... 
        
entity_set_model(ent,"models/chick.mdl"// put your entity model path here (you should precache it first) 

        
entity_set_int(ent,EV_INT_solid,SOLID_NOT// don't make it solid 
        
entity_set_int(ent,EV_INT_movetype,MOVETYPE_NONE// don't move 

        
static Float:origin[3
        
entity_get_vector(id,EV_VEC_origin,origin// get origin of the player 

        
entity_set_vector(ent,EV_VEC_origin,origin// set player origin to entity 
    
}



<VeCo> 05-17-2012 12:42

Re: adding model
 
Did you move after creating it? Because it creates it exaclty where you stand and you can't see it if you don't move.

alvedro 05-17-2012 13:42

Re: adding model
 
So I move. And is the correct name class_name is here important?

<VeCo> 05-17-2012 13:46

Re: adding model
 
It doesn't really matter what classname do you type.


All times are GMT -4. The time now is 00:28.

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