
/* AMX Mod script.
*
* (c) Copyright 2002, OLO
* This file is provided as is (no warranties).
*
*/

#include <amxmod> 

/* cvar:
*  amx_ownscore_mode < flags >
*  "a" - do no changes
*  "b" - make that there is no frags but team score
*  "c" - don't desplay deaths
*/

new tscore[3]
new tteamid[33]
new tfrags[33]
new tclass[33]
new tdeaths[33]
new gmsgScoreInfo

send_own_score(id) {
	new mode[8]
	get_cvar_string("amx_ownscore_mode",mode,8)
	new rules = read_flags(mode)
	if (rules & 1) return /* do no changes */
	message_begin(MSG_ALL, gmsgScoreInfo)
	write_byte(id)
	write_short( (rules&2) ? tscore[tteamid[id]] : tfrags[id] )
	write_short( (rules&4) ? 0 : tdeaths[id] )
	write_short( tclass[id] )
	write_short( tteamid[id] )
	message_end()
}

public scoreinfo_event() {
	new id = read_data(1) /* about who is this score */
	tfrags[id] = read_data(2)
	tdeaths[id] = read_data(3)
	tclass[id] = read_data(4) /* in CS there is no classes - this is always 0 */
	tteamid[id] = read_data(5)
	send_own_score(id)
}

public teamscore_event() {
	new rteam[32]
	read_data(1,rteam,32)
	if (rteam[0]=='T')
		tscore[1] = read_data(2)
	else if (rteam[0]=='C')
		tscore[2] = read_data(2)
	/* i wanted to have 1 and 2 indexes  :) (0 is useless) */
}

public plugin_init() { 
	register_plugin("Own Score Rules","0.6","default")
	register_event("ScoreInfo","scoreinfo_event","a")
	register_event("TeamScore","teamscore_event","a")
	gmsgScoreInfo = get_user_msgid("ScoreInfo")
	register_cvar("amx_ownscore_mode","bc")
	return PLUGIN_CONTINUE 
}

