updated to use the multi-lingual system | better code style

This commit is contained in:
Felix Geyer
2004-08-06 18:40:41 +00:00
parent 80a32b6d08
commit a8dab8993e
6 changed files with 562 additions and 578 deletions

View File

@ -41,6 +41,7 @@ new g_Switch
public plugin_init() {
register_plugin("TimeLeft",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("timeleft.txt")
register_cvar("amx_time_voice","1")
register_srvcmd("amx_time_display","setDisplaying")
register_cvar("amx_timeleft","00:00",FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
@ -50,7 +51,7 @@ public plugin_init() {
}
public sayTheTime(id){
if ( get_cvar_num("amx_time_voice") ){
if ( get_cvar_num("amx_time_voice") ) {
new mhours[6], mmins[6], whours[32], wmins[32], wpm[6]
get_time("%H",mhours,5)
get_time("%M",mmins,5)
@ -74,11 +75,11 @@ public sayTheTime(id){
}
new ctime[64]
get_time("%m/%d/%Y - %H:%M:%S",ctime,63)
client_print(0,print_chat, "The time: %s",ctime )
client_print(0,print_chat, "%L: %s",LANG_PLAYER,"THE_TIME",ctime )
return PLUGIN_CONTINUE
}
public sayTimeLeft(id){
public sayTimeLeft(id) {
if (get_cvar_float("mp_timelimit")) {
new a = get_timeleft()
if ( get_cvar_num("amx_time_voice") ) {
@ -86,35 +87,35 @@ public sayTimeLeft(id){
setTimeVoice( svoice , 127 , 0 , a )
client_cmd( id , svoice )
}
client_print(0,print_chat, "Time Left: %d:%02d", (a / 60) , (a % 60) )
client_print(0,print_chat, "%L: %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60) , (a % 60) )
}
else
client_print(0,print_chat, "No Time Limit" )
client_print(0,print_chat, "%L",LANG_PLAYER,"NO_T_LIMIT" )
return PLUGIN_CONTINUE
}
setTimeText(text[],len,tmlf){
setTimeText(text[],len,tmlf,id) {
new secs = tmlf % 60
new mins = tmlf / 60
if (secs == 0)
format(text,len,"%d minute%s", mins , (mins > 1) ? "s" : "" )
format(text,len,"%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE" )
else if (mins == 0)
format(text,len,"%d second%s", secs,(secs > 1) ? "s" : "" )
format(text,len,"%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND" )
else
format(text,len,"%d minute%s %d second%s", mins , (mins > 1) ? "s" : "" ,secs ,(secs > 1) ? "s" : "" )
format(text,len,"%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND" )
}
setTimeVoice(text[],len,flags,tmlf){
setTimeVoice(text[],len,flags,tmlf) {
new temp[7][32]
new secs = tmlf % 60
new mins = tmlf / 60
for(new a = 0;a < 7;++a)
for (new a = 0;a < 7;++a)
temp[a][0] = 0
if (secs > 0){
num_to_word(secs,temp[4],31)
if (!(flags & 8)) temp[5] = "seconds " /* there is no "second" in default hl */
}
if (mins > 59){
if (mins > 59) {
new hours = mins / 60
num_to_word(hours,temp[0],31)
if (!(flags & 8)) temp[1] = "hours "
@ -128,10 +129,10 @@ setTimeVoice(text[],len,flags,tmlf){
return format(text,len,"spk ^"vox/%s%s%s%s%s%s%s^"", temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6] )
}
findDispFormat(time){
for(new i = 0;g_TimeSet[i][0];++i){
if (g_TimeSet[i][1] & 16){
if (g_TimeSet[i][0] > time){
findDispFormat(time) {
for(new i = 0;g_TimeSet[i][0];++i) {
if (g_TimeSet[i][1] & 16) {
if (g_TimeSet[i][0] > time) {
if (!g_Switch) {
g_CountDown = g_Switch = time
remove_task(8648458)
@ -140,18 +141,18 @@ findDispFormat(time){
return i
}
}
else if (g_TimeSet[i][0] == time){
else if (g_TimeSet[i][0] == time) {
return i
}
}
return -1
}
public setDisplaying(){
public setDisplaying() {
new arg[32], flags[32], num[32]
new argc = read_argc() - 1
new i = 0
while (i < argc && i < 32){
while (i < argc && i < 32) {
read_argv(i+1,arg,31)
parse(arg,flags,31,num,31)
g_TimeSet[i][0] = str_to_num(num)
@ -162,7 +163,7 @@ public setDisplaying(){
return PLUGIN_HANDLED
}
public timeRemain(param[]){
public timeRemain(param[]) {
new gmtm = get_timeleft()
new tmlf = g_Switch ? --g_CountDown : gmtm
new stimel[12]
@ -174,21 +175,25 @@ public timeRemain(param[]){
set_task(0.8,"timeRemain",8648458,"",0,"b")
return
}
if (tmlf > 0 && g_LastTime != tmlf){
if (tmlf > 0 && g_LastTime != tmlf) {
g_LastTime = tmlf
new tm_set = findDispFormat(tmlf)
if ( tm_set != -1){
new flags = g_TimeSet[tm_set][1]
new arg[128]
if (flags & 1){
setTimeText(arg,127,tmlf)
if (flags & 16)
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, 1)
else
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, 1)
show_hudmessage(0,arg)
if (flags & 1) {
new players[32],pnum
get_players(players,pnum,"c")
for (new i=0;i<pnum;i++) {
setTimeText(arg,127,tmlf,players[i])
if (flags & 16)
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, 1)
else
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, 1)
show_hudmessage(players[i],arg)
}
}
if (flags & 2){
if (flags & 2) {
setTimeVoice(arg,127,flags,tmlf)
client_cmd(0,arg)
}