FIX NIE WYMAGA RESETU LVLI I EXPA!
INSTRUKCJA
Spoiler
1. Znajdź
zamień na
2. Znajdź
zamień na
3. Znajdź
zamień na
4. Znajdź
zamień na
5. Znajdź
zamień na
6. Znajdź
zamień na
7. Znajdź
dodaj za
8. Znajdź
dodaj za
9. Znajdź i usuń wszystko wymienione tutaj
w funkcji "client_putinserver" oraz "client_disconnect"
10. Znajdź
dodaj za
11. Znajdź
dodaj za
Spoiler
public sql_start()
{
if(sqlstart<0) return
if(g_boolsqlOK) return
new host[128]
new user[64]
new pass[64]
new database[64]
get_cvar_string("diablo_sql_database",database,63)
get_cvar_string("diablo_sql_host",host,127)
get_cvar_string("diablo_sql_user",user,63)
get_cvar_string("diablo_sql_pass",pass,63)
g_SqlTuple = SQL_MakeDbTuple(host,user,pass,database)
get_cvar_string("diablo_sql_table",g_sqlTable,63)
new q_command[512]
format(q_command,511,"CREATE TABLE IF NOT EXISTS `%s` ( `nick` VARCHAR( 64 ),`ip` VARCHAR( 64 ),`sid` VARCHAR( 64 ), `klasa` integer( 2 ) , `lvl` integer( 3 ) DEFAULT 1, `exp` integer( 9 ) DEFAULT 0, `str` integer( 3 ) DEFAULT 0, `int` integer( 3 ) DEFAULT 0, `dex` integer( 3 ) DEFAULT 0, `agi` integer( 3 ) DEFAULT 0 ) ",g_sqlTable)
SQL_ThreadQuery(g_SqlTuple,"TableHandle",q_command)
}
//sql//
public TableHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
// lots of error checking
g_boolsqlOK=1
if(Errcode)
{
g_boolsqlOK=0
log_to_file("addons/amxmodx/logs/diablo.log","Error on Table query: %s",Error)
}
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Could not connect to SQL database.")
g_boolsqlOK=0
return PLUGIN_CONTINUE
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Table Query failed.")
g_boolsqlOK=0
return PLUGIN_CONTINUE
}
LoadAVG()
return PLUGIN_CONTINUE
}
zamień na
Spoiler
//sql
public sql_start() {
if(g_boolsqlOK) return;
new host[128], user[64], pass[64], database[64];
get_cvar_string("diablo_sql_database", database, 63);
get_cvar_string("diablo_sql_host", host, 127);
get_cvar_string("diablo_sql_user", user, 63);
get_cvar_string("diablo_sql_pass", pass, 63);
g_SqlTuple = SQL_MakeDbTuple(host, user, pass, database);
get_cvar_string("diablo_sql_table", g_sqlTable, 63);
new q_command[512];
formatex(q_command, 511, "CREATE TABLE IF NOT EXISTS `%s` (`nick` VARCHAR(48), `ip` VARCHAR(32), `sid` VARCHAR(32), `klasa` INT(2), `lvl` INT(3) DEFAULT 1, `exp` INT(9) DEFAULT 0, `str` INT(3) DEFAULT 0, `int` INT(3) DEFAULT 0, `dex` INT(3) DEFAULT 0, `agi` INT(3) DEFAULT 0) DEFAULT CHARSET `utf8` COLLATE `utf8_general_ci`", g_sqlTable);
SQL_ThreadQuery(g_SqlTuple, "TableHandle", q_command);
}
public TableHandle(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", "Table Query failed.");
return PLUGIN_CONTINUE;
}
if(Errcode) {
log_to_file("diablo.log", "Error on Table query: %s", Error);
return PLUGIN_CONTINUE;
}
g_boolsqlOK = 1;
LoadAVG();
return PLUGIN_CONTINUE;
}
2. Znajdź
Spoiler
public create_klass(id)
{
if(g_boolsqlOK)
{
if(!is_user_bot(id) && database_user_created[id]==0)
{
new name[64]
new ip[64]
new sid[64]
get_user_name(id,name,63)
replace_all ( name, 63, "'", "Q" )
replace_all ( name, 63, "`", "Q" )
get_user_ip ( id, ip, 63, 1 )
get_user_authid(id, sid ,63)
log_to_file("addons/amxmodx/logs/test_log.log","*** %s %s *** Create Class ***",name,sid)
for(new i=1;i<9;i++)
{
new q_command[512]
format(q_command,511,"INSERT INTO `%s` (`nick`,`ip`,`sid`,`klasa`,`lvl`,`exp`) VALUES ('%s','%s','%s',%i,%i,%i ) ",g_sqlTable,name,ip,sid,i,srv_avg[i],LevelXP[srv_avg[i]-1])
SQL_ThreadQuery(g_SqlTuple,"create_klass_Handle",q_command)
}
database_user_created[id]=1
}
}
else sql_start()
}
public create_klass_Handle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
// lots of error checking
if(Errcode)
{
log_to_file("addons/amxmodx/logs/diablo.log","Error on create klass query: %s",Error)
}
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Could not connect to SQL database.")
return PLUGIN_CONTINUE
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","create klass Query failed.")
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
zamień na
Spoiler
public create_klass(id, class) {
if(g_boolsqlOK) {
if(!is_user_bot(id) && !database_user_created[id]) {
new data[2];
data[0] = id;
data[1] = class;
new name[48], ip[32], sid[32], q_command[512];
get_user_name(id, name, 47);
get_user_ip(id, ip, 31, 1);
get_user_authid(id, sid, 31);
log_to_file("test_log.log", "*** %s [%s] <%s> *** Create %s ***", name, ip, sid, Race[class]);
replace_all(name, 47, "'", "\'");
formatex(q_command, 511, "INSERT INTO `%s` (`nick`,`ip`,`sid`,`klasa`,`lvl`,`exp`) VALUES ('%s','%s','%s',%i,%i,%i)", g_sqlTable, name, ip, sid, class, srv_avg[class], LevelXP[srv_avg[class]-1]);
SQL_ThreadQuery(g_SqlTuple, "create_klass_handle", q_command, data, 2);
database_user_created[id] = 1;
}
}
else sql_start();
}
public create_klass_handle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize) {
new id = Data[0];
database_user_created[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", "create_klass Query failed.");
return PLUGIN_CONTINUE;
}
if(Errcode) {
log_to_file("diablo.log", "Error on create_klass query: %s", Error);
return PLUGIN_CONTINUE;
}
LoadXP(id, Data[1]);
return PLUGIN_CONTINUE;
}
3. Znajdź
Spoiler
public SaveXP(id)
{
if(g_boolsqlOK)
{
if(!is_user_bot(id) && player_xp[id]!=player_xp_old[id])
{
new name[64]
new ip[64]
new sid[64]
get_user_name(id,name,63)
replace_all ( name, 63, "'", "Q" )
replace_all ( name, 63, "`", "Q" )
get_user_ip(id, ip ,63,1)
get_user_authid(id, sid ,63)
if(get_cvar_num("diablo_sql_save")==0)
{
new q_command[512]
format(q_command,511,"UPDATE `%s` SET `ip`='%s',`sid`='%s',`lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`agi`='%i' WHERE `nick`='%s' AND `klasa`='%i' ",g_sqlTable,ip,sid,player_lvl[id],player_xp[id],player_strength[id],player_intelligence[id],player_dextery[id],player_agility[id],name,player_class[id])
SQL_ThreadQuery(g_SqlTuple,"Save_xp_handle",q_command)
}
else if(get_cvar_num("diablo_sql_save")==1)
{
new q_command[512]
format(q_command,511,"UPDATE `%s` SET `nick`='%s',`sid`='%s',`lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`agi`='%i' WHERE `ip`='%s' AND `klasa`='%i' ",g_sqlTable,name,sid,player_lvl[id],player_xp[id],player_strength[id],player_intelligence[id],player_dextery[id],player_agility[id],ip,player_class[id])
SQL_ThreadQuery(g_SqlTuple,"Save_xp_handle",q_command)
}
else if(get_cvar_num("diablo_sql_save")==2)
{
new q_command[512]
format(q_command,511,"UPDATE `%s` SET `nick`='%s',`ip`='%s',`lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`agi`='%i' WHERE `sid`='%s' AND `klasa`='%i' ",g_sqlTable,name,ip,player_lvl[id],player_xp[id],player_strength[id],player_intelligence[id],player_dextery[id],player_agility[id],sid,player_class[id])
SQL_ThreadQuery(g_SqlTuple,"Save_xp_handle",q_command)
}
player_xp_old[id]=player_xp[id]
}
}
else sql_start()
return PLUGIN_HANDLED
}
public Save_xp_handle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(Errcode)
{
log_to_file("addons/amxmodx/logs/diablo.log","Error on Save_xp query: %s",Error)
}
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Could not connect to SQL database.")
return PLUGIN_CONTINUE
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Save_xp Query failed.")
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
zamień na
Spoiler
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[512];
get_user_name(id, name, 47);
get_user_ip(id, ip, 31, 1);
get_user_authid(id, sid, 31);
replace_all(name, 47, "'", "\'");
switch(get_cvar_num("diablo_sql_save")) {
case 0:
{
formatex(q_command,511,"UPDATE `%s` SET `ip`='%s',`sid`='%s',`lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`agi`='%i' WHERE `nick`='%s' AND `klasa`='%i'",g_sqlTable,ip,sid,player_lvl[id],player_xp[id],player_strength[id],player_intelligence[id],player_dextery[id],player_agility[id],name,player_class[id]);
}
case 1:
{
formatex(q_command,511,"UPDATE `%s` SET `nick`='%s',`sid`='%s',`lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`agi`='%i' WHERE `ip`='%s' AND `klasa`='%i'",g_sqlTable,name,sid,player_lvl[id],player_xp[id],player_strength[id],player_intelligence[id],player_dextery[id],player_agility[id],ip,player_class[id])
}
case 2:
{
formatex(q_command,511,"UPDATE `%s` SET `nick`='%s',`ip`='%s',`lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`agi`='%i' WHERE `sid`='%s' AND `klasa`='%i'",g_sqlTable,name,ip,player_lvl[id],player_xp[id],player_strength[id],player_intelligence[id],player_dextery[id],player_agility[id],sid,player_class[id])
}
default:
{
formatex(q_command,511,"UPDATE `%s` SET `ip`='%s',`sid`='%s',`lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`agi`='%i' WHERE `nick`='%s' AND `klasa`='%i'",g_sqlTable,ip,sid,player_lvl[id],player_xp[id],player_strength[id],player_intelligence[id],player_dextery[id],player_agility[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;
}
4. Znajdź
Spoiler
public LoadXP(id, klasa){
if(is_user_bot(id) || asked_sql[id]==1) return PLUGIN_HANDLED
if(player_class[id]==0)load_xp(id)
if(g_boolsqlOK )
{
new name[64]
new data[2]
data[0]=id
data[1]=klasa
if(get_cvar_num("diablo_sql_save")==0)
{
get_user_name(id,name,63)
replace_all ( name, 63, "'", "Q" )
replace_all ( name, 63, "`", "Q" )
new q_command[512]
format(q_command,511,"SELECT * FROM `%s` WHERE `nick`='%s' AND `klasa`='%i'", g_sqlTable, name, player_class[id])
SQL_ThreadQuery(g_SqlTuple,"Load_xp_handle",q_command,data,2)
asked_sql[id]=1
}
else if(get_cvar_num("diablo_sql_save")==1)
{
get_user_ip(id, name ,63,1)
new q_command[512]
format(q_command,511,"SELECT * FROM `%s` WHERE `ip`='%s' AND `klasa`='%i'", g_sqlTable, name, player_class[id])
SQL_ThreadQuery(g_SqlTuple,"Load_xp_handle",q_command,data,2)
asked_sql[id]=1
}
else if(get_cvar_num("diablo_sql_save")==2)
{
get_user_authid(id, name ,63)
new q_command[512]
format(q_command,511,"SELECT * FROM `%s` WHERE `sid`='%s' AND `klasa`='%i'", g_sqlTable, name, player_class[id])
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(Errcode)
{
log_to_file("addons/amxmodx/logs/diablo.log","Error on Load_xp query: %s",Error)
}
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Could not connect to SQL database.")
return PLUGIN_CONTINUE
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Load_xp Query failed.")
return PLUGIN_CONTINUE
}
if(SQL_MoreResults(Query))
{
player_class[id] = Data[1]
player_lvl[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"lvl"))
player_xp[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"exp"))
player_xp_old[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"exp"))
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_point[id]=(player_lvl[id]-1)*2-player_intelligence[id]-player_strength[id]-player_dextery[id]-player_agility[id]
if(player_point[id]<0) player_point[id]=0
player_damreduction[id] = (47.3057*(1.0-floatpower( 2.7182, -0.06798*float(player_agility[id])))/100)
}
return PLUGIN_CONTINUE
}
zamień na
Spoiler
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[512];
switch(get_cvar_num("diablo_sql_save")) {
case 0: {
get_user_name(id, name, 47);
replace_all(name, 47, "'", "\'");
formatex(q_command, 511, "SELECT * FROM `%s` WHERE `nick`='%s' AND `klasa`='%i'", g_sqlTable, name, klasa);
}
case 1: {
get_user_ip(id, name, 31, 1)
formatex(q_command, 511, "SELECT * FROM `%s` WHERE `ip`='%s' AND `klasa`='%i'", g_sqlTable, name, klasa);
}
case 2: {
get_user_authid(id, name, 31)
formatex(q_command, 511, "SELECT * FROM `%s` WHERE `sid`='%s' AND `klasa`='%i'", g_sqlTable, name, klasa);
}
default: {
get_user_name(id, name, 47);
replace_all(name, 47, "'", "\'");
formatex(q_command, 511, "SELECT * FROM `%s` WHERE `nick`='%s' AND `klasa`='%i'", g_sqlTable, 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_point[id] = (player_lvl[id]-1)*2-player_intelligence[id]-player_strength[id]-player_dextery[id]-player_agility[id];
if(player_point[id] < 0) player_point[id] = 0;
player_damreduction[id] = (47.3057*(1.0-floatpower( 2.7182, -0.06798*float(player_agility[id])))/100);
}
else
create_klass(id, klasa);
return PLUGIN_CONTINUE;
}
5. Znajdź
Spoiler
public select_class_query(id)
{
if(is_user_bot(id) || asked_klass[id]!=0) return PLUGIN_HANDLED
if(loaded_xp[id]==0)
{
load_xp(id)
return PLUGIN_HANDLED
}
if(g_boolsqlOK)
{
asked_klass[id]=1
new name[64]
new data[1]
data[0]=id
new lx[9]
if(player_class_lvl_save[id]==0)
{
if(get_cvar_num("diablo_sql_save")==0)
{
get_user_name(id,name,63)
replace_all ( name, 63, "'", "Q" )
replace_all ( name, 63, "`", "Q" )
new q_command[512]
format(q_command,511,"SELECT `klasa`,`lvl` FROM `%s` WHERE `nick`='%s' ",g_sqlTable,name)
SQL_ThreadQuery(g_SqlTuple,"select_class_handle", q_command,data,1)
}
else if(get_cvar_num("diablo_sql_save")==1)
{
get_user_ip(id, name ,63,1)
new q_command[512]
format(q_command,511,"SELECT `klasa`,`lvl` FROM `%s` WHERE `ip`='%s' ",g_sqlTable,name)
SQL_ThreadQuery(g_SqlTuple,"select_class_handle",q_command,data,1)
}
else if(get_cvar_num("diablo_sql_save")==2)
{
get_user_authid(id, name ,63)
new q_command[512]
format(q_command,511,"SELECT `klasa`,`lvl` FROM `%s` WHERE `sid`='%s' ",g_sqlTable,name)
SQL_ThreadQuery(g_SqlTuple,"select_class_handle",q_command,data,1)
}
/*
if(ret == RESULT_FAILED)
{
new szError[126]
dbi_error(sql,szError,125)
log_to_file("addons/amxmodx/logs/diablo.log","[Command Log] nie moglem wczytac lvl'i dla %s | klasy ** %s",name,szError)
dbi_free_result(ret)
g_boolsqlOK=0
player_class_lvl_save[id]=0
dbi_close(sql)
return PLUGIN_HANDLED
}
else if(ret == RESULT_NONE)
{
log_to_file("addons/amxmodx/logs/diablo.log","[Command Log] nie ma danych dla /klasa")
create_klass(id)
return PLUGIN_HANDLED
}
else while(ret && dbi_nextrow(ret)>0)
{
new i = dbi_result(ret, "klasa")
lx[i] = dbi_result(ret, "lvl")
player_class_lvl[id][i] = lx[i]
}
dbi_free_result(ret)
player_class_lvl_save[id]=1
*/
}
else
{
for(new i=1;i<9;i++) lx[i]=player_class_lvl[id][i]
select_class(id,lx)
}
}
else sql_start()
return PLUGIN_HANDLED
}
public select_class_handle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
new id=Data[0]
if(Errcode)
{
log_to_file("addons/amxmodx/logs/diablo.log","Error on select_class_handle query: %s",Error)
asked_klass[id]=0
}
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Could not connect to SQL database.")
asked_klass[id]=0
return PLUGIN_CONTINUE
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","select_class_handle Query failed.")
asked_klass[id]=0
return PLUGIN_CONTINUE
}
if(SQL_MoreResults(Query))
{
new lx[9]
while(SQL_MoreResults(Query))
{
new i = SQL_ReadResult(Query, SQL_FieldNameToNum(Query, "klasa"))
lx[i] = SQL_ReadResult(Query, SQL_FieldNameToNum(Query, "lvl"))
player_class_lvl[id][i] = lx[i]
SQL_NextRow(Query)
}
if(asked_klass[id]==1)
{
asked_klass[id]=2
select_class(id,lx)
}
}
return PLUGIN_CONTINUE
}
zamień na
Spoiler
public select_class_query(id) {
if(is_user_bot(id) || asked_klass[id])
return PLUGIN_HANDLED;
if(g_boolsqlOK) {
new name[48], data[1], q_command[512];
data[0] = id;
switch(get_cvar_num("diablo_sql_save")) {
case 0:
{
get_user_name(id, name, 47);
replace_all(name, 47, "'", "\'");
formatex(q_command, 511, "SELECT `klasa`, `lvl` FROM `%s` WHERE `nick`='%s'", g_sqlTable, name);
}
case 1:
{
get_user_ip(id, name, 31, 1)
formatex(q_command, 511, "SELECT `klasa`, `lvl` FROM `%s` WHERE `ip`='%s'", g_sqlTable, name);
}
case 2:
{
get_user_authid(id, name, 31)
formatex(q_command, 511, "SELECT `klasa`, `lvl` FROM `%s` WHERE `sid`='%s'", g_sqlTable, name);
}
default:
{
get_user_name(id, name, 47);
replace_all(name, 47, "'", "\'");
formatex(q_command, 511, "SELECT `klasa`, `lvl` FROM `%s` WHERE `nick`='%s'", g_sqlTable, name);
}
}
SQL_ThreadQuery(g_SqlTuple, "select_class_handle", q_command, data, 1);
asked_klass[id] = 1;
}
else sql_start();
return PLUGIN_HANDLED;
}
public select_class_handle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize) {
new id = Data[0];
if(FailState == TQUERY_CONNECT_FAILED) {
log_to_file("diablo.log", "Could not connect to SQL database.");
asked_klass[id] = 0;
return PLUGIN_CONTINUE;
}
if(FailState == TQUERY_QUERY_FAILED) {
log_to_file("diablo.log", "select_class_query Query failed.");
asked_klass[id] = 0;
return PLUGIN_CONTINUE;
}
if(Errcode) {
log_to_file("diablo.log", "Error on select_class_query query: %s", Error);
asked_klass[id] = 0;
return PLUGIN_CONTINUE;
}
if(SQL_MoreResults(Query)) {
new i, numklasa, numlvl;
numklasa = SQL_FieldNameToNum(Query, "klasa");
numlvl = SQL_FieldNameToNum(Query, "lvl");
while(SQL_MoreResults(Query)) {
i = SQL_ReadResult(Query, numklasa);
player_class_lvl[id][i] = SQL_ReadResult(Query, numlvl);
SQL_NextRow(Query);
}
}
if(asked_klass[id] == 1) {
asked_klass[id] = 2;
select_class(id);
}
return PLUGIN_CONTINUE;
}
6. Znajdź
Spoiler
public select_class(id,lx[])
{
if(is_user_bot(id)) return
new flags[10]
get_cvar_string("diablo_classes",flags,9)
new text[512]
new keys = read_flags(flags)
asked_klass[id]=0
format(text, 511,"\yWybierz Klase - ^n")
for(new i=0;i<8;i++)
{
format(text, 511,"%s%s%d. %s Level :%d ^n",text,(keys)&(1<<i)?"\w":"\d",i+1,Race[i+1], lx[i+1])
}
show_menu(id, keys, text)
}
zamień na
Spoiler
public select_class(id) {
if(is_user_bot(id)) return;
new flags[10], text[512], i;
get_cvar_string("diablo_classes", flags, 9);
new keys = read_flags(flags);
formatex(text, 511, "\yWybierz Klase -^n");
for(i=1; i<9; i++)
formatex(text, 511, "%s%s%i. %s [Level: %i]^n", text, (keys & (1<<i-1)) ? "\w" : "\d", i, Race[i], player_class_lvl[id][i]);
show_menu(id, keys, text);
}
7. Znajdź
public select_class_menu(id, key)
{
g_haskit[id] = 0
dodaj za
asked_klass[id] = 0;
8. Znajdź
public client_putinserver(id)
{
loaded_xp[id]=0
dodaj za
for(new i=1; i<9; i++)
player_class_lvl[id][i] = 1;
9. Znajdź i usuń wszystko wymienione tutaj
new sqlstart = 30 // Tyle prob jest na mape na poprawne polaczenie - bo cos sie zapetla gdy wylancza sie serwer (zmiena mapy?)
Spoiler
public load_xp(id)
{
if(g_boolsqlOK /*&& */)
{
if(!is_user_bot(id))
{
new name[64]
new data[1]
data[0]=id
if(get_cvar_num("diablo_sql_save")==0)
{
get_user_name(id,name,63)
replace_all ( name, 63, "'", "Q" )
replace_all ( name, 63, "`", "Q" )
new q_command[512]
format(q_command,511,"SELECT `klasa` FROM `%s` WHERE `nick`='%s' ",g_sqlTable,name)
SQL_ThreadQuery(g_SqlTuple,"SelectHandle",q_command,data,1)
}
else if(get_cvar_num("diablo_sql_save")==1)
{
get_user_ip(id, name ,63,1)
new q_command[512]
format(q_command,511,"SELECT `klasa` FROM `%s` WHERE `ip`='%s' ",g_sqlTable,name)
SQL_ThreadQuery(g_SqlTuple,"SelectHandle",q_command,data,1)
}
else if(get_cvar_num("diablo_sql_save")==2)
{
get_user_authid(id, name ,63)
new q_command[512]
format(q_command,511,"SELECT `klasa` FROM `%s` WHERE `sid`='%s' ",g_sqlTable,name)
SQL_ThreadQuery(g_SqlTuple,"SelectHandle",q_command,data,1)
}
loaded_xp[id]=1
}
}
else sql_start()
}
public SelectHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(Errcode)
{
log_to_file("addons/amxmodx/logs/diablo.log","Error on load_xp query: %s",Error)
}
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Could not connect to SQL database.")
return PLUGIN_CONTINUE
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","load_xp Query failed.")
return PLUGIN_CONTINUE
}
if(SQL_MoreResults(Query)) return PLUGIN_CONTINUE
else create_klass(Data[0])
return PLUGIN_CONTINUE
}
new player_class_lvl_save[33]
w funkcji "client_putinserver" oraz "client_disconnect"
player_class_lvl_save[id]=0
10. Znajdź
register_forward(FM_TraceLine,"fw_traceline");
dodaj za
set_task(1.0, "sql_start");
11. Znajdź
public client_connect(id)
{
// reset_item_skills(id) - nie tutaj bo nie loaduje poziomow
asked_sql[id]=0
dodaj za
asked_klass[id] = 0;
Polecam także wgranie tego fixa (już po wykonaniu fixa z tego tematu):
- http://amxx.pl/topic...wanie-sie-klas/
czyli szukamy
formatex(q_command, 511, "CREATE TABLE IF NOT EXISTS `%s` (`nick` VARCHAR(48), `ip` VARCHAR(32), `sid` VARCHAR(32), `klasa` INT(2), `lvl` INT(3) DEFAULT 1, `exp` INT(9) DEFAULT 0, `str` INT(3) DEFAULT 0, `int` INT(3) DEFAULT 0, `dex` INT(3) DEFAULT 0, `agi` INT(3) DEFAULT 0) DEFAULT CHARSET `utf8` COLLATE `utf8_general_ci`", g_sqlTable);
i zamieniamy na
new typ_primary[5];
switch(get_cvar_num("diablo_sql_save")) {
case 0: typ_primary = "nick";
case 1: typ_primary = "ip";
case 2: typ_primary = "sid";
default: typ_primary = "nick";
}
formatex(q_command, 511, "CREATE TABLE IF NOT EXISTS `%s` (`nick` VARCHAR(48), `ip` VARCHAR(32), `sid` VARCHAR(32), `klasa` INT(2), `lvl` INT(3) DEFAULT 1, `exp` INT(9) DEFAULT 0, `str` INT(3) DEFAULT 0, `int` INT(3) DEFAULT 0, `dex` INT(3) DEFAULT 0, `agi` INT(3) DEFAULT 0, PRIMARY KEY (`%s`, `klasa`)) DEFAULT CHARSET `utf8` COLLATE `utf8_general_ci`", g_sqlTable, typ_primary);
Jeśli chcesz pozbyć się niepotrzebnych wpisów z bazy, to wykonaj takie zapytanie (np. w phpMyAdmin)
DELETE FROM `nazwa_tabeli` WHERE `exp`='0'Oczywiście zamiast nazwa_tabeli, wpisz swoją nazwę tabeli jaką masz w bazie.
Po dodaniu fixa nie dodawać:
- http://amxx.pl/topic...zie-nowy-gracz/
- http://amxx.pl/topic...resetu-exp-sql/ (także już nie potrzebne, po tym fixie wystarczy kolejno dodawać nowe klasy)
Jeśli ktoś się nie zna, nie powinien także dodawać:
- http://amxx.pl/topic...klas-nowe-menu/
- http://amxx.pl/topic...do-diablo-moda/
Plik z instrukcją:
instrukcja.txt 24,3 KB 332 Ilość pobrań
Użytkownik sebul edytował ten post 12.11.2011 11:02