AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   detect if Ct are standing in there spawn? (https://forums.alliedmods.net/showthread.php?t=221105)

Blizzard_87 07-18-2013 03:48

detect if Ct are standing in there spawn?
 
ive tried finding on search but must be using wrong search tags...

i need to be able to detect if a CT player in standing in there spawn area and if so execute a command?

EDIT:

i found this https://forums.alliedmods.net/showpo...72&postcount=6

but only when player is NEAR spawn area not actually IN the spawn area.

EDIT: found solution havent tested in main plugin but will soon

Code:
public test( id ) {     new Float:origin[3]     entity_get_vector(id, EV_VEC_origin, origin)     new ent = find_ent_in_sphere(id, origin, 128.0)     while(ent > 0)     {         new classname[32]         entity_get_string(ent, EV_SZ_classname, classname, 31)         if(equal(classname, "info_player_start"))         {             client_print( id, print_center, "CT Spawn" )         }         if(equal(classname, "info_player_deathmatch"))         {             client_print( id, print_center, "T Spawn" )         }         ent = find_ent_in_sphere(ent, origin, 128.0)     } }

^SmileY 07-18-2013 18:46

Re: detect if Ct are standing in there spawn?
 
OR Just use StatusIcon event ;)

Example.

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

new p_Active;
new 
p_Team;

public 
plugin_init()
{
    
register_plugin("Buy Zone God Mode",AMXX_VERSION_STR,"SmileY");
    
    
p_Active     register_cvar("amx_godmode_respawn","1");
    
p_Team         register_cvar("amx_godmode_teams","ANY"); // ANY = ALL (TR = TRs | CT = CTs)
    
    
register_message(get_user_msgid("StatusIcon"),"MSG_StatusIcon"); // Optmize this event?
}

public 
MSG_StatusIcon(iMsg,iDest,id)
{
    if(
get_pcvar_num(p_Active))
    {
        new 
szTeam[4];
        
get_pcvar_string(p_Team,szTeam,charsmax(szTeam));
        
        static 
szIcon[8];     // Optmize this event?
        
get_msg_arg_string(2,szIcon,charsmax(szIcon));
        
        if(
equal(szTeam,"ANY") && equal(szIcon,"buyzone")) set_pev(id,pev_takedamage,get_msg_arg_int(1) ? DAMAGE_NO DAMAGE_AIM);
        
        else if(
equal(szTeam,"TR") && equal(szIcon,"buyzone") && (cs_get_user_team(id) == CS_TEAM_T)) set_pev(id,pev_takedamage,get_msg_arg_int(1) ? DAMAGE_NO DAMAGE_AIM);
        
        else if(
equal(szTeam,"CT") && equal(szIcon,"buyzone") && (cs_get_user_team(id) == CS_TEAM_CT)) set_pev(id,pev_takedamage,get_msg_arg_int(1) ? DAMAGE_NO DAMAGE_AIM);
    }


Sorry, Optmized version:

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

new p_Active;
new 
p_Team;

public 
plugin_init()
{
    
register_plugin("Buy Zone God Mode",AMXX_VERSION_STR,"SmileY");
    
    
p_Active     register_cvar("amx_godmode_respawn","1");
    
p_Team         register_cvar("amx_godmode_teams","ANY"); // ANY = ALL (TR = TRs | CT = CTs)
    
    
register_event("StatusIcon","MSG_StatusIcon","be","2=buyzone"); // Optmize this event?
}

public 
MSG_StatusIcon(id)
{
    if(
get_pcvar_num(p_Active))
    {
        new 
szTeam[4];
        
get_pcvar_string(p_Team,szTeam,charsmax(szTeam));
        
        if(
equal(szTeam,"ANY")) set_pev(id,pev_takedamage,read_data(1) ? DAMAGE_NO DAMAGE_AIM);
        
        else if(
equal(szTeam,"TR") && (cs_get_user_team(id) == CS_TEAM_T)) set_pev(id,pev_takedamage,read_data(1) ? DAMAGE_NO DAMAGE_AIM);
            
        else if(
equal(szTeam,"CT") && (cs_get_user_team(id) == CS_TEAM_CT)) set_pev(id,pev_takedamage,read_data(1) ? DAMAGE_NO DAMAGE_AIM);
    }



Blizzard_87 07-18-2013 19:57

Re: detect if Ct are standing in there spawn?
 
I'm assuming that would be more efficient? Thanks. It does use less code.

^SmileY 07-18-2013 21:22

Re: detect if Ct are standing in there spawn?
 
Quote:

Originally Posted by Blizzard_87 (Post 1994057)
I'm assuming that would be more efficient? Thanks. It does use less code.

Not necessary efficient, but i think its more "Native" and simple to use.


All times are GMT -4. The time now is 06:24.

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