Gdy w swoim diablomodzie zauwazysz, ze gdy wchodzi nowy gracz, to musi czekac do zmiany mapy aby wyswietlila mu sie /klasa mozesz to latwo naprawic stosujac ponizsze rozwiazanie:
Znajdz:
Spoiler
//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
}
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
}
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()
}
Zamien na:
Spoiler
//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
}
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)
new data[1]
data[0]=id
new q_command[2048]
new i=1
database_user_created[id]=1
format(q_command,2047,"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])
for(i=2;i<9;i++)
{
format(q_command,2047,"%s, ('%s','%s','%s',%i,%i,%i)",q_command,name,ip,sid,i,srv_avg[i],LevelXP[srv_avg[i]-1])
}
SQL_ThreadQuery(g_SqlTuple,"create_klass_Handle",q_command,data,1)
}
}
else sql_start()
}
public create_klass_Handle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
// lots of error checking
new id=Data[0]
if(Errcode)
{
log_to_file("addons/amxmodx/logs/diablo.log","Error on create klass query: %s",Error)
database_user_created[id]=0
asked_klass[id]=0
}
if(FailState == TQUERY_CONNECT_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","Could not connect to SQL database.")
database_user_created[id]=0
asked_klass[id]=0
return PLUGIN_CONTINUE
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_to_file("addons/amxmodx/logs/diablo.log","create klass Query failed.")
database_user_created[id]=0
asked_klass[Data[0]]=0
return PLUGIN_CONTINUE
}
asked_klass[id]=0
database_user_created[id]=2
changerace(id)
return PLUGIN_CONTINUE
}
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()
}
Dodatkowo trzeba zrobić jeszcze to: http://amxx.pl/topic...post__p__227378