C-подобный:
/////////////Пример №1//////////////////////
int Index_WeaponLr[MAXPLAYERS+1];
void SetAmmo(int t, int ct)
{
int entity_ct = GivePlayerItem(ct, "weapon_deagle");
int entity_t = GivePlayerItem(t, "weapon_deagle");
SetEntProp(entity_ct, Prop_Send, "m_iPrimaryReserveAmmoCount", 0); // патроны в запасе
SetEntProp(entity_t, Prop_Send, "m_iPrimaryReserveAmmoCount", 0); // патроны в запасе
SetEntProp(entity_ct, Prop_Send, "m_iClip1", 1); // патроны в обойме
SetEntProp(entity_t, Prop_Send, "m_iClip1", 0); // патроны в обойме
Index_WeaponLr[ct] = EntIndexToEntRef(entity_ct);
Index_WeaponLr[t] = EntIndexToEntRef(entity_t);
PrintToChatAll("entity_ct = %d", entity_ct);
PrintToChatAll("entity_t = %d", entity_t);
}
public item_pickup(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
}
public Action:WeaponCanUse(int client, int weapon)
{
int entity = EntRefToEntIndex(Index_WeaponLr[client]);
PrintToChat(client, "entity == weapon (%d=%d)", entity, weapon);
if (entity != weapon) return Plugin_Handled; //Не даем взять оружие если оно не то что мы выдали в SetAmmo
return Plugin_Continue; //Оружие взялось, но в нем почему-то нет указанного в SetAmmo количества патронов
}
/////////////Пример №2//////////////////////
int Index_WeaponLr[MAXPLAYERS+1];
void SetAmmo(int t, int ct)
{
Index_WeaponLr[ct] = GivePlayerItem(ct, "weapon_deagle");
int Index_WeaponLr[t] = GivePlayerItem(t, "weapon_deagle");
SetEntProp(Index_WeaponLr[ct], Prop_Send, "m_iPrimaryReserveAmmoCount", 0); // патроны в запасе
SetEntProp(Index_WeaponLr[t], Prop_Send, "m_iPrimaryReserveAmmoCount", 0); // патроны в запасе
SetEntProp(Index_WeaponLr[ct], Prop_Send, "m_iClip1", 1); // патроны в обойме
SetEntProp(Index_WeaponLr[t], Prop_Send, "m_iClip1", 0); // патроны в обойме
PrintToChatAll("entity_ct = %d", entity_ct);
PrintToChatAll("entity_t = %d", entity_t);
}
public item_pickup(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
}
public Action:WeaponCanUse(int client, int weapon)
{
if (Index_WeaponLr[client] != weapon) return Plugin_Handled; //Не даем взять оружие если оно не то что мы выдали в SetAmmo
return Plugin_Continue; //Оружие взялось, И В НЕМ НУЖНОЕ КОЛИЧЕСТВО ПАТРОНОВ
}
Почему так?