Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <sampgdk\a_samp.h>
- #include <map>
- #include <string>
- #include <functional>
- #ifndef _ZCMD_H
- #define _ZCMD_H
- extern std::map<std::string, std::function<bool(int, char*)>> commands;
- #define COMMAND:command(playerid, params) \
- bool cmd_command(int playerid, char* params); \
- commands[#command] = cmd_command(playerid, params); \
- bool cmd_command(int playerid, char* params)
- #define CMD:command(playerid, params) \
- COMMAND:command(playerid, params)
- #define command(cmd, playerid, params) \
- COMMAND:cmd(playerid, params)
- #define cmd(command, playerid, params) \
- COMMAND:command(playerid, params)
- #ifndef isnull
- #define isnull(str) \
- ((!(str[0])) || (((str[0]) == '\1') && (!(str[1]))))
- #endif
- PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerCommandText(int playerid, const char* cmdtext)
- {
- char* cmd;
- int pos;
- while (cmdtext[++pos] > ' ')
- cmd[pos - 1] = tolower(cmdtext[pos]);
- while (cmdtext[pos] == ' ') pos++;
- char* params = const_cast<char*>(strstr(cmdtext, &cmdtext[pos]));
- if (!cmdtext[pos])
- return commands[cmd](playerid, "");
- else
- return commands[cmd](playerid, params);
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment