Raised This Month: $ Target: $400
 0% 

NPC spawns in ground


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
GinNNy
Senior Member
Join Date: Mar 2014
Old 05-21-2014 , 08:19   NPC spawns in ground
Reply With Quote #1

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
}


GinNNy is offline
 



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 09:44.


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