SA-MP Forums Archive
Not correct serverID - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Not correct serverID (/showthread.php?tid=562434)



Not correct serverID - norton2 - 08.02.2015

I do not correctly extract [ vServerID ] mysql database !
VehiclesInfo[i][vModel],VehiclesInfo[i][vPositionX],VehiclesInfo[i][vPositionY],VehiclesInfo[i][vPositionZ],VehiclesInfo[i][vAngle],VehiclesInfo[i][vColor1],VehiclesInfo[i][vColor2] are extracted correctly !

Код HTML:
stock LoadVehiclesMySQL()
{
    new Str[128], query[128], i = 1;
    mysql_format(handle, query, sizeof(query), "SELECT * FROM `vehicles`");
    mysql_tquery(handle, query, "", "");

    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "p<|>iffffiiiiiiis[16]iiiiiiiiiiiiiiiiiii", VehiclesInfo[i][vModel], VehiclesInfo[i][vPositionX], VehiclesInfo[i][vPositionY], VehiclesInfo[i][vPositionZ], VehiclesInfo[i][vAngle],
            VehiclesInfo[i][vColor1], VehiclesInfo[i][vColor2], VehiclesInfo[i][vPaintJob], VehiclesInfo[i][vOwner], VehiclesInfo[i][vLock], VehiclesInfo[i][vKM], VehiclesInfo[i][vDays], VehiclesInfo[i][vNumberPlate],
            VehiclesInfo[i][vComponent1], VehiclesInfo[i][vComponent2], VehiclesInfo[i][vComponent3], VehiclesInfo[i][vComponent4], VehiclesInfo[i][vComponent5],
            VehiclesInfo[i][vComponent6], VehiclesInfo[i][vComponent7], VehiclesInfo[i][vComponent8], VehiclesInfo[i][vComponent9], VehiclesInfo[i][vComponent10],
            VehiclesInfo[i][vComponent11], VehiclesInfo[i][vComponent12], VehiclesInfo[i][vComponent13], VehiclesInfo[i][vComponent14], VehiclesInfo[i][vComponent15],
            VehiclesInfo[i][vComponent16], VehiclesInfo[i][vComponent17], VehiclesInfo[i][vServerID], VehiclesInfo[i][vSlot]);
            VehiclesInfo[i][vServerID] = CreateVehicle(VehiclesInfo[i][vModel],VehiclesInfo[i][vPositionX],VehiclesInfo[i][vPositionY],VehiclesInfo[i][vPositionZ],VehiclesInfo[i][vAngle],VehiclesInfo[i][vColor1],VehiclesInfo[i][vColor2],60000);
            mysql_format(handle, query, sizeof(query), "UPDATE `vehicles` SET `ServerID` = '%i' WHERE ID = '%i'", VehiclesInfo[i][vServerID], VehiclesInfo[i][vID]);
            mysql_query(handle, query);
            if(i > MotoCros[20])
            {
                Tunen(i);
            }
            SetVehicleToRespawn(i);
            i++;
        }
    }
    mysql_free_result();
    printf("--- %i vehicles loaded from the MySQL Database. ---", i);
    return 1;
}
Database table:
Код HTML:
CREATE TABLE IF NOT EXISTS `vehicles` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Model` int(11) NOT NULL,
  `PositionX` float NOT NULL,
  `PositionY` float NOT NULL,
  `PositionZ` float NOT NULL,
  `Angle` float NOT NULL,
  `Color1` int(11) NOT NULL,
  `Color2` int(11) NOT NULL,
  `PaintJob` int(11) NOT NULL,
  `Owner` int(11) NOT NULL,
  `Lock` int(11) NOT NULL,
  `KM` int(11) NOT NULL,
  `Days` int(11) NOT NULL,
  `NumberPlate` varchar(16) NOT NULL,
  `Component1` int(11) NOT NULL,
  `Component2` int(11) NOT NULL,
  `Component3` int(11) NOT NULL,
  `Component4` int(11) NOT NULL,
  `Component5` int(11) NOT NULL,
  `Component6` int(11) NOT NULL,
  `Component7` int(11) NOT NULL,
  `Component8` int(11) NOT NULL,
  `Component9` int(11) NOT NULL,
  `Component10` int(11) NOT NULL,
  `Component11` int(11) NOT NULL,
  `Component12` int(11) NOT NULL,
  `Component13` int(11) NOT NULL,
  `Component14` int(11) NOT NULL,
  `Component15` int(11) NOT NULL,
  `Component16` int(11) NOT NULL,
  `Component17` int(11) NOT NULL,
  `ServerID` int(11) NOT NULL,
  `Slot` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Код HTML:
new v;
        v = PlayerInfo[playerid][pCarKey];
        printf("serverid: %i", VehiclesInfo[v][vServerID]); // debugging.
LOG: serverid: 0
correctly should be: serveri:17

[+REP]


Re: Not correct serverID - iZN - 09.02.2015

Please learn how the plugin works. This version is quite different as compared to previous versions.

Check this tutorial out (made for older versions (R7, R8), but it should be able to tell you enough): https://sampforum.blast.hk/showthread.php?tid=337810
Example registration system made for R33+: https://sampforum.blast.hk/showthread.php?tid=485633


Re: Not correct serverID - norton2 - 09.02.2015

I need loadcar! No MYSQL Account Registration


Re: Not correct serverID - norton2 - 09.02.2015

bump


Re: Not correct serverID - HazardouS - 09.02.2015

mysql_tquery uses cached results, here: https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_tquery

Read the example, read the syntax, understand both of them, look for tutorials on Threaded Queries, then fix your problem. It's easy, but you have to be willing to do it.