AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Define Team to show HUD Message (https://forums.alliedmods.net/showthread.php?t=327037)

Ark_Procession 08-29-2020 12:46

Define Team to show HUD Message
 
I have this code made by bugsy.

I tried to show the HUD to only terrorists and i don't seem to get it to work.
CT still can see the HUD message with this code:

I'm probably placing the if(cs_get_user_team(id) == CS_TEAM_T) on the wrong part.

Anyone care to show me how to do it correctly?


Code:

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <dhudmessage>

new const Version[] = "0.1";

#define IsPlayer(%1)    (1<=%1<=32)

public plugin_init()
{
    register_plugin( "Bomb Spawn HUD" , Version , "bugsy" );
   
    register_logevent( "SpawnedWithBomb" , 3 , "2=Spawned_With_The_Bomb" );
}

public SpawnedWithBomb()

       
    set_task( 0.1 , "DelayC4" );
}

public DelayC4()
{
       

    new szName[ 32 ] , iBomb , id;
   
    iBomb = find_ent_by_class( -1 , "weapon_c4" );
    id = entity_get_edict( iBomb , EV_ENT_owner );
       
        if(cs_get_user_team(id) == CS_TEAM_T)
        {
       
        get_user_name( id , szName , charsmax( szName ) );
        set_dhudmessage( 255 , 50 , 0 , 0 , 0.73 , 0 , 0.0 , 10.0 );
        show_dhudmessage( 0 , "[ %s has the bomb ]" , szName ); 
 
  }
     
     
}


ZaX 08-29-2020 15:29

Re: Define Team to show HUD Message
 
inside the if() condition, use get_players function and get the terrorist team then loop.

BTW.
show_dhudmessage(0, ....)
0 Means everyone will get the message.
Use the proper player index(or the indexes when you loop).

Ark_Procession 08-29-2020 23:16

Re: Define Team to show HUD Message
 
I'm sorry, i'm am VERY new to pawn, and is really hard to start.

Could you maybe, write the line with the solution? and i will take it as reference to understand how it works.

Since i don't really understood how to apply the get_players function, player index, or how to loop.

Shadows Adi 08-30-2020 06:01

Re: Define Team to show HUD Message
 
Code:
public DelayC4() {     new szName[ 32 ] , iBomb , id;         iBomb = find_ent_by_class( -1 , "weapon_c4" );     id = entity_get_edict( iBomb , EV_ENT_owner );         if(cs_get_user_team(id) == CS_TEAM_T)     {             get_user_name( id , szName , charsmax( szName ) );         new players[32];         new pnum;         new tempid;         get_players(players, pnum, "ceh", "TERRORIST"); /* Getting players list which are respecting filtering flags ( See this: <a href="https://www.amxmodx.org/api/amxmodx/get_players" target="_blank" rel="nofollow noopener">https://www.amxmodx.org/api/amxmodx/get_players</a> ) */         for (new i; i < pnum; i++) /* Looping through the players num */         {             tempid = players[i]; /* Assigning a temporay index for the certain players */             set_dhudmessage( 255 , 50 , 0 , 0 , 0.73 , 0 , 0.0 , 10.0 );             show_dhudmessage( tempid, "[ %s has the bomb ]" , szName ); /* Displaying the dhud message for all players from the array */         }     }       }

Ark_Procession 08-30-2020 11:23

Re: Define Team to show HUD Message
 
Thank you, the code works and i'm trying to comprehend it so i can apply it to other plugins as well.


All times are GMT -4. The time now is 13:44.

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