Szerző Téma: [C++, PY] Cset lassítása  (Megtekintve 428 alkalommal)

Nem elérhető 66Dragon99

  • Trainee
  • *
  • Hozzászólások: 132
  • Segített: 1
  • fb.com/Lovagias66Dragon99
[C++, PY] Cset lassítása
« Dátum: 2020-10-10, 10:21:23 »
Biztonsági mentést csinálj,
ha elrontottam valamit PMben írd le,
hogy mit hol korrigáljak és ha segítség
kell akk a téma alján találsz 1 quicklinket
 a segítségkérő téma nyitásához

Rendszer:
megnyithatsz 1 ablakot a játékban, amivel lelassíthatod a chaten pörgő szövegek sebességét.

Spoiler for KLIENSFORRÁS RÉSZE:
:
locale_inc.h
-ban új sorba
#define CHAT_SLOW_MODEPythonApplicationModule.cpp-ben a  többi  modul alá
#ifdef CHAT_SLOW_MODE
PyModule_AddIntConstant(poModule, "CHAT_SLOW_MODE", true);
#else
PyModule_AddIntConstant(poModule, "CHAT_SLOW_MODE", false);
#endif
Spoiler for Szerverforrás:
common mappa:
service.h-ben új sort csinálsz
a services alatt beilleszted ezt
#define CHAT_SLOW_MODEgame mappa
src mappa
Spoiler for char.cpp:
//Keresd
m_dwLastAttackTime = get_dword_time() - 20000;   
///Rakd alá új sorba
#if defined(CHAT_SLOW_MODE)
m_dwLastTalkTime = 0;
#endif

//Keresd
void CHARACTER::StopStateMachine()
{
CHARACTER_MANAGER::instance().RemoveFromStateList(this);
}

///Rakd alá új sorba
#if defined(CHAT_SLOW_MODE)
bool CHARACTER::CheckSlowMode(bool button, BYTE type)
{
auto slowtime = quest::CQuestManager::instance().GetEventFlag("chatslowmode");
if (slowtime < 0)
slowtime = -1;
auto IsEqual = [type](const std::list<BYTE>& list) -> bool {return std::find(list.begin(), list.end(), type) != list.end();};
auto GenerateTime = [](auto sec) {
char buf[128 + 1];
long hour = sec / 3600;
sec -= hour * 3600;
long min = (sec / 60);
sec -= min * 60;
if (hour > 0 && min > 0)
snprintf(buf, sizeof(buf), "Slow mode enabled.You can talk in %d hour, %d min and %d sec after.", hour, min, sec);
else if (hour > 0 && min == 0)
snprintf(buf, sizeof(buf), "Slow mode enabled.You can talk in %d hour and %d sec after.", hour, sec);
else if (hour == 0 && min > 0)
snprintf(buf, sizeof(buf), "Slow mode enabled.You can talk in %d min and %d sec after.", min, sec);
else
snprintf(buf, sizeof(buf), "Slow mode enabled.You can talk in %d sec after.", sec);
return buf;
};
if (button) {
ChatPacket(CHAT_TYPE_COMMAND, "chatslowmode %d", slowtime);
if (slowtime > 0)
ChatPacket(CHAT_TYPE_INFO, "Slow mode enabled.");
if (slowtime < 0)
ChatPacket(CHAT_TYPE_INFO, "Chat closed.");
return false;
}
if (slowtime && /*!IsGM() &&*/ IsEqual({ CHAT_TYPE_TALKING , CHAT_TYPE_PARTY , CHAT_TYPE_GUILD, CHAT_TYPE_SHOUT })) {
if (slowtime < 0) {
ChatPacket(CHAT_TYPE_INFO, "Chat closed.");
return true;
}
if (get_global_time() < GetLastTalkTime()) {
ChatPacket(CHAT_TYPE_INFO, GenerateTime(GetLastTalkTime() - get_global_time()));
return true;
}
SetLastTalkTime(get_global_time() + slowtime);
}
return false;
}
#endif

Spoiler for char.h:
//Keresd
DWORD GetLastAttackTime() const { return m_dwLastAttackTime; }      
///Rakd alá új sorba
#if defined(CHAT_SLOW_MODE)
bool CheckSlowMode(bool button, BYTE type = 0);
DWORD GetLastTalkTime() const { return m_dwLastTalkTime; }
void SetLastTalkTime(DWORD time) { m_dwLastTalkTime = time; }
#endif

