AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Copy and paste ents (https://forums.alliedmods.net/showthread.php?t=56241)

mateo10 06-09-2007 16:02

Copy and paste ents
 
This function:
Code:
public function_paste_ent( id ) {     if( ! get_pcvar_num( p_enable ) )     {         return PLUGIN_HANDLED;     }         if( ! is_user_admin( id ) )     {         return PLUGIN_HANDLED;     }         if( ! g_hascopied )     {         return PLUGIN_HANDLED;     }         new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "func_wall" ) );         new Float: xorigin[ 3 ];     get_user_hitpoint( id, xorigin );         engfunc( EngFunc_SetModel, ent, g_model );     engfunc( EngFunc_SetSize, ent, g_mins, g_maxs );         set_pev( ent, pev_mins, g_mins );     set_pev( ent, pev_maxs, g_maxs );     set_pev( ent, pev_absmin, g_mins );     set_pev( ent, pev_absmax, g_maxs );         engfunc( EngFunc_SetOrigin, ent, xorigin );         set_pev( ent, pev_solid, SOLID_BBOX );     set_pev( ent, pev_movetype, MOVETYPE_FLY );     set_pev( ent, pev_takedamage, DAMAGE_NO );         static Float: rvec[ 3 ];     pev( id, pev_v_angle, rvec );         rvec[ 0 ] = 0.0;         set_pev( ent, pev_angles, rvec );         engfunc(EngFunc_DropToFloor, ent );         client_print( id, print_center, "Ent succefully pasted!" );         return PLUGIN_HANDLED; }
gives me this error:
Code:


L 06/09/2007 - 22:12:07: [FAKEMETA] Invalid entity
L 06/09/2007 - 22:12:07: [AMXX] Displaying debug trace (plugin "entmod.amxx")
L 06/09/2007 - 22:12:07: [AMXX] Run time error 10: native error (native "engfunc")
L 06/09/2007 - 22:12:07: [AMXX]    [0] entmod.sma::function_paste_ent (line


regalis 06-09-2007 16:14

Re: Copy and paste ents
 
Code:

    if( ! g_hascopied )
    {
        return PLUGIN_HANDLED;
    }

greetz regalis

mateo10 06-09-2007 16:15

Re: Copy and paste ents
 
What is wrong now (just updated the post) ?

regalis 06-09-2007 16:21

Re: Copy and paste ents
 
you should build in more debug messages...
and tell us which line the error exists...(the error message is truncated..)

Maybe here is a problem:
Code:

    new ent = engfunc( EngFunc_CreateEntity, engfunc( EngFunc_AllocString, "func_wall" ) );
i would do that with
Code:

ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));

pRED* 06-09-2007 18:48

Re: Copy and paste ents
 
Yea regalis Is right.

But you can leave it as a func_wall.

It needs to be createNAMEDentity not just createentity..

mateo10 06-10-2007 03:39

Re: Copy and paste ents
 
Thank you for your help.

EDIT: Another problem, now it says "Ent succefully pasted", but nothing happens. The ent doesn't spawn.

regalis 06-10-2007 05:05

Re: Copy and paste ents
 
Sorry i was very tired yesterday...
I just read that you want to spawn a func_wall...
AFAIK you have to do that in plugin_precache..
And also you have to set_kvd for that entity because it is a brushbased entity...please correct me if im wrong!

greetz regalis

PS: something like this..don't know exactly..maybe play a little with it..
Code:

public precache_ent()
{
    ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_wall"));
   
    set_kvd(0, KV_KeyName, "rendermode");
    set_kvd(0, KV_Value, "2");
    set_kvd(0, KV_fHandled, 0);
    dllfunc(DLLFunc_KeyValue, ent, 0);
   
    set_kvd(0, KV_KeyName, "renderamt");
    set_kvd(0, KV_Value, "255");
    set_kvd(0, KV_fHandled, 0);
    dllfunc(DLLFunc_KeyValue, ent, 0);
   
    dllfunc(DLLFunc_Spawn, ent);
    engfunc(EngFunc_SetOrigin, ent, origin);
}


mateo10 06-10-2007 09:36

Re: Copy and paste ents
 
I took the creating of entities from SAMURAI16's Pallets with bags plugin. It works for him...


All times are GMT -4. The time now is 10:44.

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