Seton
Участник
- Сообщения
- 44
- Реакции
- 41
Суть в принципе понял, только как получить индекс второго игрока, через for или как то иначе?Создать bool на каждого игрока и переключать в нужный момент в зависимости от того, нажата клавиша или нет
C-подобный:bool bPressed[MAXPLAYERS+1] = {false,...}; ... public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) { if(buttons & IN_ATTACK || buttons & IN_USE) bPressed[client] = true; //нажата E или ЛКМ else bPressed[client] = false; return Plugin_Continue; } ... ... if(bPressed[client1] || bPressed[client2] && GetClientTeam(client1) == GetClientTeam(client2)) { ... }
C-подобный:
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2])
{
if(buttons & IN_USE)
bPressed[client] = true;
else
bPressed[client] = false;
for(new i = 1; i <= MaxClients; i++) for(new i2 = 1; i2 <= MaxClients; i2++) if(IsClientInGame(i) && IsPlayerAlive(i) if(IsClientInGame(i2) && IsPlayerAlive(i2))
if(bPressed[i] || bPressed[i2] && GetClientTeam(i) == GetClientTeam(i2))
SetEntData(client, g_iCollisionGroup, 5, 4, true);
else
SetEntData(client, g_iCollisionGroup, 2, 4, true);
return Plugin_Continue;
}