04.02.2014, 21:00
There's a better way about getting the player's ID when register.
Set a callback while executing a query with INSERT INTO clause and use cache_insert_id function to get the value (auto increment must be on).
An example (consider of using default values while creating the table):
Set a callback while executing a query with INSERT INTO clause and use cache_insert_id function to get the value (auto increment must be on).
An example (consider of using default values while creating the table):
pawn Code:
mysql_format(mysql, query, sizeof (query), "INSERT INTO `players` (`Username`, `Password`, `IP`) VALUES ('%e', '%s', '%s')", Name[playerid], pInfo[playerid][Password], IP[playerid]);
mysql_tquery(mysql, query, "OnAccountCreate", "i", playerid);
pawn Code:
forward OnAccountCreate(playerid);
public OnAccountCreate(playerid)
{
pInfo[playerid][ID] = cache_insert_id();
// some other code such as SetSpawnInfo and SpawnPlayer or whatever..
}

