How to save it? MYSQL
#1

Any can give me a base on mysql to save it? I make to load (i think will work), any can give me a base pls?

Код:
CarregarFactions()
{
    mysql_tquery(ConnectMYSQL, "SELECT * FROM factions", "Carregar_Factions", "");
    return 1;
}

forward Carregar_Factions();
public Carregar_Factions()
{
    if(!cache_num_rows()) return 0;
    for(new row; row < cache_num_rows(); row++) {
		cache_get_field_content(row, "facname", FactionInfo[row][facname]);
		cache_get_field_content(row, "lider1", FactionInfo[row][lider1]);
		cache_get_field_content(row, "lider2", FactionInfo[row][lider2]);
		cache_get_field_content(row, "lider3", FactionInfo[row][lider3]);
		cache_get_field_content(row, "membro1", FactionInfo[row][membro1]);
		cache_get_field_content(row, "membro2", FactionInfo[row][membro2]);
		cache_get_field_content(row, "membro3", FactionInfo[row][membro3]);
		cache_get_field_content(row, "membro4", FactionInfo[row][membro4]);
		cache_get_field_content(row, "membro5", FactionInfo[row][membro5]);
		cache_get_field_content(row, "membro6", FactionInfo[row][membro6]);
		cache_get_field_content(row, "membro7", FactionInfo[row][membro7]);
		cache_get_field_content(row, "membro8", FactionInfo[row][membro8]);
		cache_get_field_content(row, "membro9", FactionInfo[row][membro9]);
		cache_get_field_content(row, "membro10", FactionInfo[row][membro10]);
		cache_get_field_content(row, "membro11", FactionInfo[row][membro11]);
		cache_get_field_content(row, "membro12", FactionInfo[row][membro12]);

		FactionInfo[row][HQposX] = cache_get_field_content_float(row, "HQposX");
		FactionInfo[row][HQposY] = cache_get_field_content_float(row, "HQposY");
		FactionInfo[row][HQposZ] = cache_get_field_content_float(row, "HQposZ");

		FactionInfo[row][hq] = cache_get_field_content_int(row, "hq");
		FactionInfo[row][cofredinheiro] = cache_get_field_content_int(row, "cofredinheiro");
		FactionInfo[row][cofresalario] = cache_get_field_content_int(row, "cofresalario");
		FactionInfo[row][cofrematerial] = cache_get_field_content_int(row, "cofrematerial");
		FactionInfo[row][cofremaconha] = cache_get_field_content_int(row, "cofremaconha");
		FactionInfo[row][EagleSPAWNfac] = cache_get_field_content_int(row, "EagleSPAWNfac");
		FactionInfo[row][shotgunSPAWNfac] = cache_get_field_content_int(row, "shotgunSPAWNfac");
		FactionInfo[row][spazSPAWNfac] = cache_get_field_content_int(row, "spazSPAWNfac");
		FactionInfo[row][mp5SPAWNfac] = cache_get_field_content_int(row, "mp5SPAWNfac");
		FactionInfo[row][akSPAWNfac] = cache_get_field_content_int(row, "akSPAWNfac");
		FactionInfo[row][m4SPAWNfac] = cache_get_field_content_int(row, "m4SPAWNfac");
		FactionInfo[row][rifleSPAWNfac] = cache_get_field_content_int(row, "rifleSPAWNfac");
		FactionInfo[row][sniperSPAWNfac] = cache_get_field_content_int(row, "sniperSPAWNfac");
		FactionInfo[row][meleeSPAWNfac] = cache_get_field_content_int(row, "meleeSPAWNfac");
    }
    return 1;
}
Reply
#2

Hi

You have to use mysql_format and the SQl request is
PHP код:
for(new row0row<max_row;row++)
mysql_format(mysqlquerysizeof(query), "UPDATE nameofthetable SET lider1='%s' WHERE row='%d'"FactionInfo[row][lider1], row); 
This is an example

Flo'
Reply
#3

Get urself a Denwer. It helps u to create a SQL database on ur PC as a localhost. Helps a lot!
Reply
#4

Ok ty guys, rep u @Florentin77

Any can say if this is right? \/\/
Код:
forward SalvarFactions();
public SalvarFactions() {
	for(new factionid; factionid < MAX_FACTIONS; factionid++) {
		new query[1030];
		format(query, sizeof(query), "UPDATE `factions` SET `facname` = '%s', `HQposX` = '%f', `HQposY` = '%f', `HQposZ` = '%f', `EagleSPAWNfac` = '%d', `shotgunSPAWNfac` = '%d', `spazSPAWNfac` = '%d', `mp5SPAWNfac` = '%d', `akSPAWNfac` = '%d', `m4SPAWNfac` = '%d', `rifleSPAWNfac` = '%d', `sniperSPAWNfac` = '%d', `meleeSPAWNfac` = '%d', `cofredinheiro` = '%d', `cofresalario` = '%d', `cofrematerial` = '%d', `cofremaconha` = '%d' WHERE `ID` = '%i' ",
            FactionInfo[factionid][facname],
            FactionInfo[factionid][HQposX],
            FactionInfo[factionid][HQposY],
            FactionInfo[factionid][HQposZ],
            FactionInfo[factionid][EagleSPAWNfac],
            FactionInfo[factionid][shotgunSPAWNfac],
			FactionInfo[factionid][spazSPAWNfac],
			FactionInfo[factionid][mp5SPAWNfac],
			FactionInfo[factionid][akSPAWNfac],
			FactionInfo[factionid][m4SPAWNfac],
			FactionInfo[factionid][rifleSPAWNfac],
			FactionInfo[factionid][sniperSPAWNfac],
			FactionInfo[factionid][meleeSPAWNfac],
			FactionInfo[factionid][cofredinheiro],
			FactionInfo[factionid][cofresalario],
			FactionInfo[factionid][cofrematerial],
			FactionInfo[factionid][ID] );
		mysql_pquery(ConnectMYSQL, query);

		format(query, sizeof(query), "UPDATE `factions` SET `lider1` = '%d', `lider2` = '%d', `lider3` = '%d', `membro1` = '%d', `membro2` = '%d', `membro3` = '%d', `membro4` = '%d', `membro5` = '%d', `membro6` = '%d', `membro7` = '%d', `membro8` = '%d', `membro9` = '%d', `membro10` = '%d', `membro11` = '%d', `membro12` = '%d' WHERE `ID` = '%i' ",
			FactionInfo[factionid][lider1],
			FactionInfo[factionid][lider2],
			FactionInfo[factionid][lider3],
			FactionInfo[factionid][membro1],
			FactionInfo[factionid][membro2],
			FactionInfo[factionid][membro3],
			FactionInfo[factionid][membro4],
			FactionInfo[factionid][membro5],
			FactionInfo[factionid][membro6],
			FactionInfo[factionid][membro7],
			FactionInfo[factionid][membro8],
			FactionInfo[factionid][membro9],
			FactionInfo[factionid][membro10],
			FactionInfo[factionid][membro11],
			FactionInfo[factionid][membro12],
			FactionInfo[factionid][ID] );
		mysql_pquery(ConnectMYSQL, query);
	}
}
Reply
#5

Hi,
Ty, This code looks like correct
Try it

Flo'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)