14.05.2015, 21:16
So, I have this example script:
It's supposed to check if a default GetVehicleColor is supplied (like from YSF), and if not, add its own implementation (which needs external color saving). To me, this code seems perfectly valid. So why the hell is this shown in the console when I run the script (crashdetect):
Some things to note:
pawn Code:
#include <a_samp>
#if !defined GetVehicleColor
new vehiclecolor[MAX_VEHICLES*2 char];
stock GetVehicleColor(vehicleid, &color1, &color2)
{
color1 = vehiclecolor{vehicleid};
color2 = vehiclecolor{vehicleid+1};
}
stock SaveVehicleColor(vehicleid, color1, color2)
{
vehiclecolor{vehicleid} = color1;
vehiclecolor{vehicleid+1} = color2;
}
#else
stock SaveVehicleColor(vehicleid, color1, color2)
{
#pragma unused vehicleid, color1, color2
}
#endif
main()
{
new c1,c2;
print("Start");
GetVehicleColor(0, c1, c2);
printf("%d %d", c1, c2);
}
Code:
Start [debug] Run time error 6: "Invalid instruction" [debug] Unknown opcode 0x0 at address 0x00000928 [debug] AMX backtrace: [debug] #0 00000928 in main () from <unknown> Script[gamemodes/../test.amx]: Run time error 6: "Invalid instruction" Number of vehicle models: 0
- The #include is needed only for print and printf, not for GetVehicleColor.
- When I access "vehiclecolor" in "main", is says 'undefined symbol "vehiclecolor"'.
- If I put #error DEFINED under #if, it correctly outputs the error.
- If I put #error NOTDEFINED under #else, it also outputs the error.
- If I add "hello[]" in the parameter list of the second SaveVehicleColor, it outputs "function heading differs from prototype" on that line.