PHP Code:
//Crosshair Type
//Special thanks to <VeCo>
#include <amxmodx>
#include <engine>
#define PLUGIN "Crosshair Type"
#define VERSION "1.1"
#define AUTHOR "DavidJr"
// *restricted* sniper weapons
#define SNIPER_WEAPONS (1 << CSW_AWP | 1 << CSW_SCOUT | 1 << CSW_G3SG1 | 1 << CSW_SG550)
new sync
new user_crosshair_type[33]
public plugin_init() {
register_plugin("PLUGIN","VERSION","DavidJr")
sync = CreateHudSyncObj() // HUD sync object
new ent = create_entity("info_target")
entity_set_string(ent,EV_SZ_classname,"dot_crosshair") // classname
entity_set_float(ent,EV_FL_nextthink,get_gametime() + 1.0) // think every second
//server command
server_cmd("bind o show_menu_ch")
//console command
register_concmd("show_menu_ch","cmd_show_menu_ch")
//thinking entity
register_think("cross_crosshair","cross_crosshair_think") // call "cross_crosshair_think" function on think
register_think("dot_crosshair","dot_crosshair_think") // call "dot_crosshair_think" function on think
register_think("round_crosshair","round_crosshair_think") // call "round_crosshair_think" function on think
}
public cross_crosshair_think(ent) // entity thinks...
{
entity_set_float(ent,EV_FL_nextthink,get_gametime() + 1.0) // continue thinking every second
if(!get_playersnum()) return // server is empty, there's no need to show HUD messages...
static players[32],num, i,id
get_players(players,num,"a") // get all alive players in the server
for(i=0;i<num;i++) // loop trough them...
{
id = players[i] // store player index in a more convenient variable
if(1 << get_user_weapon(id) & SNIPER_WEAPONS) continue // if this player is holding a sniper - continue with the next player
// else, show the HUD message...
set_hudmessage(0, 255, 0, -1.0, -1.0, .holdtime = 1.0) // skip default values
ShowSyncHudMsg(id,sync, "+",user_crosshair_type[id]) // show crosshair HUD
}
}
public dot_crosshair_think(ent) // entity thinks...
{
entity_set_float(ent,EV_FL_nextthink,get_gametime() + 1.0) // continue thinking every second
if(!get_playersnum()) return // server is empty, there's no need to show HUD messages...
static players[32],num, i,id
get_players(players,num,"a") // get all alive players in the server
for(i=0;i<num;i++) // loop trough them...
{
id = players[i] // store player index in a more convenient variable
if(1 << get_user_weapon(id) & SNIPER_WEAPONS) continue // if this player is holding a sniper - continue with the next player
// else, show the HUD message...
set_hudmessage(0, 255, 0, -1.0, -1.0, .holdtime = 1.0) // skip default values
ShowSyncHudMsg(id,sync, "*",user_crosshair_type[id]) // show crosshair HUD
}
}
public round_crosshair_think(ent) // entity thinks...
{
entity_set_float(ent,EV_FL_nextthink,get_gametime() + 1.0) // continue thinking every second
if(!get_playersnum()) return // server is empty, there's no need to show HUD messages...
static players[32],num, i,id
get_players(players,num,"a") // get all alive players in the server
for(i=0;i<num;i++) // loop trough them...
{
id = players[i] // store player index in a more convenient variable
if(1 << get_user_weapon(id) & SNIPER_WEAPONS) continue // if this player is holding a sniper - continue with the next player
// else, show the HUD message...
set_hudmessage(0, 255, 0, -1.0, -1.0, .holdtime = 1.0) // skip default values
ShowSyncHudMsg(id,sync, "%c",user_crosshair_type[id]) // show crosshair HUD
}
}
// Show Menu CH
public cmd_show_menu_ch(id)
{
new menu = menu_create("\yChoose Crosshair Type", "menu_crosshair")
menu_additem(menu, "Cross +", "43", 0) // actually this 0 is set by default, you don't need to write it
menu_additem(menu, "Dot *", "42", 0)
menu_additem(menu, "Round o", "111", 0)
// Add more Options if you wish
menu_display(id, menu, 0)
}
// Menu CH
public menu_crosshair(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64], access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
user_crosshair_type[id] = str_to_num(data)
menu_destroy(menu)
return PLUGIN_HANDLED
}
public client_connect(id) user_crosshair_type[id] = 111 // default crosshair is "o"