Untitled

 avatar
unknown
plain_text
2 years ago
2.8 kB
13
Indexable
#include <YSI\y_hooks>

	//-------------------------------------------------------------------
	//					Project create by #nDP 						   //
	//					Fb.com/nguyenduyphuong.com  			       //
	//					Copyright by nDP" 							   //
	//-------------------------------------------------------------------

//____________________________________________________________________________//

new DCC_Channel:bangrell;
new DCC_Guild:guildName;
new DCC_Role:verifyRole;

hook OnGameModeInit()
{
    bangrell = DCC_FindChannelById("991217799559131206");
    guildName = DCC_FindGuildById("980135398770606101");
    verifyRole = DCC_FindRoleById("994917029226233866");
    return 1;
}

DCMD:kichhoat(user, channel, params[])
{
	if(channel != bangrell) return DCC_SendChannelMessage(channel, "[ERROR] Ban vui long truy cap dung noi de kich hoat tai khoan!");

	new bool:hasRole;
    DCC_HasGuildMemberRole(guildName, user, verifyRole, hasRole);

   	if(hasRole){
        DCC_SendChannelMessage(channel, "```Tai khoan #Discord nay da xac minh cho mot account nao roi , khong the kich hoat tiep tuc!```");
        return 1;
    }
	else {
		new name[MAX_PLAYER_NAME];
		if(sscanf(params, "s[124]", name)) return DCC_SendChannelMessage(channel, "```SU DUNG: !kichhoat [player name]```");
		new giveplayerid = ReturnUser(name);

		if(IsPlayerConnected(giveplayerid)) {
			new string[128];
		    format(string,sizeof(string),"```Tai khoan %s dang online, vui long /q truoc khi kich hoat !```", name);
	    	DCC_SendChannelMessage(channel, string);
	    	return 1;
		}
		else {
			new tmpName[24], query[512];
			mysql_escape_string(name, tmpName);

			new userid[21];
			DCC_GetUserId(user, userid, DCC_ID_SIZE);

			format(query,sizeof(query),"UPDATE `accounts` SET `Verified`=1 WHERE `Username` = '%s'", tmpName);
			mysql_function_query(MainPipeline, query, false, "OnVerifyAccountDiscord", "ss", userid, tmpName);
		}
	}
	return 1;
}

forward OnVerifyAccountDiscord(index[],name[]);
public OnVerifyAccountDiscord(index[],name[])
{
	new string[256];
	new DCC_User:userVerify;
	new namedis[DCC_USERNAME_SIZE];

	userVerify = DCC_FindUserById(index);
	DCC_GetUserName(userVerify, namedis, sizeof namedis);

	if(mysql_affected_rows(MainPipeline)) {
		format(string, sizeof(string), "```Ban da kich hoat tai khoan %s thanh cong.```", name);
		DCC_SendChannelMessage(bangrell, string);

		DCC_AddGuildMemberRole(guildName, userVerify, verifyRole);
		
		format(string, sizeof(string), "Verify: Account Discord %s da kich hoat tai khoan %s thanh cong!", namedis, name);
		Log("logs/verify.log", string);
	}
	else {
		format(string, sizeof(string), "```Ten nhan vat %s nay khong ton tai trong may chu!```", name);
		DCC_SendChannelMessage(bangrell, string);
	}
	return 1;
}
Editor is loading...
Leave a Comment