AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Problem with entity (https://forums.alliedmods.net/showthread.php?t=334942)

The overrated maniac 10-28-2021 15:08

Problem with entity
 
When I spawn it shutdowns the server.

PHP Code:

CreateCal(const Float:vOrigin[3]){
    new 
iEntity create_entity("ambient_generic");
    if(!
iEntity){
        return 
0;
    }
    
set_pev(iEntitypev_messageSOUND_CAL);
    
set_pev(iEntitypev_spawnflagsRADIO_SOUND);
    
//set_pev( iEntity, pev_effects, EF_BRIGHTFIELD);
    
set_pev(iEntitypev_health10.0);
    
DispatchSpawn(iEntity); 
    
entity_set_string(iEntityEV_SZ_classname"env_cal");
    
entity_set_int(iEntityEV_INT_solidSOLID_NOT);
    
entity_set_int(iEntityEV_INT_movetypeMOVETYPE_NONE);
    
entity_set_size(iEntityFloat:{ -1.0, -1.0, -1.0 }, Float:{ 1.01.036.0 });
    
entity_set_origin(iEntityvOrigin);
    
entity_set_model(iEntityMODEL_CAL);
    
drop_to_floor(iEntity);
    
    return 
iEntity;


The sound is in the route and is .wav, also the model. The radio sound is defined to 2.
PHP Code:

new Float:vOrigin[3];
entity_get_vector(idEV_VEC_originvOrigin);
CreateCal(vOrigin); 


Celena Luna 10-28-2021 22:06

Re: Problem with entity
 
have you try to comment each line to see which cause the crash?

Natsheh 10-29-2021 01:11

Re: Problem with entity
 
Assuming the model?
Those type of entities can have models unless i am wrong.

DJEarthQuake 10-29-2021 10:12

Re: Problem with entity
 
Precache is required. Where is it?

There are valid parameters for ambient_generic.

PHP Code:

 classname ambient_generic
ambient_generic origin 
-1976 -179 -3618
ambient_generic angles 0 0 0
ambient_generic targetname wav_wrong
ambient_generic message misc
/machine_off.wav
ambient_generic health 10
ambient_generic preset 0
ambient_generic volstart 0
ambient_generic fadein 0
ambient_generic fadeout 0
ambient_generic pitch 100
ambient_generic pitchstart 100
ambient_generic spinup 0
ambient_generic spindown 0
ambient_generic lfotype 0
ambient_generic lforate 0
ambient_generic lfomodpitch 0
ambient_generic lfomodvol 0
ambient_generic cspinup 0
ambient_generic spawnflags 36 

Get it working the stock way first then complicate later.

The overrated maniac 10-30-2021 19:06

Re: Problem with entity
 
Thanks for the answer, the problem is the model, how can I add it right?

PHP Code:

new const MODEL_CAL[] = "models/cal.mdl";
new 
bool:bCal;

public 
plugin_init(){
    
register_plugin"Tree Spawner""1.0""xPaw" );

    
bCal =     true;
}

public 
plugin_precache(){
    if(
bCal){
        
precache_model(MODEL_CAL);
    }
}

then just the code posted before 

Tree Spawner by xPaw use ambient_generic and a tree model. Why I can't?

DJEarthQuake 10-30-2021 20:50

Re: Problem with entity
 
Liable to be a precache issue. Post all the code.

The overrated maniac 10-30-2021 23:15

Re: Problem with entity
 
Quote:

Originally Posted by DJEarthQuake (Post 2762104)
Liable to be a precache issue. Post all the code.

Thats all the code that is needed. The model is in the route and with the right name.

Also there is the precache from the model.. when the plugins starts it sets the boolean variable on true, then the precache ask if the variable is true and if it is, then precache the model.

Can the problem be that the precache is exed before plugin init? I dont know who starts first.

DJEarthQuake 10-30-2021 23:40

Re: Problem with entity
 
Ambient is a sound. Precache the sound. That bool is needless how it is shown. It will always be true.

Natsheh 10-30-2021 23:41

Re: Problem with entity
 
Yeah plugin_precache is executed first, you might want to remove the variable bCal

The overrated maniac 10-31-2021 03:16

Re: Problem with entity
 
Quote:

Originally Posted by Natsheh (Post 2762108)
Yeah plugin_precache is executed first, you might want to remove the variable bCal

Thanks


All times are GMT -4. The time now is 11:34.

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