Chat Bug ? Or something else
#1

Well do you see any type of problem on the following code? , cause when someone types something (Even some of the commands) my server crashes and closes up !


Code :


Код:
 OnPlayerText Code
public OnPlayerText(playerid, text[])
{
    RecordPlayerText(playerid,text);
    new namer[24],string[156];
    GetPlayerName(playerid,namer,sizeof(namer));
    format(string,sizeof(string),"13%s[%d] Got Kicked - Reason: Advertising",namer,playerid);
    if(FindIP(text)) { ircSay(EchoConnection,EchoChan,string); return kick4IP(playerid); }


	if(!strcmp( text, "acceot", true))
	{
        if(Accept[playerid] == 0)
        {
            Accept[playerid] = 1;
            SendClientMessage(playerid, COLOR_YAY, ">> Thanks, You have agreed to our rules here, Have Fun!");
            TogglePlayerControllable(playerid, 1);
            TextDrawHideForPlayer(playerid,txtTypeAccept);
            TextDrawHideForPlayer(playerid,txtTypeAccept2);
            TextDrawHideForPlayer(playerid,txtTypeAccept3);
			if(NewlyReg[playerid] == 1)
			{
				new player[30];
				GetPlayerName(playerid,player,30);
                format(string, sizeof(string), "~w~Welcome To ~p~The Server~n~~b~%s~n~~w~Type ~y~/help ~w~, ~w~/rules ~w~or~n~~y~/cmds~w~for more game info", player);
                TextDrawSetString(txtAdminAnnounce,string);
                TextDrawShowForPlayer(playerid,txtAdminAnnounce);
                AdminAnnouncedRNT =10;
			}
        }
	}


    
    if (text[0] == '@')
    {
		if(!IsServerAdmin(playerid))
		{
            SendClientMessage(playerid,COLOR_ADMIN,"Invalid Admin Status");
            return 1;
		}

		if(strlen(text) < 1)
		{
		    SendClientMessage(playerid,COLOR_ADMIN,"Your message must be longer!");
		    return 1;
		}
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(text, 128, "[ADMIN CHAT] %s:%s", name, text[1]);
	    SendClientMessageToAllAdmins(text);
     	ircSay(EchoConnection,EchoChan2,text);
        return 1;
    }
    

    

    
    if(Muted[playerid] == 1)
    {
		return 1;
    }
    
    TextSpammer[playerid] ++;

	if(TextSpammer[playerid] >= 5 && TextSpammer[playerid] <= 7)
	{
		SendClientMessage(playerid,COLOR_RED,SpammerDenied);
		TextSpammer[playerid] --;
		return 1;
	}

	if(TextSpammer[playerid] >= 8)
	{
		Kick(playerid);
		return 1;
	}
   	new PlayerName1[24];
   	new tString[128];
   	new Num[MAX_SERVER_SLOTS] = -1;
   	Num[playerid]=randarg(5,3,10);


	GetPlayerName(playerid, PlayerName1, sizeof(PlayerName1));

    if(IsPlayerNPC(playerid)) return 1;
	if(gTeam[playerid] >= 1 && gTeam[playerid] <= 2 && Undercover[playerid] == 0 && !IsPlayerNPC(playerid))
	{
	    format(tString, sizeof(tString), "12 %s [%d] - %s",PlayerName1,playerid, text);
        ircSay(EchoConnection,EchoChan,tString);
	}
	
	if(gTeam[playerid] >= 1 && gTeam[playerid] <= 2 && Undercover[playerid] == 1 && !IsPlayerNPC(playerid))
	{
	    format(tString, sizeof(tString), "1 %s [%d] - %s",PlayerName1,playerid, text);
        ircSay(EchoConnection,EchoChan,tString);
	}

	if(gTeam[playerid] >= 3 && gTeam[playerid] <= 4 && !IsPlayerNPC(playerid))
	{
 	    format(tString, sizeof(tString), "5 %s [%d] - %s",PlayerName1,playerid, text);
        ircSay(EchoConnection,EchoChan,tString);
	}

	if(gTeam[playerid] >= 5 && !IsPlayerNPC(playerid))
	{
		new Wanted = GetPlayerWantedLevel(playerid);
		if(Wanted >= 0 && Wanted <= 3)
		{
	        format(tString, sizeof(tString), "1 %s [%d] - %s",PlayerName1,playerid, text);
            ircSay(EchoConnection,EchoChan,tString);
        }
		if(Wanted >= 4 && Wanted <= 9&& !IsPlayerNPC(playerid))
		{
	        format(tString, sizeof(tString), "7 %s [%d] - %s",PlayerName1,playerid, text);
            ircSay(EchoConnection,EchoChan,tString);
        }
		if(Wanted >= 10 && !IsPlayerNPC(playerid))
		{
	        format(tString, sizeof(tString), "4 %s [%d] - %s",PlayerName1,playerid, text);
            ircSay(EchoConnection,EchoChan,tString);

        }
	}


	
    for(new d; d<sizeof(Filter); d++)
    

    
    
	if(strfind(text,Filter[d],true) != -1 ) return 1;
	

	
	if(!strcmp( text, "RehaB", true)) // Weps Dealer
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 784.0547,-1131.4712,23.8281))
		{
		    if(gTeam[playerid] <= 2) return SendClientMessage(playerid,COLOR_YELLOW,"PM From RehaB: Hey Officer! Nothing to see here!");

                if(IsThereAnyCopsNearMe(playerid))
				{
					PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
					SendClientMessage(playerid,COLOR_YELLOW,"PM From RehaB: Come back later! There is a Police Officer nearby!");
					ApplyAnimation(GetRehaBID(),"PED","IDLE_CHAT",4.1,0,1,1,0,-1);
					return 1;
				}
			SendClientMessage(playerid,COLOR_YELLOW,"PM From RehaB: Hey! What you want?");
			PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
    		ApplyAnimation(GetRehaBID(),"PED","IDLE_CHAT",4.1,0,1,1,0,-1);
    		ShowPlayerDialog(playerid,DIALOG_REHAB_OPTIONS,2,"Please select an option from below!","Buy Weapons from RehaB\nBuy Drugs from RehaB","Go","Cancel");
			return 1;
		}
	}




    new pname[MAX_PLAYER_NAME+5];
    new pname2[MAX_PLAYER_NAME+5];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(pname2,sizeof(pname2),"%s[%d]",pname,playerid);
    SetPlayerName(playerid,pname2);
    SendPlayerMessageToAll(playerid,text);
    SetPlayerName(playerid,pname);
    return 1;
}
Reply
#2

