| Backstabnoob |
12-28-2010 13:55 |
Server crashing
Is there any reason why this probably causes crashes? A little too often, around two times per map (sometimes it doesn't crash the whole map and sometimes it crashes 8x).
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <sqlx>
#include <hamsandwich>
#include <engine>
#include <colorchat>
new Handle: g_SqlTuple, g_Cache[512]
new g_PlayerSkins[3][33] = {0,0,0}
new g_PlayerUntil[3][33] = {0,0,0}
new g_PlayerModel[3][33][128]
new g_PlayerHat[33][128]
new g_PlayerOmezeni[3][33] = {0,0,0}
new g_itemname[3][33][128]
new g_iEnt[33]
new cvar_port
public client_infochanged(id)
{
for(new x = 0; x < 3; x++)
if(g_PlayerModel[x][id][0])
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
public plugin_init()
{
cvar_port = register_cvar("store_port", "27000")
register_plugin("Skins Store", "1.0.1", "IdiotStrike")
RegisterHam(Ham_Spawn, "player", "client_spawn", 1)
register_event("DeathMsg", "client_death", "a")
set_task(1.0, "LoadDatabase")
}
public LoadDatabase()
{
new Host[64],User[64],Pass[64],Db[64]
get_cvar_string("amx_sql_host",Host,63)
get_cvar_string("amx_sql_user",User,63)
get_cvar_string("amx_sql_pass",Pass,63)
get_cvar_string("amx_sql_db",Db,63)
g_SqlTuple = SQL_MakeDbTuple(Host, User, Pass, Db)
}
/*
public client_PostThink(id)
{
if (is_user_alive(id) && is_valid_ent(g_iEnt[id]))
{
new rendermode, red, green, blue, renderfx, renderamt
get_rendering(id, rendermode, red, green, blue, renderfx, renderamt)
set_rendering(g_iEnt[id], rendermode, red, green, blue, renderfx, renderamt)
}
}
*/
public client_death()
{
new id = read_data(2)
if (is_valid_ent(g_iEnt[id]))
remove_entity(g_iEnt[id])
}
public client_authorized(id)
{
for(new x = 0; x < 3; x++)
ResetVar(id, x)
set_task(1.0, "LoadClient", id)
}
public LoadClient(id)
{
if(!is_user_bot(id) && 1 <= id <= 32)
{
new authid[36]
get_user_authid(id, authid, 35)
format(g_Cache, 511, "SELECT * FROM skiny_data WHERE authid='%s' AND server=%d", authid, get_pcvar_num(cvar_port))
new Data[1]
Data[0] = id
SQL_ThreadQuery(g_SqlTuple, "LoadSkin", g_Cache, Data, 1)
}
}
public LoadSkin(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if (FailState == TQUERY_CONNECT_FAILED)
set_fail_state("CONNECT_FAILED")
else if (FailState == TQUERY_QUERY_FAILED)
set_fail_state("QUERY_FAILED")
if (Errcode)
set_fail_state(Error)
new id = Data[0]
if(SQL_NumResults(Query) > 0)
{
new x = 0
while(SQL_MoreResults(Query))
{
g_PlayerSkins[x][id] = SQL_ReadResult(Query, 2)
g_PlayerUntil[x][id] = SQL_ReadResult(Query, 3)
format(g_Cache, 511, "SELECT * FROM skiny_list WHERE id=%d", g_PlayerSkins[x][id])
new TheData[2]
TheData[0] = id
TheData[1] = x
SQL_ThreadQuery(g_SqlTuple, "LoadSkin_Info", g_Cache, TheData, 2)
x++
SQL_NextRow(Query)
}
}
}
public LoadSkin_Info(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if (FailState == TQUERY_CONNECT_FAILED)
set_fail_state("CONNECT_FAILED")
else if (FailState == TQUERY_QUERY_FAILED)
set_fail_state("QUERY_FAILED")
if (Errcode)
set_fail_state(Error)
new id = Data[0]
new num = Data[1]
if(SQL_NumResults(Query) > 0)
{
new type = SQL_ReadResult(Query, 1)
new path[128]
SQL_ReadResult(Query, 2, path, 127)
SQL_ReadResult(Query, 7, g_itemname[num][id], 127)
if(type == 2)
{
format(g_PlayerModel[num][id], 127, path)
}
else
format(g_PlayerHat[id], 127, path)
g_PlayerOmezeni[num][id] = SQL_ReadResult(Query, 8)
}
}
public IgnoreHandle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if (FailState == TQUERY_CONNECT_FAILED)
set_fail_state("CONNECT_FAILED")
else if (FailState == TQUERY_QUERY_FAILED)
set_fail_state("QUERY_FAILED")
if (Errcode)
set_fail_state(Error)
}
public client_spawn(id)
{
set_task(0.1, "LoadSkinIn_Game", id)
}
public LoadSkinIn_Game(id)
{
if(is_user_connected(id) && is_user_alive(id) && !is_user_bot(id))
{
cs_reset_user_model(id)
new authid[36]
get_user_authid(id, authid, 35)
for(new num = 0; num < 3; num++)
{
if(g_PlayerSkins[num][id])
{
if(g_PlayerUntil[num][id] < get_systime())
ResetVar(id, num)
if(g_PlayerUntil[num][id] > get_systime() && g_PlayerSkins[num][id])
{
if(Is_Model(id, num))
{
if(g_PlayerOmezeni[num][id] == 1 && cs_get_user_team(id) == CS_TEAM_CT)
{
cs_set_user_model(id, g_PlayerModel[num][id])
ColorChat(id, GREEN, "[TraxX Store] ^x01'^x03%s^x01' skin byl nacten.", g_itemname[num][id])
}
else if(g_PlayerOmezeni[num][id] == 2 && cs_get_user_team(id) == CS_TEAM_T)
{
cs_set_user_model(id, g_PlayerModel[num][id])
ColorChat(id, GREEN, "[TraxX Store] ^x01'^x03%s^x01' skin byl nacten.", g_itemname[num][id])
}
else if(g_PlayerOmezeni[num][id] == 3)
{
cs_set_user_model(id, g_PlayerModel[num][id])
ColorChat(id, GREEN, "[TraxX Store] ^x01'^x03%s^x01' skin byl nacten.", g_itemname[num][id])
}
}
else if(!is_valid_ent(g_iEnt[id]) || g_iEnt[id] == 0)
{
new iEnt
if (!(iEnt = create_entity("info_target")))
{
client_print(id, print_chat, "Tvoje cepice je roztrhana nebo neco. Kontaktuj developera!")
return
}
if(is_valid_ent(iEnt))
{
entity_set_model(iEnt, g_PlayerHat[id])
entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_FOLLOW)
entity_set_edict(iEnt, EV_ENT_aiment, id)
}
g_iEnt[id] = iEnt
ColorChat(id, GREEN, "[TraxX Store] ^x01'^x03%s^x01' klobouk byl nacten.", g_itemname[num][id])
}
}
}
}
}
return
}
public client_disconnect(id)
for(new x = 0; x < 3; x++)
ResetVar(id, x)
public ResetVar(id, num)
{
g_PlayerOmezeni[num][id] = 0
g_PlayerUntil[num][id] = 0
g_PlayerSkins[num][id] = 0
if(Is_Model(id, num))
g_PlayerModel[num][id] = ""
else
{
g_PlayerHat[id] = ""
if (is_valid_ent(g_iEnt[id]))
remove_entity(g_iEnt[id])
}
g_itemname[num][id] = ""
}
public plugin_end()
SQL_FreeHandle(g_SqlTuple)
/*
stock get_rendering(index, &rendermode, &red, &green, &blue, &renderfx, &renderamt)
{
rendermode = entity_get_int(index, EV_INT_rendermode)
new Float:color[3]
entity_get_vector(index, EV_VEC_rendercolor, color)
red = floatround(color[0])
green = floatround(color[1])
blue = floatround(color[2])
renderfx = entity_get_int(index, EV_INT_renderfx)
renderamt = floatround(entity_get_float(index, EV_FL_renderamt))
}
*/
stock Is_Model(id, num)
{
if(g_PlayerModel[num][id][0])
return 1
return 0
}
I checked the code many times and haven't found anything wrong by myself. I hope you can help.
|