Instrukcja w kodzie
//Na poczatku pluginu
enum Type {
DONT_IGNORE_TEAMMATES,
IGNORE_TEAMMATES
};
new g_sSprLaser;
//Dodajemy to do public plugin_precache()
g_sSprLaser = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr");
//To gdzie chcesz
stock createColouredLineByTeam(id, iTarget){
new Float:fOrigin[0x2][0x3], iColor[0x3];
pev(id, pev_origin, fOrigin[0]);
pev(iTarget, pev_origin, fOrigin[1]);
if(get_user_team(iTarget)==0x2)
iColor[2]=0xFF;
else
iColor[0]=0xFF;
message_begin(MSG_ONE, SVC_TEMPENTITY, {0x0, 0x0, 0x0}, id);
write_byte(0x0);
engfunc(EngFunc_WriteCoord, fOrigin[0x0][0x0]);
engfunc(EngFunc_WriteCoord, fOrigin[0x0][0x1]);
engfunc(EngFunc_WriteCoord, fOrigin[0x0][0x2]);
engfunc(EngFunc_WriteCoord, fOrigin[0x1][0x0]);
engfunc(EngFunc_WriteCoord, fOrigin[0x1][0x1]);
engfunc(EngFunc_WriteCoord, fOrigin[0x1][0x2]);
write_short(g_sSprLaser);
write_byte(0x3);
write_byte(0x0);
write_byte(0x1);
write_byte(0xA);
write_byte(0x0);
write_byte(iColor[0x0]);
write_byte(iColor[0x1]);
write_byte(iColor[0x2]);
write_byte(0x40);
write_byte(0x0);
message_end();
}
stock getClosestPlayer(id, Type:ignoreteammates){
new iPlayers[0x20], Float:flClosestDist = 9999.9, Float:flDist, Float:fOrigin[0x2][0x3], iNum, iPlayer, iClosestPlayer;
ignoreteammates ? get_players(iPlayers, iNum, "ache", get_user_team(id) == 2 ? "TERRORIST" : "CT") : get_players(iPlayers, iNum, "ach");
for(new i = 0; i < iNum; i++){
iPlayer = iPlayers[i];
pev(iPlayer, pev_origin, fOrigin[0x0]);
pev(id, pev_origin, fOrigin[0x1]);
flDist = get_distance_f(fOrigin[0x0], fOrigin[0x1]);
if(flDist <= flClosestDist){
iClosestPlayer = iPlayer;
flClosestDist = flDist;
}
}
if(is_user_alive(iClosestPlayer))
return iClosestPlayer;
return -1;
}
//A to nasz action
actionGps(id){
new iClosestEnemy = getClosestPlayer(id, IGNORE_TEAMMATES);
if(is_user_alive(iClosestEnemy))
createColouredLineByTeam(id, iClosestEnemy);
else{
set_hudmessage(255, 255, 255, 0.03, 0.34, 0, 0.1, 0.1, 0.2, 0.2);
show_hudmessage(id, "Brak zadnych przeciwnikow w zasiegu");
}
}