Raised This Month: $ Target: $400
 0% 

detect if Ct are standing in there spawn?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 07-18-2013 , 03:48   detect if Ct are standing in there spawn?
Reply With Quote #1

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)     } }
__________________

Last edited by Blizzard_87; 07-18-2013 at 04:19.
Blizzard_87 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-18-2013 , 18:46   Re: detect if Ct are standing in there spawn?
Reply With Quote #2

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);
    }

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 07-18-2013 at 19:13. Reason: Optmized
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 07-18-2013 , 19:57   Re: detect if Ct are standing in there spawn?
Reply With Quote #3

I'm assuming that would be more efficient? Thanks. It does use less code.
__________________
Blizzard_87 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-18-2013 , 21:22   Re: detect if Ct are standing in there spawn?
Reply With Quote #4

Quote:
Originally Posted by Blizzard_87 View Post
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.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 06:24.


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