Is this code correct ? - 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: Is this code correct ? (
/showthread.php?tid=508026)
Is this code correct ? -
S4t3K - 20.04.2014
Hi.
I'm working on my accessories system, and for saving, I use OnPlayerEditAttachedObject.
But I'd like to know if my code is correct
PHP код:
new bandana1[] = {18891, 18892, 18895, 18896, 18897, 18898, 18899};
for(a; a < sizeof(bandana1); a++)
{
if(a == modelid)
{
PlayerInfo[playerid][pBandana1o][0] = fOffsetX;
PlayerInfo[playerid][pBandana1o][1] = fOffsetY;
PlayerInfo[playerid][pBandana1o][2] = fOffsetZ;
PlayerInfo[playerid][pBandana1o][3] = fRotX;
PlayerInfo[playerid][pBandana1o][4] = fRotY;
PlayerInfo[playerid][pBandana1o][5] = fRotZ;
PlayerInfo[playerid][pBandana1o][6] = fScaleX;
PlayerInfo[playerid][pBandana1o][7] = fScaleY;
PlayerInfo[playerid][pBandana1o][8] = fScaleZ;
}
}
I mean, does the for loop will browse each value of the bandana1 array ?
Will "a" get the values 18891, 18892, 18895, 18896, 18897, 18898, 18899 in this order ?
Thanks in advance.
Re: Is this code correct ? -
Conradus - 20.04.2014
One way to find out is to print the values, which you can see in the console and logs:
Код:
new debug[50];
new bandana1[] = {18891, 18892, 18895, 18896, 18897, 18898, 18899};
for(a; a < sizeof(bandana1); a++)
{
if(a == modelid)
{
format(debug, sizeof(debug), "---- Player Bandana ID: %d ----", pBandana1o);
print(debug);
PlayerInfo[playerid][pBandana1o][0] = fOffsetX;
PlayerInfo[playerid][pBandana1o][1] = fOffsetY;
PlayerInfo[playerid][pBandana1o][2] = fOffsetZ;
format(debug, sizeof(debug), "Offset: x:%f y:%f z:%f", fOffsetX, fOffsetY, fOffsetZ);
print(debug);
PlayerInfo[playerid][pBandana1o][3] = fRotX;
PlayerInfo[playerid][pBandana1o][4] = fRotY;
PlayerInfo[playerid][pBandana1o][5] = fRotZ;
format(debug, sizeof(debug), "Rotation: x:%f y:%f z:%f", fRotX, fRotY, fRotZ);
print(debug);
PlayerInfo[playerid][pBandana1o][6] = fScaleX;
PlayerInfo[playerid][pBandana1o][7] = fScaleY;
PlayerInfo[playerid][pBandana1o][8] = fScaleZ;
format(debug, sizeof(debug), "Scale: x:%f y:%f z:%f", fScaleX, fScaleY, fScaleZ);
print(debug);
}
}
Re : Is this code correct ? -
S4t3K - 20.04.2014
Thanks a lot, I'll try right now.
+rep.