Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <zombie_escape>
- #include <xs>
- #define IsInSafeZone(%0) bool:(is_user_alive(%0) && !ze_is_user_zombie(%0) && g_bIsInSafeZone[%0])
- #define SAFEZONE_CLASSNAME "custom_safezone"
- #define ADMIN_ACCESS ADMIN_RCON
- #define TASK_BASIS_SHOWZONES 1000
- new const g_szSafeZoneDir[] = "ze_safezones"
- static const szCoordsNames[3][] =
- {
- "X-Coordinates",
- "Y-Coordinates",
- "Z-Coordinates"
- }
- const OFFSET_CSMENUCODE = 205
- const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
- new bool:g_bIsInSafeZone[33] = false,
- Float:g_flEscapeTime = 10.0,
- g_iDirection = 0,
- g_iStepUnits = 10,
- g_iEditorId = 0,
- g_iSpriteDot
- public plugin_precache()
- {
- g_iSpriteDot = precache_model("sprites/dot.spr")
- precache_model("models/gib_skull.mdl")
- }
- public plugin_init()
- {
- register_plugin("[ZE] Addons: Safe Zone", "1.0", "Jack")
- RegisterHam(Ham_Touch, "trigger_hurt", "Fw_TouchTrigger_Pre", 0)
- RegisterHam(Ham_Touch, "info_target", "Fw_TouchSafeZone_Post", 0)
- register_clcmd("szm", "OpenSafeZoneMenu", ADMIN_ACCESS, " - Open the safezone menu")
- register_menu("Safe Zone Menu", KEYSMENU, "MainHandler")
- register_menu("Edit Zone Menu", KEYSMENU, "EditHandler")
- register_menu("Delete Zone Menu", KEYSMENU, "DeleteHandler")
- set_task(0.1, "LoadZoneTask")
- }
- public LoadZoneTask()
- {
- LoadZone()
- }
- public Fw_TouchTrigger_Pre(iEnt, id)
- {
- if(!is_user_alive(id) || !pev_valid(iEnt))
- return HAM_IGNORED
- if (pev(iEnt, pev_dmg) > 8000)
- {
- return HAM_SUPERCEDE
- }
- return HAM_IGNORED
- }
- public Fw_TouchSafeZone_Post(iEnt, id)
- {
- if (g_iEditorId)
- return HAM_IGNORED
- if (!is_entity(iEnt))
- return HAM_IGNORED
- if (!FClassnameIs(iEnt, SAFEZONE_CLASSNAME))
- return HAM_IGNORED
- if (!FClassnameIs(id, "player"))
- return HAM_IGNORED
- g_bIsInSafeZone[id] = true
- return HAM_IGNORED
- }
- public client_disconnected(id)
- {
- if (id == g_iEditorId)
- HideTheZone()
- }
- public OpenSafeZoneMenu(id)
- {
- if (!(get_user_flags(id) & ADMIN_ACCESS))
- {
- console_print(id, "You have no access.")
- return PLUGIN_HANDLED
- }
- g_iEditorId = id
- if (rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME) > 0)
- ShowTheZone()
- ShowSafeZoneMenu(id)
- return PLUGIN_HANDLED
- }
- ShowSafeZoneMenu(id)
- {
- static szMenu[250]
- new iLen, iEnt
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\rSafe Zone Menu^n^n")
- iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- if (iEnt > 0)
- {
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. Create safe zone^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y2\d. \wEdit current safe zone^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y3\d. \wDelete current zone^n")
- }
- else
- {
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y1\d. \wCreate safe zone^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. Edit current safe zone^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d3. Delete current zone^n")
- }
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y4\d. \wSave all zones^n^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y0\d. \r%L", id, "EXIT")
- set_pdata_int(id, OFFSET_CSMENUCODE, 0)
- show_menu(id, KEYSMENU, szMenu, -1, "Safe Zone Menu")
- }
- public MainHandler(id, key)
- {
- if (key == MENU_EXIT)
- {
- HideTheZone()
- return
- }
- new iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- switch(key)
- {
- case 0: // Create safe zone
- {
- if (iEnt <= 0)
- {
- CreateZone(id)
- MainHandler(id, 1)
- }
- else
- {
- ze_colored_print(id, "There is already an existing safe zone.")
- ShowSafeZoneMenu(id)
- }
- }
- case 1: // Edit safe zone
- {
- if (iEnt > 0)
- {
- OpenEditMenu(id)
- ShowTheZone()
- }
- else
- {
- ze_colored_print(id, "There are no existing safe zones.")
- ShowSafeZoneMenu(id)
- }
- }
- case 2:
- {
- if (iEnt > 0)
- {
- OpenKillMenu(id)
- }
- else
- {
- ze_colored_print(id, "There are no existing safe zones.")
- ShowSafeZoneMenu(id)
- }
- }
- case 3:
- {
- if (iEnt > 0)
- {
- if (SaveZone())
- ze_colored_print(id, "Zone has been saved.")
- }
- else
- ze_colored_print(id, "There are no zones to save.")
- ShowSafeZoneMenu(id)
- }
- }
- }
- ShowTheZone()
- {
- new iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- remove_task(TASK_BASIS_SHOWZONES + iEnt)
- set_entvar(iEnt, var_solid, SOLID_NOT)
- set_task(0.2, "ShowZoneBox", TASK_BASIS_SHOWZONES + iEnt, _, _, "b")
- }
- public ShowZoneBox(taskid)
- {
- new iEnt = taskid - TASK_BASIS_SHOWZONES
- if (!is_entity(iEnt) || g_iEditorId < 1)
- return
- new Float:flPos[3]
- get_entvar(iEnt, var_origin, flPos)
- if (!fm_is_in_viewcone(g_iEditorId, flPos))
- return
- new Float:flEditorPos[3], Float:flHitPoint[3]
- get_entvar(g_iEditorId, var_origin, flEditorPos)
- fm_trace_line(-1, flEditorPos, flPos, flHitPoint)
- // Line from the center of the entity to the creator of it
- DrawLine(flEditorPos[0], flEditorPos[1], flEditorPos[2] - 16.0, flPos[0], flPos[1], flPos[2], {255, 0, 0})
- new Float:flDH = vector_distance(flEditorPos, flPos) - vector_distance(flEditorPos, flHitPoint)
- if (floatabs(flDH) > 128.0)
- return
- new Float:flMins[3], Float:flMaxs[3]
- get_entvar(iEnt, var_mins, flMins)
- get_entvar(iEnt, var_maxs, flMaxs)
- for (new i = 0; i < 3; i++)
- {
- flMins[i] += flPos[i]
- flMaxs[i] += flPos[i]
- }
- new color[3]
- color[0] = 255
- color[1] = 0
- color[2] = 255
- // Sides of the created shape
- DrawLine(flMaxs[0], flMaxs[1], flMaxs[2], flMins[0], flMaxs[1], flMaxs[2], color)
- DrawLine(flMaxs[0], flMaxs[1], flMaxs[2], flMaxs[0], flMins[1], flMaxs[2], color)
- DrawLine(flMaxs[0], flMaxs[1], flMaxs[2], flMaxs[0], flMaxs[1], flMins[2], color)
- DrawLine(flMins[0], flMins[1], flMins[2], flMaxs[0], flMins[1], flMins[2], color)
- DrawLine(flMins[0], flMins[1], flMins[2], flMins[0], flMaxs[1], flMins[2], color)
- DrawLine(flMins[0], flMins[1], flMins[2], flMins[0], flMins[1], flMaxs[2], color)
- DrawLine(flMins[0], flMaxs[1], flMaxs[2], flMins[0], flMaxs[1], flMins[2], color)
- DrawLine(flMins[0], flMaxs[1], flMins[2], flMaxs[0], flMaxs[1], flMins[2], color)
- DrawLine(flMaxs[0], flMaxs[1], flMins[2], flMaxs[0], flMins[1], flMins[2], color)
- DrawLine(flMaxs[0], flMins[1], flMins[2], flMaxs[0], flMins[1], flMaxs[2], color)
- DrawLine(flMaxs[0], flMins[1], flMaxs[2], flMins[0], flMins[1], flMaxs[2], color)
- DrawLine(flMins[0], flMins[1], flMaxs[2], flMins[0], flMaxs[1], flMaxs[2], color)
- // Tendon of the active coodinates
- switch(g_iDirection)
- {
- case 0: // X-Coordinates
- {
- DrawLine(flMaxs[0], flMaxs[1], flMaxs[2], flMaxs[0], flMins[1], flMins[2], { 255, 255, 0 })
- DrawLine(flMaxs[0], flMaxs[1], flMins[2], flMaxs[0], flMins[1], flMaxs[2], { 255, 255, 0 })
- DrawLine(flMins[0], flMaxs[1], flMaxs[2], flMins[0], flMins[1], flMins[2], { 255, 0, 0 })
- DrawLine(flMins[0], flMaxs[1], flMins[2], flMins[0], flMins[1], flMaxs[2], { 255, 0, 0 })
- }
- case 1: // Y-Coordinates
- {
- DrawLine(flMins[0], flMins[1], flMins[2], flMaxs[0], flMins[1], flMaxs[2], { 255, 0, 0 })
- DrawLine(flMaxs[0], flMins[1], flMins[2], flMins[0], flMins[1], flMaxs[2], { 255, 0, 0 })
- DrawLine(flMins[0], flMaxs[1], flMins[2], flMaxs[0], flMaxs[1], flMaxs[2], { 255, 255, 0 })
- DrawLine(flMaxs[0], flMaxs[1], flMins[2], flMins[0], flMaxs[1], flMaxs[2], { 255, 255, 0 })
- }
- case 2: // Z-Coordinates
- {
- DrawLine(flMaxs[0], flMaxs[1], flMaxs[2], flMins[0], flMins[1], flMaxs[2], { 255, 255, 0 })
- DrawLine(flMaxs[0], flMins[1], flMaxs[2], flMins[0], flMaxs[1], flMaxs[2], { 255, 255, 0 })
- DrawLine(flMaxs[0], flMaxs[1], flMins[2], flMins[0], flMins[1], flMins[2], { 255, 0, 0 })
- DrawLine(flMaxs[0], flMins[1], flMins[2], flMins[0], flMaxs[1], flMins[2], { 255, 0, 0 })
- }
- }
- }
- HideTheZone()
- {
- g_iEditorId = 0
- new iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- remove_task(TASK_BASIS_SHOWZONES + iEnt)
- set_entvar(iEnt, var_solid, SOLID_TRIGGER)
- }
- CreateZone(id)
- {
- new Float:flPos[3]
- get_entvar(id, var_origin, flPos)
- CreateNewZone(flPos)
- }
- CreateNewZone(Float:flPos[3])
- {
- new Float:flMins[3] = { -32.0, -32.0, -32.0 }
- new Float:flMaxs[3] = { 32.0, 32.0, 32.0 }
- ShowZone(flPos, flMins, flMaxs)
- }
- ShowZone(Float:flPos[3], Float:flMins[3], Float:flMaxs[3])
- {
- new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
- set_entvar(iEnt, var_classname, SAFEZONE_CLASSNAME)
- set_entvar(iEnt, var_model, "models/gib_skull.mdl")
- set_entvar(iEnt, var_origin, flPos)
- set_entvar(iEnt, var_movetype, MOVETYPE_FLY)
- set_entvar(iEnt, var_solid, (g_iEditorId > 0) ? SOLID_NOT : SOLID_TRIGGER)
- engfunc(EngFunc_SetSize, iEnt, flMins, flMaxs)
- set_pev(iEnt, pev_effects, pev(iEnt, pev_effects) | EF_NODRAW)
- }
- OpenEditMenu(id)
- {
- static szMenu[300]
- new iLen
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\rSafe Zone Menu\d:^n\rEdit current menu^n^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y1\d. \wEscape time\d: \r%.1f^n", g_flEscapeTime)
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y2\d. \wLess^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y3\d. \wMore^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y4\d. \wChange size over\d: \r%s^n", szCoordsNames[g_iDirection])
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y5\d. \wStrip^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y6\d. \wWiden^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y7\d. \wStrip^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y8\d. \wWiden^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y9\d. \wIncreament \r%i \wunits^n^n", g_iStepUnits)
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y0\d. \r%L", id, "BACK")
- set_pdata_int(id, OFFSET_CSMENUCODE, 0)
- show_menu(id, KEYSMENU, szMenu, -1, "Edit Zone Menu")
- }
- public EditHandler(id, key)
- {
- switch(key)
- {
- case 0: OpenEditMenu(id) // Useless
- case 1: // Increase escape time
- {
- g_flEscapeTime -= 1.0
- OpenEditMenu(id)
- }
- case 2: // Decrease escape time
- {
- g_flEscapeTime += 1.0
- OpenEditMenu(id)
- }
- case 3: // Change size over coordinates
- {
- g_iDirection = (g_iDirection < 2) ? g_iDirection + 1 : 0
- OpenEditMenu(id)
- }
- case 4: // Decrease the mins
- {
- DecreaseMins()
- OpenEditMenu(id)
- }
- case 5: // Increase the mins
- {
- IncreaseMins()
- OpenEditMenu(id)
- }
- case 6: // Decrease the maxs
- {
- DecreaseMaxs()
- OpenEditMenu(id)
- }
- case 7: // Increase the maxs
- {
- IncreaseMaxs()
- OpenEditMenu(id)
- }
- case 8: // Change unit
- {
- g_iStepUnits = (g_iStepUnits < 100) ? g_iStepUnits * 10 : 1
- OpenEditMenu(id)
- }
- default: // Leave
- {
- ShowSafeZoneMenu(id)
- }
- }
- }
- DecreaseMins()
- {
- new iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- new Float:flPos[3], Float:flMins[3], Float:flMaxs[3]
- get_entvar(iEnt, var_origin, flPos)
- get_entvar(iEnt, var_mins, flMins)
- get_entvar(iEnt, var_maxs, flMaxs)
- if ((floatabs(flMins[g_iDirection]) + flMaxs[g_iDirection]) < g_iStepUnits + 1)
- return
- flMins[g_iDirection] += float(g_iStepUnits) / 2.0
- flMaxs[g_iDirection] -= float(g_iStepUnits) / 2.0
- flPos[g_iDirection] += float(g_iStepUnits) / 2.0
- set_entvar(iEnt, var_origin, flPos)
- engfunc(EngFunc_SetSize, iEnt, flMins, flMaxs)
- }
- IncreaseMins()
- {
- new iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- new Float:flPos[3], Float:flMins[3], Float:flMaxs[3]
- get_entvar(iEnt, var_origin, flPos)
- get_entvar(iEnt, var_mins, flMins)
- get_entvar(iEnt, var_maxs, flMaxs)
- flPos[g_iDirection] -= float(g_iStepUnits) / 2.0
- flMins[g_iDirection] -= float(g_iStepUnits) / 2.0
- flMaxs[g_iDirection] += float(g_iStepUnits) / 2.0
- set_entvar(iEnt, var_origin, flPos)
- engfunc(EngFunc_SetSize, iEnt, flMins, flMaxs)
- }
- DecreaseMaxs()
- {
- new iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- new Float:flPos[3], Float:flMins[3], Float:flMaxs[3]
- get_entvar(iEnt, var_origin, flPos)
- get_entvar(iEnt, var_mins, flMins)
- get_entvar(iEnt, var_maxs, flMaxs)
- if ((floatabs(flMins[g_iDirection]) + flMaxs[g_iDirection]) < g_iStepUnits + 1)
- return
- flMins[g_iDirection] += float(g_iStepUnits) / 2.0
- flMaxs[g_iDirection] -= float(g_iStepUnits) / 2.0
- flPos[g_iDirection] -= float(g_iStepUnits) / 2.0
- set_entvar(iEnt, var_origin, flPos)
- engfunc(EngFunc_SetSize, iEnt, flMins, flMaxs)
- }
- IncreaseMaxs()
- {
- new iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- new Float:flPos[3], Float:flMins[3], Float:flMaxs[3]
- get_entvar(iEnt, var_origin, flPos)
- get_entvar(iEnt, var_mins, flMins)
- get_entvar(iEnt, var_maxs, flMaxs)
- flMins[g_iDirection] -= float(g_iStepUnits) / 2.0
- flMaxs[g_iDirection] += float(g_iStepUnits) / 2.0
- flPos[g_iDirection] += float(g_iStepUnits) / 2.0
- set_entvar(iEnt, var_origin, flPos)
- engfunc(EngFunc_SetSize, iEnt, flMins, flMaxs)
- }
- OpenKillMenu(id)
- {
- static szMenu[300]
- new iLen
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\rDelete current zone\d?^n^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y1\d. \wYes, delete^n^n")
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y0\d. \rNo, back")
- set_pdata_int(id, OFFSET_CSMENUCODE, 0)
- show_menu(id, KEYSMENU, szMenu, -1, "Delete Zone Menu")
- }
- public DeleteHandler(id, key)
- {
- switch(key)
- {
- case 0: // Zone deleted
- {
- engfunc(EngFunc_RemoveEntity, rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME))
- DeleteZone()
- ze_colored_print(id, "Zone has been deleted.")
- }
- case MENU_EXIT: ze_colored_print(id, "Zone has not been deleted.") // Zone not deleted
- }
- ShowSafeZoneMenu(id)
- }
- SaveZone()
- {
- new szConfigPath[50], szFilePath[50]
- get_configsdir(szConfigPath, charsmax(szConfigPath))
- formatex(szFilePath, charsmax(szFilePath), "%s/%s", szConfigPath, g_szSafeZoneDir)
- if (!dir_exists(szFilePath))
- mkdir(szFilePath)
- new szMapName[50], szZoneFile[100], szLine[100]
- get_mapname(szMapName, charsmax(szMapName))
- formatex(szZoneFile, charsmax(szZoneFile), "%s/%s.sz", szFilePath, szMapName)
- if (file_exists(szZoneFile))
- delete_file(szZoneFile)
- new iFileHandle = fopen(szZoneFile, "wt")
- if (!iFileHandle)
- {
- set_fail_state("Couldn't open %s.", szZoneFile)
- return false
- }
- new Float:flPos[3], Float:flMins[3], Float:flMaxs[3]
- new iEnt = rg_find_ent_by_class(-1, SAFEZONE_CLASSNAME)
- get_entvar(iEnt, var_origin, flPos)
- get_entvar(iEnt, var_mins, flMins)
- get_entvar(iEnt, var_maxs, flMaxs)
- formatex(szLine, charsmax(szLine),
- "%.1f %.1f %.1f %.0f %.0f %.0f %.0f %.0f %.0f %.1f",
- flPos[0], flPos[1], flPos[2],
- flMins[0], flMins[1], flMins[2],
- flMaxs[0], flMaxs[1], flMaxs[2],
- g_flEscapeTime)
- fputs(iFileHandle, szLine)
- fclose(iFileHandle)
- return true
- }
- LoadZone()
- {
- new szConfigPath[25], szZoneFile[40], szMapName[40]
- get_configsdir(szConfigPath, charsmax(szConfigPath))
- get_mapname(szMapName, charsmax(szMapName))
- formatex(szZoneFile, charsmax(szZoneFile), "%s/%s/%s.sz", szConfigPath, g_szSafeZoneDir, szMapName)
- if (file_exists(szZoneFile))
- {
- new iFileHandle = fopen(szZoneFile, "rt")
- if (!iFileHandle)
- {
- set_fail_state("Couldn't open %s.", szZoneFile)
- return
- }
- new iLine, szLine[40], iLen,
- szMins[3][10], szMaxs[3][10], szPos[3][10], szEscapetime[5],
- Float:flPos[3], Float:flMins[3], Float:flMaxs[3]
- while ((iLine = read_file(szZoneFile, iLine, szLine, charsmax(szLine)), iLen) != 0)
- {
- if (!strlen(szLine) || szLine[0] == ';')
- continue
- parse(szLine,
- szPos[0], charsmax(szPos[]),
- szPos[1], charsmax(szPos[]),
- szPos[2], charsmax(szPos[]),
- szMins[0], charsmax(szMins[]),
- szMins[1], charsmax(szMins[]),
- szMins[2], charsmax(szMins[]),
- szMaxs[0], charsmax(szMaxs[]),
- szMaxs[1], charsmax(szMaxs[]),
- szMaxs[2], charsmax(szMaxs[]),
- szEscapetime, charsmax(szEscapetime))
- for (new i = 0; i < 3; i++)
- {
- flPos[i] = str_to_float(szPos[i])
- flMins[i] = str_to_float(szMins[i])
- flMaxs[i] = str_to_float(szMaxs[i])
- }
- g_flEscapeTime = str_to_float(szEscapetime)
- break
- }
- fclose(iFileHandle)
- }
- else
- {
- log_amx("No safe zones found")
- }
- }
- DeleteZone()
- {
- new szConfigPath[50], szFilePath[100], szMapName[50]
- get_configsdir(szConfigPath, charsmax(szConfigPath))
- get_mapname(szMapName, charsmax(szMapName))
- formatex(szFilePath, charsmax(szFilePath), "%s/%s/%s.sz", szConfigPath, g_szSafeZoneDir, szMapName)
- if (file_exists(szFilePath))
- delete_file(szFilePath)
- }
- DrawLine(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, color[3])
- {
- new flStart[3], flStop[3]
- flStart[0] = floatround(x1)
- flStart[1] = floatround(y1)
- flStart[2] = floatround(z1)
- flStop[0] = floatround(x2)
- flStop[1] = floatround(y2)
- flStop[2] = floatround(z2)
- FX_Line(flStart, flStop, color)
- }
- FX_Line(flStart[3], flStop[3], iColor[3])
- {
- message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, g_iEditorId)
- write_byte(TE_BEAMPOINTS)
- write_coord(flStart[0])
- write_coord(flStart[1])
- write_coord(flStart[2])
- write_coord(flStop[0])
- write_coord(flStop[1])
- write_coord(flStop[2])
- write_short(g_iSpriteDot)
- write_byte(1)
- write_byte(1)
- write_byte(4)
- write_byte(5)
- write_byte(0)
- write_byte(iColor[0])
- write_byte(iColor[1])
- write_byte(iColor[2])
- write_byte(200)
- write_byte(0)
- message_end()
- }
- stock bool:fm_is_in_viewcone(iEnt, const Float:flPoint[3])
- {
- new Float:flAngles[3]
- get_entvar(iEnt, var_angles, flAngles)
- engfunc(EngFunc_MakeVectors, flAngles)
- global_get(glb_v_forward, flAngles)
- flAngles[2] = 0.0
- new Float:flOrigin[3], Float:flDiff[3], Float:flNorm[3]
- get_entvar(iEnt, var_origin, flOrigin)
- xs_vec_sub(flPoint, flOrigin, flDiff)
- flDiff[2] = 0.0
- xs_vec_normalize(flDiff, flNorm)
- new Float:flDot, Float:flFov
- flDot = xs_vec_dot(flNorm, flAngles)
- get_entvar(iEnt, var_fov, flFov)
- if (flDot >= floatcos(flFov * M_PI / 360))
- return true
- return false
- }
- stock fm_trace_line(ignoreent, const Float:flStart[3], const Float:flEnd[3], Float:flRet[3])
- {
- engfunc(EngFunc_TraceLine, flStart, flEnd, ignoreent == -1 ? 1 : 0, ignoreent, 0)
- new iEnt = get_tr2(0, TR_pHit)
- get_tr2(0, TR_vecEndPos, flRet)
- return is_entity(iEnt) ? iEnt : 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement