Hey, did not figure out better place to post this.
I made my first AMX Mod X plugin for my server since I could not find plugin like this and it seems to be working OK, I guess I just wanted feedback that am I doing everything correct, properly and so on.
Code:
#include <amxmodx>
#include <csx>
#include <cstrike>
/* Changes kill rewards to match CSGO */
/* BUGS: HUD icon still shows +300 even if reward is more or less */
/* TODO: CVAR control for rewards, make other economy (round win, loss, by exploding bomb, by killing enemies) match CSGO too */
#define PLUGIN "Weapon Rewards Plugin"
#define VERSION "1.0"
#define AUTHOR "hts"
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
register_event("DeathMsg", "event_death", "a" )
}
public get_award( wpn_id )
{
new kill_award = 0
switch( wpn_id )
{
case CSW_P228:
kill_award = 300
case CSW_SCOUT:
kill_award = 300
case CSW_HEGRENADE:
kill_award = 300
case CSW_XM1014:
kill_award = 900
case CSW_MAC10:
kill_award = 600
case CSW_AUG:
kill_award = 300
case CSW_SMOKEGRENADE:
kill_award = 300
case CSW_ELITE:
kill_award = 300
case CSW_FIVESEVEN:
kill_award = 300
case CSW_UMP45:
kill_award = 600
case CSW_SG550:
kill_award = 100
case CSW_GALIL:
kill_award = 600
case CSW_FAMAS:
kill_award = 300
case CSW_USP:
kill_award = 300
case CSW_GLOCK18:
kill_award = 300
case CSW_AWP:
kill_award = 100
case CSW_MP5NAVY:
kill_award = 600
case CSW_M249:
kill_award = 300
case CSW_M3:
kill_award = 900
case CSW_M4A1:
kill_award = 300
case CSW_TMP:
kill_award = 600
case CSW_G3SG1:
kill_award = 100
case CSW_FLASHBANG:
kill_award = 300
case CSW_DEAGLE:
kill_award = 300
case CSW_SG552:
kill_award = 300
case CSW_AK47:
kill_award = 300
case CSW_KNIFE:
kill_award = 1500
case CSW_P90:
kill_award = 300
default:
return PLUGIN_CONTINUE
}
return kill_award
}
public event_death()
{
new killer = read_data(1)
new wpn_id = get_user_weapon(killer)
new award = get_award( wpn_id )
if( award > 0 )
{
new cur_money = cs_get_user_money( killer );
new num_money = 0;
if( cur_money + award >= 16000 )
{
num_money = 16000;
}
else
{
num_money = cur_money + award;
num_money -= 300; // CS 1.6 gives 300 dollars by default for every weapon, we don't want it in this case.
}
cs_set_user_money( killer, num_money );
}
return PLUGIN_CONTINUE
}
I realized later that same syntax as in C++:
Code:
case 1:
case 2:
case 3:
return same_value_for_these;
would probably work for Pawn too. Am I correct? Cba to compile / upload to server again since I've got work in the morning.
I should also probably check killer / weapon_id variable values too before doing anything, dunno how well AMX Mod X (or Metamod?) handles mistakes like this but I will definately check their values in the future.