AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spawning an Ent/Model at a XYZ Location (https://forums.alliedmods.net/showthread.php?t=58047)

wesnc 07-17-2007 19:08

Spawning an Ent/Model at a XYZ Location
 
I was wondering, How could I spawn an Ent/Model at an XYZ location on a certain map, how could I do so?


-Wes

GrimReaperCdn 07-17-2007 22:29

Re: Spawning an Ent/Model at a XYZ Location
 
Excuse me if i understood you wrong but i think you must specify an 'X', 'Y', and 'Z' everytime you spawn one. Im just not sure if understand your question.

stupok 07-17-2007 23:26

Re: Spawning an Ent/Model at a XYZ Location
 
Here's a start:

PHP Code:

//...

public create_entity(Float:origin[3])
{        
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))

    if(!
pev_valid(ent)) return 0

    engfunc
(EngFunc_SetModelent"models\chick.mdl")
    
engfunc(EngFunc_SetOriginentorigin)

    return 
ent
}

//... 


wesnc 07-18-2007 10:29

Re: Spawning an Ent/Model at a XYZ Location
 
What I meant was: How can I spawn a model with physics like the ball in SoccerJam.

stupok69: Fakemeta? D:

GrimReaperCdn 07-18-2007 11:05

Re: Spawning an Ent/Model at a XYZ Location
 
Usually if i wanna know how to do something that someone else did i go look at there source you know, thats how i learned to code by looking how other people did things.

stupok 07-18-2007 14:21

Re: Spawning an Ent/Model at a XYZ Location
 
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



dakata 12-02-2009 12:15

Re: Spawning an Ent/Model at a XYZ Location
 
could some one edit this code and add cvar for adding the balls in soccerjam mode ? :{

fysiks 12-02-2009 18:27

Re: Spawning an Ent/Model at a XYZ Location
 
Quote:

Originally Posted by dakata (Post 1005065)
could some one edit this code and add cvar for adding the balls in soccerjam mode ? :{

There is no full code in this thread so it's not possible.

dakata 12-03-2009 07:52

Re: Spawning an Ent/Model at a XYZ Location
 
here had the full code http://forums.alliedmods.net/showthr...ight=soccerjam im not good in scripting and i dono what to get from this code ....


All times are GMT -4. The time now is 21:29.

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