#define MAX_REPAIR_PICKUPS 20
enum aInfo
{
PickupID,
Float: pux,
Float: puy,
Float: puz,
Text3D: TextLabel
};
new ARepairPickups[MAX_REPAIR_PICKUPS][aInfo];
AddARepairPickups(Float:x, Float:y, Float:z)
{
for (new i; i < sizeof(ARepairPickups); i++)
{
if (ARepairPickups[i][PickupID] == 0)
{
ARepairPickups[i][PickupID] = CreatePickup(3096, 1, x, y, z, 0);
ARepairPickups[i][pux] = x;
ARepairPickups[i][puy] = y;
ARepairPickups[i][puz] = z;
Create3DTextLabel("{FFFF00}Type {00FF00}/repair {FFFF00}to repair your vehicle!", -1, x, y, z +0.5, 50.0, 0);
CreateDynamicMapIcon(x, y, z, 63, 0, 0, 0, -1, 300.0);
break;
}
}
}
bool:IsPlayerAtRepair(playerid)
{
for(new i; i != sizeof(ARepairPickups); i++)
if(IsPlayerInRangeOfPoint(playerid, 5.0, ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]))
return true;
return false;
}
CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z;
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
AddARepairPickups(x, y, z);
return 1;
}
CMD:repair(playerid, params[])
{
SendMessageToAdmins(playerid, "/repair", params);
if(!IsPlayerAtRepair(playerid)) SendClientMessage(playerid, COLOUR_RED, "You are not at repair station!");
else if(GetPlayerVehicleSeat(playerid) != 0) SendClientMessage(playerid, COLOUR_RED, "You are not in a vehicle");
else{
SetTimerEx("Repair", 5000, false, "i", playerid);
TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, "~r~Fixing...~n~Please Wait...", 7000, 6);
}
return 1;
}
forward Repair(playerid);
public Repair(playerid)
{
GameTextForPlayer(playerid, "~g~Fixed!", 3000, 6);
RepairVehicle(GetPlayerVehicleID(playerid));
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, -1, "{FFFF00}[GARAGE]: {FFFFFF}Your vehicle has been serviced!");
return 1;
}
CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z, query[128];
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
mysql_format(g_Sql, query, 128, "INSERT INTO ...");
mysql_tquery(g_Sql, query, "AddARepairPickups", "fff", x, y, z); // AddARepairPickups must be a public function
return 1;
}
public OnGameModeInit()
{
mysql_tquery(g_Sql, "SELECT * FROM repair_pickups", "OnLoadRepairPickups");
// ...
}
public OnLoadRepairPickups()
{
new count;
cache_get_row_count(count); // Get total rows
for(new i; i < count; i++)
{
// ...
// Use cache_get_* function here to retrieve value from the query result
}
return 1;
}
|
Use mysql_tquery under createrepair command to save, and under OnGameModeInit to load.
Example: Код:
CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z, query[128];
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
mysql_format(g_Sql, query, 128, "INSERT INTO ...");
mysql_tquery(g_Sql, query, "AddARepairPickups", "fff", x, y, z); // AddARepairPickups must be a public function
return 1;
}
public OnGameModeInit()
{
mysql_tquery(g_Sql, "SELECT * FROM repair_pickups", "OnLoadRepairPickups");
// ...
}
public OnLoadRepairPickups()
{
new count;
cache_get_row_count(count); // Get total rows
for(new i; i < count; i++)
{
// ...
// Use cache_get_* function here to retrieve value from the query result
}
return 1;
}
|

CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z, query[128];
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
AddARepairPickups(x, y, z);
mysql_format(mysql, query, 128, "INSERT INTO `repair system` (`) VALUES (')");
mysql_tquery(mysql, query, "repair system", "fff", x, y, z); // AddARepairPickups must be a public function
return 1;
}
|
The insert statement is incorrect, you can learn it from here https://dev.mysql.com/doc/refman/5.7/en/insert.html
And also 3rd parameter in mysql_tquery() is for callback. And i think, it's better to use _ instead of blank space in table name. |
mysql_format(mysql, query, 128, "INSERT INTO `repair_system` (`PickupID`,`pux`),(`puy`),(`puz`) VALUES ('%s', '%s', '%s', '%s')");
[19:14:52] [ERROR] error #1064 while executing query "INSERT INTO `repair system` (`) VALUES (')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
[19:27:20] [WARNING] mysql_connect: no password specified
[19:27:53] [ERROR] mysql_format: no value for specifier '%s' passed
[19:27:53] [ERROR] error #1065 while executing query "": Query was empty
CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z, query[128];
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
AddARepairPickups(x, y, z);
mysql_format(mysql, query, 128, "INSERT INTO `repair_system` (`PickupID`,`pux`),(`puy`),(`puz`) VALUES ('%s', '%s', '%s', '%s')");
mysql_tquery(mysql, query, "repair_system", "fff", x, y, z); // AddARepairPickups must be a public function
print(query);
return 1;
}
|
i did it current?
Код:
mysql_format(mysql, query, 128, "INSERT INTO `repair_system` (`PickupID`,`pux`),(`puy`),(`puz`) VALUES ('%s', '%s', '%s', '%s')");
my logs said when i created Код:
[19:14:52] [ERROR] error #1064 while executing query "INSERT INTO `repair system` (`) VALUES (')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
[19:27:20] [WARNING] mysql_connect: no password specified
[19:27:53] [ERROR] mysql_format: no value for specifier '%s' passed
[19:27:53] [ERROR] error #1065 while executing query "": Query was empty
Код:
CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z, query[128];
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
AddARepairPickups(x, y, z);
mysql_format(mysql, query, 128, "INSERT INTO `repair_system` (`PickupID`,`pux`),(`puy`),(`puz`) VALUES ('%s', '%s', '%s', '%s')");
mysql_tquery(mysql, query, "repair_system", "fff", x, y, z); // AddARepairPickups must be a public function
print(query);
return 1;
}
|
CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z, query[128];
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
mysql_format(mysql, query, 128, "INSERT INTO `repair_system` (`pux`,`puy`,`puz`) VALUES (%f, %f, %f)", x, y, z); // Use %f specifier here, because we insert float for pux puy puz
mysql_tquery(mysql, query, "AddARepairPickups", "fff", x, y, z); // AddARepairPickups must be a public function
return 1;
}
|
Your insert statement is incorrect, learn about basic MySQL syntax before starting off writing MySQL based gamemode.
Try this code: Код:
CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z, query[128];
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
mysql_format(mysql, query, 128, "INSERT INTO `repair_system` (`pux`,`puy`,`puz`) VALUES (%f, %f, %f)", x, y, z); // Use %f specifier here, because we insert float for pux puy puz
mysql_tquery(mysql, query, "AddARepairPickups", "fff", x, y, z); // AddARepairPickups must be a public function
return 1;
}
|
public OnLoadRepairPickups()
{
new count;
cache_get_row_count(count); // Get total rows
for(new i; i < count; i++)
{
// ...
// Use cache_get_* function here to retrieve value from the query result
}
return 1;
}