Hi all how make then you go in server and start play you automatically selects the class? and then you die you respawn and again auto class select. the class not the same, but different
PHP Code:
/* Stay Alive Mod By Ziugis or PsychoPach. Special Thanks: Pur3Biatch, Exolent[jNr] */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Stay Alive!"
#define VERSION "0.1"
#define AUTHOR "Ziugis"
#define Ham_Player_ResetMaxSpeed Ham_Item_PreFrame
enum _:CLASSES {
CLASS_CT = 0,
CLASS_BERSERK,
CLASS_CARMINE,
CLASS_VOX,
CLASS_GIRL,
CLASS_BLADE,
CLASS_ROBOT,
CLASS_HELLKNIGHT
}
new const className[CLASSES][] = {
"CT",
"Berserk",
"Carmine",
"Vox",
"Girl",
"Blade",
"Robot",
"Hellknight"
};
new Trie:classNameToIndex;
enum _:MODELS {
MODEL_PLAYER,
MODEL_WEAPON_P,
MODEL_WEAPON_V
}
new const classModels[CLASSES][MODELS][] = {
{"CT", "", ""},
{"Berserk", "", "models/Alive/v_claws.mdl"},
{"Carmine", "models/Alive/p_bak.mdl", "models/Alive/v_bak.mdl"},
{"Vox", "models/Alive/p_samurai.mdl", "models/Alive/v_samurai.mdl"},
{"Girl", "models/Alive/p_pockets.mdl", "models/Alive/v_pockets.mdl"},
{"Blade", "models/Alive/p_khanjar.mdl", "models/Alive/v_khanjar.mdl"},
{"Robot", "models/Alive/p_chainsaw.mdl", "models/Alive/v_chainsaw.mdl"},
{"Hellknight", "", ""}
};
// must untag (_:value) all floats, but keep the variable tagged as float
// use _:-1.0 for damage to not alter the original damage
new const Float:classDamage[CLASSES] = {
_:-1.0, _:70.0, _:30.0, _:60.0, _:40.0, _:40.0, _:150.0, _:100.0
};
new const classHealth[CLASSES] = {
50, 1200, 200, 150, 125, 150, 700, 5000
};
new const classArmor[CLASSES] = {
100, 500, 250, 500, 0, 50, 800, 0
};
// must untag (_:value) all floats, but keep the variable tagged as float
new const Float:classSpeed[CLASSES] = {
_:400.0, _:115.0, _:300.0, _:1000.0, _:1500.0, _:500.0, _:450.0, _:600.0
};
new const classWeapons[CLASSES] = {
(1<<CSW_M3),
(1<<CSW_M249),
(1<<CSW_MAC10)|(1<<CSW_TMP),
(1<<CSW_MP5NAVY),
(1<<CSW_M4A1),
(1<<CSW_XM1014),
(1<<CSW_AWP),
0
};
new PlayerClass[33]
new maxPlayers;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say", "CmdSay");
RegisterHam(Ham_Item_Deploy, "knife", "FwdDeployKnifePost", 1);
RegisterHam(Ham_TakeDamage, "player", "KniveTakeDamage");
RegisterHam(Ham_Player_ResetMaxSpeed, "player", "FwdResetMaxSpeedPost", 1);
maxPlayers = get_maxplayers();
}
public plugin_precache()
{
classNameToIndex = TrieCreate();
new model[64];
for(new class = 0; class < CLASSES; class++) {
copy(model, charsmax(model), className[class]);
strtolower(model);
TrieSetCell(classNameToIndex, model, class);
if(classModels[class][MODEL_PLAYER][0]) {
formatex(model, charsmax(model), "models/player/%s/%s.mdl", classModels[class][MODEL_PLAYER], classModels[class][MODEL_PLAYER]);
precache_model(model);
}
if(classModels[class][MODEL_WEAPON_P][0]) {
precache_model(classModels[class][MODEL_WEAPON_P]);
}
if(classModels[class][MODEL_WEAPON_V][0]) {
precache_model(classModels[class][MODEL_WEAPON_V]);
}
}
return PLUGIN_CONTINUE
}
public CmdSay(id) {
new args[194];
read_args(args, charsmax(args));
remove_quotes(args);
if(args[0] == '/') {
new command[32];
parse(args[1], command, charsmax(command));
strtolower(command);
new class;
if(TrieGetCell(classNameToIndex, command, class) && PlayerClass[id] != class) {
PlayerClass[id] = class;
set_user_health(id, classHealth[class]);
set_user_armor(id, classArmor[class]);
set_user_maxspeed(id, classSpeed[class]);
if(classModels[class][MODEL_PLAYER][0]) {
cs_set_user_model(id, classModels[class][MODEL_PLAYER]);
} else {
cs_reset_user_model(id);
}
new weaponName[20]; // weapon_smokegrenade = 19
for(new i = CSW_P228; i <= CSW_P90; i++) {
if(classWeapons[class] & (1<<i) && get_weaponname(i, weaponName, charsmax(weaponName))) {
give_item(id, weaponName);
}
}
client_print(id, print_chat, "[Stay Alive] You are %s now.", className[class]);
}
}
}
public FwdDeployKnifePost(weapon) {
new id = pev(weapon, pev_owner);
new class = PlayerClass[id];
if(classModels[class][MODEL_WEAPON_P][0]) {
set_pev(id, pev_weaponmodel2, classModels[class][MODEL_WEAPON_P]);
}
if(classModels[class][MODEL_WEAPON_V][0]) {
set_pev(id, pev_viewmodel2, classModels[class][MODEL_WEAPON_V]);
}
}
public FwdResetMaxSpeedPost(id) {
set_user_maxspeed(id, classSpeed[PlayerClass[id]]);
}
public KniveTakeDamage(victim, inflictor, attacker, Float:damage, damage_bits)
{
if( attacker == inflictor
&& attacker != victim
&& (1 <= attacker <= maxPlayers)
&& classDamage[PlayerClass[attacker]] >= 0.0
&& get_user_weapon(attacker) == CSW_KNIFE)
{
SetHamParamFloat(4, classDamage[PlayerClass[attacker]]);
}
}