pawn Код:
TextSpammer[playerid] ++;

    if(TextSpammer[playerid] >= 5 && TextSpammer[playerid] <= 7)
    {
        SendClientMessage(playerid,COLOR_RED,SpammerDenied);
        TextSpammer[playerid] --;
        return 1;
    }
To

pawn Код:
TextSpammer[playerid] ++;

    if(TextSpammer[playerid] >= 5 && TextSpammer[playerid] <= 7)
    {
        SendClientMessage(playerid,COLOR_RED,"SpammerDenied"); //Maybe do this?
        TextSpammer[playerid] --;
        return 1;
    }
And use [ pawn ] [ / pawn ]
Reply
#3

what's this: "RecordPlayerText(playerid,text);" -- show is the code of it... maybe you forgot to create a folder or so where the "Record" is being saved or whatever this should do..
possibly there is a mistake in it which makes it crash
Reply
#4

Quote:
Originally Posted by Markx
Посмотреть сообщение
pawn Код:
TextSpammer[playerid] ++;

    if(TextSpammer[playerid] >= 5 && TextSpammer[playerid] <= 7)
    {
        SendClientMessage(playerid,COLOR_RED,SpammerDenied);
        TextSpammer[playerid] --;
        return 1;
    }
To

pawn Код:
TextSpammer[playerid] ++;

    if(TextSpammer[playerid] >= 5 && TextSpammer[playerid] <= 7)
    {
        SendClientMessage(playerid,COLOR_RED,"SpammerDenied"); //Maybe do this?
        TextSpammer[playerid] --;
        return 1;
    }
And use [ pawn ] [ / pawn ]
I fixed it , and now maybe it will behave better but still the Crash is going on :/


Quote:
Originally Posted by Sascha
Посмотреть сообщение
what's this: "RecordPlayerText(playerid,text);" -- show is the code of it... maybe you forgot to create a folder or so where the "Record" is being saved or whatever this should do..
possibly there is a mistake in it which makes it crash
Where should i add the Record Folder to ? Scriptfiles right?


Thanks both for helping Keep up the good work

Maybe somehow to fix this part?
Reply
#5

I have this problem as well , can someone please Help us ?

Please please ?
Reply
#6

Show the code for the function RecordPlayerText(playerid,text);.
Reply
#7

You mean that code part ?

pawn Код:
RecordPlayerText(playerid,text);
    new namer[24],string[156];
    GetPlayerName(playerid,namer,sizeof(namer));
    format(string,sizeof(string),"13%s[%d] Got Kicked - Reason: Advertising",namer,playerid);
    if(FindIP(text)) { ircSay(EchoConnection,EchoChan,string); return kick4IP(playerid); }

OR--------------------------
This

stock RecordPlayerText(playerid,lolstra[])
{
    if(PLAYERLIST_authed[playerid])
    {
        new fname[100], final[500];
        format(fname,sizeof(fname),"playertext/%s.txt",PlayerName(playerid));

        format(final,sizeof(final),"%s\r\n",lolstra);

        if(!fexist(fname))
        {
            fcreate(fname);
        }

        new File:razz = fopen(fname, io_append);

        fwrite(razz,final);

        fclose(razz);

    }
}
SOrry for the delay , had RL problem .
Reply
#8

Go to your server folder and then go to the scriptfiles folder.
Make sure you have a folder called "playertext".

If you have that folder, then probably this function is not the problem.
Try to add some print function in the callback to debug and find out which part of it crashes the server.
Reply
#9

Thanks God Mate you are correct , i gotta say REALLY REALLY THANKS!!

And one more request after this,

After fixing the chat , when i write something on the chat it shows up like the following image.




Why do all palyers Double Chat?
Reply
#10

change "return 1; " to "return 0;" at the end of "OnPlayerText"
Reply
#11

Cool it worked !! Thanks really much all of you guys!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)