01.01.2019, 12:08
So I have been scripting a Marijuana plant system..
I can create the plant successfully, it spawns, all data showing correctly....
when I delete it, it deletes correctly, but it hasnt saved/deleted from MySQL at all during this process
Very very confused as it looks like it should be good to go for saving MYSQL, any help or advice would be appreciated thanks
I can create the plant successfully, it spawns, all data showing correctly....
when I delete it, it deletes correctly, but it hasnt saved/deleted from MySQL at all during this process
pawn Code:
stock Create_Weed(playerid, weedid, Float:x, Float:y, Float:z)
{
new createweedstockstring[150];
GetPlayerPos(playerid, x, y, z);
WeedPlants[weedid][Exists] = 1;
WeedPlants[weedid][ID] = cache_insert_id();
WeedPlants[weedid][Planter] = GetPlayerNameEx(playerid);
WeedPlants[weedid][PosX] = x;
WeedPlants[weedid][PosY] = y;
WeedPlants[weedid][PosZ] = z -1.0;
WeedPlants[weedid][InteriorID] = GetPlayerInterior(playerid);
WeedPlants[weedid][WorldID] = GetPlayerVirtualWorld(playerid);
WeedPlants[weedid][NameTextLabel] = Text3D:INVALID_3DTEXT_ID;
WeedPlants[weedid][Object] = -1;
WeedPlants[weedid][Buds] = 20;
if(WeedPlants[weedid][Exists])
{
DestroyDynamic3DTextLabel(WeedPlants[weedid][NameTextLabel]);
DestroyObject(WeedPlants[weedid][Object]);
new stringz[90];
format(stringz, sizeof(stringz), "[%i] {33CCFF}Marijuana Plant | %i Buds | Planter: %s{FFFFFF}", weedid, WeedPlants[weedid][Buds], WeedPlants[weedid][Planter]);
WeedPlants[weedid][NameTextLabel] = CreateDynamic3DTextLabel(stringz, -1, x, y, z, 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, WeedPlants[weedid][WorldID], WeedPlants[weedid][InteriorID], -1, 20.0);
WeedPlants[weedid][Object] = CreateObject(3409, x, y, z-5.0, 0.0, 0.0, 0.0, 50.0);
format(createweedstockstring,sizeof(createweedstockstring), "SERVER: {ffff00}%i Marijuana Plant{ffffff} created successfully!",weedid);
SendClientMessage(playerid, -1, createweedstockstring);
mysql_format(Database, queryForm, sizeof(queryForm), "INSERT INTO weedplants (id, x, y, z, worldid, interiorid, buds, planter) VALUES(%i, '%f', '%f', '%f', %i, %i, %i, %s)", WeedPlants[weedid][ID], x, y, z, WeedPlants[weedid][WorldID], WeedPlants[weedid][InteriorID], WeedPlants[weedid][Buds], WeedPlants[weedid][Planter]);
mysql_tquery(Database, queryForm);
mysql_format(Database, queryForm, sizeof(queryForm), "UPDATE weedplants SET world = %i WHERE id = %i", WeedPlants[weedid][WorldID], WeedPlants[weedid][ID]);
mysql_tquery(Database, queryForm);
}
return 1;
}
pawn Code:
CMD:removeweed(playerid, params[])
{
if(Player[playerid][AdminLevel] >= 3)//Head Administrator
{
new weedid, string[150];
if(sscanf(params, "i", weedid))
{
return SendClientMessage(playerid, -1, "SERVER: /removeweed [weedid]");
}
if(!(0 <= weedid < MAX_WEEDPLANTS) || !WeedPlants[weedid][Exists])
{
return SendClientMessage(playerid, -1, "SERVER: That Marijuana Plant ID Does not exist.");
}
DestroyDynamic3DTextLabel(WeedPlants[weedid][NameTextLabel]);
DestroyObject(WeedPlants[weedid][Object]);
mysql_format(Database, queryForm, sizeof(queryForm), "DELETE FROM weedplants WHERE id = %i", WeedPlants[weedid][ID]);
mysql_tquery(Database, queryForm);
WeedPlants[weedid][Exists] = 0;
WeedPlants[weedid][ID] = 0;
WeedPlants[weedid][PosX] = 0;
WeedPlants[weedid][Planter] = -1;
WeedPlants[weedid][ID] = cache_insert_id();
WeedPlants[weedid][PosX] = 0;
WeedPlants[weedid][PosY] = 0;
WeedPlants[weedid][PosZ] = 0;
WeedPlants[weedid][InteriorID] = 999999;
WeedPlants[weedid][WorldID] = 999999;
WeedPlants[weedid][NameTextLabel] = Text3D:INVALID_3DTEXT_ID;
WeedPlants[weedid][Object] = -1;
format(string,sizeof(string),"SERVER: You have removed Marijuana Plant ID {ffff00}%i",weedid);
SendClientMessage(playerid, -1, string);
}
else
{
SendClientMessage(playerid, -1, "SERVER: You are not authorized to use that command!");
}
return 1;
}