//Keresd
DWORD m_dwLastAttackTime;      
///Rakd alá új sorba
#if defined(CHAT_SLOW_MODE)
DWORD m_dwLastTalkTime;
#endif

Spoiler for cmd.cpp:
///a fájlban szereplő if defined-ek után új sorba megy ez
#if defined(CHAT_SLOW_MODE)
ACMD(chat_slow_mode);
#endif

//Keresd
{ "pcbang_check", do_pcbang_check, 0, POS_DEAD, GM_LOW_WIZARD },
      
///Rakd alá új sorba
#if defined(CHAT_SLOW_MODE)
{ "chat_slow_mode", chat_slow_mode, 0, POS_DEAD, GM_LOW_WIZARD },
#endif

Spoiler for cmd_gm.cpp:
///Rakd a fájl legaljúra új sorba
#if defined(CHAT_SLOW_MODE)
ACMD(chat_slow_mode)
{
char arg1[256];
one_argument(argument, arg1, sizeof(arg1));

if (*arg1) {
int set;
str_to_number(set, arg1);
quest::CQuestManager::instance().SetEventFlag("chatslowmode", set);
for (auto it : DESC_MANAGER::instance().GetClientSet())
if (auto ch = it->GetCharacter())
ch->CheckSlowMode(true);
}
}
#endif
Spoiler for input_login.cpp:
//Keresd
ch->StartCheckSpeedHackEvent();
///Rakd alá új sorba
#if defined(CHAT_SLOW_MODE)
ch->CheckSlowMode(true);
#endif
Spoiler for input_main.cpp:
//Keresd
if (true == SpamBlockCheck(ch, buf, buflen))
{
return iExtraLen;
}
   
///Rakd alá új sorba
#if defined(CHAT_SLOW_MODE)
if (ch->CheckSlowMode(false, pinfo->type))
return iExtraLen;
#endif




Spoiler for A KLIENS része::
Spoiler for root:
Spoiler for game.py:
#Keresd
for serverCommandItem in serverCommandList.items():
self.serverCommander.SAFE_RegisterCallBack(
serverCommandItem[0], serverCommandItem[1]
)

#Rakd alá
if app.CHAT_SLOW_MODE:
self.serverCommander.SAFE_RegisterCallBack("chatslowmode", self.ChatSlowMode)
         
#Valahova a fájl aljára kerüljön ez
if app.CHAT_SLOW_MODE:
def ChatSlowMode(self, var):
if self.interface:
self.interface.ChatSlowMode(var)
Spoiler for interfacemodule.py:
#importok alá
if app.CHAT_SLOW_MODE:
import uiChatSlow
   
#Keresd
def __MakeGuildWindow(self):
self.wndGuild = uiGuild.GuildWindow()
      
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
def ChatSlowMode(self, var):
self.wndChat.SetSlowMode(var)
def OpenChatSlowDialog(self):
self.dlgChatSlow.OpenDialog()
         
#Keresd
self.dlgShop.Hide()
      
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
self.dlgChatSlow = uiChatSlow.ChatSlowMode()
self.dlgChatSlow.LoadDialog()
self.dlgChatSlow.Hide()
         
#Keresd
if self.dlgRestart:
self.dlgRestart.Destroy()
         
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE and self.dlgChatSlow:
self.dlgChatSlow.Destroy()
      
#Keresd
del self.dlgRestart
      
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
del self.dlgChatSlow

Spoiler for uichat.py:
#Rakd az importok alá
if app.CHAT_SLOW_MODE:
import uiToolTip, uichatslow
   
#Keresd
CHAT_WINDOW_WIDTH = 600
   
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
CHAT_WINDOW_WIDTH += 20
      
#Keresd
btnSendWhisper = ui.Button()
   
#Rakd alá új üres sorba Above
if app.CHAT_SLOW_MODE:
self.btnSlowMode = ui.Button()
self.btnSlowMode.SetParent(self)
self.btnSlowMode.SetEvent(ui.__mem_func__(self.ChatSlowMode))
self.btnSlowMode.Hide()
self.InformationText = []
         
#Keresd
def SetSendWhisperEvent(self, event):
self.btnSendWhisper.SetEvent(event)
         
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
def ChatSlowMode(self):
if str(player.GetName()).find("[") != -1:
self.interface.OpenChatSlowDialog()

