Script is corrupting server?
#1

Hi guys,

i have a script, which is basically duel script. In this script two people joins the duel, and box each other. Who kills the other person, wins.

I made this, it is working without any problem (no errors) but, when i uploaded my gamemode with this thing, and joined the duel (typed /dueljoin) the server crashed and restarted.

Do you guys know, where can be the problem? Thanks.

Код:
new Dueler[2] = INVALID_PLAYER_ID;
new Duelers;
new DuelBegin;
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   	if(DuelBegin == 1)
	{
		if(Dueler[0] == playerid && Dueler[1] == killerid)
	    {
	        GivePlayerMoney(killerid, 100);
	        SetPlayerPos(Dueler[1], 0, 0, 0);
	        SetPlayerVirtualWorld(Dueler[1], 0);
	        DuelBegin = 0;
	        Dueler[0] = INVALID_PLAYER_ID; 
	        Dueler[1] = INVALID_PLAYER_ID;
	    }
	    else if(Dueler[1] == playerid && Dueler[0] == killerid)
	    {
	        GivePlayerMoney(killerid, 100);
	        SetPlayerPos(Dueler[0], 0, 0, 0);
	        SetPlayerVirtualWorld(Dueler[0], 0);
			DuelBegin = 0; 
			Dueler[0] = INVALID_PLAYER_ID
			Dueler[1] = INVALID_PLAYER_ID;
	    }
	}
	return 1;
}
Код:
dcmd_dueljoin(playerid, params[])
{
	#pragma unused params
	if(GetPlayerTeam(playerid) != 0) return SendClientMessage(playerid,F_F,"You can duel just in prison mode.");
	if(Duelers > 1) return SendClientMessage(playerid, F_F, "Duel is already started.");


	SetPlayerPos(playerid, 0, 0, 0);
	SetPlayerVirtualWorld(playerid, 1);
	TogglePlayerControllable(playerid, 0);

	if(Dueler[0] != INVALID_PLAYER_ID) Dueler[0] = playerid;
    if(Dueler[1] != INVALID_PLAYER_ID) Dueler[1] = playerid;


    if(Dueler[0] == playerid) SendClientMessageToAll(F_F, "[ DUEL ] Player %s joined to the duel.");

    if(Dueler[1] == playerid)
	{
		SendClientMessageToAll(F_F, "[ DUEL ] Player %s joined to the duel, duel started.");
		TogglePlayerControllable(playerid, 1);
		TogglePlayerControllable(Dueler[0], 1);
		SendClientMessage(playerid, F_F, "[ DUEL ] Start!");
}
	return 1;
}
thanks guys
Reply
#2

use crashdetect plugin to see where it crash and what is the reason, most likely accessing invalid/negative index


you can also try to put print("1"); print("2"); between each row to see where script crash the server.
Reply
#3

Код:
dcmd_dueljoin(playerid, params[])
{
	#pragma unused params
	if(GetPlayerTeam(playerid) != 0) return SendClientMessage(playerid,F_F,"You can duel just in prison mode.");
	if(Duelers > 1) return SendClientMessage(playerid, F_F, "Duel is already started.");
	if(Dueler[0] == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player.");
        new message[128];
        Duelers = 2;
        Dueler[1] = playerid;
	SetPlayerPos(playerid, 0, 0, 0);
	SetPlayerVirtualWorld(playerid, 1);
	TogglePlayerControllable(playerid, 0);
        format(message, 128, "[ DUEL ] Duel Started! %s is dueling %s.", GetName(playerid), GetName(Dueler[0]));
        SendClientMessageToAll(F_F, message);
	TogglePlayerControllable(playerid, 1);
	TogglePlayerControllable(Dueler[0], 1);
	SendClientMessage(Dueler[1], F_F, "[ DUEL ] Start!");
        SendClientMessage(Dueler[0], F_F, "[ DUEL ] Start!");
	return 1;
}
I really can't help more because you didn't show us dcmd_duel.
Basically Dueler[1] is the guy who did /dueljoin , dueler[0] is the guy who did /duel
Reply
#4

What /duel? I have no /duel command. /dueljoin is only command using.

Dueler 0 is joining via /dueljoin
Dueler 1 also
Reply
#5

I guided him using crashdetector over skype, he'll send it below.
Reply
#6

Код:
[18:06:08] [debug] #0 native SendClientMessageToAll () from samp-server.exe
[18:06:08] [debug] #1 00034b8c in ?? (0, 16933576) from jailbreak.amx
[18:06:08] [debug] #2 0002eef4 in ?? (0, 16954308) from jailbreak.amx
[18:06:08] [debug] #3 0000b720 in public OnPlayerCommandText (0, 16954308) from jailbreak.amx
[18:06:09] [debug] Native backtrace:
[18:06:09] [debug] #0 0049940c in ?? () from samp-server.exe
[18:06:09] [debug] #1 774ac2c0 in ?? () from samp-server.exe
[18:06:09] [debug] #2 770e32f8 in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[18:06:09] [debug] #3 770e32f8 in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[18:06:09] [debug] #4 770e3327 in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[18:06:09] [debug] #5 770e6e1d in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[18:06:09] [debug] #6 0049829a in ?? () from samp-server.exe
[18:06:09] [debug] #7 0048b188 in ?? () from samp-server.exe
[18:06:09] [debug] #8 00470ac0 in ?? () from samp-server.exe
[18:06:09] [debug] #9 004010b6 in ?? () from samp-server.exe
[18:06:09] [debug] #10 658e62ca in ?? () from plugins\crashdetect.DLL
[18:06:09] [debug] #11 658e8b28 in ?? () from plugins\crashdetect.DLL
[18:06:09] [debug] #12 658e09c7 in ?? () from plugins\crashdetect.DLL
[18:06:09] [debug] #13 658e631a in ?? () from plugins\crashdetect.DLL
[18:06:09] [debug] #14 0046d320 in ?? () from samp-server.exe
[18:06:09] [debug] #15 004529e0 in ?? () from samp-server.exe
[18:06:09] [debug] #16 658e631a in ?? () from plugins\crashdetect.DLL
[18:06:09] [debug] #17 0046dee0 in ?? () from samp-server.exe
[18:06:09] [debug] #18 0049a6f9 in ?? () from samp-server.exe
[18:06:09] [debug] #19 0045b4ca in ?? () from samp-server.exe
[18:06:09] [debug] #20 770d5b0c in ?? () from C:\Windows\SYSTEM32\ntdll.dll
Hope you guys will get the problem from this one.
Reply
#7

Can you guys help me please? I posted log from crashdetect above.
Reply
#8

Well, i have to bump it again.

Please guys help me.. i need it alot..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)