PHP- Kodu:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#define PLUGIN "LightSaber"
#define VERSION "1.0"
#define AUTHOR "akcaliberkk"
new usercolor[33];
new const models[][] = {
"models/v_light_saber_blu.mdl",
"models/p_light_saber_blu.mdl",
"models/v_light_saber_green.mdl",
"models/p_light_saber_green.mdl",
"models/v_light_saber_red.mdl",
"models/p_light_saber_red.mdl"
}
new const sounds[][] = {
"weapons/lightsaber_deploy1.wav",
"weapons/lightsaber_hit1.wav",
"weapons/lightsaber_hit2.wav",
"weapons/lightsaber_hitwall1.wav",
"weapons/lightsaber_slash1.wav",
"weapons/lightsaber_slash2.wav",
"weapons/lightsaber_stab.wav"
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("drop","ChangeColor")
register_event("CurWeapon","eCurWeapon","be","1=1")
register_forward(FM_EmitSound, "fwdEmitSound")
}
public plugin_precache() {
for(new i; i<sizeof(models);i++) precache_model(models[i]);
for(new i; i<sizeof(sounds);i++) precache_sound(sounds[i]);
}
public client_connect(id) {
usercolor[id] = 0;
}
public ChangeColor(id) {
if(get_user_weapon(id) == CSW_KNIFE) {
usercolor[id] = ++usercolor[id] % 3
CheckModel(id)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public eCurWeapon(id) {
new wpnID = read_data(2);
if(wpnID == CSW_KNIFE) {
CheckModel(id)
}
}
public CheckModel(id) {
switch(usercolor[id]) {
case 0: {
set_pev(id, pev_viewmodel2, models[0])
set_pev(id, pev_weaponmodel2, models[1])
}
case 1: {
set_pev(id, pev_viewmodel2, models[2])
set_pev(id, pev_weaponmodel2, models[3])
}
case 2: {
set_pev(id, pev_viewmodel2, models[4])
set_pev(id, pev_weaponmodel2, models[5])
}
}
}
public fwdEmitSound(id, channel, const sound[], Float:volume, Float:attn, flags, pitch) {
if(containi(sound,"knife_deploy1") != -1) {
engfunc(EngFunc_EmitSound, id, channel, sounds[0], volume, attn, flags, pitch)
return FMRES_SUPERCEDE
}
else if(containi(sound,"knife_hit") != -1) {
if(containi(sound, "hitwall") != -1) {
engfunc(EngFunc_EmitSound, id, channel, sounds[3], volume, attn, flags, pitch)
}
else engfunc(EngFunc_EmitSound, id, channel, sounds[random_num(1,2)], volume, attn, flags, pitch)
return FMRES_SUPERCEDE
}
else if(containi(sound,"knife_slash") != -1) {
engfunc(EngFunc_EmitSound, id, channel, sounds[random_num(4,5)], volume, attn, flags, pitch)
return FMRES_SUPERCEDE
}
else if(containi(sound,"knife_stab") != -1) {
engfunc(EngFunc_EmitSound, id, channel, sounds[6], volume, attn, flags, pitch)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}