Raised This Month: $ Target: $400
 0% 

Recorrect my code.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Screeaam..
Senior Member
Join Date: Jun 2010
Location: Poland
Old 12-04-2010 , 20:18   Re: Recorrect my code.
Reply With Quote #3

@Emp`

It's helped. Thanks. But I have next problem...

PHP Code:
#include <amxmodx>
#include <amxmisc>

#include <engine>
#include <superspawns>    

#include <fun>
#include <cstrike>

#include <colorchat>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define MAX_PLAYERS 32
#define MAX_SANTA 1

new santa_npc[33];
new 
bool:have_gift[33];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_think("npc_santa","npc_think");
    
    
register_logevent("Round_End"2"1=Round_End"
    
register_logevent("Round_Start"2"1=Round_Start"
}

public 
santa(id)
{
    new 
Float:origin[3]
    
id -= 666
    
    
new seq random_num(0,50)
    
    if(
SsGetOrigin(origin))
    {
        
santa_npc[id] = create_entity("info_target")
        
give_weapon(santa_npc[id])

                
entity_set_origin(santa_npc[id],origin);

                
entity_set_float(santa_npc[id],EV_FL_takedamage,0.0)
                
entity_set_float(santa_npc[id],EV_FL_health,100.0)

                
entity_set_string(santa_npc[id],EV_SZ_classname,"npc_santa");
                
entity_set_model(santa_npc[id],"models/mikolaj.mdl");
                
entity_set_int(santa_npc[id],EV_INT_solid2)

                
entity_set_byte(santa_npc[id],EV_BYTE_controller1,125);
                
entity_set_byte(santa_npc[id],EV_BYTE_controller2,125);
                
entity_set_byte(santa_npc[id],EV_BYTE_controller3,125);
                
entity_set_byte(santa_npc[id],EV_BYTE_controller4,125);

                new 
Float:maxs[3] = {16.0,16.0,36.0}
                new 
Float:mins[3] = {-16.0,-16.0,-36.0}
                
entity_set_size(santa_npc[id],mins,maxs)

                
entity_set_float(santa_npc[id],EV_FL_animtime,2.0)
                
entity_set_float(santa_npc[id],EV_FL_framerate,1.0)
                
entity_set_int(santa_npc[id],EV_INT_sequence,seq);

                
entity_set_float(santa_npc[id],EV_FL_nextthink,halflife_time() + 0.01)

                
drop_to_floor(santa_npc[id])
        
        return 
1;
    }
    else
    {
        
server_print("No free location")
    }
    return 
PLUGIN_CONTINUE;
}

public 
scan()
{
    
SsInit(3500.0)
    
SsScan()
    
SsDump()

    for(new 
id=1;id<=MAX_SANTA;id++)
    {
        
set_task(5.0"santa"id+666)
    }
}

public 
Round_End(){
    for(new 
id=1;id<=32;id++)
    {
        
remove_entity(santa_npc[id])
        
        
have_gift[id] = false;
    }
}

public 
Round_Start(){
    for(new 
id=1;id<=32;id++)
    {
        
remove_entity(santa_npc[id])
    }
    
set_task(5.0"scan")
}

public 
npc_think(ent)
{
    
entity_set_float(ent,EV_FL_nextthink,halflife_time() + 0.01)
    
    new 
Float:npcorigin[3]
    
entity_get_vector(entEV_VEC_originnpcorigin)
    
        new 
Float:playerOrigin[3]
    
        for (new 
i=1MAX_PLAYERSi++)
        {
                if (!
is_user_connected(i) || !is_user_alive(i))
                         continue;
        
        
pev(i,pev_origin,playerOrigin)
        
                if (
get_distance_f(npcoriginplayerOrigin) < 150.0
                {
            if(
have_gift[i] == false)
            {
                new 
random random_num(1,6)
                                switch(
random)
                {
                            case 
1:
                            {
                                   
client_print(iprint_center,"Gift number 1.")
                        
have_gift[i] = true;
                              }
                                case 
2:
                              {
                                   
client_print(iprint_center,"Gift number 2.")
                        
have_gift[i] = true;
                               }
                              case 
3:
                            {
                                      
client_print(iprint_center,"Gift number 3.")
                        
have_gift[i] = true;
                             }
                              case 
4:
                                   {
                                   
client_print(iprint_center,"Gift number 4.")
                        
have_gift[i] = true;
                                }
                    }
            }
            else if(
have_gift[i] == false)
            {
                
client_print(iprint_center,"You have a gift")
            }
        }
        }
    return 
PLUGIN_CONTINUE;
}
    

public 
give_weapon(ent)
{
    new 
entWeapon create_entity("info_target")
    
    
entity_set_string(entWeaponEV_SZ_classname"npc_weapon")
    
    
entity_set_int(entWeaponEV_INT_movetypeMOVETYPE_FOLLOW)
    
entity_set_int(entWeaponEV_INT_solidSOLID_NOT)
    
entity_set_edict(entWeaponEV_ENT_aimentent)
    
entity_set_model(entWeapon"models/p_gauss.mdl"
}

public 
plugin_precache()
{
    
precache_model("models/mikolaj.mdl")
    
precache_model("models/p_gauss.mdl")

I need to have only one model spawned per round. But with that code I have two models at round, and one of it don't remove at end round, why?
Screeaam.. 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 11:15.


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