public SaveXP(id)
{
if(g_boolsqlOK)
{
if(!is_user_bot(id) && player_xp[id] != player_xp_old[id])
{
new name[48], ip[32], sid[32], q_command[1024];
get_user_name(id, name, 47);
get_user_ip(id, ip, 31, 1);
get_user_authid(id, sid, 31);
replace_all(name, 47, "'", "\'");
format(q_command,1023,"UPDATE `%s` SET `ip`='%s',`sid`='%s',`lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`kam`='%i',`pak`='%i',`kas`='%i',`dam`='%i',`man`='%i',`grw`='%i',`men`='%i',`agi`='%i',`mis`='%i',`art`='%i',`wyt`='%i' WHERE `nick`='%s' AND `klasa`='%i' ",
g_sqql,ip,sid,player_lvl[id],player_xp[id],player_strength[id],
player_intelligence[id],player_dextery[id],player_kamien[id],player_expstat[id],player_kas[id],player_dama[id],mana_gracza[id],player_grw[id],
player_men[id],player_agility[id],player_misja[id],player_artefakt[id],czas_artefaktu[id],name,player_class[id])
SQL_ThreadQuery(g_SqlTuple, "Save_xp_handle", q_command);
player_xp_old[id] = player_xp[id];
}
}
else sql_start();
}
public Save_xp_handle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("diablo.log", "Could not connect to SQL database.");
return PLUGIN_CONTINUE;
}
if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("diablo.log", "Save_xp Query failed.");
return PLUGIN_CONTINUE;
}
if(Errcode)
{
log_to_file("diablo.log", "Error on Save_xp query: %s", Error);
return PLUGIN_CONTINUE;
}
return PLUGIN_CONTINUE;
}
public LoadXP(id, klasa)
{
if(is_user_bot(id) || asked_sql[id] || klasa == NONE)
return PLUGIN_HANDLED;
if(g_boolsqlOK)
{
new data[2];
data[0] = id;
data[1] = klasa;
new name[48], q_command[1024];
get_user_name(id, name, 47);
replace_all(name, 47, "'", "\'");
formatex(q_command, 1023, "SELECT * FROM `%s` WHERE `nick`='%s' AND `klasa`='%i'", g_sqql, name, klasa);
SQL_ThreadQuery(g_SqlTuple, "Load_xp_handle", q_command, data, 2);
asked_sql[id] = 1;
}
else sql_start();
return PLUGIN_HANDLED;
}
public Load_xp_handle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
new id = Data[0];
asked_sql[id] = 0;
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("diablo.log", "Could not connect to SQL database.");
return PLUGIN_CONTINUE;
}
if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("diablo.log", "Load_xp Query failed.");
return PLUGIN_CONTINUE;
}
if(Errcode)
{
log_to_file("diablo.log", "Error on Load_xp query: %s", Error);
return PLUGIN_CONTINUE;
}
new klasa = Data[1];
if(SQL_MoreResults(Query))
{
player_class[id] = klasa;
player_lvl[id] = player_class_lvl[id][klasa];
player_xp[id] = SQL_ReadResult(Query, SQL_FieldNameToNum(Query, "exp"));
player_xp_old[id] = player_xp[id];
player_intelligence[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"int"))
player_strength[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"str"))
player_agility[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"agi"))
player_dextery[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"dex"))
player_kamien[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"kam"))
player_expstat[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"pak"))
player_dama[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"dam"))
mana_gracza[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"man"))
player_men[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"men"))
player_kas[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"kas"))
player_misja[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"mis"))
player_artefakt[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"art"))
czas_artefaktu[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"wyt"))
player_grw[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"grw"))
player_point[id]=(player_lvl[id]-2)*2-player_intelligence[id]-player_strength[id]-player_dextery[id]-player_agility[id]-player_kas[id]*15-player_dama[id]-player_men[id]*30-player_grw[id]
if(player_point[id]<0) player_point[id]=0
player_damreduction[id] = (50.1110*(1.0-floatpower( 2.7182, -0.06798*float(player_agility[id])))/200)
suma_kryt[id] = player_dama[id]/4
}
else
create_klass(id, klasa);
return PLUGIN_CONTINUE;
}