public client_putinserver(id) {
if(is_user_bot(id))
return;
betoltve[id] = false;
Dollar[id] = 0;
Rang[id] = 0;
Oles[id] = 0;
Kulcs[id] = 0;
SMS[id] = 0;
Masodpercek[id] = 0;
g_Id[id] = 0;
g_MVP[id] = 0;
Vip[id] = 0;
for(new i;i < MAX; i++)
OsszesSkin[i][id] = 0;
for(new i;i < LADA; i++)
Lada[i][id] = 0;
SelectDataTable(id);
}
public client_disconnected(id)
{
if(is_user_bot(id))
return;
TableUpdate(id);
}
new Handle:g_SqlTuple;
public plugin_cfg()
{
//Kiszolgáló | Felhasználó | Jelszó | Adatbázis
g_SqlTuple = SQL_MakeDbTuple("mysql8.srkhost.eu", "", "", "s44532_outside_mod");
CreateTable();
}
public CreateTable(){
new iLen;
static sQuery[10048];
iLen += formatex(sQuery[iLen], charsmax(sQuery), "CREATE TABLE IF NOT EXISTS \\`%s\\` ", Tablename);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "( ");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`Id\\` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`SteamId\\` varchar(64) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`Masodpercek\\` int(11) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`Ultimate\\` int(11) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`Dollar\\` int(11) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`Szint\\` int(11) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`Oles\\` int(11) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`DropOles\\` int(11) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`Vip\\` int(11) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`Kulcs\\` int(11) NOT NULL,");
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`MVP\\` int(11) NOT NULL)");
for(new i;i < MAX; i++)
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`F%d\\` int(11) NOT NULL,", i);
for(new i;i < LADA; i++)
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`L%d\\` int(11) NOT NULL,", i);
for(new i;i < 11; i++)
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "\\`S%d\\` int(11) NOT NULL,", i);
SQL_ThreadQuery(g_SqlTuple, "TableCreateThread", sQuery);
}
public TableUpdate(id)
{
if(betoltve[id]) {
static sQuery[10048];
new iLen, g_sSteamID[64];
get_user_authid(id, g_sSteamID, charsmax(g_sSteamID));
iLen += formatex(sQuery[iLen], charsmax(sQuery), "UPDATE \\`%s\\` SET ", Tablename);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "Masodpercek = ^"%i^", ", Masodpercek[id]+get_user_time(id));
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "Ultimate = ^"%i^", ", SMS[id]);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "Dollar = ^"%i^", ", Dollar[id]);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "Szint = ^"%i^", ", Rang[id]);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "Oles = ^"%i^", ", Oles[id]);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "DropOles = ^"%i^", ", D_Oles[id]);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "Vip = ^"%i^", ", Vip[id]-get_user_time(id));
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "MVP = ^"%i^", ", g_MVP[id]);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "Kulcs = ^"%s^";", Kulcs[id]);
for(new i=0;i < MAX; i++)
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "F%d = ^"%i^", ", i, OsszesSkin[i][id]);
for(new i;i < LADA; i++)
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "L%d = ^"%i^", ", i, Lada[i][id]);
for(new i;i < 11; i++)
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "S%d = ^"%i^", ", i, Skin[i][id]);
iLen += formatex(sQuery[iLen], charsmax(sQuery)-iLen, "Kulcs = ^"%i^" WHERE \\`SteamId\\` = ^"%s^";", Kulcs[id], g_sSteamID);
SQL_ThreadQuery(g_SqlTuple, "QuerySetDataTable", sQuery);
}
}
public TableCreateThread(iFailState, Handle:sQuery, sError[], iErrcode, sData[], iDataSize, Float:fQueuetime)
{
if(iFailState == TQUERY_CONNECT_FAILED)
set_fail_state("[Create] Nem lehet csatlakozni az adatbazishoz!");
else if(iFailState == TQUERY_QUERY_FAILED)
set_fail_state("[Create] Lekerdezesi hiba");
if(iErrcode)
log_amx("[Create] Hiba:**!! %s !!**", sError);
}
public TableInsert(id)
{
static sQuery[10048], g_sSteamID[64];
get_user_authid(id, g_sSteamID, charsmax(g_sSteamID));
formatex(sQuery, charsmax(sQuery), "INSERT INTO \\`%s\\` (\\`Steamid\\`) VALUES (^"%s^");", Tablename, g_sSteamID);
SQL_ThreadQuery(g_SqlTuple, "QuerySetDataTable", sQuery);
betoltve[id] = true;
}
public SelectDataTable(id)
{
static sQuery[10048];
new sData[1], g_sSteamID[64];
sData[0] = id;
get_user_authid(id, g_sSteamID, charsmax(g_sSteamID));
formatex(sQuery, charsmax(sQuery), "SELECT * FROM \\`%s\\` WHERE Steamid = ^"%s^";", Tablename, g_sSteamID);
SQL_ThreadQuery(g_SqlTuple, "QuerySelectDataTable", sQuery, sData, 1);
}
public QuerySelectDataTable(iFailState, Handle:sQuery, sError[], iErrcode, sData[], iDataSize, Float:fQueuetime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("[Insert] Hiba:**!! %s !!**", sError);
return;
}
else
{
new id = sData[0];
if(SQL_NumRows(sQuery) > 0)
{
Masodpercek[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "Masodpercek"));
SMS[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "Ultimate"));
Dollar[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "Dollar"));
Rang[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "Szint"));
Oles[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "Oles"));
D_Oles[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "DropOles"));
Vip[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "Vip"));
g_MVP[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "MVP"));
for(new i;i < MAX; i++)
{
new String[64];
formatex(String, charsmax(String), "F%d", i);
OsszesSkin[i][id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, String));
}
for(new i;i < LADA; i++)
{
new String[64];
formatex(String, charsmax(String), "L%d", i);
Lada[i][id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, String));
}
for(new i;i < 11; i++)
{
new String[64];
formatex(String, charsmax(String), "S%d", i);
Skin[i][id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, String));
}
Kulcs[id] = SQL_ReadResult(sQuery, SQL_FieldNameToNum(sQuery, "Kulcs"));
betoltve[id] = true;
}
else
TableInsert(id);
}
}
public QuerySetDataTable(iFailState, Handle:sQuery, sError[], iErrcode, sData[], iDataSize, Float:fQueuetime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("[SetData] Hiba:**!! %s !!**", sError);
return;
}
}
public sayhook(id)
{
new sMessage[512], sText[128], sDeath[16], iLen, sName[64];
read_args(sMessage, charsmax(sMessage));
remove_quotes(sMessage);
if(strlen(sMessage) == 0 || sMessage[0] == '/' || sMessage[0] == '@')
return PLUGIN_HANDLED_MAIN;
new iTeam, iColor;
iTeam = get_user_team(id);
switch(iTeam)
{
case CS_TEAM_CT: iColor = -3;
case CS_TEAM_T: iColor = -2;
case CS_TEAM_SPECTATOR: iColor = -1;
}
format(sDeath, charsmax(sDeath), is_user_alive(id) ? "":"*Halott*");
iLen += formatex(sText[iLen], charsmax(sText)-iLen, "^1%s", sDeath);
if(get_user_flags(id) & OWNER)
iLen += formatex(sText[iLen], charsmax(sText)-iLen, "^1[^4Tulaj^1]");
else if(get_user_flags(id) & FOADMIN)
iLen += formatex(sText[iLen], charsmax(sText)-iLen, "^1[^4FőAdmin^1]");
else if(get_user_flags(id) & ADMIN)
iLen += formatex(sText[iLen], charsmax(sText)-iLen, "^1[^4Admin^1]");
else if(get_user_flags(id) & VIP)
iLen += formatex(sText[iLen], charsmax(sText)-iLen, "^1[^4Vip^1]");
else
iLen += formatex(sText[iLen], charsmax(sText)-iLen, "^1[^4Játékos^1]");
//iLen += formatex(sText[iLen], charsmax(sText)-iLen, "^1[^4%s^1]", Rangok[g_Rang[id]][Szint]);
get_user_name(id, sName, charsmax(sName));
format(sMessage, charsmax(sMessage), "%s ^1%s ^3»^3 %s", sText, sName, sMessage);
for(new i; i < get_maxplayers(); i++)
{
if(!is_user_connected(i))
continue;
client_print_color(i, iColor, sMessage);
}
return PLUGIN_HANDLED_MAIN;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
*/