Базовая часть шаблона AsiPlugin. Содержимое файлов в ней не меняется при создании проекта из шаблона.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SAMPInputInfo.h 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef SAMPINPUTINFO_H
  2. #define SAMPINPUTINFO_H
  3. enum LimitInputInfos
  4. {
  5. SAMP_MAX_CLIENTCMDS = 144
  6. };
  7. #include "../samp.h"
  8. #include "SAMPInputBox.h"
  9. /**
  10. * @todo write docs
  11. */
  12. typedef void(__cdecl *CMDPROC) (PCHAR);
  13. #pragma pack(push, 1)
  14. class SAMPInputInfo
  15. {
  16. public:
  17. void *pD3DDevice;
  18. void *pDXUTDialog;
  19. SAMPInputBox *pDXUTEditBox;
  20. CMDPROC pCMDs[SAMP_MAX_CLIENTCMDS];
  21. char szCMDNames[SAMP_MAX_CLIENTCMDS][33];
  22. int iCMDCount;
  23. int iInputEnabled;
  24. char szInputBuffer[129];
  25. char szRecallBufffer[10][129];
  26. char szCurrentBuffer[129];
  27. int iCurrentRecall;
  28. int iTotalRecalls;
  29. CMDPROC pszDefaultCMD;
  30. bool addChatCommand(std::string cmd, CMDPROC proc);
  31. template<class C>
  32. bool addChatCommand(std::string cmd, C *obj, void(C::*method)(char*)){
  33. CShortAsm *rasm = new CShortAsm();
  34. rasm->push(r86::EBP);
  35. rasm->mov(r86::EBP, r86::ESP);
  36. rasm->mov(r86::EAX, r86::EBP, 8);
  37. rasm->push(r86::ECX);
  38. rasm->mov(r86::ECX, reinterpret_cast<const int>(obj));
  39. rasm->push(r86::EAX);
  40. rasm->call(reinterpret_cast<int>(reinterpret_cast<void*>(method)));
  41. rasm->pop(r86::ECX);
  42. rasm->pop(r86::EBP);
  43. rasm->ret();
  44. byteValue<CShortAsm*> p;
  45. p.value = rasm;
  46. rasm->insert({ p.bytes[0], p.bytes[1], p.bytes[2], p.bytes[3] }); //0x15
  47. rasm->insert({ 0xDE, 0xAD, 0xC0, 0xDE });
  48. return addChatCommand(cmd, (CMDPROC)rasm->getAddr());
  49. }
  50. bool deleteCommand(std::string cmd);
  51. bool sendCommand(std::string cmdWithParams);
  52. bool execCommand(std::string cmd, std::string params);
  53. bool execCommand(int cmdId, std::string params);
  54. int getCommandId(std::string cmd);
  55. bool changeCommand(int cmdId, std::string cmd, CMDPROC proc); // change cmd name and proc by cmdId
  56. bool changeCommand(int cmdId, std::string cmd); // change cmd name by cmdId
  57. bool changeCommand(int cmdId, CMDPROC proc); // change proc by cmdId
  58. bool changeCommand(std::string cmd, CMDPROC proc); // change proc by cmd name
  59. bool changeCommand(std::string cmd, std::string new_cmd); // change cmd name by cmd name
  60. bool changeCommand(std::string cmd, std::string new_cmd, CMDPROC proc); // change cmd name and proc by cmd name
  61. };
  62. #pragma pack(pop)
  63. #endif // SAMPINPUTINFO_H