enum
{
PRISONER_NORMAL = 0,
PRISONER_FREEDOM,
PRISONER_WANTED
}
new g_jaildoor_button[10], Trie:g_jaildoor_manager, g_precachekey_foward
public plugin_init()
{
// Forward
unregister_forward(FM_KeyValue, g_precachekey_foward)
set_jaildoor_config()
}
public plugin_precache()
{
g_jaildoor_manager = TrieCreate()
g_precachekey_foward = register_forward(FM_KeyValue, "precache_keyvalue", 1)
}
public precache_keyvalue(ent, kvd_handle)
{
new info[32]
if(!is_valid_ent(ent))
return FMRES_IGNORED
get_kvd(kvd_handle, KV_ClassName, info, charsmax(info))
if(!equal(info, "multi_manager"))
return FMRES_IGNORED
get_kvd(kvd_handle, KV_KeyName, info, charsmax(info))
TrieSetCell(g_jaildoor_manager, info, ent)
return FMRES_IGNORED
}
public set_jaildoor_config()
{
new ent[3]
new Float:origin[3]
new info[32]
new pos
while((pos <= sizeof(g_jaildoor_button)) && (ent[0] = engfunc(EngFunc_FindEntityByString, ent[0], "classname", "info_player_deathmatch")))
{
pev(ent[0], pev_origin, origin)
while((ent[1] = engfunc(EngFunc_FindEntityInSphere, ent[1], origin, 200.0)))
{
if(!is_valid_ent(ent[1]))
continue
entity_get_string(ent[1], EV_SZ_classname, info, charsmax(info))
if(!equal(info, "func_door"))
continue
entity_get_string(ent[1], EV_SZ_targetname, info, charsmax(info))
if(!info[0])
continue
if(TrieKeyExists(g_jaildoor_manager, info))
{
TrieGetCell(g_jaildoor_manager, info, ent[2])
}
else
{
ent[2] = engfunc(EngFunc_FindEntityByString, 0, "target", info)
}
if(is_valid_ent(ent[2]) && (in_array(ent[2], g_jaildoor_button, sizeof(g_jaildoor_button)) < 0))
{
g_jaildoor_button[pos] = ent[2]
pos++
break
}
}
}
TrieDestroy(g_jaildoor_manager)
}
public client_putinserver(id)
{
if(!is_user_connected(id))
return
g_isalive[id] = 0
set_task(1.0, "show_jail_hud", id+TASK_HUD1, _, _, "b")
}
public show_jail_hud(id)
{
id -= TASK_HUD1
new TimeType[10]
if(!custom_day)
{
if(g_time < 18)
{
if(!g_wakeup)
{
format(TimeType, sizeof(TimeType), "Thuc day")
} else {
if(g_time < 12) format(TimeType, sizeof(TimeType), "Buoi sang")
else format(TimeType, sizeof(TimeType), "Buoi chieu")
}
} else {
format(TimeType, sizeof(TimeType), "Buoi toi")
}
} else {
format(TimeType, sizeof(TimeType), "Buoi toi")
}
if(g_jailday == ZOMBIE_DAY)
{
format(g_day_type, sizeof(g_day_type), "Zombie Day")
} else {
format(g_day_type, sizeof(g_day_type), "JailBreak")
}
if(!custom_day)
{
set_hudmessage(0, 255, 0, HUD_TIME_X, HUD_TIME_Y, 0, 1.5, 1.5)
ShowSyncHudMsg(id, g_hud_time, "%s - Ngay %i (%s - %i Gio)", g_day_type, g_jailday, TimeType, g_time)
} else {
set_hudmessage(0, 255, 0, HUD_TIME_X, HUD_TIME_Y, 0, 1.5, 1.5)
ShowSyncHudMsg(id, g_hud_time, "%s - Ngay %i (%s - %i Gio)", g_day_type, g_jailday, TimeType, g_time)
}
}
public set_prisoner_type(id, type)
{
if(g_sex[id] == SEX_MALE)
{
if(get_user_weapon(id) == CSW_KNIFE)
{
set_pev(id, pev_viewmodel2, prisoner_vmodel[type])
set_pev(id, pev_weaponmodel2, "")
}
set_pev(id, pev_body, PL_MALE_PRI)
if(type == PRISONER_NORMAL)
set_pev(id, pev_skin, SKIN_MALE_PRI_N)
else if(type == PRISONER_FREEDOM)
set_pev(id, pev_skin, SKIN_MALE_PRI_G)
else if(type == PRISONER_WANTED)
set_pev(id, pev_skin, SKIN_MALE_PRI_R)
} else if(g_sex[id] == SEX_FEMALE) {
if(get_user_weapon(id) == CSW_KNIFE)
{
set_pev(id, pev_viewmodel2, prisoner_vmodel[type])
set_pev(id, pev_weaponmodel2, "")
}
if(type == PRISONER_NORMAL)
set_pev(id, pev_body, PL_FEMALE_PRI_N)
else if(type == PRISONER_FREEDOM)
set_pev(id, pev_body, PL_FEMALE_PRI_G)
else if(type == PRISONER_WANTED)
set_pev(id, pev_body, PL_FEMALE_PRI_R)
}
}
public jail_open()
{
new i
for(i = 0; i < sizeof(g_jaildoor_button); i++)
{
if(g_jaildoor_button[i])
{
ExecuteHamB(Ham_Use, g_jaildoor_button[i], 0, 0, 1, 1.0)
entity_set_float(g_jaildoor_button[i], EV_FL_frame, 0.0)
}
}
}
public remove_all_door()
{
new classname[32]
for(new i = 0; i < entity_count(); i++)
{
if(pev_valid(i))
{
pev(i, pev_classname, classname, sizeof(classname))
if(equal(classname, "func_door"))
remove_entity(i)
}
}
}
public time_change(current_time)
{
if(custom_day)
return
set_lights(time_light[current_time])
if(current_time == AUTO_OPEN_TIME)
{
// Auto Open Jail Door
jail_open()
} else if(current_time == REAL_GAME_STARTED_TIME) {
g_real_game_started = 1
} else if(current_time == FREETIME_START || current_time == FREETIME2_START) {
remove_task(TASK_HUD_CMD)
stop_all_command()
g_freetime = 1
PlaySound(0, jailbreak_sound[SND_FREETIME_START])
// Show Notice
set_hudmessage(0, 255, 0, HUD_CMD_X, HUD_CMD_Y, 0, 7.0, 7.0)
if(current_time == FREETIME_START)
ShowSyncHudMsg(0, g_hud_cmd, "Den gio an trua. Tat ca tu nhan Free !!!")
else if(current_time == FREETIME2_START)
ShowSyncHudMsg(0, g_hud_cmd, "Den gio an toi. Tat ca tu nhan Free !!!")
for(new i = 0; i < g_maxplayers; i++)
{
if(g_isalive[i] && is_user_connected(i) && g_player_team[i] == TEAM_PRISONER && g_prisoner_type[i] != PRISONER_WANTED && g_freetime)
{
g_prisoner_type[i] = PRISONER_FREEDOM
set_prisoner_type(i, g_prisoner_type[i])
}
}
} else if(current_time == FREETIME_END || current_time == FREETIME2_END) {
g_freetime = 0
// Show Notice
set_hudmessage(0, 255, 0, HUD_CMD_X, HUD_CMD_Y, 0, 7.0, 7.0)
if(current_time == FREETIME_END)
{
PlaySound(0, jailbreak_sound[SND_FREETIME_END])
ShowSyncHudMsg(0, g_hud_cmd, "Da het an trua. Tat ca tu nhan quay lai trai giam !!!")
} else if(current_time == FREETIME2_END) {
PlaySound(0, jailbreak_sound[SND_DAY_END])
ShowSyncHudMsg(0, g_hud_cmd, "Da het gio an toi. Toi gio di ngu...")
}
for(new i = 0; i < g_maxplayers; i++)
{
if(g_isalive[i] && is_user_connected(i) && g_player_team[i] == TEAM_PRISONER && g_prisoner_type[i] != PRISONER_WANTED && !g_freetime)
{
g_prisoner_type[i] = PRISONER_NORMAL
set_prisoner_type(i, g_prisoner_type[i])
}
}
}
}
public fw_spawn_post(id)
{
if(!is_user_connected(id))
return HAM_IGNORED
// Set Player Visible (After use C4)
set_user_rendering(id)
g_isalive[id] = 1
g_had_c4[id] = 0
g_bombing[id] = 0
g_warden[id] = 0
g_setting_one_time[id] = 0
g_prisoner_type[id] = PRISONER_NORMAL
g_zombie[id] = 0
remove_task(id+TASK_EXPLOSION)
set_task(random_float(0.01, 0.03), "delay_spawn", id)
return HAM_HANDLED
}
public delay_spawn(id)
{
new current_model[32]
fm_cs_get_user_model(id, current_model, sizeof(current_model))
if(!equal(current_model, player_model))
fm_cs_set_user_model(id, player_model)
if(cs_get_user_team(id) == CS_TEAM_CT)
{
if(g_will_be[id] == PRISONER)
{
g_player_team[id] = TEAM_PRISONER
fm_cs_set_user_team(id, CS_TEAM_T, 1)
respawn_player(id)
return
}
player_strip_weapons(id)
g_player_team[id] = TEAM_JAILER
g_warden[id] = 0
set_user_health(id, JAILER_HEALTH)
set_user_armor(id, JAILER_ARMOR)
set_pev(id, pev_body, PL_JAILER)
display_equipmenu(id)
if(!g_setting_one_time[id])
{
set_task(1.0, "show_notice", id)
g_setting_one_time[id] = 1
}
} else if(cs_get_user_team(id) == CS_TEAM_T) {
if(g_will_be[id] == JAILER)
{
g_player_team[id] = TEAM_JAILER
fm_cs_set_user_team(id, CS_TEAM_CT, 1)
respawn_player(id)
return
}
player_strip_weapons(id)
g_was_ct[id] = 0
g_player_team[id] = TEAM_PRISONER
g_prisoner_type[id] = PRISONER_NORMAL
g_sex[id] = get_random_sex(id)
set_prisoner_type(id, g_prisoner_type[id])
set_user_health(id, PRISONER_HEALTH)
set_user_armor(id, PRISONER_ARMOR)
g_jail_reason[id] = random_num(0, charsmax(jail_reason))
if(!g_setting_one_time[id])
{
set_task(1.0, "show_notice", id)
set_task(1.0, "open_prisoner_shop", id)
g_setting_one_time[id] = 1
}
}
}