|
Senior Member
|

07-16-2007
, 00:39
Re: nVault
|
#2
|
Srry also here is a look at code i am using for top 10
Code:
public topten_update(id) {
new szvault[64], szmap[32], kreedztime
get_mapname(szmap,32)
format(szvault,64,"bhop_%s",szmap)
new time = getusertime(id)
new vault = nvault_open(szvault) // Now we have to sort the new list :o
if(vault != -1) {
new szkey[8]
for(new i=1;i<=10;i++) {
new szreturn[128]
new arg1[32], arg2[8]
format(szkey,8,"%d",i)
nvault_get(vault,szkey,szreturn,128)
if(parse(szreturn,arg1,32,arg2,8) == 0 || getusertime(id) < str_to_num(arg2))
{
if(getusertime(id) < str_to_num(arg2))
nvault_remove(vault, szreturn)
else {
new sznew[128], szname[32]
get_user_name(id,szname,32)
format(sznew,128,"^"%s^" ^"%d^" ^"%d^" ^"%d^" ^"%d^"",szname,time,timer[id-1][TMR_CPSCNT],timer[id-1][TMR_GCSCNT],timer[id-1][TMR_BOOSTS])
if(i < 10) {
for(new x=10;x>i;x--) {
new sztemp[128], sztempkey[8]
format(sztempkey,8,"%d",x-1)
nvault_get(vault,sztempkey,sztemp,128)
if(!equal(sztemp,"")) {
format(sztempkey,8,"%d",x)
nvault_pset(vault,sztempkey,sztemp)
}
}
}
nvault_pset(vault,szkey,sznew)
if(i == 1)
client_print(0,print_chat,"[KZ] Congratulations, %s has a new record !",szname)
break
}
}
}
nvault_close(vault)
}
}
Code:
public topten_show(id) {
new motd[2048]
new szvault[64], szmap[32]
get_mapname(szmap,32)
format(szvault,64,"bhop_%s",szmap)
new vault = nvault_open(szvault)
if(vault != -1) {
add(motd,2048,"<html><head><style>")
add(motd,2048,"body { background-color:#000000; font-family:Tahoma; font-size:10px; color:#FFFFFF; }")
add(motd,2048,".tabel { border-style:solid; border-width:1px; border-color:#FFFFFF; font-family:Tahoma; font-size:10px; color:#FFFFFF; }")
add(motd,2048,".header { background-color:#292929; font-family:Tahoma; font-size:10px; color:#FFFFFF; font-weight:800; }")
add(motd,2048,"</style></head><body>")
add(motd,2048,"<br><br><table border=0 cellspacing=0 cellpadding=1 width=90% align=center class=tabel>")
add(motd,2048,"<tr><td class=header>#</td><td class=header>Name</td><td class=header>Time</td><td class=header>Check Points Saved</td><td class=header>Go checks Used</td><td class=header>Boosts Used</td></tr>")
new szkey[8]
for(new i=1;i<=10;i++) {
new szreturn[128]
format(szkey,8,"%d",i)
nvault_get(vault,szkey,szreturn,128)
new arg1[32], arg2[8], arg3[8], arg4[8], arg5[8]
if(parse(szreturn,arg1,32,arg2,8,arg3,8,arg4,8,arg5,8) != 0) {
new sztime[32]
new imin, kreedztime = str_to_num(arg2)
if((kreedztime / 60.0) >= 1) {
imin = floatround(kreedztime / 60.0,floatround_floor)
kreedztime -= (floatround(kreedztime / 60.0,floatround_floor) * 60)
}
format(sztime,32,"%d minutes and %d seconds",imin,kreedztime)
add(motd,2048,"<tr><td>")
add(motd,2048,szkey)
add(motd,2048,"</td><td>")
add(motd,2048,arg1)
add(motd,2048,"</td><td>")
add(motd,2048,sztime)
add(motd,2048,"</td><td>")
add(motd,2048,arg3)
add(motd,2048,"</td><td>")
add(motd,2048,arg4)
add(motd,2048,"</td><td>")
add(motd,2048,arg5)
add(motd,2048,"</td></tr>")
}
}
nvault_close(vault)
add(motd,2048,"</table></body></html>")
show_motd(id,motd,"KZ TOP 10")
}
}
|
|