fork download
  1. #pragma once
  2.  
  3. #include <string>
  4. #include <map>
  5.  
  6. namespace SAMPGDK
  7. {
  8. namespace ZCMD
  9. {
  10. class Command
  11. {
  12. public:
  13. virtual bool do_command(int playerid, std::string params) = 0;
  14. };
  15. namespace Internal
  16. {
  17. void register_command(Command* cmd, std::string name);
  18. extern std::map<std::string, Command*> command_map;
  19. };
  20. };
  21. };
  22.  
  23. //VS and clang have a mangled name limit of 2048 chars, g++ "unlimited" (well, limited by memory).
  24. #define ZERO_COMMAND(name) \
  25. class cmd ## name : public SAMPGDK::ZCMD::Command\
  26. {\
  27. public:\
  28. cmd ## name() { SAMPGDK::ZCMD::Internal::register_command(this, "/"#name); }\
  29. bool do_command(int playerid, std::string params);\
  30. };\
  31. inline bool cmd ## name::do_command(int playerid, std::string params)
  32.  
  33. bool OnPlayerCommandReceived(int playerid,std::string command, std::string params);
  34. void OnPlayerCommandExecuted(int playerid, std::string, std::string params, bool success);
  35.  
  36. //note that the 'command' is always in lower-case because of the transformation done in the main processing step
  37. bool OnUnknownCommand(int playerid, std::string command, std::string params);
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty