enum pInfo{ pWP0, pWP1, pWP2, pWP3, pWP4, pWP5, pWP6, pWP7, pWP8, pWP9, pWP10, pWP11, pWP12} new Informacion[MAX_PLAYERS][pInfo]; stock ResetVariables(playerid){ Informacion[playerid][pWP0] = 0; Informacion[playerid][pWP1] = 0; Informacion[playerid][pWP2] = 0; Informacion[playerid][pWP3] = 0; Informacion[playerid][pWP4] = 0; Informacion[playerid][pWP5] = 0; Informacion[playerid][pWP6] = 0; Informacion[playerid][pWP7] = 0; Informacion[playerid][pWP8] = 0; Informacion[playerid][pWP9] = 0; Informacion[playerid][pWP10] = 0; Informacion[playerid][pWP11] = 0; Informacion[playerid][pWP12] = 0;} /* Esto es en el cargado, es MYSQL R39 */ Informacion[playerid][pWP0] = cache_get_row_int(0, 26, MySQL); Informacion[playerid][pWP1] = cache_get_row_int(0, 27, MySQL); Informacion[playerid][pWP2] = cache_get_row_int(0, 28, MySQL); Informacion[playerid][pWP3] = cache_get_row_int(0, 29, MySQL); Informacion[playerid][pWP4] = cache_get_row_int(0, 30, MySQL); Informacion[playerid][pWP5] = cache_get_row_int(0, 31, MySQL); Informacion[playerid][pWP6] = cache_get_row_int(0, 32, MySQL); Informacion[playerid][pWP7] = cache_get_row_int(0, 33, MySQL); Informacion[playerid][pWP8] = cache_get_row_int(0, 34, MySQL); Informacion[playerid][pWP9] = cache_get_row_int(0, 35, MySQL); Informacion[playerid][pWP10] = cache_get_row_int(0, 36, MySQL); Informacion[playerid][pWP11] = cache_get_row_int(0, 37, MySQL); Informacion[playerid][pWP12] = cache_get_row_int(0, 38, MySQL); /* Esto es el guardado */ mysql_format(MySQL, query, sizeof(query), "UPDATE `cuentas` SET `WP0`='%i', `WP1`='%i', `WP2`='%i', `WP3`='%i', `WP4`='%i', `WP5`='%i', `WP6`='%i', `WP7`='%i', `WP8`='%i', `WP9`='%i', `WP10`='%i', `WP11`='%i', `WP12`='%i' WHERE `Nombre`='%s'", Informacion[playerid][pWP0], Informacion[playerid][pWP1], Informacion[playerid][pWP2], Informacion[playerid][pWP3], Informacion[playerid][pWP4], Informacion[playerid][pWP5], Informacion[playerid][pWP6], Informacion[playerid][pWP7], Informacion[playerid][pWP8], Informacion[playerid][pWP9], Informacion[playerid][pWP10], Informacion[playerid][pWP11], Informacion[playerid][pWP12], NombreJugador(playerid)); mysql_query(MySQL, query);
//Agrega esto en tu tabla:
ALTER TABLE `cuentas` ADD `WPS` VARCHAR(45) NOT NULL DEFAULT '0,0,0,0,0,0,0,0,0,0,0,0,0' ;
enum pInfo
{
pWP[13],
pWPIndex[45]
}
new Informacion[MAX_PLAYERS][pInfo];
stock ResetVariables(playerid)
{
Informacion[playerid][pWP0] = 0;
Informacion[playerid][pWP1] = 0;
Informacion[playerid][pWP2] = 0;
Informacion[playerid][pWP3] = 0;
Informacion[playerid][pWP4] = 0;
Informacion[playerid][pWP5] = 0;
Informacion[playerid][pWP6] = 0;
Informacion[playerid][pWP7] = 0;
Informacion[playerid][pWP8] = 0;
Informacion[playerid][pWP9] = 0;
Informacion[playerid][pWP10] = 0;
Informacion[playerid][pWP11] = 0;
Informacion[playerid][pWP12] = 0;
}
/* Esto es en el cargado, es MYSQL R39 */
cache_get_field_content(0, "WPS", PlayerInfo[playerid][pWPIndex], MySQL, 45);
sscanf(PlayerInfo[playerid][pWPIndex], "p<,>iiiiiiiiiiiii",
PlayerInfo[playerid][pWP][0], PlayerInfo[playerid][pWP][1], PlayerInfo[playerid][pWP][2], PlayerInfo[playerid][pWP][3], PlayerInfo[playerid][pWP][4],
PlayerInfo[playerid][pWP][5], PlayerInfo[playerid][pWP][6], PlayerInfo[playerid][pWP][7], PlayerInfo[playerid][pWP][8], PlayerInfo[playerid][pWP][9],
PlayerInfo[playerid][pWP][10], PlayerInfo[playerid][pWP][11], PlayerInfo[playerid][pWP][12]);
/* Esto es el guardado */
new str[5], result[5*13], queryx[130];
for(new i = 0; i < 12; i++)
{
format(str, sizeof(str), "%d,", PlayerInfo[playerid][pWP][i]);
strcat(result, str);
}
format(str, sizeof(str), "%d", PlayerInfo[playerid][pWP][12]);
strcat(result, str);
mysql_format(MySQL, queryx, sizeof(queryx), "UPDATE `usuarios` SET `WPS` = '%s' WHERE `Nombre`='%s'", result, NombreJugador(playerid));
mysql_tquery(MySQL, queryx, "", "");
"varchar" no es para ese tipo de cosas. Ocupa una nueva tabla.
|
No se refiere a que no funcione, la forma mбs уptima no es es a lo que se refiere. Lo mбs ordenado es hacer otra tabla que indexe las armas por ID a la ID de cuenta por ejemplo.
Hay que tener en cuenta que tu mйtodo es mбs bien una forma mъy precipitada y un mйtodo (usar sscanf para filtrar datos cuando tendrнas la posibilidad de obtener ya los datos asн) y a los inicios eso no es ningъn problema pero a la larga cuando hay muchas tablas y bъsquedas no trae nada bueno |
Entonces estбs diciendo que la mejor forma de hacerlo serнa crear otra tabla, como la de cuentas por asн decirlo llamada ejemplo armas, y que ahн diga el nombre del jugador, y otro campos con las armas no?.
|