help onplayertext server crashed :s
#7

Quote:
Originally Posted by Konstantinos
View Post
Take a look here carefully:

As you can see, he typed nothing (second line) and pressed enter. OnPlayerText was called and it passed an empty string in CallLocalFunction.

You can fix it by checking if the text is not empty/null:
pawn Code:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
pawn Code:
public OnPlayerText(playerid, text[])
{
    if (isnull(text)) return 0;
   
    CallLocalFunction("StoreChatLine", "ds", playerid, text);
// rest of code..
If it's null, it doesn't send anything and it prevents the server from being crashed.

However, there isn't any reason to use StoreChatLine with foward/public if you don't want to call it in another script or by a timer, you can use stock instead and just call it directly:
pawn Code:
StoreChatLine(playerid, text);
Thanks! so i must add
Code:
#if !defined isnull
	#define isnull(%1) \
				((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
in anywhere above 

and under onplayertext
if (isnull(text)) return 0;
Right?
Reply


Messages In This Thread
help onplayertext server crashed :s - by Mahde - 04.02.2014, 10:25
Re: help onplayertext server crashed :s - by Mahde - 04.02.2014, 11:03
Re: help onplayertext server crashed :s - by EmilLykke - 04.02.2014, 11:08
Re: help onplayertext server crashed :s - by Konstantinos - 04.02.2014, 11:18
Re: help onplayertext server crashed :s - by Mahde - 04.02.2014, 11:20
Re: help onplayertext server crashed :s - by Konstantinos - 04.02.2014, 11:30
Re: help onplayertext server crashed :s - by Mahde - 04.02.2014, 11:50
Re: help onplayertext server crashed :s - by Konstantinos - 04.02.2014, 11:52
Re: help onplayertext server crashed :s - by Mahde - 04.02.2014, 11:56
Re: help onplayertext server crashed :s - by Konstantinos - 04.02.2014, 12:25

Forum Jump:


Users browsing this thread: 1 Guest(s)