1. sayfa (Toplam 1 sayfa)

Request fix compilation error

Gönderilme zamanı: Sal Mar 16, 2021 5:19 pm
gönderen Midnight1338
Hi, i try to add gag list to read from ini file, but i am not able to fix this error please help.

Kod: Tümünü seç

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <regex>

#define GAG_DEFAULT_TIME	2
#define TASK				12830
#define EXCLUDE_GAG			ADMIN_CHAT
#define G_A_G				60

#define REGEX_IP_PATTERN "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
#define IsIP(%1) (regex_match_c(%1, g_IP_pattern, g_regex_return) > 0)

new Regex:g_IP_pattern
new g_regex_return
new DataDir[64]
new gagIp[512][32]
new gagDetails[512][256]
new gagPlayer[33]=false

new SERVERNAME [] = "BlackJack";

new Reads;
new Read_All[100][64];

new const bChat[] = "addons/amxmodx/configs/forbidden_words.ini";

public plugin_init() {
	register_plugin("Gag sistem", "0.1", "")

	register_clcmd("say", "vSay")
	register_clcmd("say_team", "vSay")
	register_clcmd("amx_chat","vSay")
	register_clcmd("amx_gag", "cAmxGag", ADMIN_CHAT, "- <Name> <duration> <reason>")
	register_clcmd("amx_ungag", "cAmxUnGag", ADMIN_CHAT, "<Name>")

	get_datadir(DataDir, charsmax(DataDir))
	new error[2]
	g_IP_pattern = regex_compile(REGEX_IP_PATTERN, g_regex_return, error, sizeof(error) - 1)

	if(!file_exists(bChat)) {
		set_fail_state("Forbidden Words File Not Found.");
	}
}

public plugin_precache() {
	new TxtLen;
	new Max_Lines = file_size(bChat, 1);
	
	for(new i; i < Max_Lines; i++) {
		read_file(bChat, i, Read_All[i], 31, TxtLen);
		Reads++;
	}
}


public vSay(id) {
	new sText[256]
	read_args(sText, 255)
	remove_quotes(sText)
	if (equali(sText, "/scoategagbot"))
	{
		new hGag = CheckPlayerGag(id)
		RemoveIp(hGag)
		gagPlayer[id]=false
		remove_task(hGag+TASK)
		client_print_color(id, id, "^4BlackJack De_dust2 4FUN^1 Welcome to the server")
		return PLUGIN_HANDLED
	}
	if (gagPlayer[id]) {
		new slot = CheckPlayerGag(id)
		new dName[32], dTime[32], dDurate[10], dReason[126], transTime[2]
		parse(gagDetails[slot], dName, 31, dTime, 31, dDurate, 9, dReason, 125)
		fTransformSec((str_to_num(dTime) + (str_to_num(dDurate) * G_A_G) - time()), transTime)
		client_print_color(id, id, "^4[BlackJack]^1 Admin ^4%s^1 Gag you. Reason:^4 %s^1. Time left:^4 %d^1 minute%s ^4%d^1 second%s", dName, dReason, transTime[0], transTime[0]==1 ? "" : "s", transTime[1], transTime[1]==1 ? "s" : "s")
		return PLUGIN_HANDLED
	} else {
		new nSay[32], whyGag[64]
		if (!strlen(sText))
			return PLUGIN_CONTINUE
		strtoupper(sText)
		if (VerifySayIP(sText, nSay, 31)) {
			format(whyGag, 63, "You spammed the IP [%s]", nSay)
			ActGagJucator(0, id, time(), GAG_DEFAULT_TIME, whyGag)
			client_print_color(id, id, "^4[BlackJack]^1 Gagged automatically because you spammed an ip:^4 %s", nSay)
			return PLUGIN_HANDLED
		}
		for (new i=0; i < sizeof(bChat);i++) {
			strtoupper(bChat[i])
			if (contain(bChat, Read_All[i]) != -1) {
				if (get_user_flags(id) & ADMIN_RESERVATION) {
					format(whyGag, 63, "Blocked word [%s]", bChat[i])
					client_print_color(id, id, "^4[BlackJack]^1 The message was not sent because it contains:^4 %s.", bChat[i])
					return PLUGIN_HANDLED
				} else {
					format(whyGag, 63, "Blocked word [%s]", bChat[i])
					client_print_color(id, id, "^4[BlackJack]^1 The message was not sent because it contains:^4 %s.", bChat[i])
					return PLUGIN_HANDLED
				}
			}
		}
	}
	return PLUGIN_CONTINUE
}

