Timeleft: replace len hardcoded content by charsmax and sizeof

This commit is contained in:
Freeman-AM 2014-10-11 19:51:57 +02:00
parent 93d37a6366
commit 59cb65f47a

View File

@ -30,7 +30,7 @@ public plugin_init() {
set_task(0.8,"timeRemain",8648458,"",0,"b")
new szMapName[4]
get_mapname(szMapName, 3)
get_mapname(szMapName, charsmax(szMapName))
if (equal(szMapName, "co_")) {
register_event("PlayHUDNot", "roundChange", "bc", "1=0", "2>56", "2<59")
is_combat = true
@ -40,12 +40,12 @@ public plugin_init() {
public sayTheTime(id){
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)
get_time("%H",mhours,charsmax(mhours))
get_time("%M",mmins,charsmax(mmins))
new mins = str_to_num(mmins)
new hrs = str_to_num(mhours)
if (mins)
num_to_word(mins,wmins,31)
num_to_word(mins,wmins,charsmax(wmins))
else
wmins[0] = 0
if (hrs < 12)
@ -55,13 +55,13 @@ public sayTheTime(id){
wpm = "pm "
}
if (hrs)
num_to_word(hrs,whours,31)
num_to_word(hrs,whours,charsmax(whours))
else
whours = "twelve "
client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"",whours,wmins,wpm )
}
new ctime[64]
get_time("%m/%d/%Y - %H:%M:%S",ctime,63)
get_time("%m/%d/%Y - %H:%M:%S",ctime,charsmax(ctime))
client_print(0,print_chat, "The time: %s",ctime )
return PLUGIN_CONTINUE
}
@ -71,7 +71,7 @@ public sayTimeLeft(id){
new a = get_timeleft()
if ( get_cvar_num("amx_time_voice") ) {
new svoice[128]
setTimeVoice( svoice , 127 , 0 , a )
setTimeVoice( svoice , charsmax(svoice) , 0 , a )
client_cmd( id , "%s", svoice )
}
client_print(0,print_chat, "Time Left: %d:%02d", (a / 60) , (a % 60) )
@ -108,20 +108,20 @@ 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 < sizeof(temp);++a)
temp[a][0] = 0
if (secs > 0){
num_to_word(secs,temp[4],31)
num_to_word(secs,temp[4],charsmax(temp[]))
if (!(flags & 8)) temp[5] = "seconds " /* there is no "second" in default hl */
}
if (mins > 59){
new hours = mins / 60
num_to_word(hours,temp[0],31)
num_to_word(hours,temp[0],charsmax(temp[]))
if (!(flags & 8)) temp[1] = "hours "
mins = mins % 60
}
if (mins > 0) {
num_to_word(mins ,temp[2],31)
num_to_word(mins ,temp[2],charsmax(temp[]))
if (!(flags & 8)) temp[3] = "minutes "
}
if (!(flags & 4)) temp[6] = "remaining "
@ -163,8 +163,8 @@ public setDisplaying(){
new arg[32], flags[32], num[32]
new argc = read_argc() - 1
for(new i; (argc > i < 32); ++i) {
read_argv(i+1,arg,31)
parse(arg,flags,31,num,31)
read_argv(i+1,arg,charsmax(arg))
parse(arg,flags,charsmax(flags),num,charsmax(num))
g_TimeSet[i][0] = str_to_num(num)
g_TimeSet[i][1] = read_flags(flags)
g_TimeSet[i+1][0] = 0
@ -175,7 +175,7 @@ public setDisplaying(){
public timeRemain(param[]){
new gmtm = get_timeleft()
new stimel[12]
format(stimel,11,"%02d:%02d",gmtm / 60, gmtm % 60)
format(stimel,charsmax(stimel),"%02d:%02d",gmtm / 60, gmtm % 60)
set_cvar_string("amx_timeleft",stimel)
if (!is_combat)
@ -196,7 +196,7 @@ public timeRemain(param[]){
new flags = g_TimeSet[tm_set][1]
new arg[128]
if (flags & 1){ // display white text on bottom
setTimeText(arg,127,tmlf)
setTimeText(arg,charsmax(arg),tmlf)
if (flags & 16) // show/speak if current time is less than this set in parameter
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
else
@ -204,7 +204,7 @@ public timeRemain(param[]){
show_hudmessage(0, "%s", arg)
}
if (flags & 2){ // use voice
setTimeVoice(arg,127,flags,tmlf)
setTimeVoice(arg,charsmax(arg),flags,tmlf)
client_cmd(0, "%s", arg)
}
}