Objekt[o][Ob] = CreateDynamicObject(Objekt[o][Model], Objekt[o][PositsionX], Objekt[o][PositsionY], Objekt[o][PositsionZ],IG[playerid][PVW],IG[playerid][PINT],100.0);
new Objekt[o][Ob];
func LisaObjekt(playerid)
{
for(new o = 1; o <= MAX_OBJEKTE; o++)
{
if(Objekt[o][Mudel] == 0)
{
Objekt[o][VW] = IG[playerid][PVW];
Objekt[o][Int] = IG[playerid][PINT];
Objekt[o][PositsionX] = IG[playerid][PosX];
Objekt[o][PositsionZ] = IG[playerid][PosY];
Objekt[o][PositsionY] = IG[playerid][PosZ];
Objekt[o][Mudel] = IG[playerid][Mudel];
Objekt[o][PositsionRX] = 0;
Objekt[o][PositsionRY] = 0;
Objekt[o][PositsionRZ] = 0;
Objekt[o][Ob] = CreateDynamicObject(Objekt[o][Mudel], Objekt[o][PositsionX], Objekt[o][PositsionY], Objekt[o][PositsionZ],IG[playerid][PVW],IG[playerid][PINT],100.0);
EditDynamicObject(playerid, Objekt[o][Ob]);
GameTextForPlayer(playerid, "~g~Objekt lisatud", 5000, 1);
return 1;
}
}
return 1;
}
|
Код:
func LisaObjekt(playerid)
{
for(new o = 1; o <= MAX_OBJEKTE; o++)
{
if(Objekt[o][Mudel] == 0)
{
Objekt[o][VW] = IG[playerid][PVW];
Objekt[o][Int] = IG[playerid][PINT];
Objekt[o][PositsionX] = IG[playerid][PosX];
Objekt[o][PositsionZ] = IG[playerid][PosY];
Objekt[o][PositsionY] = IG[playerid][PosZ];
Objekt[o][Mudel] = IG[playerid][Mudel];
Objekt[o][PositsionRX] = 0;
Objekt[o][PositsionRY] = 0;
Objekt[o][PositsionRZ] = 0;
Objekt[o][Ob] = CreateDynamicObject(Objekt[o][Mudel], Objekt[o][PositsionX], Objekt[o][PositsionY], Objekt[o][PositsionZ],IG[playerid][PVW],IG[playerid][PINT],100.0);
EditDynamicObject(playerid, Objekt[o][Ob]);
GameTextForPlayer(playerid, "~g~Objekt lisatud", 5000, 1);
return 1;
}
}
return 1;
}
|
for(new o = 0; o < MAX_OBJEKTE; o++)
|
Will probably produce a runtime error.
The indexes of arrays work like follows: If you have an array of the size 10, you must access it from 0 to 9, not 1 to 10. Your loop starts at 1, and runs until the size of the array (which is 1 too high). Change the loop to: Код:
for(new o = 0; o < MAX_OBJEKTE; o++) You are trying to help, but please think a bit more before replying. He didn't say anything about compiler errors, also your code would not work at all either. |