Incompatibility at OnPlayerDeath
#1

Codes:

Code in my gamemode:
Код:
public OnVehicleDeath(vehicleid, killerid)
{
	printf("%s destroyed", VehicleNames[VehicleModel[vehicleid]-400]);
	if(IsValidVehicle(vehicleid))
	{
	   	new Nombre[24], Dueno;
	    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
	    {
	    	GetPlayerName(i, Nombre, sizeof(Nombre));
	    	if(GetPlayerVehicleAccess(i, vehicleid))
	    	{
				Dueno = i;
	    	}
		}
    	SFM(Dueno, COLOR_WHITE, "Your %s were destroyed. The goberment sent it to it's parking, but not at all repaired.", VehicleNames[VehicleModel[vehicleid]-400]);
	    vHealth[vehicleid] = 500.0;
	}
    return 1;
}
ELC_AC_BASE Include(Anticheat)
Код:
public OnVehicleDeath(vehicleid, killerid)
{
	CheatVehicleInfo[vehicleid][elc_vX]=0;
	#if defined INCLUDE_BASE_MODE
	return CallLocalFunction("ELC_AC_OnVehicleDeath", "dd",vehicleid, killerid);
	#else
	return 1;
	#endif
}
/*----------------------------------------------------------------------------*/
#if defined INCLUDE_BASE_MODE
//ALS_SYSTEME --------------------
#if defined _ALS_OnVehicleDeath
	#undef OnVehicleDeath
#else
	#define _ALS_OnVehicleDeath
#endif
#define OnVehicleDeath ELC_AC_OnVehicleDeath
forward ELC_AC_OnVehicleDeath(vehicleid, killerid);
#endif
Answers from Crashdetect:
Код:
[17:19:28] [debug] Run time error 4: "Array index out of bounds"
[17:19:28] [debug] AMX backtrace:
[17:19:28] [debug] #0 00066214 in public ELC_AC_OnVehicleDeath (vehicleid=12, killerid=0) at F:\Users\ByMatt20030\Desktop\San Jose\Scrath-RP 0.0.20\gamemodes\S-RP_Traducida.pwn:1390
[17:19:28] [debug] #1 native CallLocalFunction () from samp-server.exe
[17:19:28] [debug] #2 00059df4 in public OnVehicleDeath (vehicleid=12, killerid=0) at F:\Users\ByMatt20030\Desktop\San Jose\Scrath-RP 0.0.20\pawno\include\ELC_AC_BASE.inc:1186
їHelp?
Reply
#2

line 1390 is ?
Reply
#3

Quote:
Originally Posted by Jefff
Посмотреть сообщение
line 1390 is ?
Sorry,

Код:
return CallLocalFunction("ELC_AC_OnVehicleDeath", "dd",vehicleid, killerid);
Reply
#4

gamemodes\S-RP_Traducida.pwn:1390
Reply
#5

Quote:
Originally Posted by Jefff
Посмотреть сообщение
gamemodes\S-RP_Traducida.pwn:1390
Solved, i just remove that print that i really don't need haha, sorry twice




Closed.
Reply
#6

Код:
SFM(Dueno, COLOR_WHITE, "Your %s were destroyed. The goberment sent it to it's parking, but not at all repaired.", VehicleNames[VehicleModel[vehicleid]-400]);
This line is outside of the for loop, so if it doesn't find a player it's going to be wasted code.

It could cause trouble in the future. If anything, that line, should be 'in' the loop, so if the car isn't owned by anyone it won't fire. That, or have a check to ensure that if the player isn't found, then it won't fire, such as setting Dueno to -1, and checking if it's not -1 before making the announcement.
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Код:
SFM(Dueno, COLOR_WHITE, "Your %s were destroyed. The goberment sent it to it's parking, but not at all repaired.", VehicleNames[VehicleModel[vehicleid]-400]);
This line is outside of the for loop, so if it doesn't find a player it's going to be wasted code.

It could cause trouble in the future. If anything, that line, should be 'in' the loop, so if the car isn't owned by anyone it won't fire. That, or have a check to ensure that if the player isn't found, then it won't fire, such as setting Dueno to -1, and checking if it's not -1 before making the announcement.
Yep.
After deleting the printf, i have problem with that line. I did just what you said.
Ty
Reply
#8

ByMatt20030, I use ELC too (unfortunately... gonna switch to NEX ASAP as I spend too much time patching the terrible thing than coding useful stuff), you might want to be careful about the systematic use of "return CallLocalFunction" in this script, it might prevent some client updates from being made (like OnVehicleMod). I replaced some of those with successive CallLocalFunction then return 1; to fix the issues.

EDIT: IIRC there might be a better way with some function that finds if symbols are declared or something, but that might be a bit more advanced and if you don't plan to prevent the updates in your FS anyways it's not necessary.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)