PDA

View Full Version : Teleport listing mysql problem


Metharon
26/11/2014, 04:43 PM
I'm trying to create a dynamic teleport system , i want in this dialog to look "Name of the frist teleport ,Name of The 2tH teleport" but only the frist teleport name's is loading.... can somebody help me ?
i think is something wrong with the loading because when i'm creating them in-game and after type /tplist is working.

The last teleport "Name" has been created 2 seconds before calling the dialog.

In-game:

http://i.imgur.com/T2FhWejl.png (http://imgur.com/T2FhWej)


But my DB is :

http://i.imgur.com/jEPBqqvl.png (http://imgur.com/jEPBqqv)



My loading code.



stock IncarcaTeleporturi()
{
new Cache: Result = mysql_query( SQL, "SELECT * FROM `teleports`" ), Get[ 2 ];
cache_get_data( Get[ 0 ], Get[ 1 ], SQL ); // Get[ 0 ] - Rows || Get[ 1 ] - Fields || SQL - connectionHandle
for(new i = 0; i < Get[ 0 ]; i++)
{
new field[129];
new tid = cache_get_field_content_int( i, "ID", SQL );
TeleportInfo[tid][TeleportAngle] = cache_get_field_content_int( i, "Angle", SQL );
TeleportInfo[tid][Interior] = cache_get_field_content_int( i, "INT", SQL );
TeleportInfo[tid][State] = cache_get_field_content_int( i, "State", SQL );
TeleportInfo[tid][World] = cache_get_field_content_int( i, "VW", SQL );
TeleportInfo[tid][TeleportX] = cache_get_field_content_float( i, "X", SQL );
TeleportInfo[tid][TeleportY] = cache_get_field_content_float( i, "Y", SQL );
TeleportInfo[tid][TeleportZ] = cache_get_field_content_float( i, "Z", SQL );
cache_get_field_content( 0, "Name", field, SQL, sizeof( field ) );
format( TeleportInfo[tid][Name], 50, "%s", field );
sTeles++;
}
cache_delete( Result );
printf("[6.] Am incarcat toate teleporturile [%d]",sTeles);
return 1;
}



My command to create & list


if(strcmp(cmd, "/createtp", true) == 0 || strcmp(cmd, "/createteleport", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][Administrator] != 20)
{
SendClientMessage(playerid, -1, "{FFFFFF}(( {FFCC00}Informatie -{C0C0C0} nu ai accces la aceasta comanda! {FFFFFF}))");
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_YELLOW2, "{FFFFFF}(( {FFCC00}Exemplu folosire: {C0C0C0} /createteleport [nume] {FFFFFF}))");
return 1;
}
new Float:x, Float:y, Float:z, Float:Angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, Angle);
sTeles++;
new tid = sTeles;
TeleportInfo[tid][TeleportX] = x;
TeleportInfo[tid][TeleportY] = y;
TeleportInfo[tid][TeleportZ] = z;
TeleportInfo[tid][State] = 1;
TeleportInfo[tid][TeleportAngle] = Angle;
TeleportInfo[tid][Interior] = GetPlayerInterior(playerid);
TeleportInfo[tid][World] = GetPlayerVirtualWorld(playerid);
format(TeleportInfo[tid][Name], 50,"%s", result);
szQuery[ 0 ] = EOS;
format( szQuery , 500 , "INSERT INTO `teleports` ( ID, Name, X, Y, Z, Angle, `INT`, VW, State) VALUES ( %d,'%s',%f,%f,%f,%f,%d,%d, %d )", tid, TeleportInfo[tid][Name], TeleportInfo[tid][TeleportX],TeleportInfo[tid][TeleportY],TeleportInfo[tid][TeleportZ],TeleportInfo[tid][TeleportAngle],TeleportInfo[tid][Interior],TeleportInfo[tid][World],TeleportInfo[tid][State]);
mysql_tquery( SQL , szQuery , "" , "" );
SendClientMessage(playerid, -1 , "done");

}
return 1;
}


if (strcmp(cmd, "/tplist", true) == 0 || strcmp(cmd, "/teleports", true) == 0)
{
if(PlayerInfo[playerid][Administrator] >= 1 || PlayerInfo[playerid][Helper] == 1)
{
new count = 0;
new string[766];
for(new i = 0; i < MAX_TELES; i++)
{
if(TeleportInfo[i][State] == 1)
{
format(string, sizeof(string), "%s\n%s \n", string,TeleportInfo[i][Name]);
count++;

}
}
new string2[456];
format(string2, sizeof(string2), "Lista de teleportare (%d in total)", count);
ShowPlayerDialog(playerid, DIALOG_TPLIST, DIALOG_STYLE_LIST, string2, string, "Teleport", "Cancel");

}
return 1;
}

Metharon
26/11/2014, 04:47 PM
Done , fixed.