| bazhenov93 |
04-19-2012 22:50 |
(KREEDZ) How to check New record?
I tried it but i can't :( :( :cry:
PHP Code:
public Set_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime) { new id = cData[0] new style = cData[1] if( iFailState != TQUERY_SUCCESS ) { log_amx("[KREEDZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError) ColorChat(0, RED, "Warring the SQL Tops can not be saved, notify this to a server ADMIN!") } server_print("[KREEDZ] Server geting info of SQL server") new createinto[1001] new x1[16], x2[4], x3[5], x4[5] parse(cData[2], x1, 15, x2, 3, x3, 4, x4, 4)
new dia[64], steam[32], name[32], ip[15], country[3], checkpoints[32], gochecks[32] new Float:newtime = str_to_float(x1) new iMin, iSec, iMs, server[64] get_pcvar_string(kz_sql_name, server, 63) get_time("%Y%m%d%H%M%S", dia, sizeof dia - 1) get_user_authid(id, steam, 31) get_user_name(id, name, sizeof name - 1) get_user_ip (id, ip, sizeof ip - 1, 1) geoip_code2_ex( ip, country) replace_all(name, 31, "\", "") replace_all(name, 31, "`", "") replace_all(name, 31, "'", "")
if( SQL_NumResults(hQuery) == 0 ) { formatex(checkpoints, 31, ", '%d'", str_to_num(x3)) formatex(gochecks, 31, ", '%d'", str_to_num(x4)) formatex( createinto, sizeof createinto - 1, "INSERT INTO `%s` VALUES('%s', '%s','%s','%s','%f','%s','%s','%s'%s%s)", style == PRO_TOP ? "kz_pro" : "kz_general", MapName, steam,country, name, newtime, dia, g_weaponsnames[str_to_num(x2)], server, style == PRO_TOP ? "" : checkpoints, style == PRO_TOP ? "" : gochecks) SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto) GetNewRank(id, style) } else { new Float:oldtime, Float:thetime SQL_ReadResult(hQuery, 0, oldtime) if(newtime < oldtime) { thetime = oldtime - newtime iMin = floatround(thetime / 60.0, floatround_floor) iSec = floatround(thetime - iMin * 60.0,floatround_floor) iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor ) set_hudmessage(0, 255, 0, -1.0, 0.26, 1, 6.0, 07.0) show_hudmessage(id, "You improved your time by %02i:%02i.%02i in %s", iMin, iSec, iMs, style == PRO_TOP ? "Professional Top" : "General Top") formatex(checkpoints, 31, ", checkpoints='%d'", str_to_num(x3)) formatex(gochecks, 31, ", gocheck='%d'", str_to_num(x4)) if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18) formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE name='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro" : "kz_general",newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, name, MapName) else formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE authid='%s' AND mapname='%s'", style ==PRO_TOP ? "kz_pro" :"kz_general", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, steam, MapName) SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto ) GetNewRank(id, style) } else { thetime = newtime - oldtime iMin = floatround(thetime / 60.0, floatround_floor) iSec = floatround(thetime - iMin * 60.0,floatround_floor) iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor ) set_hudmessage(255, 0, 0, -1.0, 0.26, 1, 6.0, 07.0) show_hudmessage(id, "You failed your best time by %02i:%02i.%02i in %s", iMin, iSec, iMs, style == PRO_TOP ? "Professional Top" : "General Top") } } return PLUGIN_CONTINUE }
PHP Code:
public GetNewRank_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime) {
new id = cData[0] if( iFailState != TQUERY_SUCCESS ) { return log_amx("TOP15 SQL: SQL Error #%d - %s", iErrnum, szError) } new steam[32], authid[32], namez[32], name[32], i = 0, weapon = get_user_weapon(id) get_user_authid(id, steam, 31) get_user_name(id, namez, 31)
while( SQL_MoreResults(hQuery) ) { i++ if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18) { SQL_ReadResult(hQuery, 0, name, 31) if( equal(name, namez) ) { ColorChat(0, GREY, "%s is now on place #%d in %s", namez, i, cData[1] == PRO_TOP ? "Professional Top" : "General Top"); break; } } else { SQL_ReadResult(hQuery, 0, authid, 31) if( equal(authid, steam) ) { ColorChat(0, GREY, "%s is now on place #%d in %s", namez, i, cData[1] == PRO_TOP ? "Professional Top" : "General Top"); break; } } SQL_NextRow(hQuery) } return PLUGIN_CONTINUE }
If a new record is established skip ColorChat(0, GREY, "%s is now on place #%d in %s", namez, i, cData[1] == PRO_TOP ? "Professional Top" : "General Top");
and write this: ColorChat(0, GREY, "%s established a new record in %s", namez, cData[1] == PRO_TOP ? "Professional Top" : "General Top");
|