Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Welcome to another OUTWARDLY EXPERIENCE!!!
- In this we will learn how to control a discord command to affect ingame activities like banning, kicking or sending a message to a player!
- Let's GO!
- */
- #include <a_samp>
- #include <sscanf2>
- #include <discord-connector> // Including the include of the plugin //
- /*
- Welcome to another OUTWARDLY EXPERIENCE!!!
- In this we will learn how to control a discord command to affect ingame activities like banning, kicking or sending a message to a player!
- Let's GO!
- */
- #include <a_samp>
- #include <sscanf2>
- #include <discord-connector> // ปลักอิน //
- static DCC_Channel:commandChannel;
- static DCC_Guild:guildName;
- static DCC_Role:adminRole;
- public OnGameModeInit(){
- commandChannel = DCC_FindChannelById("651471342180368394"); // ห้องดิษคอส
- guildName = DCC_FindGuildById("651471013850382337"); // ชื่อเซิฟเวอร์ดิษคอส
- adminRole = DCC_FindRoleById("651471401408135180"); // ยศดิษดิษคอส
- // DCC_Channel ได้เปลี่ยนเป็น commandChannel //
- return 1;
- }
- public OnGameModeExit(){
- return 1;
- }
- // ~~~~~~~~~~~~~~~~~~~ DISCORD COMMANDS SECTION ~~~~~~~~~~~~~~~~ //
- public DCC_OnMessageCreate(DCC_Message:message){ // Callback เชื่อมต่อ Discord กับ Serevr
- new DCC_Channel:channel;
- DCC_GetMessageChannel(message, channel);
- // ถ้า ห้องที่ใช้คำสั่ง ไม่ตรงกับ ห้องที่เรากำหนดไว้ให้ใช้คำสั่ง เซิฟเวอร์จะตีกลับ
- if(channel != commandChannel)
- return 1;
- //ค้นหาคนออกคำสั่งว่าเป็นใคร
- new DCC_User:author;
- DCC_GetMessageAuthor(message, author);
- //เอาคนที่ใช้คำสั่งมาตรวจสอบว่าเป็นคนหรอบอท
- new bool:isBot;
- DCC_IsUserBot(author, isBot);
- if(isBot) return 1;
- // ตรวจสอบคนใช้คำสั่งว่ามียศถึงที่ทางเซิฟเวอร์กำหนดหรอป่าว ? //
- new bool:hasRole;
- DCC_HasGuildMemberRole(guildName, author, adminRole, hasRole);
- // หากคนใช้คำสั่งมียศไม่ถึงที่กำหนดส่งกลับ
- if(!hasRole){
- DCC_SendChannelMessage(commandChannel, "You do not have the role required");
- return 1;
- }
- new str[256];
- new command[32], params[128];
- DCC_GetMessageContent(message, str); // ข้อความที่ส่งมาจาก Discord จะถุกจัดเก็บไว้ภายใน Str
- // แยกคำสั่ง และ จำนวน ออกจากกัน //
- sscanf(str, "s[32]s[128]", command, params);
- // ตรวจสอบว่าใช้คำสั่งถุกหรอป่าว
- if(!strcmp(command, "&chat", true))
- {
- new playerID, _message[128];
- sscanf(params, "us[128]", playerID, _message); // แยกไอดีผู้เล่นและข้อความ //
- if(!IsPlayerConnected(playerID))
- return DCC_SendChannelMessage(channel, "The player is not online!");
- SendClientMessage(playerID, -1, _message);
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment