Syncope.T-*
728x90

아래의 예제 : <Zombie Claw>

new String:Claws[MAX_CLAWS+1][PLATFORM_MAX_PATH];

new MaxClaws, Human_Knife, viewModelweaponindex[MAXPLAYERS+1];


public ZR_OnClientInfected(client, attacker, bool:motherInfect, bool:respawnOverride, bool:respawn)
{
if (!enabled)
return;

decl String:Weapon[32];
new ActiveWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");

GetEdictClassname(ActiveWeapon, Weapon, sizeof(Weapon));

if (StrEqual(Weapon, "weapon_knife"))
{
new ClawNumber = Math_GetRandomInt(1, MaxClaws);
Weapon_SetViewModelIndex(client, Claws[ClawNumber]);
}
}

public ZR_OnClientHumanPost(client, bool:respawn, bool:protect)
{
if (viewModelweaponindex[client])
{
SetEntProp(viewModelweaponindex[client], Prop_Send, "m_nModelIndex", Human_Knife);
ChangeEdictState(viewModelweaponindex[client], FindDataMapOffs(viewModelweaponindex[client], "m_nModelIndex"));
}
}

public OnClientDisconnect_Post(client)
{
viewModelweaponindex[client] = 0;
}


Weapon_SetViewModelIndex(client, String:Model[])
{
if (StrEqual(Model, "-1", false) || !IsClientInGame(client) || !IsPlayerAlive(client))
return;

new index = PrecacheModel(Model);

if (index < 1)
{
LogError("Unable to precache model '%s'", Model);
return;
}

viewModelweaponindex[client] = Weapon_GetViewModelIndex(client);

if (viewModelweaponindex[client] < 1)
{
LogError("Unable to get a viewmodel index");
return;
}

SetEntProp(viewModelweaponindex[client], Prop_Send, "m_nModelIndex", index);
ChangeEdictState(viewModelweaponindex[client], FindDataMapOffs(viewModelweaponindex[client], "m_nModelIndex"));
}

Weapon_GetViewModelIndex(client)
{
new index = -1;
while ((index = FindEntityByClassname2(index, "predicted_viewmodel")) != -1)
{
new Owner = GetEntPropEnt(index, Prop_Send, "m_hOwner");
new ClientWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
new Weapon = GetEntPropEnt(index, Prop_Send, "m_hWeapon");
if (Owner != client)
continue;
if (ClientWeapon != Weapon)
continue;
return index;
}
return -1;
}

stock FindEntityByClassname2(startEnt, const String:classname[])
{
while (startEnt > -1 && !IsValidEntity(startEnt)) startEnt--;
return FindEntityByClassname(startEnt, classname);
}

profile

Syncope.T-*

@Syncope

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

profile on loading

Loading...