def SetSlowMode(self, var):
InformationTextArr = [["Slowmode is closed."], ["Chat is closed.","You can not talk."], ["Slowmode is enabled:","Members can send one"]]
sec = int(var)
hour = sec / 3600
sec -= hour * 3600
min = (sec / 60)
sec -= min * 60
if hour > 0 and min > 0:
InformationTextArr[2].append("message every %d hour and %d min" % (hour, min))
elif hour > 0 and min == 0:
InformationTextArr[2].append("message every %d hour." % (hour))
elif hour == 0 and min > 0 and sec == 0:
InformationTextArr[2].append("message every %d min" % (min))
elif min > 0 and sec > 0:
InformationTextArr[2].append("message every %d min and %d sec" % (min, sec))
else:
InformationTextArr[2].append("message every %d seconds." % sec)
var = int(var)
if var == -1:
var = 1
elif var > 0:
var = 2
self.InformationText = InformationTextArr[var]
self.btnSlowMode.SetUpVisual("d:/ymir work/ui/game/taskbar/chat_%d_0.png" % var)
self.btnSlowMode.SetOverVisual("d:/ymir work/ui/game/taskbar/chat_%d_1.png" % var)
self.btnSlowMode.SetDownVisual("d:/ymir work/ui/game/taskbar/chat_%d_2.png" % var)
self.tooltipI = uiToolTip.ItemToolTip()
self.tooltipI.Hide()
self.tooltipInfo = [self.tooltipI]*len(self.InformationText)
for i in xrange(len(self.InformationText)):
self.tooltipInfo[i].AlignHorizonalCenter()
if i == 0:
self.tooltipInfo[i].AppendTextLine(self.InformationText[i], 0xffffff00)
else:
self.tooltipInfo[i].AppendTextLine(self.InformationText[i])
self.tooltipInfo[i].Hide()
            
#Keresd
self.btnSendWhisper = 0
   
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
self.btnSlowMode = 0
         
#Keresd
self.btnChatLog.SetPosition(self.GetWidth() - 25, 2)
      
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
self.btnSlowMode.SetPosition(self.GetWidth() - 80, -5)
self.btnSlowMode.Show()
         
#Keresd
self.btnSendWhisper.Hide()      
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
self.btnSlowMode.Hide()
      
#Keresd
def OnUpdate(self):   
#Rakd alá új üres sorba in
if app.CHAT_SLOW_MODE:
(x, y) = self.btnSlowMode.GetGlobalPosition()
for i in xrange(len(self.InformationText)):
if self.btnSlowMode.IsIn():
self.tooltipInfo[i].SetToolTipPosition(x+20, y-10)
self.tooltipInfo[i].Show()
else:
self.tooltipInfo[i].Hide()
               
#Keresd
self.chatInputSet.BindInterface(interface)
      
#Rakd alá új üres sorba
if app.CHAT_SLOW_MODE:
self.interface = interface
Spoiler for uichatslow.py-t csinálsz:
Kód: (UTF8-as kódolással) [Kijelölés]
import dbg
import app
import net

import ui
class ChatSlowMode(ui.ScriptWindow):

def __init__(self):
ui.ScriptWindow.__init__(self)

def __del__(self):
ui.ScriptWindow.__del__(self)

