Server crash
#1

when i use this code the server crashes if u joined

Код:
public OnPlayerConnect(playerid)
{
    new str[196];
    Account_Reset(playerid);
    Character_Reset(playerid);
	NameCheck(playerid);
	IP_Lookup(playerid);
	//Account_Lookup(playerid);

    format(str, 128, "%s csatlakozott.", GetName(playerid));
    SendAdminsMessage(1, COLOR_GRAY, str);

	TogglePlayerSpectating(playerid, 1);
	SetPlayerColor(playerid, COLOR_WHITE);

	SetTimerEx("PlayerConnected", 100, false, "d", playerid);
}

IP_Lookup(playerid)
{
	new query[128], ip[18];
	GetPlayerIp(playerid, ip, sizeof(ip));
	mysql_format(SQL_CONNECTION, query, sizeof(query), "SELECT * FROM Bans WHERE IP = '%e'", ip);
	mysql_tquery(SQL_CONNECTION, query, "CheckBanList", "i", playerid);
	return 1;
}

forward CheckBanList(playerid);
public CheckBanList(playerid)
{
	if(!cache_num_rows())
	{
		SetTimerEx("PlayerConnected", 100, false, "d", playerid);
	}
	else
	{
		new query[128], ip[18];
		GetPlayerIp(playerid, ip, sizeof(ip));
		SendClientMessage(playerid, COLOR_GRAY, "Your IP \"%s\" is banned from our servers.", ip);
		SendClientMessage(playerid, COLOR_GRAY, "You may appeal your ban on our forums.");
		return Kick(playerid);
	}
	return 1;
}
Reply
#2

The compiler is there to help you write good code.
pawn Код:
SendClientMessage(playerid, COLOR_GRAY, "Your IP \"%s\" is banned from our servers.", ip);
since it does give you a warning for number of arguments does not match, why do you ignore it? Also the use of specifiers in client messages results in server crashes as it's stated in wiki.

Solution: format message first.
Reply
#3

still crashing

Код:
		new query[128], ip[18], str[128];
		GetPlayerIp(playerid, ip, sizeof(ip));
		format(str, sizeof(str), "Your IP \"%s\" is banned from our servers.", ip);
		SendClientMessage(playerid, COLOR_GRAY, str);
		SendClientMessage(playerid, COLOR_GRAY, "You may appeal your ban on our forums.");
		return Kick(playerid);
Reply
#4

