CMD:savebase(playerid, params[])
{
if(BuildMode[playerid] == 1)
{
if(BuildProgress[playerid] == 6)
{
new string[128],query[1024];
mysql_format(mysql, query, sizeof(query), "INSERT INTO `bases` (`Name`, `Description`, `Creater`, `Interior`, `aPosX`, `aPosY`, `aPosZ`, `aFacingAng`, `dPosX`, `dPosY`, `dPosZ`, `dFacingAng`, `cpPosX`, `cpPosY`, `cpPosZ`) VALUES ('%s', '%s', '%s', '%d', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f')", BuildInfo[playerid][BaseName], BuildInfo[playerid][Description],PlayerName(playerid), BuildInfo[playerid][Interior],
BuildInfo[playerid][aPosX],BuildInfo[playerid][aPosY],BuildInfo[playerid][aPosZ],BuildInfo[playerid][aFacingAng],BuildInfo[playerid][dPosX],BuildInfo[playerid][dPosY],BuildInfo[playerid][dPosZ],BuildInfo[playerid][dFacingAng],
BuildInfo[playerid][cpPosX],BuildInfo[playerid][cpPosY],BuildInfo[playerid][cpPosZ]);
BuildInfo[playerid][ID] = cache_insert_id();
printf(query); //Debug
BuildProgress[playerid] = 0;
BuildMode[playerid] = 0;
SpawnPlayer(playerid);
format(string, sizeof string,"{4BFF5D}Your base have been saved! {FFFFFF}ID: %d",BuildInfo[playerid][ID]);
SendClientMessage(playerid,0x4BFF5DFF,string);
printf("%s created a new base - ID: %d",PlayerName(playerid), BuildInfo[playerid][ID]);
}
else return SendClientMessage(playerid,0xFFFFFFFF,"{FFFFFF}Error: {791A1A}You cant use this command yet!");
}
else return SendClientMessage(playerid,0xFFFFFFFF,"{FFFFFF}Error: {791A1A}You are currently not in the Buildmode!");
return 1;
}
[16:16:51] INSERT INTO `bases` (`Name`, `Description`, `Creater`, `Interior`, `aPosX`, `aPosY`, `aPosZ`, `aFacingAng`, `dPosX`, `dPosY`, `dPosZ`, `dFacingAng`, `cpPosX`, `cpPosY`, `cpPosZ`) VALUES ('saize test wf lobby', 'so pro', '[PeM]Saize420', '18', '1728.435', '-1668.262', '22.609', '22.609', '1728.563', '-1668.736', '22.609', '22.609', '1726.611', '-1668.707', '22.58') [16:16:51] [PeM]Saize420 created a new base - ID: 0 |
mysql_format merely formats the query. You still need to send it with mysql_tquery. Then you also need to wait for the result to use cache_insert_id (means you need a callback).
|
public OnBaseCreate(playerid)
{
new string[128];
BuildInfo[playerid][ID] = cache_get_field_content_int(0, "ID");
BuildInfo[playerid][BaseName] = cache_get_field_content_int(0, "BaseName");
BuildInfo[playerid][Description] = cache_get_field_content_int(0, "Description");
BuildInfo[playerid][Creater] = cache_get_field_content_int(0, "Creater");
BuildInfo[playerid][Interior] = cache_get_field_content_int(0, "Interior");
BuildInfo[playerid][aPosX] = cache_get_field_content_float(0, "aPosX");
BuildInfo[playerid][aPosY] = cache_get_field_content_float(0, "aPosX");
BuildInfo[playerid][aPosZ] = cache_get_field_content_float(0, "aPosX");
BuildInfo[playerid][aFacingAng] = cache_get_field_content_float(0, "aFacingAng");
BuildInfo[playerid][dPosX] = cache_get_field_content_float(0, "dPosX");
BuildInfo[playerid][dPosY] = cache_get_field_content_float(0, "dPosY");
BuildInfo[playerid][dPosZ] = cache_get_field_content_float(0, "dPosZ");
BuildInfo[playerid][dFacingAng] = cache_get_field_content_float(0, "dFacingAng");
format(string, sizeof string,"{4BFF5D}Your base have been saved! {FFFFFF}ID: %d",BuildInfo[playerid][ID]);
SendClientMessage(playerid,0x4BFF5DFF,string);
printf("%s created a new base - ID: %d",PlayerName(playerid), BuildInfo[playerid][ID]);
return 1;
}
CMD:savebase(playerid, params[])
{
if(BuildMode[playerid] == 1)
{
if(BuildProgress[playerid] == 6)
{
new query[1024];
mysql_format(mysql, query, sizeof(query), "INSERT INTO `bases` (`Name`, `Description`, `Creater`, `Interior`, `aPosX`, `aPosY`, `aPosZ`, `aFacingAng`, `dPosX`, `dPosY`, `dPosZ`, `dFacingAng`, `cpPosX`, `cpPosY`, `cpPosZ`) VALUES ('%s', '%s', '%s', '%d', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f')", BuildInfo[playerid][BaseName], BuildInfo[playerid][Description],PlayerName(playerid), BuildInfo[playerid][Interior],
BuildInfo[playerid][aPosX],BuildInfo[playerid][aPosY],BuildInfo[playerid][aPosZ],BuildInfo[playerid][aFacingAng],BuildInfo[playerid][dPosX],BuildInfo[playerid][dPosY],BuildInfo[playerid][dPosZ],BuildInfo[playerid][dFacingAng],
BuildInfo[playerid][cpPosX],BuildInfo[playerid][cpPosY],BuildInfo[playerid][cpPosZ]);
mysql_tquery(mysql, query, "OnBaseCreate", "i", playerid);
printf(query); //Debug
BuildProgress[playerid] = 0;
BuildMode[playerid] = 0;
SpawnPlayer(playerid);
}
else return SendClientMessage(playerid,0xFFFFFFFF,"{FFFFFF}Error: {791A1A}You cant use this command yet!");
}
else return SendClientMessage(playerid,0xFFFFFFFF,"{FFFFFF}Error: {791A1A}You are currently not in the Buildmode!");
return 1;
}