Client Login Portal   News Support
  • 22
  •   Request Server
  •   Control Panel
  •   Services
  •   
     Ultra-Host - Portal
    Ultra-Host - Portal
    Dear Guest! You are not registered or logged in! Click here to register or click here to login.



    You are not registered or logged in! Click here to register or click here to login.



    [Tutorial]Discord-connector+discord logs from ingame (Read 78 times)
    Posted: July 7, 2020 1:57:55
    Offline xTrevor
    Member

     
     
    Posts: 63
    Private message
    [Tutorial]Discord-connector+discord logs from ingame
     
     
    Hello guys i would today learn you how to setup up a discord-connector to your gamemode.
    first we need discord-connector include+plugin

    second
     new DCC_Channel:g_Discord_Chat;


    now under ongamemodeinit
    g_Discord_Chat = DCC_FindChannelById("");  //add your channel id here


    now to create the message
    forward DCC_OnMessageCreate(DCC_Message:message);
    public DCC_OnMessageCreate(DCC_Message:message)
    {
        new realMsg[100];
        DCC_GetMessageContent(message, realMsg, 100);
        new bool:IsBot;
        new DCC_Channel:channel;
        DCC_GetMessageChannel(message, channel);
        new DCC_User:author;
        DCC_GetMessageAuthor(message, author);
        DCC_IsUserBot(author, IsBot);
        if(channel == g_Discord_Chat && !IsBot) 
        {
            new user_name[32 + 1], str[152];
            DCC_GetUserName(author, user_name, 32);
            format(str,sizeof(str), "{8a6cd1}[Discord] {aa1bb5}%s: {ffffff}%s",user_name, realMsg);
            SendClientMessageToAll(-1, str);
        }
     
        return 1;
    } 


    now under onplayertext

    new name[MAX_PLAYER_NAME + 1];
        GetPlayerName(playerid, name, sizeof name);
        new msg[128];
        format(msg, sizeof(msg), "```%s: %s```", name, text);
        DCC_SendChannelMessage(g_Discord_Chat, msg); 


    now under onplayerconnect
     new name[MAX_PLAYER_NAME + 1];
        GetPlayerName(playerid, name, sizeof name);
     
    	new string[128];
        if (_:g_Discord_Chat == 0) // allowing the message to create
        g_Discord_Chat = DCC_FindChannelById(""); // your channel id
     
        format(string, sizeof string, " ```%s Joined The Server```", name);
        DCC_SendChannelMessage(g_Discord_Chat, string);


    now under onplayerdiscoonect
     new name[MAX_PLAYER_NAME + 1];
        GetPlayerName(playerid, name, sizeof name);
     
        if (_:g_Discord_Chat == 0) //allowing the message to create
        g_Discord_Chat = DCC_FindChannelById(""); //channel id 


    now lets go to make logs

    new DCC_Channel:logs; 


    now again under ongamemodeinit

    pm = DCC_FindChannelById("");  //your channel id where the logs will be posted


    now for example i wanna the pms logs to be posted in my discord channel
    i will also post the cmd

     CMD:pm(playerid, params[])
    {
           new id, string[128], string2[128], sender[MAX_PLAYER_NAME], reciever[MAX_PLAYER_NAME];
           if(sscanf(params, "us[75]", id, params[2])) return SendClientMessage(playerid, COLOR_RED, "Usage: /pm <id> <message>");
           GetPlayerName(playerid, sender, sizeof(sender));
           GetPlayerName(id, reciever, sizeof(reciever));
           format(string, sizeof(string), "pm From %s: %s", sender, params[2]);
    	   format(string2, sizeof(string2), "pm For %s: %s", reciever, params[2]);
    	   SendClientMessage(id, COLOR_YELLOW, string);
    	   SendClientMessage(playerid, COLOR_YELLOW, string2);
           new name[MAX_PLAYER_NAME + 1];
       	   GetPlayerName(playerid, name, sizeof name);
       	   new msg[128];
       	   format(msg, sizeof(msg), "```%s Pmed %s: %s```", sender, reciever, params[2]);
       	   DCC_SendChannelMessage(logs, msg);
           return 1;
    }


    you can also do it with any other cmd just add thoso

    for example in the end of the ban cmd
    new name[MAX_PLAYER_NAME + 1];
       	   GetPlayerName(playerid, name, sizeof name);
       	   new msg[128];
       	   format(msg, sizeof(msg), "```%s banned %s reason: %s```", admin, banner, reason); // edit them
       	   DCC_SendChannelMessage(logs, msg); 




     


     


    Statistics
    Services
    Support

    - Online servers: 1,547
    - Registered users: 132,485
    - Uptime: 7 years, 6 months and 9 days.

    © Ultra-Host v9.2 (2013-2020) - All Rights Reserved.