[PAWN bug?] OK... Now I'm totaly lost...
#1

Ok guys... maybe I'm smoking too much and I can't see anything obvious
or, maybe, It's a freaking bug... I really don't know...

So... It's a simple...

1) I save "Sem Nome" on the string NikoHQInfo[hqId][HQNome].
2) I print the string to see it's been formated corrctly
3) I save value 8 on the var NikoHQInfo[hqId][OrgDona].
4) I print the string again and it's value is different!!

what the ****!??

if you also print the value on NikoHQInfo[hqId][OrgDona], it won't be 8... it will be 83

so...
WHAT THE **** !??!

o.O

Код:
#include		<a_samp>
#include		<YSI\y_hooks>
#include		<sscanf2>
#include		<DOF2>

#define MAX_HQS 10
#define MAX_ORG_PORTOES 10
#define MAX_ORG_CARROS 20
#define MAX_ORG_MOTOS 10
#define MAX_ORG_HELIS 3
#define MAX_NOME_HQ 30

#define function%0(%1) forward %0(%1); public %0(%1)
main() { }
enum nhqinfo
{
	OrgDona,
	FamiliaDona,
	HQNome[MAX_NOME_HQ],

}
new NikoHQInfo[MAX_HQS][nhqinfo];


public OnGameModeInit()
{
	new hqId = 10;
	
	format(NikoHQInfo[hqId][HQNome], MAX_NOME_HQ, "Sem Nome");
	printf("nome = %s", NikoHQInfo[hqId][HQNome]);
	NikoHQInfo[hqId][OrgDona] = 8;
	printf("nome = %s", NikoHQInfo[hqId][HQNome]);
	NikoHQInfo[hqId][FamiliaDona] = 0;
	printf("nome = %s", NikoHQInfo[hqId][HQNome]);
	NikoSalvarRegrasHQ(hqId);
	DOF2_Exit();
}


function NikoSalvarRegrasHQ(hqId)
{
	new arquivo[60];
	format(arquivo,sizeof(arquivo),"/RPG/HQs/HQRegras%d.txt", hqId);
	
	if(!fexist(arquivo))
		DOF2_CreateFile(arquivo);
	
	printf("nome = %s", NikoHQInfo[hqId][HQNome]);
	DOF2_SetString(arquivo,"NomeHQ",NikoHQInfo[hqId][HQNome]);
	DOF2_SetInt(arquivo,"OrgDona",NikoHQInfo[hqId][OrgDona]);

	return 1;
}

@Edit

ok, now it's getting worse..



if I do
Код:
enum nhqinfo
{
	FamiliaDona,
	HQNome[MAX_NOME_HQ],
	OrgDona,
	
}
everything works fine



if I do
Код:
enum nhqinfo
{
	HQNome[MAX_NOME_HQ],
	OrgDona,
	FamiliaDona,
}
even the first format on the string doesn't work



if I do
Код:
enum nhqinfo
{
	OrgDona,
	FamiliaDona,
	HQNome[MAX_NOME_HQ],

}
the format works but when I change OrgDona value, it gets messed up

so... again... WTF!?
Reply
#2

Array index is out of bounds. If you have 10 headquarters then the available slots are 0 through 9.

By the way, I misread those defines. Thought it said potatoes and carrots. :')
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Array index is out of bounds. If you have 10 headquarters then the available slots are 0 through 9.

By the way, I misread those defines. Thought it said potatoes and carrots. :')
thank you for replying =)
yeah, I messed up here #define MAX_HQS 10

but it's still strange...
if it's out of bounds, why didn't it break the code as pawn ever did?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)