/*
* This is "AMX Jump Cup V1.0" by Juzam Djinn
* This file is provided as is (no warranties).
* This plugin manages the jump cup.
*
* Commands:
*
* say /poscheck - displays a menue to check the finish positions of the climbers
* say /admincup - displays the admin menue for the Climb cup
*
*
* Last updated on: Juni 19, 2004
*/
#include <amxmod>
#include <amxmisc>
#define CUP_DEFAULT_TIME 300
#define CUP_STATUS_NONE 0
#define CUP_STATUS_RUNNING 1
#define CUP_STATUS_FINISHED 2
#define CUP_VOICE_FEMALE 0
#define CUP_VOICE_MALE 1
#define CUP_START_COUNTDOWN 10
#define ACCESS_LEVEL ADMIN_LEVEL_A
new jc_pluginname[] = "Jump Cup"
new announc_interval
new announc_voice
new announcments
new cup_time
new cup_start_time // the time when the cup started
new cup_status // the cup status (none, running or finished)
new cup_start_id // the starte of the cup
new cup_start_countdown
new cup_rr_start
new cup_rr_end
new cup_god_mode
new finish_locs[33][3] // the locs from the climbers when climbtime is 0 (the finish loc)
new climber[33][33] // the climbers name
new climbers // the number of climbers
new menupos[33]
public plugin_init() {
register_plugin(jc_pluginname,"1.0","Juzam Djinn")
register_clcmd("say /poscheck","jc_menu",0," - displays a menue to check the finish positions of the climbers")
register_menucmd(register_menuid("\yPos check menue"),1023,"action_cup_menu")
register_clcmd("say /admincup","jc_amenu", ACCESS_LEVEL, " - displays the admin menue for the climb cup")
register_menucmd(register_menuid("\yCup admin menu"),1023,"action_cup_amenu")
cup_status = CUP_STATUS_NONE
cup_time = CUP_DEFAULT_TIME
announc_interval = 30
announc_voice = CUP_VOICE_MALE
cup_start_countdown = CUP_START_COUNTDOWN
cup_rr_start = 0
cup_rr_end = 1
cup_god_mode = 2
return PLUGIN_CONTINUE
}
public action_cup_menu(id,key) {
if( cup_status != CUP_STATUS_FINISHED )
return PLUGIN_HANDLED
switch(key){
case 8: display_cup_menu(id,++menupos[id])
case 9: display_cup_menu(id,--menupos[id])
default:{
set_user_origin( id, finish_locs[menupos[id]*8+key] )
client_print(id,print_chat,"[%s] You have been teleported to the finish position of climber ^"%s^".", jc_pluginname, climber[menupos[id]*8+key] )
display_cup_menu( id, menupos[id] )
}
}
return PLUGIN_HANDLED
}
loc_is_set(i) {
if( finish_locs[i][0] != 0 && finish_locs[i][1] != 0 && finish_locs[i][2] != 0 )
return 1
return 0
}
display_cup_menu(id, pos) {
if( pos < 0 )
return
if( cup_status != CUP_STATUS_FINISHED ) {
client_print(id,print_chat,"[%s] Cup-menu is only available when the climb cup has finished.", jc_pluginname )
return
}
new page = pos + 1
new pages = (climbers /
+ ((climbers % 8 ) ? 1 : 0)
new i = pos * 8
new keys = (1<<9)
new key = 0
new menuBody[512]
new len = format(menuBody, 511, "\yPos check menue\R%d/%d^n\w^n", page, pages )
while( !equal( climber[i], "" ) && key < 8 ){
if( loc_is_set(i) ) {
keys |= (1<<key)
key++
len += format( menuBody[len], 511-len, "%d. %s^n\w",key,climber[i])
}
else {
key++
len += format( menuBody[len], 511-len, "\d%d. %s^n\w",key,climber[i])
}
i++
}
if ( page != pages )
{
len += format(menuBody[len],511-len,"^n9. More...^n0. Back")
keys |= (1<<
}
else
{
len += format(menuBody[len],511-len,"^n0. Back")
}
show_menu( id, keys, menuBody )
}
public jc_menu(id,level,cid) {
display_cup_menu( id, menupos[id] = 0 )
return PLUGIN_HANDLED
}
public action_cup_amenu(id,key) {
switch(key){
case 0: jc_start_cup(id)
case 1: {
cup_time += 60
if( cup_time > 900 )
cup_time = 60
display_cup_amenu( id, 0 )
}
case 2: {
announc_interval += 15
if( announc_interval > 180 )
announc_interval = 15
display_cup_amenu( id, 0 )
}
case 3: {
announc_voice = (announc_voice == CUP_VOICE_FEMALE ? CUP_VOICE_MALE : CUP_VOICE_FEMALE)
display_cup_amenu( id, 0 )
}
case 4: {
cup_rr_start = (cup_rr_start ? 0 : 1)
display_cup_amenu( id, 0 )
}
case 5: {
cup_rr_end = (cup_rr_end ? 0 : 1)
display_cup_amenu( id, 0 )
}
case 6: {
cup_god_mode++;
if( cup_god_mode >= 3 )
cup_god_mode = 0
display_cup_amenu( id, 0 )
}
case 7: {
for( new i = 0 ; i < 33; i++) {
finish_locs[i][0] = 0
finish_locs[i][1] = 0
finish_locs[i][2] = 0
climber[i] = ""
}
cup_status = CUP_STATUS_NONE
display_cup_amenu( id, 0 )
}
default:{
display_cup_amenu( id, -1 )
}
}
return PLUGIN_HANDLED
}
display_cup_amenu(id, pos) {
if( pos < 0 )
return
new keys = (1<<9)
new key = 0
new menuBody[512]
new len = format(menuBody, 511, "\yCup admin menu\R^n\w^n" )
keys |= (1<<key)
key++
len += format( menuBody[len], 511-len, "%d. Start Climb Cup.^n\w", key )
keys |= (1<<key)
key++
len += format( menuBody[len], 511-len, "%d. Cup Time: %d:%02d min^n\w", key, (cup_time / 60), (cup_time % 60) )
keys |= (1<<key)
key++
len += format( menuBody[len], 511-len, "%d. Announc interval: %d sec^n\w", key, announc_interval )
keys |= (1<<key)
key++
len += format( menuBody[len], 511-len, "%d. Announc voice: %s^n\w", key, announc_voice == CUP_VOICE_FEMALE ? "Female" : "Male" )
keys |= (1<<key)
key++
len += format( menuBody[len], 511-len, "%d. Start Cup with restartround: %s^n\w", key, cup_rr_start ? "on" : "off" )
keys |= (1<<key)
key++
len += format( menuBody[len], 511-len, "%d. End Cup with restartround: %s^n\w", key, cup_rr_end ? "on" : "off" )
keys |= (1<<key)
key++
//len += format( menuBody[len], 511-len, "%d. Give Climers God-Mode on Start: %s^n\w", key, cup_god_mode ? "on" : "off" )
switch( cup_god_mode ) {
case 0: len += format( menuBody[len], 511-len, "%d. Give Climers God-Mode on Start: off^n\w", key )
case 1: len += format( menuBody[len], 511-len, "%d. Give Climers God-Mode on Start: on (amx_godmode)^n\w", key )
case 2: len += format( menuBody[len], 511-len, "%d. Give Climers God-Mode on Start: on (admin_godmode)^n\w", key )
}
keys |= (1<<key)
key++
len += format( menuBody[len], 511-len, "%d. Erase finish locs^n\w", key )
len += format(menuBody[len],511-len,"^n0. Back")
show_menu( id, keys, menuBody )
}
public jc_amenu(id,level,cid) {
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
display_cup_amenu( id, 0 )
return PLUGIN_HANDLED
}
public say_time_remaining( time ) {
if( time < 0 )
return
new secs = time % 60
new mins = time / 60
new time_str[128]
new say_str[128]
new voice[6]
if( announc_voice == CUP_VOICE_FEMALE )
voice = "fvox"
else
voice = "vox"
if( time < 11 ) {
format( time_str, 127, "%d", secs )
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, 1)
new sec_str[32]
num_to_word(secs,sec_str,31)
format( say_str,127,"spk ^"%s/%s^"", voice, sec_str )
}
else {
format( time_str, 127, "Time remaining: %d:%02d", mins, secs )
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, 1)
new sec_str[32]
num_to_word(secs,sec_str,31)
if( mins != 0 ) {
new min_str[32]
num_to_word(mins,min_str,31)
if( secs != 0 )
format( say_str, 127,"spk ^"%s/%sminutes %sseconds remaining ^"", voice, min_str, sec_str )
else
format( say_str, 127,"spk ^"%s/%sminutes remaining ^"", voice, min_str )
}
else
format( say_str, 127,"spk ^"%s/%sseconds remaining ^"", voice, sec_str )
}
show_hudmessage(0,time_str)
client_cmd(0,say_str)
}
public time_remaining() {
if( cup_start_time < 0)
cup_start_time = get_user_time(cup_start_id)
new climb_time = get_user_time(cup_start_id) - cup_start_time
new left_time = cup_time - climb_time
if( (announc_interval * announcments) <= climb_time ) {
announcments++
say_time_remaining( left_time )
}
if( left_time < 11 )
say_time_remaining( left_time )
if( left_time < 0 )
jc_finish_cup()
}
public start_countdown() {
say_time_remaining( cup_start_countdown )
cup_start_countdown--
if( cup_start_countdown <= 0 ) {
client_print(0,print_chat,"[%s] Jump Cup has benn started!", jc_pluginname )
remove_task(863845
set_task(1.0,"time_remaining",8638459,"",0,"b ")
}
}
public enable_godmode() {
if( cup_god_mode ) {
new players[32], inum
get_players(players,inum)
for(new i = 0; i < inum; ++i) {
new command[128], name[32]
get_user_name(players[i],name,31)
format( command, 127, "admin_godmode ^"%s^" on", name )
switch( cup_god_mode ) {
case 1: set_user_godmode(players[i], 1 )
case 2: client_cmd( cup_start_id, command )
}
}
client_print(0,print_chat,"[%s] God Mode has been enabled on all climbers!", jc_pluginname )
}
}
public jc_start_cup(id) {
for( new i = 0 ; i < 33; i++) {
finish_locs[i][0] = 0
finish_locs[i][1] = 0
finish_locs[i][2] = 0
climber[i] = ""
}
cup_start_id = id
cup_start_time = -1
cup_status = CUP_STATUS_RUNNING
announcments = 0
if( cup_rr_start ) {
set_cvar_string( "sv_restartround", "1")
set_task(1.0,"time_remaining",8638459,"",0,"b ")
client_print(0,print_chat,"[%s] Jump Cup has benn started!", jc_pluginname )
}
else {
cup_start_countdown = CUP_START_COUNTDOWN
set_task(1.0,"start_countdown",8638458,"",0," b")
client_print(0,print_chat,"[%s] Jump Cup will start in %d seconds!", jc_pluginname, cup_start_countdown )
}
set_task(2.5,"enable_godmode",8638457,"",0)
return PLUGIN_HANDLED
}
public jc_finish_cup() {
remove_task(8638459)
new players[32]
get_players(players,climbers)
for(new i = 0; i < climbers; ++i) {
if( is_user_alive(players[i]) )
get_user_origin(players[i], finish_locs[i], 0 )
get_user_name(players[i],climber[i],31)
}
cup_status = CUP_STATUS_FINISHED
if( cup_rr_end )
set_cvar_string( "sv_restartround", "1")
client_print(0,print_chat,"[%s] Jump Cup has ended. say /poscheck to check the finish positions!", jc_pluginname )
}