AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   NPC spawns in ground (https://forums.alliedmods.net/showthread.php?t=240734)

GinNNy 05-21-2014 08:19

NPC spawns in ground
 
Hi,
I have made a npc plugin but the problem is the npc stuck on the ground but before i add the animation code server reads a origins config and respawning them in the places written in the configfile but they dont move after i add the animation code all the npcs stuck on one place and attacking.
PHP Code:

Load_Npc()

    
//Get the correct filepath and mapname 
    
new szConfigDir[256], szFile[256], szNpcDir[256];
    
    
get_configsdir(szConfigDircharsmax(szConfigDir));
    
    new 
szMapName[32];
    
get_mapname(szMapNamecharsmax(szMapName));
    
    
formatex(szNpcDircharsmax(szFile),  "%s/zombie_nightmare"szConfigDir);
    
formatex(szFilecharsmax(szFile),  "%s/%s.cfg"szNpcDirszMapName);
    
    
//If the map config file does not exist we will make one
    
if (!file_exists(szFile))
    {
        
//return PLUGIN_HANDLED_MAIN;
        //write_file(szFile, "");
    
}
    
    
//Variables to store when reading our file
    
new szFileOrigin[3][32];
    new 
sOrigin[128], sAngle[128], Float:fOrigin[3], Float:fAngles[3];
    new 
iLineiLengthsBuffer[256];
    
    
//When we are reading our file...
    
while (read_file(szFileiLine++, sBuffercharsmax(sBuffer), iLength))
    {
        
//Move to next line if the line is commented
        
if((sBuffer[0]== ';') || !iLength)
            continue;
        
        
//Split our line so we have origin and angle. The split is the vertical bar character
        
strtok(sBuffersOrigincharsmax(sOrigin), sAnglecharsmax(sAngle), '|'0);
        
        
//Store the X, Y and Z axis to our variables made earlier
        
parse(sOriginszFileOrigin[0], charsmax(szFileOrigin[]), szFileOrigin[1], charsmax(szFileOrigin[]), szFileOrigin[2], charsmax(szFileOrigin[]));
        
        
fOrigin[0] = str_to_float(szFileOrigin[0]);
        
fOrigin[1] = str_to_float(szFileOrigin[1]);
        
fOrigin[2] = str_to_float(szFileOrigin[2]);
        
        
//Store the yawn angle
        
fAngles[1] = str_to_float(sAngle[1]);
        
//Keep reading the file until the end
        
create_zombie()
    }
    return 
PLUGIN_CONTINUE;
}

public 
create_zombie()
{    
    new 
ent create_entity("info_target")
    
ent2 ent
    
    entity_set_origin
(entg_spawn_point)
    
    
entity_set_float(entEV_FL_takedamage,1.0)
    
entity_set_float(entEV_FL_health100.0)
    
    
entity_set_string(entEV_SZ_classnameZB_CLASSNAME)
    
entity_set_model(entzombie_model)
    
entity_set_int(entEV_INT_solid2)
    
    
entity_set_int(entEV_INT_movetypeMOVETYPE_STEP)
    
    
set_pev(entpev_victim0)
    
    
entity_set_byte(entEV_BYTE_controller1125)
    
entity_set_byte(entEV_BYTE_controller2125)
    
entity_set_byte(entEV_BYTE_controller3125)
    
entity_set_byte(entEV_BYTE_controller4125)
    
    new 
Float:maxs[3] = {16.016.036.0}
    new 
Float:mins[3] = {-16.0, -16.0, -36.0}
    
entity_set_size(entminsmaxs)
    
    
play_anim(entANIM_IDLE1.0)
    
    
entity_set_float(ent,EV_FL_nextthinkhalflife_time() + 0.01)
    
drop_to_floor(ent)
    
    
RegisterHamFromEntity(Ham_TakeDamageent"fw_zb_takedmg")
    
RegisterHamFromEntity(Ham_Killedent"fw_zb_killed")
    
    return 
1
}




DavidJr 05-21-2014 09:04

Re: NPC spawns in ground
 
In Load_NPC()

PHP Code:

create_zombie() 

:arrow:

PHP Code:

create_zombie(fOrigin

then

PHP Code:

public create_zombie() 

:arrow:

PHP Code:

public create_zombie(flOrigin[3]) 

and a bit finishing

PHP Code:

entity_set_origin(entg_spawn_point

:arrow:

PHP Code:

entity_set_vector(entEV_VEC_originflOrigin); 


GinNNy 05-21-2014 20:37

Re: NPC spawns in ground
 
1 Attachment(s)
worked but check this problem

DavidJr 05-21-2014 21:32

Re: NPC spawns in ground
 
I don't see any problem there, what's wrong?

GinNNy 05-22-2014 03:00

Re: NPC spawns in ground
 
they dont move lol they teleporting :|

DavidJr 05-22-2014 03:25

Re: NPC spawns in ground
 
PHP Code:

entity_set_int(entEV_INT_movetypeMOVETYPE_STEP

:arrow:

PHP Code:

entity_set_int(entEV_INT_movetypeMOVETYPE_PUSHSTEP



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

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