def LoadDialog(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/chatslowmode.py")
self.OkeyButton=self.GetChild("AcceptButton")
self.CancelButton=self.GetChild("CancelButton")
self.pos=0
self.type = 0
self.GaugeChatSlow = self.GetChild("gaugeslow")
self.TittleBar = self.GetChild("TitleBar")
self.ValText = self.GetChild("ValText")
self.GaugeChatSlow.SetSliderPos(0.0)
self.GaugeChatSlow.SetEvent(ui.__mem_func__(self.OnChangeSlowGauge))
self.OkeyButton.SetEvent(ui.__mem_func__(self.SetSlowMode))
self.CancelButton.SetEvent(ui.__mem_func__(self.Close))
self.TypeButtonList = []
for bl in xrange(3):
self.TypeButtonList.append(self.GetChild("type_" + str(bl)))
self.TypeButtonList[bl].SetToggleUpEvent(lambda arg=bl: self.ChangeType(arg))
self.TypeButtonList[bl].SetToggleDownEvent(lambda arg=bl: self.ChangeType(arg))
self.TittleBar.SetCloseEvent(ui.__mem_func__(self.Close))
self.ChangeType(self.type)
return 1

def ChangeType(self, type):
self.type = type
for bl in xrange(3):
if not self.type == bl:
self.TypeButtonList[bl].SetUp()
else:
self.TypeButtonList[bl].Down()

self.OnChangeSlowGauge()
def Destroy(self):
self.GaugeChatSlow=0
self.pos=0
self.type = 0
self.OkeyButton=0
self.TittleBar=0
self.CancelButton=0
self.ClearDictionary()

def OnChangeSlowGauge(self):
self.pos = self.GaugeChatSlow.GetSliderPos() * 100
if self.GaugeChatSlow.GetSliderPos() == 1:
self.ValText.SetText("Close Chat")
self.pos = -1
elif int(self.pos) == 0:
self.ValText.SetText("Disable Slow Mode")
else:
if self.type == 0:
self.ValText.SetText("%d seconds" % self.pos)
elif self.type == 1:
self.ValText.SetText("%d minute" % self.pos)
else:
self.ValText.SetText("%d hour" % self.pos)
def OpenDialog(self):
self.SetTop()
self.SetCenterPosition()
self.Show()

def Close(self):
self.Hide()
return TRUE

def SetSlowMode(self):
if self.type == 1:
self.pos = int(self.pos)*60
elif self.type == 2:
self.pos = int(self.pos)*3600
net.SendChatPacket("/chat_Slow_mode %d" % self.pos)
self.Close()

def OnPressEscapeKey(self):
self.Close()
return TRUE

Spoiler for képfájlok:
Spoiler for uiscript:
Kód: (chatslowmode.py-t csinálsz) [Kijelölés]
import app
import item
import uiScriptLocale
P_X = 200
P_Y = 145
BUTTON_ROOT = "d:/ymir work/ui/public/"
window = {
"name" : "ChatSlowMode",
"x" : 0,
"y" : 0,
"style" : ("movable", "float",),
"width" : P_X,
"height" : P_Y,
"children" :
(
{
"name" : "board",
"type" : "board",
"style" : ("attach",),
"x" : 0,
"y" : 0,
"width" : P_X,
"height" : P_Y,
"children" :
(
{
"name" : "TitleBar",
"type" : "titlebar",
"style" : ("attach",),
"x" : 6,
"y" : 6,
"width" : P_X-12,
"color" : "yellow",
"children" :
(
{
"name":"TitleName",
"type":"text",
"x":95,
"y":3,
"text":"Chat Slow",
"text_horizontal_align":"center"
},
),
},
{
"name":"ValText",
"type":"text",
"x":105,
"y":30,
"text":"",
"text_horizontal_align":"center"
},
{
"name" : "type_0",
"type" : "toggle_button",

"x" : 27,
"y" : 80,

"text" : "Sec",

"default_image" : BUTTON_ROOT + "small_Button_01.sub",
"over_image" : BUTTON_ROOT + "small_Button_02.sub",
"down_image" : BUTTON_ROOT + "small_Button_03.sub",
},
{
"name" : "type_1",
"type" : "toggle_button",

"x" : 77,
"y" : 80,

"text" : "Min",

"default_image" : BUTTON_ROOT + "small_Button_01.sub",
"over_image" : BUTTON_ROOT + "small_Button_02.sub",
"down_image" : BUTTON_ROOT + "small_Button_03.sub",
},
{
"name" : "type_2",
"type" : "toggle_button",

"x" : 127,
"y" : 80,

"text" : "Hour",

"default_image" : BUTTON_ROOT + "small_Button_01.sub",
"over_image" : BUTTON_ROOT + "small_Button_02.sub",
"down_image" : BUTTON_ROOT + "small_Button_03.sub",
},
{
"name" : "AcceptButton",
"type" : "button",
"x" : 35,
"y" : 110,
"text" : "",
"default_image" : BUTTON_ROOT+"AcceptButton00.sub",
"over_image" : BUTTON_ROOT+"AcceptButton01.sub",
"down_image" : BUTTON_ROOT+"AcceptButton02.sub",
},
{
"name" : "CancelButton",
"type" : "button",
"x" : 109,
"y" : 110,
"text" : "",
"default_image" : BUTTON_ROOT+"CancleButton00.sub",
"over_image" : BUTTON_ROOT+"CancleButton01.sub",
"down_image" : BUTTON_ROOT+"CancleButton02.sub",
},
{
"name" : "gaugeslow",
"type" : "sliderbar",

"x" : 15,
"y" : 55,
},
),
},
),
}


Hiba vagy bug észlelése esetén ezzel nyithatsz új segítségkérő témát
Csatlakozz még ma -->discord.gg/fankpew <-- menőőő
"Te$a csak utald Paypalon meg a bankszámlára a zsét és minden rendben leszö"