16.01.2012, 16:10
Hello,im not very good with the mysql so i need your help,i made something but it dosent work,
it should load every faction in mysql table(theres like 10 factions in mysql table
so heres the code:
mysql table
it should load every faction in mysql table(theres like 10 factions in mysql table
so heres the code:
Код:
stock FactionsLoad() { new QueryString[ 128 ], i = 1; mysql_query( "SELECT `fName`, `fRank1`,`fRank2`, `fRank3`, `fRank4`, `fRank5`, `fRank6`, `fEnteranceX`, `fEnteranceY`, `fEnteranceZ`, `fExitX`, `fExitY`, `fExitZ`, `fInt`, `fID`, `fLocked` FROM `factions`"); mysql_store_result(); if( mysql_num_rows() >= 1 ) { new idx; while (idx < sizeof(Factions)) { mysql_fetch_field( "fName", QueryString ); Factions[ idx ][ fName ] = strval( QueryString ); mysql_fetch_field( "fRank1", QueryString ); Factions[ idx ][ fRank1 ] = strval( QueryString ); mysql_fetch_field( "fRank2", QueryString ); Factions[ idx ][ fRank2 ] = strval( QueryString ); mysql_fetch_field( "fRank3", QueryString ); Factions[ idx ][ fRank3 ] = strval( QueryString ); mysql_fetch_field( "fRank4", QueryString ); Factions[ idx ][ fRank4 ] = strval( QueryString ); mysql_fetch_field( "fRank5", QueryString ); Factions[ idx ][ fRank5 ] = strval( QueryString ); mysql_fetch_field( "fRank6", QueryString ); Factions[ idx ][ fRank6 ] = strval( QueryString ); mysql_fetch_field( "fEnteranceX", QueryString ); Factions[ idx ][ fEnteranceX ] = floatstr( QueryString ); mysql_fetch_field( "fEnteranceY", QueryString ); Factions[ idx ][ fEnteranceY ] = floatstr( QueryString ); mysql_fetch_field( "fEnteranceZ", QueryString ); Factions[ idx ][ fEnteranceZ ] = floatstr( QueryString ); mysql_fetch_field( "fExitX", QueryString ); Factions[ idx ][ fExitX ] = floatstr( QueryString ); mysql_fetch_field( "fExitY", QueryString ); Factions[ idx ][ fExitY ] = floatstr( QueryString ); mysql_fetch_field( "fExitZ", QueryString ); Factions[ idx ][ fExitZ ] = floatstr( QueryString ); mysql_fetch_field( "fInt", QueryString ); Factions[ idx ][ fInt ] = strval( QueryString ); mysql_fetch_field( "fID", QueryString ); Factions[ idx ][ fID ] = strval( QueryString ); mysql_fetch_field( "fLocked", QueryString ); Factions[ idx ][ fLocked ] = strval( QueryString ); mysql_query( QueryString ); idx++; } } mysql_free_result(); return 1; }
Код:
enum FactionsEnum { fName, fRank1, fRank2, fRank3, fRank4, fRank5, fRank6, Float: fEnteranceX, Float: fEnteranceY, Float: fEnteranceZ, Float: fExitX, Float: fExitY, Float: fExitZ, fInt, fID, fLocked, } new Factions[ MAX_FACTIONS ][ FactionsEnum ];
Код:
under ongamemodeinit FactionsLoad(); for(new f = 0; f < 100; f++) { AddStaticPickup(1239, 2, Factions[f][fEnteranceX], Factions[f][fEnteranceY], Factions[f][fEnteranceZ]); Create3DTextLabel("[ Faction HQ ]", 0x00A0F6AA, Factions[f][fEnteranceX], Factions[f][fEnteranceY], Factions[f][fEnteranceZ] + 0.75, 15.0, 0, 1); pickups++; }
Код:
-- phpMyAdmin SQL Dump -- version 3.2.0.1 -- http://www.phpmyadmin.netnl6766e203c238a...3.27450256-- Host: localhost -- Generation Time: May 26, 2011 at 05:18 PM -- Server version: 5.1.36 -- PHP Version: 5.3.0 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `samp` -- -- -------------------------------------------------------- -- -- Table structure for table `factions` -- CREATE TABLE IF NOT EXISTS `factions` ( `fName` text NOT NULL, `fRank1` tinytext NOT NULL, `fRank2` tinytext NOT NULL, `fRank3` tinytext NOT NULL, `fRank4` tinytext NOT NULL, `fRank5` tinytext NOT NULL, `fRank6` tinytext NOT NULL, `fEnteranceX` float NOT NULL DEFAULT '0', `fEnteranceY` float NOT NULL DEFAULT '0', `fEnteranceZ` float NOT NULL DEFAULT '0', `fExitX` float NOT NULL DEFAULT '0', `fExitY` float NOT NULL DEFAULT '0', `fExitZ` float NOT NULL DEFAULT '0', `fInt` tinytext NOT NULL, `fID` tinytext NOT NULL, `fLocked` tinytext NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `factions` -- INSERT INTO `factions` (`fName`, `fRank1`, `fRank2`, `fRank3`, `fRank4`, `fRank5`, `fRank6`, `fEnteranceX`, `fEnteranceY`, `fEnteranceZ`, `fExitX`, `fExitY`, `fExitZ`, `fInt`, `fID`, `fLocked`) VALUES ('0', '0', '0', '0', '0', '0', '0', 0, 0, 0, 0, 0, 0, '0', '1', '0');