A najoptymalniej bedzie mozna zrobic to w ten sposob.
#include <sourcemod>
#include <codmod>
new const String:nazwa[] = "Kameleon";
new const String:opis[] = "Jest mniej widoczny na nożu na kucaka";
new const String:bronie[] = "#weapon_mp7#weapon_glock";
new const inteligencja = 0;
new const zdrowie = 0;
new const obrazenia = 0;
new const wytrzymalosc = 10;
new const kondycja = 0;
new bool:ma_klase[65],
bool:ma_render[65];
public Plugin:myinfo =
{
name = nazwa,
author = "Linux`",
description = "Cod Item",
version = "1.0",
url = "http://steamcommunity.com/id/linux2006"
};
public OnPluginStart()
{
cod_register_class(nazwa, opis, bronie, inteligencja, zdrowie, obrazenia, wytrzymalosc, kondycja);
ServerCommand("sv_disable_immunity_alpha 1");
HookEvent("player_spawn", OdrodzenieGracza);
}
public cod_class_enabled(client)
{
ma_klase[client] = true;
ma_render[client] = false;
}
public cod_class_disabled(client)
{
ma_klase[client] = false;
StopRender(client);
}
public Action:OdrodzenieGracza(Handle:event, String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(!IsValidClient(client) || !ma_klase[client])
return Plugin_Continue;
ma_render[client] = false;
return Plugin_Continue;
}
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapons)
{
if(!IsValidClient(client) || !ma_klase[client])
return Plugin_Continue;
if(!IsPlayerAlive(client))
return Plugin_Continue;
if(buttons & IN_DUCK)
{
new String:weapon[32];
GetClientWeapon(client, weapon, sizeof(weapon));
if(StrEqual(weapon, "weapon_knife"))
StartRender(client);
else
StopRender(client);
}
else
StopRender(client);
return Plugin_Continue;
}
public Action:StartRender(client)
{
if(!ma_render[client])
{
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 255, 255, 255, 50);
ma_render[client] = true;
}
return Plugin_Continue;
}
public Action:StopRender(client)
{
if(ma_render[client])
{
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 255, 255, 255, 255);
ma_render[client] = false;
}
return Plugin_Continue;
}