Load crashdetect plugin: https://github.com/Zeex/crashdetect/releases
Compile with debug info: https://github.com/Zeex/crashdetect/...ith-debug-info
Re-compile script, start server and post server log when server will crash again.
Reply
#5

Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:          16660 bytes
Code size:           871104 bytes
Data size:          4965924 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements: 5870072 bytes
Код:
[21:21:39] [debug] Server crashed while executing SCRP-R39.amx
[21:21:39] [debug] AMX backtrace:
[21:21:39] [debug] #0 native SetPlayerName () [f6a4ce10] from sscanf.so
[21:21:39] [debug] #1 000461e0 in public _y_utils_OnPlayerDisconnect (playerid=0, reason=2) at C:\Users\Lenovo\Downloads\Small-County-RP-Release (1)\gamemodes\SCRP-R39.pwn:1325
[21:21:39] [debug] #2 00011508 in public Itter_OnPlayerDisconnect (playerid=0, reason=2) at C:\Users\Lenovo\Downloads\Invincible-Roleplay (2)\Invincible-Roleplay (2)\pawno\include\YSI\..\YSI_Coding\..\YSI_Core\y_utils.inc:263
[21:21:39] [debug] #3 native CallLocalFunction () [080dfac0] from samp03svr
[21:21:39] [debug] #4 00007cc0 in public SSCANF_OnPlayerDisconnect (playerid=0, reason=2) at C:\Users\Lenovo\Downloads\Invincible-Roleplay (2)\Invincible-Roleplay (2)\pawno\include\foreach.inc:643
[21:21:39] [debug] #5 native CallLocalFunction () [080dfac0] from samp03svr
[21:21:39] [debug] #6 00001064 in public OnPlayerDisconnect (playerid=0, reason=2) at C:\Users\Lenovo\Downloads\Invincible-Roleplay (2)\Invincible-Roleplay (2)\pawno\include\sscanf2.inc:143
[21:21:39] [debug] #7 native Kick () [080d7300] from samp03svr
[21:21:39] [debug] #8 00043e10 in public CheckBanList (playerid=0) at C:\Users\Lenovo\Downloads\Small-County-RP-Release (1)\gamemodes\SCRP-R39.pwn:1036
[21:21:40] [debug] Native backtrace:
[21:21:40] [debug] #0 f7325a5b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[21:21:40] [debug] #1 f731e852 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[21:21:40] [debug] #2 f731f35c in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[21:21:40] [debug] #3 f731f86e in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[21:21:40] [debug] #4 f732576d in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #5 f7709cb0 in __kernel_rt_sigreturn () from linux-gate.so.1
[21:21:40] [debug] #6 080d5a67 in ?? () from ./samp03svr
[21:21:40] [debug] #7 080d7a95 in ?? () from ./samp03svr
[21:21:40] [debug] #8 f6a4ced7 in ?? () from plugins/sscanf.so
[21:21:40] [debug] #9 080950e4 in ?? () from ./samp03svr
[21:21:40] [debug] #10 f6a810b5 in ?? () from plugins/streamer.so
[21:21:40] [debug] #11 f731c10c in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[21:21:40] [debug] #12 f7321348 in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #13 f7327db5 in amx_Exec () from plugins/crashdetect.so
[21:21:40] [debug] #14 f731e6ab in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[21:21:40] [debug] #15 f7321149 in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #16 f6a81173 in ?? () from plugins/streamer.so
[21:21:40] [debug] #17 080dfd62 in ?? () from ./samp03svr
[21:21:40] [debug] #18 080950e4 in ?? () from ./samp03svr
[21:21:40] [debug] #19 f6a810b5 in ?? () from plugins/streamer.so
[21:21:40] [debug] #20 f731c10c in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[21:21:40] [debug] #21 f7321348 in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #22 f7327db5 in amx_Exec () from plugins/crashdetect.so
[21:21:40] [debug] #23 f731e6ab in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[21:21:40] [debug] #24 f7321149 in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #25 f6a81173 in ?? () from plugins/streamer.so
[21:21:40] [debug] #26 080dfd62 in ?? () from ./samp03svr
[21:21:40] [debug] #27 080950e4 in ?? () from ./samp03svr
[21:21:40] [debug] #28 f6a810b5 in ?? () from plugins/streamer.so
[21:21:40] [debug] #29 f731c10c in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[21:21:40] [debug] #30 f7321348 in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #31 f7327db5 in amx_Exec () from plugins/crashdetect.so
[21:21:40] [debug] #32 f731e6ab in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[21:21:40] [debug] #33 f7321149 in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #34 f6a81173 in ?? () from plugins/streamer.so
[21:21:40] [debug] #35 080a523a in ?? () from ./samp03svr
[21:21:40] [debug] #36 080d0b31 in ?? () from ./samp03svr
[21:21:40] [debug] #37 080ae94b in ?? () from ./samp03svr
[21:21:40] [debug] #38 080d731e in ?? () from ./samp03svr
[21:21:40] [debug] #39 080950e4 in ?? () from ./samp03svr
[21:21:40] [debug] #40 f6a810b5 in ?? () from plugins/streamer.so
[21:21:40] [debug] #41 f731c10c in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[21:21:40] [debug] #42 f7321348 in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #43 f7327db5 in amx_Exec () from plugins/crashdetect.so
[21:21:40] [debug] #44 f731e6ab in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[21:21:40] [debug] #45 f7321149 in ?? () from plugins/crashdetect.so
[21:21:40] [debug] #46 f6a81173 in ?? () from plugins/streamer.so
[21:21:40] [debug] #47 f65c1ff1 in amx_Exec () from plugins/mysql_static.so
[21:21:40] [debug] #48 f659b30d in _ZN9CCallback16ProcessCallbacksEv () from plugins/mysql_static.so
[21:21:40] [debug] #49 f65c2fa2 in ProcessTick () from plugins/mysql_static.so
[21:21:40] [debug] #50 080d1ce2 in ?? () from ./samp03svr
[21:21:40] [debug] #51 080aef3a in ?? () from ./samp03svr
[21:21:40] [debug] #52 080aa13a in ?? () from ./samp03svr
[21:21:40] [debug] #53 f734e286 in __libc_start_main () from /lib32/libc.so.6
Reply
#6

OK great. SetPlayerName function crashes the server when the new name that is passed (2nd parameter) to the function is empty/null. In OnPlayerDisconect, you set player's name (line 1325) to nothing.
Reply
#7

okay, not crashing but

Код:
		format(str, sizeof(str), "Your IP \"%s\" is banned from our servers.", ip);
		SendClientMessage(playerid, COLOR_GRAY, str);
		SendClientMessage(playerid, COLOR_GRAY, "You may appeal your ban on our forums.");
not displaying
Reply
#8

If you kick directly after the messages, player won't receive them.

https://sampwiki.blast.hk/wiki/Kick

Look at the bottom how to delay it.
Reply
#9

thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)