MYSQL
#9

pawn Код:
#define MAX_POBJECTS 35

// When server starts
// for(new i = 0; i < MAX_POBJECTS; i++)LoadObjects(i);
 
LoadObjetcs(id){
    Obj[id][Exists] = 0;
    new DB_Query[64];
    mysql_format(Database2, DB_Query, sizeof(DB_Query), "SELECT * FROM `usersobjectsinfo`");
    mysql_tquery(Database2, DB_Query, "LoadObjectsCoordinates","i", id);
    return 1;
 
}
You execute `LoadObjects` 35 times but your query selects all the data each time. Execute 1 query and a loop to load all the objects at once.

Does it also mean that a player can only create 1 object (35 players max) or 35 objects per player?

Remove the save cache, set active cache and delete cache parts.

pawn Код:
strcat(DB_Query, "CREATE TABLE IF NOT EXISTS `usersobjectsinfo`");
        strcat(DB_Query,"(`ID` int(11) NOT NULL AUTO_INCREMENT,");
        strcat(DB_Query,"`USERNAME` varchar(24),`POSX` float(12),"); // To get track of who created that obj
        strcat(DB_Query,"`POSY` float(12),");
        strcat(DB_Query,"`POSZ` float(12),");
        strcat(DB_Query,"`ROTX` float(12),");
        strcat(DB_Query,"`ROTY` float(12),");
        strcat(DB_Query,"`ROTZ` float(12),");
        strcat(DB_Query,"`OBJECTID` mediumint(7) NOT NULL,");
        strcat(DB_Query,"PRIMARY KEY (`ID`))");
The main reason I had suggested to you to use 2 tables was to avoid storing the name of player in each row. At least, insert the registration ID instead.

What pair is unique? userid + objectid
Set those two columns as a UNIQUE KEY (yes, multi-column in 1 key). Now you do not even need the select query, nor checking if x is equal to y.

pawn Код:
INSERT INTO usersobjectsinfo (...) VALUES (...) ON DUPLICATE KEY UPDATE ...
Reply


Messages In This Thread
MYSQL (edited reply) - by v1k1nG - 08.10.2018, 09:38
Re: MYSQL - by Calisthenics - 08.10.2018, 10:14
Re: MYSQL - by v1k1nG - 08.10.2018, 11:10
Re: MYSQL - by v1k1nG - 08.10.2018, 12:43
Re: MYSQL - by v1k1nG - 08.10.2018, 13:48
Re: MYSQL - by v1k1nG - 08.10.2018, 14:01
Re: MYSQL - by Calisthenics - 08.10.2018, 18:32
Re: MYSQL - by v1k1nG - 08.10.2018, 18:58
Re: MYSQL - by Calisthenics - 08.10.2018, 20:40
Re: MYSQL - by v1k1nG - 10.10.2018, 12:10

Forum Jump:


Users browsing this thread: 4 Guest(s)