Raised This Month: $ Target: $400
 0% 

Help with ttt golden gun


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 12-14-2022 , 02:16   Help with ttt golden gun
Reply With Quote #1

When playing ttt, is there a way to make it only possible for detectives to pick up the golden guns when they walk over it? Sometimes you are innocent or traitor and you walk over an empty golden gun and it's kind of annoying. Thanks!

PHP Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#include <cs_weapons_api>
#include <amx_settings_api>
#include <fun>
#include <ttt>

#define WEAPON_CSWID CSW_DEAGLE
#define WEAPON_NAME "weapon_deagle"

new g_iItemIDg_pMsgScreenFade;
new 
g_szModels[3][TTT_FILELENGHT];
new 
cvar_weapon_damagecvar_weapon_speedcvar_weapon_ammocvar_weapon_clipcvar_weapon_pricecvar_weapon_reloadcvar_weapon_recoil;
new 
g_iGlowing[33], g_iAlreadyShot[33];

public 
plugin_precache()
{
    if(!
amx_load_setting_string(TTT_SETTINGSFILE"Golden Gun""MODEL_V"g_szModels[0], charsmax(g_szModels[])))
    {
        
g_szModels[0] = "models/ttt/v_golden.mdl";
        
amx_save_setting_string(TTT_SETTINGSFILE"Golden Gun""MODEL_V"g_szModels[0]);
    }
    
precache_model(g_szModels[0]);

    if(!
amx_load_setting_string(TTT_SETTINGSFILE"Golden Gun""MODEL_P"g_szModels[1], charsmax(g_szModels[])))
    {
        
g_szModels[1] = "models/ttt/p_golden.mdl";
        
amx_save_setting_string(TTT_SETTINGSFILE"Golden Gun""MODEL_P"g_szModels[1]);
    }
    
precache_model(g_szModels[1]);

    if(!
amx_load_setting_string(TTT_SETTINGSFILE"Golden Gun""MODEL_W"g_szModels[2], charsmax(g_szModels[])))
    {
        
g_szModels[2] = "models/ttt/w_golden.mdl";
        
amx_save_setting_string(TTT_SETTINGSFILE"Golden Gun""MODEL_W"g_szModels[2]);
    }
    
precache_model(g_szModels[2]);
}

public 
plugin_init()
{
    
register_plugin("[TTT] Item: Golden Gun"TTT_VERSIONTTT_AUTHOR);

    
cvar_weapon_clip    my_register_cvar("ttt_golden_clip",    "1",    "Golden Gun clip ammo. (Default: 1)");
    
cvar_weapon_ammo    my_register_cvar("ttt_golden_ammo",    "0",    "Golden Gun backpack ammo. (Default: 0)");
    
cvar_weapon_speed    my_register_cvar("ttt_golden_speed",    "0.1",    "Golden Gun attack speed delay. (Default: 0.1)");
    
cvar_weapon_damage    my_register_cvar("ttt_golden_damage",    "0.0",    "Golden Gun damage multiplier. (Default: 0.0)");
    
cvar_weapon_reload    my_register_cvar("ttt_golden_reload",    "0.0",    "Golden Gun reload speed. (Default: 0.0)");
    
cvar_weapon_recoil    my_register_cvar("ttt_golden_recoil",    "0.0",    "Golden Gun recoil. (Default: 0.0)");
    
cvar_weapon_price    my_register_cvar("ttt_price_golden",    "2",    "Golden Gun price. (Default: 2)");

    
g_pMsgScreenFade    get_user_msgid("ScreenFade");
}

public 
ttt_plugin_cfg()
{
    new 
name[TTT_ITEMLENGHT];
    
formatex(namecharsmax(name), "%L"LANG_PLAYER"TTT_ITEM_ID14");
    
g_iItemID ttt_buymenu_add(nameget_pcvar_num(cvar_weapon_price), PC_DETECTIVE);
}

public 
ttt_gamemode(gamemode)
{
    if(
gamemode == GAME_PREPARING || gamemode == GAME_RESTARTING)
    {
        new 
numid;
        static 
players[32];
        
get_players(playersnum);
        for(--
numnum >= 0num--)
        {
            
id players[num];
            
g_iAlreadyShot[id] = false;
            if(
g_iGlowing[id])
            {
                
g_iGlowing[id] = false;
                
set_user_rendering(id);
            }
        }
    }
}

