21.05.2013, 05:42
Hello, so I have a gate system that loads normally out the database, i've printed stuff, everything was loading fine. But then when /open 'ing the gate, it's only for the first gate that got loaded from the database.
Here the command and the loadfunction:
Command:
Log when printing the for loop:
Can anyone tell me what I did wrong? I've tried heaps of things but none of them actually worked.
Thanks!
-Kevin
Here the command and the loadfunction:
pawn Код:
stock LoadGates()
{
new query[300],line[1000],totalgates;
format(query, sizeof(query), "SELECT * FROM gates");
mysql_query(query);
mysql_store_result();
new GID=0;
while(mysql_fetch_row(line))
{
new Owner2[MAX_PLAYER_NAME];
sscanf(line, "p<|>ds[24]dffffffffffffd",
sGates[GID][GateID],
Owner2,
sGates[GID][GateModel],
sGates[GID][OLocX],
sGates[GID][OLocY],
sGates[GID][OLocZ],
sGates[GID][OLocRX],
sGates[GID][OLocRY],
sGates[GID][OLocRZ],
sGates[GID][CLocX],
sGates[GID][CLocY],
sGates[GID][CLocZ],
sGates[GID][CLocRX],
sGates[GID][CLocRY],
sGates[GID][CLocRZ],
sGates[GID][Airline]);
sGates[GID][Closed] = true;
format(sGates[GID][Owner], 24 ,"%s", Owner2);
printf("%s",sGates[GID][Owner]);
GateObject[GID] = CreateObject(sGates[GID][GateModel],sGates[GID][CLocX],sGates[GID][CLocY],sGates[GID][CLocZ],sGates[GID][CLocRX],sGates[GID][CLocRY],sGates[GID][CLocRZ]);
printf("%d", GID);
GID=GID+1;
totalgates++;
}
printf("Loaded %d gates from the database",totalgates);
mysql_free_result();
for(new gi; gi<MAX_GATES; gi++)
{
printf("%s",sGates[gi][Owner]);
printf("%f", sGates[gi][CLocX]);
printf("%f", sGates[gi][CLocY]);
printf("%f", sGates[gi][CLocZ]);
}
return 1;
}
pawn Код:
if(!strcmp(cmdtext, "/o", true,2))
{
for(new gi; gi< sizeof(sGates); gi++)
{
printf("%s",sGates[gi][Owner]);
printf("%f", sGates[gi][CLocX]);
printf("%f", sGates[gi][CLocY]);
printf("%f", sGates[gi][CLocZ]);
if(IsPlayerInRangeOfPoint(playerid, 25.0, sGates[gi][CLocX], sGates[gi][CLocY], sGates[gi][CLocZ]))
{
if(sGates[gi][Closed] == true)
{
if(sGates[gi][Airline] != 0)
{
if(sGates[gi][Airline] == PInfo[playerid][Airline] || PInfo[playerid][AdminLevel] > 0)
{
MoveGate(gi);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You're not part of this airline");
return 1;
}
}
else
{
if(!strcmp(PlayerName(playerid),sGates[gi][Owner], true) || PInfo[playerid][AdminLevel] > 0)
{
MoveGate(gi);
SendClientMessage(playerid, COLOR_GREEN, "Gate is being opened... Please wait.");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_ERROR,"This is not your gate");
return 1;
}
}
}
else return SendClientMessage(playerid, COLOR_ERROR, "Gate is already being opened.");
}
return 1;
}
return 1;
}
Код:
[07:36:11] Kevin(0) - (/o) [07:36:11] Kevin [07:36:11] 1239.869995 [07:36:11] -740.719970 [07:36:11] 95.290000 This means it only prints out the first one of the database while we have 4 gates in total in the database.
Thanks!
-Kevin