Raised This Month: $ Target: $400
 0% 

Spawning an Ent/Model at a XYZ Location


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stupok
Veteran Member
Join Date: Feb 2006
Old 07-18-2007 , 14:21   Re: Spawning an Ent/Model at a XYZ Location
Reply With Quote #1

Here is how Soccer Jam does it:

PHP Code:
public plugin_init()
{
    
//...
    
register_think("PwnBall","ball_think")
    
//...
}

//...

createball() {

    new 
entity create_entity("info_target")
    if (
entity) {

        
entity_set_string(entity,EV_SZ_classname,"PwnBall")
        
entity_set_model(entityball)

        
entity_set_int(entityEV_INT_solidSOLID_BBOX)
        
entity_set_int(entityEV_INT_movetypeMOVETYPE_BOUNCE)

        new 
Float:MinBox[3]
        new 
Float:MaxBox[3]
        
MinBox[0] = -15.0
        MinBox
[1] = -15.0
        MinBox
[2] = 0.0
        MaxBox
[0] = 15.0
        MaxBox
[1] = 15.0
        MaxBox
[2] = 12.0

        entity_set_vector
(entityEV_VEC_minsMinBox)
        
entity_set_vector(entityEV_VEC_maxsMaxBox)

        
glow(entity,ballcolor[0],ballcolor[1],ballcolor[2],10)

        
entity_set_float(entity,EV_FL_framerate,0.0)
        
entity_set_int(entity,EV_INT_sequence,0)
    }
    
//save our entity ID to aball variable
    
aball entity
    entity_set_float
(entity,EV_FL_nextthink,halflife_time() + 0.05)
    return 
PLUGIN_HANDLED
}

//...

public ball_think() {

    new 
maxscore get_pcvar_num(CVAR_SCORE)
    if(
score[1] >= maxscore || score[2] >= maxscore) {
        
entity_set_float(aball,EV_FL_nextthink,halflife_time() + 0.05)
        return 
PLUGIN_HANDLED
    
}

    if(
is_valid_ent(aball))
    {

        new 
Float:gametime get_gametime()
        if(
PowerPlay >= MAX_LVL_POWERPLAY && gametime fire_delay >= 0.3)
            
on_fire()

        if(
ballholder 0)
        {
            new 
team get_user_team(ballholder)
            
entity_get_vector(ballholderEV_VEC_origin,testorigin)


            if(!
is_user_alive(ballholder)) {

                new 
tname[32]
                
get_user_name(ballholder,tname,31)

                
remove_task(55555)
                
set_task(get_pcvar_float(CVAR_RESET),"clearBall",55555)

                if(!
g_sprint[ballholder])
                    
set_speedchange(ballholder)

                
format(temp1,63,"%L"LANG_PLAYER"DROPPED_BALL"TeamNames[team], tname)

                
//remove glow of owner and set ball velocity really really low
                
glow(ballholder,0,0,0,0)

                
ballowner ballholder
                ballholder 
0

                testorigin
[2] += 5
                entity_set_origin
(aballtestorigin)

                new 
Float:vel[3], x
                
for(x=0;x<3;x++)
                    
vel[x] = 1.0

                entity_set_vector
(aball,EV_VEC_velocity,vel)
                
entity_set_float(aball,EV_FL_nextthink,halflife_time() + 0.05)
                return 
PLUGIN_HANDLED
            
}
            if(
entity_get_int(aball,EV_INT_solid) != SOLID_NOT)
                
entity_set_int(aballEV_INT_solidSOLID_NOT)

            
//Put ball in front of player
            
ball_infront(ballholder55.0)
            new 
i
            
for(i=0;i<3;i++)
                
velocity[i] = 0.0
            
//Add lift to z axis
            
new flags entity_get_int(ballholderEV_INT_flags)
            if(
flags FL_DUCKING)
                
testorigin[2] -= 10
            
else
                
testorigin[2] -= 30

            entity_set_vector
(aball,EV_VEC_velocity,velocity)
              
entity_set_origin(aball,testorigin)
        }
        else {
            if(
entity_get_int(aball,EV_INT_solid) != SOLID_BBOX)
                
entity_set_int(aballEV_INT_solidSOLID_BBOX)
        }
    }
    
entity_set_float(aball,EV_FL_nextthink,halflife_time() + 0.05)
    return 
PLUGIN_HANDLED

stupok is offline
Reply



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 21:29.


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