Raised This Month: $ Target: $400
 0% 

Spawning an Ent/Model at a XYZ Location


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wesnc
New Member
Join Date: Jul 2006
Old 07-17-2007 , 19:08   Spawning an Ent/Model at a XYZ Location
Reply With Quote #1

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


-Wes

Last edited by wesnc; 07-17-2007 at 19:24.
wesnc is offline
GrimReaperCdn
Member
Join Date: Jul 2007
Location: Steamboat, Colorado
Old 07-17-2007 , 22:29   Re: Spawning an Ent/Model at a XYZ Location
Reply With Quote #2

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.
__________________
HARRR!
GrimReaperCdn is offline
Send a message via AIM to GrimReaperCdn Send a message via MSN to GrimReaperCdn
stupok
Veteran Member
Join Date: Feb 2006
Old 07-17-2007 , 23:26   Re: Spawning an Ent/Model at a XYZ Location
Reply With Quote #3

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
}

//... 
stupok is offline
wesnc
New Member
Join Date: Jul 2006
Old 07-18-2007 , 10:29   Re: Spawning an Ent/Model at a XYZ Location
Reply With Quote #4

What I meant was: How can I spawn a model with physics like the ball in SoccerJam.

stupok69: Fakemeta? D:
wesnc is offline
GrimReaperCdn
Member
Join Date: Jul 2007
Location: Steamboat, Colorado
Old 07-18-2007 , 11:05   Re: Spawning an Ent/Model at a XYZ Location
Reply With Quote #5

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.
__________________
HARRR!
GrimReaperCdn is offline
Send a message via AIM to GrimReaperCdn Send a message via MSN to GrimReaperCdn
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 #6

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
dakata
Junior Member
Join Date: Aug 2007
Location: Bulgaria
Old 12-02-2009 , 12:15   Re: Spawning an Ent/Model at a XYZ Location
Reply With Quote #7

could some one edit this code and add cvar for adding the balls in soccerjam mode ? :{
dakata is offline
Send a message via Skype™ to dakata
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-02-2009 , 18:27   Re: Spawning an Ent/Model at a XYZ Location
Reply With Quote #8

Quote:
Originally Posted by dakata View Post
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.
__________________
fysiks is offline
dakata
Junior Member
Join Date: Aug 2007
Location: Bulgaria
Old 12-03-2009 , 07:52   Re: Spawning an Ent/Model at a XYZ Location
Reply With Quote #9

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 ....
dakata is offline
Send a message via Skype™ to dakata
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