DEBUG OnPlayerText ERROR [REP+]
#1

Код:
public OnPlayerText(playerid, text[])
{
	if(ServerInfo[AntiSwear] == 1)
	{
		for(new i = 0; i <= 256; i++)
		{
	 	   	if((text[i] == 'f' || text[i] == 'F') && (text[i+1] == 'u' || text[i+1] == 'U') && (text[i+2] == 'c' || text[i+2] == 'C') && (text[i+3] == 'k' || text[i+3] == 'K'))
			{
	  			SendClientMessage(playerid,Red,"Donot Swear in the chat!");
				return 0;
			}
			if((text[i] == 'b' || text[i] == 'B') && (text[i+1] == 'a' || text[i+1] == 'A') && (text[i+2] == 's' || text[i+2] == 'S') && (text[i+3] == 't' || text[i+3] == 'T') && (text[i+4] == 'a' || text[i+4] == 'A') && (text[i+5] == 'r' || text[i+5] == 'R') && (text[i+6] == 'd' || text[i+6] == 'D'))
			{
	  			SendClientMessage(playerid,Red,"Donot Swear in the chat!");
				return 0;
			}
			if((text[i] == 'b' || text[i] == 'B') && (text[i+1] == 'i' || text[i+1] == 'I') && (text[i+2] == 't' || text[i+2] == 'T') && (text[i+3] == 'c' || text[i+3] == 'C') && (text[i+4] == 'h' || text[i+4] == 'H'))
			{
	  			SendClientMessage(playerid,Red,"Donot Swear in the chat!");
				return 0;
			}
			if((text[i] == 'd' || text[i] == 'D') && (text[i+1] == 'i' || text[i+1] == 'I') && (text[i+2] == 'c' || text[i+2] == 'C') && (text[i+3] == 'k' || text[i+3] == 'K'))
			{
	  			SendClientMessage(playerid,Red,"Donot Swear in the chat!");
				return 0;
			}
			if((text[i] == 'a' || text[i] == 'A') && (text[i+1] == 's' || text[i+1] == 'S') && (text[i+2] == 's' || text[i+2] == 'S') && (text[i+3] == 'h' || text[i+3] == 'H') && (text[i+4] == 'o' || text[i+4] == 'O') &&  (text[i+5] == 'l' || text[i+5] == 'L') && (text[i+3] == 'e' || text[i+3] == 'E'))
			{
	  			SendClientMessage(playerid,Red,"Donot Swear in the chat!");
				return 0;
			}
		}
	}
	if(pInfo[playerid][Muted] == 1)
	{
		SendClientMessage(playerid,Red,"You Cannot Chat! You Are Muted!");
		return 0;
	}
	if(text[0] == '#' && pInfo[playerid][Admin] >= 1)
	{
 		new string[128];
		format(string,sizeof(string),"Admin Chat %s(%d): %s",pName(playerid),playerid,text[1]);
		MessageToAdmins(lightred,string);
	    return 0;
	}
	if(text[0] == '"' && (pInfo[playerid][Vip] >= 1 || pInfo[playerid][Admin] >= 1))
	{
 		new string[128];
		format(string,sizeof(string),"Vip Chat: %s(%d): %s",pName(playerid),playerid,text[1]);
		MessageToVips(Yellow2,string);
	    return 0;
	}
	if(ServerInfo[AntiSpam] == 1 && (pInfo[playerid][Admin] != 6 && !IsPlayerAdmin(playerid)))
	{
		if(pInfo[playerid][SpamCount] == 0) pInfo[playerid][SpamTime] = TimeStamp();
	    pInfo[playerid][SpamCount]++;
		if(TimeStamp() - pInfo[playerid][SpamTime] > ServerInfo[SpamTimeLimit])
		{
			pInfo[playerid][SpamCount] = 0;
			pInfo[playerid][SpamTime] = TimeStamp();
		}
		else if(pInfo[playerid][SpamCount] == ServerInfo[MaxSpamMsgs])
		{
			new string[256]; format(string,sizeof(string),"ANTISPAM: %s(%d) has been Kicked.Reason: Spam Protection", pName(playerid),playerid);
			SendClientMessageToAll(Red,string);
			print(string);
			Kick(playerid);
		}
		else if(pInfo[playerid][SpamCount] == ServerInfo[MaxSpamMsgs]-1)
		{
			TextDrawShowForPlayer(playerid,SpamDetectedText);
			SetTimerEx("SpamDetectedTextDrawHide",3000,0,"d",playerid);
			return 0;
		}
	}
	return 1;
}
Server keep restarting , Crash Detected:
Код:
[15:55:32] [chat] [brailin[ID:150]: Yes i'll
[15:55:32] [debug] Run time error 5: "Invalid memory access"
[15:55:32] [debug] AMX backtrace:
[15:55:32] [debug] #0 00005530 in public OnPlayerText (0x00000054, 0x000e6c10) from DAdmin2.amx
Reply
#2

Make sure you have defined Text with Text[MAX_PLAYERS]; already so you dont need to do it upon your OnPlayerText if you got what i said.
Reply
#3

Replace:
pawn Код:
for(new i = 0; i <= 256; i++)
with:
pawn Код:
for(new i = 0, j = strlen(text); i < j; i++)
and don't use [i+1], [i+2] and [i+3] because it exceeds the bounds.
Reply
#4

Thanks Kar and Laurey
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)