AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   origin of players (https://forums.alliedmods.net/showthread.php?t=57080)

flyeni6 06-27-2007 19:06

origin of players
 
how can i place a model at both the T's spawn place and a CT's spawn place, no matter what map? thanks

hlstriker 06-27-2007 21:55

Re: origin of players
 
Hook when entities are spawned, then if it finds an "info_player_start" (CT spawn) and an "info_player_deathmatch" (T spawn), get the origin and use that to spawn one of your models.

flyeni6 06-27-2007 22:12

Re: origin of players
 
Quote:

Originally Posted by hlstriker (Post 495623)
Hook when entities are spawned, then if it finds an "info_player_start" (CT spawn) and an "info_player_deathmatch" (T spawn), get the origin and use that to spawn one of your models.

how would i do this?
sorry im newby

hlstriker 06-27-2007 22:17

Re: origin of players
 
Using this will set a model on every spawn point. If you only want one then make a variable to check if it should spawn more or not.

PHP Code:

public pfn_keyvalue(entId)
{
    new 
ent;
    new 
className[64], keyName[64], value[64];
    
    
copy_keyvalue(className63keyName63value63);
    
    
// Check if its a start
    
if(equali(className"info_player_start") && equali(keyName"origin"))
    {
        
// Make the ct spawn model
        
ent create_entity("info_target");
        
entity_set_string(entEV_SZ_classname"my_classname");
        
entity_set_origin(entvalue); // set the entity to the origin of the spawn
        
entity_set_int(entEV_INT_solidSOLID_NOT); // setting this to bbox will cause the spawning player to get stuck
        
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY);
        
entity_set_model(ent"models/barney.mdl"); // set the model here, remember to precache it
        
entity_set_size(entFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
    }
    
    
// Check if its a deathmatch
    
if(equali(className"info_player_deathmatch") && equali(keyName"origin"))
    {
        
// Make the t spawn model
        
ent create_entity("info_target");
        
entity_set_string(entEV_SZ_classname"my_classname");
        
entity_set_origin(entvalue); // set the entity to the origin of the spawn
        
entity_set_int(entEV_INT_solidSOLID_NOT); // setting this to bbox will cause the spawning player to get stuck
        
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY);
        
entity_set_model(ent"models/barney.mdl"); // set the model here, remember to precache it
        
entity_set_size(entFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
    }
    
    return 
PLUGIN_CONTINUE;



flyeni6 06-27-2007 23:08

Re: origin of players
 
thank you i will test this tonite :mrgreen:

flyeni6 06-28-2007 04:22

Re: origin of players
 
yea i got some errors and this is going to turn into a ctf plugin so im gonna need a way to make the flag model stick to a person
here is the code and it got some errors:
Code:

/home/groups/amxmodx/tmp3/textienbE6.sma(30) : error 047: array sizes do not match, or destination array is too small
/home/groups/amxmodx/tmp3/textienbE6.sma(43) : error 047: array sizes do not match, or destination array is too small

PHP Code:

/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <engine>
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
 
public plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
// Add your code here...
}
public 
pfn_keyvalue(entId)
{
    new 
ent;
    new 
className[64], keyName[64], value[64];
 
    
copy_keyvalue(className63keyName63value63);
 
    
// Check if its a start
    
if(equali(className"info_player_start") && equali(keyName"origin"))
    {
        
// Make the ct spawn model
        
ent create_entity("info_target");
        
entity_set_string(entEV_SZ_classname"my_classname");
        
entity_set_origin(entvalue); // set the entity to the origin of the spawn
        
entity_set_int(entEV_INT_solidSOLID_NOT); // setting this to bbox will cause the spawning player to get stuck
        
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY);
        
entity_set_model(ent"models/barney.mdl"); // set the model here, remember to precache it
        
entity_set_size(entFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
    }
 
    
// Check if its a deathmatch
    
if(equali(className"info_player_deathmatch") && equali(keyName"origin"))
    {
        
// Make the t spawn model
        
ent create_entity("info_target");
        
entity_set_string(entEV_SZ_classname"my_classname");
        
entity_set_origin(entvalue); // set the entity to the origin of the spawn
        
entity_set_int(entEV_INT_solidSOLID_NOT); // setting this to bbox will cause the spawning player to get stuck
        
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY);
        
entity_set_model(ent"models/barney.mdl"); // set the model here, remember to precache it
        
entity_set_size(entFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
    }
 
    return 
PLUGIN_CONTINUE;
}
public 
plugin_precache()
 
precache_model("models/barney.mdl"


hlstriker 06-28-2007 12:15

Re: origin of players
 
I tested this and it works. Barney models are spawned on every player spawn :P Also, since you seem to be making flag models then I would manually set them if I were you. This way you can put them exactly where you want.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
 
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
}

public 
plugin_precache()
 
precache_model("models/barney.mdl");

public 
pfn_keyvalue(entId)
{
    new 
ent;
    new 
className[64], keyName[64], value[64];
    new 
Float:origin[3], explodeOut[4][32];
    
    
copy_keyvalue(className63keyName63value63);
    
    
// Check if its a start
    
if(equali(className"info_player_start") && equali(keyName"origin"))
    {
        
// Get the 3 values to the origin
        
ExplodeString(explodeOut331value' ');
        
origin[0] = str_to_float(explodeOut[0]);
        
origin[1] = str_to_float(explodeOut[1]);
        
origin[2] = str_to_float(explodeOut[2]);
        
        
// Make the ct spawn model
        
ent create_entity("info_target");
        
entity_set_string(entEV_SZ_classname"my_classname");
        
entity_set_origin(entorigin); // set the entity to the origin of the spawn
        
entity_set_int(entEV_INT_solidSOLID_NOT); // setting this to bbox will cause the spawning player to get stuck
        
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY);
        
entity_set_model(ent"models/barney.mdl"); // set the model here, remember to precache it
        
entity_set_size(entFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
    }
 
    
// Check if its a deathmatch
    
if(equali(className"info_player_deathmatch") && equali(keyName"origin"))
    {
        
// Get the 3 values to the origin
        
ExplodeString(explodeOut331value' ');
        
origin[0] = str_to_float(explodeOut[0]);
        
origin[1] = str_to_float(explodeOut[1]);
        
origin[2] = str_to_float(explodeOut[2]);
        
        
// Make the t spawn model
        
ent create_entity("info_target");
        
entity_set_string(entEV_SZ_classname"my_classname");
        
entity_set_origin(entorigin); // set the entity to the origin of the spawn
        
entity_set_int(entEV_INT_solidSOLID_NOT); // setting this to bbox will cause the spawning player to get stuck
        
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY);
        
entity_set_model(ent"models/barney.mdl"); // set the model here, remember to precache it
        
entity_set_size(entFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
    }
    
    return 
PLUGIN_CONTINUE;
}

stock ExplodeStringp_szOutput[][], p_nMaxp_nSizep_szInput[], p_szDelimiter )
{
    new 
nIdx 0strlen(p_szInput)
    new 
nLen = (copycp_szOutput[nIdx], p_nSizep_szInputp_szDelimiter ))
    while( (
nLen l) && (++nIdx p_nMax) )
        
nLen += (copycp_szOutput[nIdx], p_nSizep_szInput[nLen], p_szDelimiter ))
    return




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

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