public client_disconnected(id) {
	gagPlayer[id]=false
	new slot = CheckPlayerGag(id)
	new pName[32]
	get_user_name(id, pName, 31)
	if (slot != 0)
		client_print_color(0, 0, "^4[BlackJack]^1 The gagged player^4 %s^1 has disconnected", pName)
}

public client_putinserver(id) {
	new slot = CheckPlayerGag(id)
	new pName[32], dName[32], dTime[32], dDurate[10], dReason[126], transTime[2]
	get_user_name(id, pName, 31)
	if (slot != 0) {
		parse(gagDetails[slot], dName, 31, dTime, 31, dDurate, 9, dReason, 125)
		fTransformSec((str_to_num(dTime) + (str_to_num(dDurate) * G_A_G) - time()), transTime)
		client_print_color(0, 0, "^4[BlackJack]^1 The gaged player^4 %s^1 has reconnected. Time left:^4 %d^1 minute%s^4 %d^1 second%s", pName, transTime[0], transTime[0]==1 ? "" : "s", transTime[1], transTime[1]==1 ? "s" : "s")
		set_speak(id, SPEAK_MUTED)
		gagPlayer[id]=true
	}
}


public cAmxUnGag(id, level, cid) {
	if(!cmd_access (id, level, cid, 1))
		return PLUGIN_HANDLED

	new Victim[32], aName[32], pName[32]
	get_user_name(id, aName, 31)
	read_argv(1,Victim,31)
	new id2 = cmd_target(id, Victim, 8)
	if (!id2)
		return PLUGIN_HANDLED
	get_user_name(id2, pName, 31)
	new hGag = CheckPlayerGag(id2)
	if (hGag != 0) {
		remove_task(hGag+TASK)
		RemoveIp(hGag)
		gagPlayer[id2]=false
		client_print_color(0, 0, "^4[BlackJack]^1 Admin ^4%s^1 has ungagged^4 %s.", aName, pName)
	} else 
		console_print(id, "The Player %s is no longer gagged.", pName)

	return PLUGIN_HANDLED	
}

public cAmxGag(id, level, cid) {
	if(!cmd_access (id, level, cid, 1))
		return PLUGIN_HANDLED
		
	new Victim[32], pName[32], transTime[2], aName[32], Temp[10], gTime[10], gReason[126]
	get_user_name(id, aName, 31)
	read_argv(1,Victim,31)
	read_argv(2, gTime, 31)
	read_argv(3, gReason, 125)
	new gagTime = str_to_num(gTime)
	if (!gagTime)
		gagTime = GAG_DEFAULT_TIME
	if (gagTime < 1) {
		console_print(id, "You can gag him for at least 2 minutes")
		return PLUGIN_CONTINUE
	}
	if (strlen(gReason) < 1)
		format(gReason, 125, "Unknown")
	
	new id2 = cmd_target(id, Victim, 8)
	if (!id2)
		return PLUGIN_HANDLED
	get_user_name(id2, pName, 31)
	new hGag = CheckPlayerGag(id2)
	if (hGag != 0) {
		new dName[32], dTime[32], dDurate[10], dReason[126]
		parse(gagDetails[hGag], dName, 31, dTime, 31, dDurate, 9, dReason, 125)
		fTransformSec((str_to_num(dTime) + (str_to_num(dDurate) * G_A_G) - time()), transTime)
		console_print(id, "#########################################")
		console_print(id, "## Player [%s] Gagged ##", pName)
		console_print(id, "# Admin: %s", dName)
		console_print(id, "# Duration: %d minute%s", str_to_num(dDurate), str_to_num(dDurate)==1 ? "" : "s")
		console_print(id, "# Have passed: %d minutes%s y %d second%s", transTime[0], transTime[0]==1 ? "" : "s", transTime[1], transTime[1]==1 ? "s" : "s")
		console_print(id, "# Reason: %s", dReason)
		console_print(id, "#########################################")
	} else {
		new gStatus = ActGagJucator(id, id2, time(), gagTime, gReason)
		if (gStatus != 0) {
			format(Temp, 9, "%d", gagTime * G_A_G)
			new Float:gagTask = floatstr(Temp)
			set_task(gagTask, "TaskUnGag", gStatus+TASK)
			client_print_color(0, 0, "^4[BlackJack]^1 Admin ^4%s^1: has gagged^4 %s^1 [Duration:^4%d^1 minute%s] [Reason: ^4%s^1]", aName, pName, gagTime, gagTime==1 ? "" : "s", gReason)
			console_print(id, "#########################################")
			console_print(id, "## Player %s Gagged", pName)
			console_print(id, "# Duration: %d minutes%s", gagTime, gagTime==1 ? "" : "s")
			console_print(id, "# Reason: %s", gReason)
			console_print(id, "#########################################")
		} else
			console_print(id, "You can't gag %s", pName)
	}

	return PLUGIN_HANDLED
}

public TaskUnGag2(s) {
	new sIp = s-TASK
	new id	= IsIidline(gagIp[sIp])
	if (id != 0) {
		new pName[32]
		get_user_name(id, pName, 31)
		gagPlayer[id]=false
	}
	RemoveIp(sIp)
}

public TaskUnGag(s) {
	new sIp = s-TASK
	new id	= IsIidline(gagIp[sIp])
	if (id != 0) {
		new pName[32]
		get_user_name(id, pName, 31)
		gagPlayer[id]=false
		client_print_color(id, id, "^4[BlackJack]^1 Player ^4%s^1 can talk now.", pName)
	}
	RemoveIp(sIp)
}

IsIidline(ip[]) {
	new xP[32], xN, uIp[32]
	get_players(xP, xN, "c")
	for (new i=0; i < xN; i++) {
		get_user_ip(xP[i], uIp, 31, 1)
		if (equal(uIp, ip))
			return xP[i]	
	}
	return 0
}

ActGagJucator(id, id2, xTime, xDurate, xReason[]) {
	new Ip[32], aNume[32]
	if (id != 0)
		get_user_name(id, aNume, 31)
	else
		format(aNume, 31, "%s",SERVERNAME)
	get_user_ip(id2, Ip, 31, 1)
	for (new i=1; i < sizeof(gagIp); i++)
		if (equal(gagIp[i], "")) {
			copy(gagIp[i], charsmax(gagIp[]), Ip)
			format(gagDetails[i], charsmax(gagDetails[]), "^"%s^" ^"%d^" ^"%d^" ^"%s^"", aNume, xTime, xDurate, xReason)
			gagPlayer[id2]=true
			set_speak(id2, SPEAK_MUTED)
			return i
		}
	return 0
}
 
RemoveIp(slot) {
	format(gagIp[slot], charsmax(gagIp[]), "")
	format(gagDetails[slot], charsmax(gagDetails[]), "")
}

fTransformSec(sec, xBack[]) {
	xBack[0] = (sec / 60) % 60		// minuta
	xBack[1] = sec % 60				// secunda
}

CheckPlayerGag(id) {
	new Ip[32]
	get_user_ip(id, Ip, 31, 1)
	for (new i=1; i < sizeof(gagIp); i++)
		if (equal(gagIp[i], Ip))
			return i
	return 0
}

VerifySayIP(sText[], nSay[], max) {
	if (strlen(sText) > 10) {
		new xC=50, xT1[126], xT2[125]
		for (new i=0; i < xC; i++) {
			if (i==0)
				argbreak(sText, xT1, 31, xT2, 31)
			else
				argbreak(xT2, xT1, 31, xT2, 31)
				
			if (IsIP(xT1)) {
				copy(nSay, max, xT1)
				return true
			}
		}
	}
	return false
} 
Compiler:

Kod: Tümünü seç

C:\Users\user\Downloads\adv_gag.sma(167) : error 035: argument type mismatch (argument 1)

Request fix compilation error

Gönderilme zamanı: Sal Mar 16, 2021 5:42 pm
gönderen Ömer TELLİ
bChat is const of your ini file path.

You must change all bChat variable to Read_All in vSay public and u must use containi sText with Read_All

Request fix compilation error

Gönderilme zamanı: Sal Mar 16, 2021 6:59 pm
gönderen Midnight1338
Ömer TELLİ yazdı: Sal Mar 16, 2021 5:42 pm bChat is const of your ini file path.

You must change all bChat variable to Read_All in vSay public and u must use containi sText with Read_All
Thanks solved, thread can be locked