Resolved Weapon Icon (little problem)

Coding Help/Re-API Supported
Post Reply
User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

Weapon Icon (little problem)

#1

Post by ArminC » 1 Year Ago

When I shot, the icon disapear until I stop shooting :\

Code: Select all

#include <amxmodx>

#define PLUGIN "Weapon Icon"
#define VERSION "1.2"
#define AUTHOR "hoboman313/Zenix"

#define MAX_PLAYERS 32

new iconstatus, pcv_iloc
new user_icons[MAX_PLAYERS+1][16]


public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_event("CurWeapon", "update_icon", "be", "1=1")
    register_event("AmmoX", "draw_icon", "be")
    register_event("DeathMsg", "event_death", "a")
    
    pcv_iloc = register_cvar("amx_weapon_location", "1")
    
    check_icon_loc()
}

public update_icon(id) 
{
    remove_weapon_icon(id)
    
    check_icon_loc()
        
    if( get_pcvar_num(pcv_iloc) == 0 || is_user_bot(id) )
        return
        
    static sprite[16], iwpn, clip, ammo

    iwpn = get_user_weapon(id, clip, ammo)
    
    switch(iwpn) 
    {
        case CSW_P228: 
        sprite = "d_p228"
        case CSW_SCOUT: 
        sprite = "d_scout"
        case CSW_HEGRENADE: 
        sprite = "d_grenade"
        case CSW_XM1014:
        sprite = "d_xm1014"
        case CSW_MAC10: 
        sprite = "d_mac10"
        case CSW_AUG: 
        sprite = "d_aug"
        case CSW_SMOKEGRENADE: 
        sprite = "d_grenade"
        case CSW_ELITE: 
        sprite = "d_elite"
        case CSW_FIVESEVEN: 
        sprite = "d_fiveseven"
        case CSW_UMP45: 
        sprite = "d_ump45"
        case CSW_SG550: 
        sprite = "d_sg550"
        case CSW_GALIL: 
        sprite = "d_galil"
        case CSW_FAMAS: 
        sprite = "d_famas"
        case CSW_USP: 
        sprite = "d_usp"
        case CSW_MP5NAVY: 
        sprite = "d_mp5navy"
        case CSW_M249: 
        sprite = "d_m249"
        case CSW_M3: 
        sprite = "d_m3"
        case CSW_M4A1: 
        sprite = "d_m4a1"
        case CSW_TMP: 
        sprite = "d_tmp"
        case CSW_G3SG1: 
        sprite = "d_g3sg1"
        case CSW_FLASHBANG:
        sprite = "d_grenade"
        case CSW_DEAGLE: 
        sprite = "d_deagle"
        case CSW_SG552: 
        sprite = "d_sg552"
        case CSW_AK47: 
        sprite = "d_ak47"
        case CSW_KNIFE: 
        sprite = "d_knife"
        case CSW_P90: 
        sprite = "d_p90"
        case CSW_GLOCK18: 
        sprite = "d_glock18"
        case CSW_AWP: 
        sprite = "d_awp"
        default: 
        return
    }    
    user_icons[id] = sprite
    
    draw_icon(id)
    
    return
} 


public draw_icon(id)
{
    static iwpn, clip, ammo, icon_color[3]
    
    iwpn = get_user_weapon(id, clip, ammo)
    
    // ammo check, this is for the color of the icon
    if ((ammo == 0 && clip == 0))
        icon_color = {255, 0, 0} // outta ammo!
    else if ( ammo==0 && iwpn!=CSW_KNIFE)
        icon_color = {255, 160, 0} // last clip!
    else 
        icon_color = {0, 160, 0}//green icon...decent ammo
    
    
    // draw the sprite itself
    message_begin(MSG_ONE,iconstatus,{0,0,0},id)
    write_byte(1) // status (0=hide, 1=show, 2=flash)
    write_string(user_icons[id]) // sprite name
    write_byte(icon_color[0]) // red
    write_byte(icon_color[1]) // green
    write_byte(icon_color[2]) // blue
    message_end()
}


public remove_weapon_icon(id) 
{
    message_begin(MSG_ONE,iconstatus,{0,0,0},id)
    write_byte(0)
    write_string(user_icons[id])
    message_end()
}


public event_death() 
{
    new id = read_data(2) // the dead player's ID (1-32)
    
    if (!is_user_bot(id)) 
        remove_weapon_icon(id) 
}


public check_icon_loc() 
{
    new value = get_pcvar_num(pcv_iloc)
    
    if (value == 1)
        iconstatus = get_user_msgid("StatusIcon")
    else if (value == 2)
        iconstatus = get_user_msgid("Scenario")
    else
        iconstatus = 0
    
    return PLUGIN_CONTINUE
}
Last edited by ArminC on 01 Feb 2018, 10:56, edited 1 time in total.

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 624
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#2

Post by Mohamed Alaa » 1 Year Ago

There is already a fixed version on gameplay section.
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#3

Post by ArminC » 1 Year Ago

Where? Anyway this plugin that I posted is the latest one appeared on the net. + It disapear when I shot if the icon is set to be to the right of the clock amx_weapon_location "2" (not tested on cvar 1)

Update If I use cvar "1" , sprite above the SHOP sprite (that green icon..) it don't disapear.. maybe it's because the sprite around the clock is refreshing like the clock.. I don't know..

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 624
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#4

Post by Mohamed Alaa » 1 Year Ago

Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#5

Post by ArminC » 1 Year Ago

(I saw it already) Lol.. this is an older version than mine nor is fixed is just a link to the topic

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#6

Post by Raheem » 1 Year Ago

I don't have this problem, By anyway i stopped this plugin time ago because it cause this: viewtopic.php?f=11&t=2748
You don't know? Learn and you will know.

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#7

Post by ArminC » 1 Year Ago

Update: I tried with 32 players (31 bots) [rip my pc] and the server didn't crash (using that revamped version, not the original one)

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 633
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 19
Contact:

#8

Post by Spir0x » 1 Year Ago

So now we use what one on gameplay section or this weapon icon ?
I trynna make money, not friends.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests