SA-MP Forums Archive
OnPlayerDeath getting stuck at if statment - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerDeath getting stuck at if statment (/showthread.php?tid=409718)



OnPlayerDeath getting stuck at if statment - happyface - 22.01.2013

I keep having issues with this callback where it just stops at an if statement and doesn't continue, I have something like:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
        print("Death1");
        if(gTeam[killerid] == TEAM_POLICE || gTeam[killerid] == TEAM_PUBLICMEDIC)
	{
	        if(gTeam[playerid] == TEAM_POLICE || gTeam[playerid] == TEAM_PUBLICMEDIC)
	        {
			SendClientMessage(playerid, COLOR_WHITE, "You Were Unfairly Killed - Continuing Previous Life.");
		}

		if(gTeam[playerid] != TEAM_POLICE && gTeam[playerid] != TEAM_PUBLICMEDIC)
		{
		         if(GetPlayerWantedLevel(playerid) < 4)
		         {
				  SendClientMessage(playerid, COLOR_WHITE, "You Were Unfairly Killed - Continuing Previous Life.");

			 }
		}
	}

        print("Death2");
        if(Authorized[playerid])
	{
                ....
It never makes it to the print "Death2".. No errors, no warnings, its not even a cop killing me, I've messed around with this for hours rewriting it and restructuring OnPlayerDeath to no avail.. So I comment the whole statement off and add some more prints in if(Authorized[playerid]), and it just ends up getting stuck on the next if statement in it.

I'm so frustrated, and it must be something simple I'm over looking.


Re: OnPlayerDeath getting stuck at if statment - FUNExtreme - 22.01.2013

Have you tried adding debug messages inside the code between "Death1" and "Death2".

The reason I ask this is because I see no reason why "Death2" shouldn't be called, something in the code above it must be stopping the rest of the code fomr being executed.


Re: OnPlayerDeath getting stuck at if statment - happyface - 22.01.2013

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
Have you tried adding debug messages inside the code between "Death1" and "Death2".

The reason I ask this is because I see no reason why "Death2" shouldn't be called, something in the code above it must be stopping the rest of the code fomr being executed.
Correct, I have another print at the very top of that first if statement and its never called, so its not even making it into it.


Re: OnPlayerDeath getting stuck at if statment - FUNExtreme - 22.01.2013

Quote:
Originally Posted by happyface
Посмотреть сообщение
Correct, I have another print at the very top of that first if statement and its never called, so its not even making it into it.
Are you being killed by a player, or are you killing yourself?
If the killer is INVALID_KILLER_ID it might give problems because gTeam goes out of bounds.