public 
ttt_item_selected(iditemname[], price)
{
    if(
g_iItemID == item)
    {
        if(
user_has_weapon(idWEAPON_CSWID))
            
engclient_cmd(id"drop"WEAPON_NAME);

        static 
data[STOREABLE_STRUCTURE];
        if(!
data[STRUCT_CSWA_CSW])
        {
            
data[STRUCT_CSWA_ITEMID] = g_iItemID;
            
data[STRUCT_CSWA_CSW] = WEAPON_CSWID;
            
data[STRUCT_CSWA_CLIP] = get_pcvar_num(cvar_weapon_clip);
            
data[STRUCT_CSWA_MAXCLIP] = get_pcvar_num(cvar_weapon_clip);
            
data[STRUCT_CSWA_AMMO] = get_pcvar_num(cvar_weapon_ammo);
            
data[STRUCT_CSWA_STACKABLE] = true;
            
data[STRUCT_CSWA_SILENCED] = -1;
            
data[STRUCT_CSWA_SPEEDDELAY] = _:get_pcvar_float(cvar_weapon_speed);
            
data[STRUCT_CSWA_DAMAGE] = _:get_pcvar_float(cvar_weapon_damage);
            
data[STRUCT_CSWA_RELOADTIME] = _:get_pcvar_float(cvar_weapon_reload);
            
data[STRUCT_CSWA_RECOIL] = _:get_pcvar_float(cvar_weapon_recoil);
            
data[STRUCT_CSWA_MODEL_V] = g_szModels[0];
            
data[STRUCT_CSWA_MODEL_P] = g_szModels[1];
            
data[STRUCT_CSWA_MODEL_W] = g_szModels[2];
        }
        
cswa_give_specific(iddata);

        
g_iAlreadyShot[id] = false;
        
client_print_color(idprint_team_default"%s %L"TTT_TAGid"TTT_ITEM2"nameid"TTT_ITEM5");
        return 
PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;
}

public 
cswa_damage(weapon_idvictimattackerFloat:damage)
{
    if(!
g_iAlreadyShot[attacker] && get_weapon_edict(weapon_idREPL_CSWA_ITEMID) == g_iItemID)
    {
        static 
name[2][32];
        
get_user_name(attackername[0], charsmax(name[]));

        new 
player_state ttt_get_playerstate(victim);
        if(
player_state == PC_TRAITOR)
            
ExecuteHamB(Ham_Killedvictimattacker2);
        else if(
player_state == PC_INNOCENT)
        {
            
g_iGlowing[victim] = true;
            
screen_fade(victim);
            
set_user_rendering(victimkRenderFxGlowShellg_iTeamColors[player_state][0], g_iTeamColors[player_state][1], g_iTeamColors[player_state][2], kRenderNormal30);
            
client_print_color(victimprint_team_default"%s %L"TTT_TAGvictim"TTT_ITEM_GOLDEN"victimspecial_names[PC_INNOCENT], victimspecial_names[ttt_get_playerstate(attacker)], name[0]);
        }

        
get_user_name(victimname[1], charsmax(name[]));
        
ttt_log_to_file(LOG_ITEM"%s used %L on [%L] %s"name[0], LANG_PLAYER"TTT_ITEM_ID14"LANG_PLAYERspecial_names[player_state], name[1]);
        
g_iAlreadyShot[attacker] = true;
    }
}

stock screen_fade(id)
{
    
message_begin(MSG_ONE_UNRELIABLEg_pMsgScreenFade_id);
    
write_short(FixedUnsigned16(1.01<<12));
    
write_short(0);
    
write_short((SF_FADE_MODULATE)); //flags (SF_FADE_IN + SF_FADE_ONLYONE) (SF_FADEOUT)
    
write_byte(g_iTeamColors[PC_INNOCENT][0]);
    
write_byte(g_iTeamColors[PC_INNOCENT][1]);
    
write_byte(g_iTeamColors[PC_INNOCENT][2]);
    
write_byte(180);
    
message_end();

JuanitoAlimana is offline
administratora
Member
Join Date: Mar 2015
Old 12-18-2022 , 09:44   Re: Help with ttt golden gun
Reply With Quote #2

Add this:

PHP Code:
public client_putinserver(id)
{
    if (
get_user_team(id) == TEAM_DETECTIVE)
    {
        
// Allow the detective to pick up the golden gun
        
g_iGlowing[id] = 0;
        
g_iAlreadyShot[id] = 0;
    }
    else
    {
        
// Disallow other players from picking up the golden gun
        
g_iGlowing[id] = 1;
    }

This checks the player's team using the get_user_team() function and assigns the value of 0 to g_iGlowing[id] if the player is a detective, and 1 otherwise. The g_iGlowing[id] variable is used to determine whether a player can pick up the golden gun, so setting it to 0 allows the detective to pick up the gun while setting it to 1 disallows other players from picking it up.

PHP Code:
public client_disconnect(id)
{
    
g_iGlowing[id] = 0;
    
g_iAlreadyShot[id] = 0;

This will reset the g_iGlowing variable for the disconnected player, allowing them to pick up the golden gun if they join the server again as a detective.
administratora is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 12-19-2022 , 02:18   Re: Help with ttt golden gun
Reply With Quote #3

I get the following error when compiling:

ttt_item_golden.sma(157) : error 017: undefined symbol "TEAM_DETECTIVE"
JuanitoAlimana is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 12-19-2022 , 17:06   Re: Help with ttt golden gun
Reply With Quote #4

This doesn't work. Unmarked people, inocent and traitor still can pick up the golden gun from the floor
JuanitoAlimana is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 12-27-2022 , 00:41   Re: Help with ttt golden gun
Reply With Quote #5

Is there a way to make the weapon undroppable?

Last edited by JuanitoAlimana; 12-27-2022 at 00:42. Reason: mistake
JuanitoAlimana is offline
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 08:17.


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