Furniture filterscript wont work
#1

Hello. I found this filterscript for furniture placement and I set up the mysql database, compiled and added it to my server.cfg but yet I have no luck in getting it to work. Nothing happens when I press why and I even made a command to see if I could get the dialogs to show, but nothing happens. It's almost as if it doesn't read any of the code.

This is the entire filterscript

Код:
/*                      FURNITURE SYSTEM v1.0 BY KIDDO
                       CREDITS: KIDDO, BLUEG, INCOGNITO, ******
					    (Do not remove this line!)
				        DO NOT (RE)RELEASE THIS SCRIPT!
																			 */
#include <a_samp>
#include <a_mysql>
#include <streamer>
#include <foreach>
#include <zcmd>

// Color Defines
#define COL_RED          "{FF2626}"
#define COL_GREEN        "{86C44D}"
#define COL_WHITE        "{FFFFFF}"
#define COL_GREY         "{CCCCCC}"
#define COL_BLUE         "{4373E6}"
#define COL_ORANGE       "{E6BA43}"
#define COL_PURPLE       "{CD8DD9}"
#define COL_LIGHTRED     "{FA6161}"
#define COL_LIGHTGREEN   "{56ED1A}"
#define COL_LIGHTBLUE    "{61BFFA}"
#define COL_AQUA         "{61FAFA}"
#define COL_LOGIN        "{FA9761}"
#define COL_PINK         "{FA61F7}"
#define COL_YELLOW       "{FFFB00}"
#define COL_BLACK        "{000000}"

#define MYSQL_HOST "localhost"
#define MYSQL_PASS ""
#define MYSQL_DATA "furniture"
#define MYSQL_USER "root"

#define MAX_FOBJECTS 200
#define DIALOG_OBJECTS   	10000
#define DIALOG_USED      	10001
#define DIALOG_NOTUSED   	10002
#define DIALOG_CHOOSETYPE   10003
#define DIALOG_TABLE        10004
#define DIALOG_BUY          10005
#define DIALOG_CHAIR        10006
#define DIALOG_BEDS         10007
#define DIALOG_SOFAS        10008
#define DIALOG_DECORATIONS  10009
#define DIALOG_APPLIANCES   10010

new smallquery[128];
new bigquery[512];
new dbhandle;
new object[MAX_FOBJECTS];
new usingslot[10];
new preview[MAX_PLAYERS];
new objectmodel[MAX_PLAYERS];
new editingobject[MAX_PLAYERS];
new objectprice[MAX_PLAYERS];

forward f_LoadPlayer(playerid);
forward f_ObjectsLoad();

enum table
{
    tid,
    tablename[48],
    tableprice,
}
new Tables[15][table] = {
{1281, "Park Table[$100]",100},
{1432, "Plain Table[$120]",120},
{1594, "Plain table + Chairs[500$]",500},
{1825, "Elegant table + Chairs[500$]",500},
{1827, "Elegant table[800$]",800},
{1433, "Living Room Table 1[[250$]",250},
{1516, "Living Room Table 2[250$]",250},
{1524, "Craps Table[3050$]",3050},
{2311, "TV Table 1[402$]",402},
{2313, "TV Table 2[450$]",450},
{2315, "TV Table 3[420$]",420},
{2346, "Hi Fi Table 1[500$]",500},
{2635, "Pizza Table[150$]",150},
{2762, "Red Table(Cluckin Bell)[402$]",402},
{2799, "Black Table + 2chairs[750$]",750}
};

enum chair
{
    cid,
    chairname[48],
    chairprice,
}
new Chairs[15][chair] = {
{1369, "Wheelchair[$100]",100},
{1663, "Office Chair 1[$200]",200},
{1704, "Chair 1[150$]",150},
{1705, "Chair 2[150$]",150},
{1708, "Chair 3[150$]",150},
{1711, "Chair 4[120$]",120},
{1714, "Elegant office chair[550$]",550},
{1720, "Rest Chair[220$]",220},
{1721, "Waiting room chair[50$]",50},
{1735, "Chair 5[120$]",120},
{1739, "Dinning Chair[230$]",230},
{1806, "Office Chair 3[150$]",150},
{1811, "Low Dinning Chair[100$]",100},
{2079, "Dinning Chair 2[120$]",120},
{2120, "Medium Dinning Chair[120$]",120}
};
enum bed
{
    bid,
    bedname[48],
    bedprice,
}
new Beds[15][bed] = {
{1700, "Sleeping Room Bed[$250]",250},
{1701, "Sleeping Room Bed 2[$250]",250},
{1745, "Sleeping Room Bed 3[$300]",300},
{1793, "Low Bed[$150]",150},
{1794, "Low Bed 2[$170]",170},
{1796, "Low Bed 3[$120]",120},
{1797, "Swank Bed[$150]",150},
{1798, "Swank Bed 2[$150]",150},
{1799, "Medium Bed[$189]",180},
{1800, "Low Bed[$150]",150},
{1802, "Medium Bed[$230]",230},
{1803, "Medium Bed 2[$1230]",230},
{2299, "Elegant Bed[$450]",450},
{2563, "Bed Set 1[$1500]",1500},
{2566, "Bed Set 2[$1700]",1700}
};

enum sofa
{
    sid,
    sofaname[48],
    sofaprice,
}
new Sofas[15][sofa] = {
{1702, "Living Room Couch[$250]",250},
{1703, "Living Room Couch 2[$250]",250},
{1706, "Living Room Couch 3[$250]",250},
{1707, "Living Room Couch 4[$250]",250},
{1712, "Living Room Couch 5[$250]",250},
{1713, "Living Room Couch 6[$250]",250},
{1753, "Swank Couch [$300]",300},
{1756, "Low Couch[$300]",300},
{1757, "Low Couch 2[$300]",300},
{1760, "Medium Couch[$320]",320},
{1761, "Swank Couch 2[$220]",220},
{1763, "Low Couch 3[$308]",308},
{1764, "Low Couch 4[$308]",308},
{1766, "Medium Couch 2 [$350]",350},
{1768, "Low Couch 5[$499]",499}
};

enum decoration
{
    did,
    decname[48],
    decprice,
}
new Decorations[15][decoration] = {
{2833, "Living Grug[$130]",130},
{1834, "Living Grug 2[$130]",130},
{1835, "Living Grug 3[$130]",130},
{1836, "Living Grug 4[$130]",130},
{1811, "Flower Pot 1[$15]",15},
{1834, "Burger Shot bag[$10]",10},
{2510, "Plane Model[$50]",50},
{2502, "Hobby Shelf[$70]",70},
{2353, "Meal object[$10]",10},
{2284, "Frame 1[$40]",40},
{2285, "Frame 2[$40]",40},
{2286, "Frame 3[$40]",40},
{2267, "Frame 4[$40]",40},
{2274, "Frame 5[$40]",40},
{2251, "Plant Pot 1[$20]",20}
};

enum appl
{
    appid,
    appname[48],
    appprice,
}
new Appliances[15][appl] = {
{1429, "Broken TV[$20]",20},
{1518, "TV[$200]",200},
{2297, "TV Unit[$350]",350},
{1429, "Broken TV [$20]",20},
{16377, "TV Stand[$150]",150},
{2131, "Kitchen Fridge[$560]",560},
{2132, "Kitchen Sink[$240]",240},
{2170, "Kitchen Cooker[$170]",170},
{2340, "Kitchen Washer[$250]",250},
{2131, "Cooker + Cabinet[$300]",300},
{2421, "Microwave[$150]",1150},
{2528, "Toilet[$100]",100},
{2526, "Bath[$150]",150},
{1514, "Till[$400]",400},
{1515, "Slot Machine[$1202]",1202}
};

enum fInfo
{
	id,
	Name[MAX_PLAYER_NAME],
	Slot[30]
};
new FurnitureInfo[MAX_PLAYERS][fInfo];

enum oInfo
{
	id,
	modelid,
	Float:x,
	Float:y,
	Float:z,
	Float:rx,
	Float:ry,
	Float:rz,
	worldid,
	interiorid,
};
new ObjectInfo[MAX_FOBJECTS][oInfo];
// -----------------------------------------------------//
public OnFilterScriptInit()
{
    dbhandle = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_DATA,MYSQL_PASS);
    if(mysql_ping())
    {
		print("\n");
		print("**********************************************");
		print("\n");
		print("> Furniture System V1.0 By Kiddo Loaded!");
		print("\n");
		print("**********************************************");
		print("\n");
		mysql_format(dbhandle,smallquery,"SELECT * FROM `objects`");
		mysql_function_query(dbhandle,smallquery,true,"f_ObjectsLoad","","");
    }
    return 1;
}
public OnFilterScriptExit()
{
	new counto;
	for(new i = 0; i < MAX_FOBJECTS; i++)
	{
		if(ObjectInfo[i][id] != 0)
		{
			f_ObjectSave(i);
			counto++;
		}
	}
	foreach(new p : Player) f_SavePlayer(p);
	printf("Saving Objects: Saved %d objects!",counto);
    mysql_close();
	return 1;
}
public OnPlayerConnect(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
	SendClientMessage(playerid,-1,""COL_LIGHTBLUE"»"COL_WHITE" This server is using "COL_LIGHTBLUE"Furniture System V1"COL_WHITE" by"COL_LIGHTBLUE" Kiddo"COL_WHITE"!"); // You can remove this line
	mysql_format(dbhandle,smallquery,"SELECT * FROM `players` WHERE `name` = '%e' LIMIT 1",name);
	mysql_function_query(dbhandle,smallquery,true,"f_LoadPlayer","i",playerid);
	usingslot[playerid] = 999;
	editingobject[playerid] = 999;
	return 1;
}
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	new Float:oldX, Float:oldY, Float:oldZ,Float:oldRotX, Float:oldRotY, Float:oldRotZ;
	GetDynamicObjectPos(objectid, oldX, oldY, oldZ);
	GetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
	if(response == EDIT_RESPONSE_FINAL)
	{
    	SetDynamicObjectPos(objectid, fX, fY, fZ);
	    SetDynamicObjectRot(objectid, fRotX, fRotY, fRotZ);
		ObjectInfo[editingobject[playerid]][x] = fX;
		ObjectInfo[editingobject[playerid]][y] = fY;
		ObjectInfo[editingobject[playerid]][z] = fZ;
		ObjectInfo[editingobject[playerid]][rx] = fRotX;
		ObjectInfo[editingobject[playerid]][ry] = fRotY;
		ObjectInfo[editingobject[playerid]][rz] = fRotZ;
		SendClientMessage(playerid,-1,""COL_YELLOW"Furniture System:"COL_WHITE" You've finished editing object!");
		f_ObjectSave(editingobject[playerid]);
		editingobject[playerid] = 999;
	}
	if(response == EDIT_RESPONSE_CANCEL)
	{
    	SetDynamicObjectPos(editingobject[playerid], oldX, oldY, oldZ);
	    SetDynamicObjectRot(editingobject[playerid], oldRotX, oldRotY, oldRotZ);
		SendClientMessage(playerid,-1,""COL_YELLOW"Furniture System:"COL_WHITE" You've canceled editing object!");
		editingobject[playerid] = 999;
	}
}
public OnPlayerDisconnect(playerid, reason)
{
	f_SavePlayer(playerid);
	return 1;
}
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
	new string[1250];
	new otext[128];
	if(newkeys & 65536) // KEY Y
	{
		for(new i = 0; i < 30; i++)
		{
			if(FurnitureInfo[playerid][Slot][i] != 0) format(otext,sizeof(otext),""COL_WHITE"Slot ID %d "COL_RED"(Used)",i);
			else format(otext,sizeof(otext),""COL_WHITE"Slot ID %d "COL_GREEN"(Not used)",i);
			format(string,sizeof(string),"%s%s\n",string,otext);
		    ShowPlayerDialog(playerid, DIALOG_OBJECTS, DIALOG_STYLE_LIST,""COL_YELLOW"Furniture System",string, "Choose", "Quit");
		}
	}
	return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		case DIALOG_OBJECTS:
		{
			if(!response) return 1;
			else if(response)
			{
                usingslot[playerid] = listitem;
				new caption[48];
				if(FurnitureInfo[playerid][Slot][listitem] != 0)
				{
					format(caption,sizeof(caption),""COL_YELLOW"Slot ID %d "COL_RED"(Used)",listitem);
					ShowPlayerDialog(playerid,DIALOG_USED,DIALOG_STYLE_LIST,caption,""COL_WHITE"Delete object\nEdit Object","Choose","Quit");
				}
				else
				{
					format(caption,sizeof(caption),""COL_YELLOW"Slot ID %d "COL_LIGHTGREEN"(Not used)",listitem);
					ShowPlayerDialog(playerid,DIALOG_NOTUSED,DIALOG_STYLE_LIST,caption,""COL_WHITE"Create object","Choose","Quit");
				}
			}
		}
		case DIALOG_NOTUSED:
		{
			new string[128];
			if(!response)
         	{
                usingslot[playerid] = 999;
                return 1;
			}
			else if(response)
			{
				format(string,sizeof(string),""COL_YELLOW"Furniture system:"COL_WHITE" You are in process of creating object in slot "COL_LIGHTGREEN"%d!",usingslot[playerid]);
				SendClientMessage(playerid,-1,string);
				SendClientMessage(playerid,-1,"Select from list what type of object you want to create.");
				ShowPlayerDialog(playerid,DIALOG_CHOOSETYPE,DIALOG_STYLE_LIST,""COL_YELLOW"Creating object..",""COL_WHITE"Tables\nChairs\nBeds\nSofas\nDecorations\nAppliances","Choose","Quit");
			}
		}
		case DIALOG_USED:
		{
			new string[128];
			if(!response)
			{
			    usingslot[playerid] = 999;
                return 1;
			}
			else if(response)
			{
				switch(listitem)
				{
				    case 0:
				    {
			    		DestroyDynamicObject(FurnitureInfo[playerid][Slot][usingslot[playerid]]);
                		ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][id] = 0;
               		 	ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][modelid] = 0;
                		ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][x] = 0.0;
                		ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][y] = 0.0;
                		ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][z] = 0.0;
               		    ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][rx] = 0.0;
                		ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][ry] = 0.0;
               			ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][rz] = 0.0;
               		    ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][worldid] = 0;
                		ObjectInfo[FurnitureInfo[playerid][Slot][usingslot[playerid]]][interiorid] = 0;
                		mysql_format(dbhandle,smallquery,"DELETE FROM `objects` WHERE `id` = '%d'",FurnitureInfo[playerid][Slot][usingslot[playerid]]);
						mysql_function_query(dbhandle,smallquery,false,"","");
						FurnitureInfo[playerid][Slot][usingslot[playerid]] = 0;
						format(string,sizeof(string),""COL_YELLOW"Furniture system:"COL_WHITE" You've deleted object from slot ID "COL_LIGHTGREEN"%d"COL_WHITE"!",usingslot[playerid]);
				        SendClientMessage(playerid,-1,string);
						usingslot[playerid] = 999;
				    }
					case 1:
					{
                        EditDynamicObject(playerid,FurnitureInfo[playerid][Slot][usingslot[playerid]]);
                        format(string,sizeof(string),""COL_YELLOW"Furniture system:"COL_WHITE" You are now editing object in slot ID "COL_LIGHTGREEN"%d"COL_WHITE"!",usingslot[playerid]);
                        SendClientMessage(playerid,-1,string);
                        editingobject[playerid] = FurnitureInfo[playerid][Slot][usingslot[playerid]];
						usingslot[playerid] = 999;
					}
				}
			}
		}
		case DIALOG_CHOOSETYPE:
		{
			if(!response)
			{
				usingslot[playerid] = 999;
				return 1;
			}
			else if(response)
			{
				new string[1024];
				switch(listitem)
				{
					case 0:
					{
       					for(new i; i < sizeof(Tables); i++)
          		        {
                        	format(string, sizeof(string), "%s%s\n", string,Tables[i][tablename]);
                            ShowPlayerDialog(playerid, DIALOG_TABLE, DIALOG_STYLE_LIST,""COL_YELLOW"Choose table model..",string, "Choose", "Cancel");
						}
					}
					case 1:
					{
       					for(new i; i < sizeof(Chairs); i++)
          		        {
                        	format(string, sizeof(string), "%s%s\n", string,Chairs[i][chairname]);
                            ShowPlayerDialog(playerid, DIALOG_CHAIR, DIALOG_STYLE_LIST,""COL_YELLOW"Choose chair model..",string, "Choose", "Cancel");
						}
					}
					case 2:
					{
       					for(new i; i < sizeof(Beds); i++)
          		        {
                        	format(string, sizeof(string), "%s%s\n", string,Beds[i][bedname]);
                            ShowPlayerDialog(playerid, DIALOG_BEDS, DIALOG_STYLE_LIST,""COL_YELLOW"Choose bed model..",string, "Choose", "Cancel");
						}
					}
					case 3:
					{
       					for(new i; i < sizeof(Sofas); i++)
          		        {
                        	format(string, sizeof(string), "%s%s\n", string,Sofas[i][sofaname]);
                            ShowPlayerDialog(playerid, DIALOG_SOFAS, DIALOG_STYLE_LIST,""COL_YELLOW"Choose sofa model..",string, "Choose", "Cancel");
						}
					}
					case 4:
					{
       					for(new i; i < sizeof(Decorations); i++)
          		        {
                        	format(string, sizeof(string), "%s%s\n", string,Decorations[i][decname]);
                            ShowPlayerDialog(playerid, DIALOG_DECORATIONS, DIALOG_STYLE_LIST,""COL_YELLOW"Choose decoration model..",string, "Choose", "Cancel");
						}
					}
					case 5:
					{
       					for(new i; i < sizeof(Appliances); i++)
          		        {
                        	format(string, sizeof(string), "%s%s\n", string,Appliances[i][appname]);
                            ShowPlayerDialog(playerid, DIALOG_APPLIANCES, DIALOG_STYLE_LIST,""COL_YELLOW"Choose appliance model..",string, "Choose", "Cancel");
						}
					}
				}
			}
		}
		case DIALOG_TABLE:
		{
			new string[128];
			new Float:fx,Float:fy,Float:fz;
			if(!response)
			{
				usingslot[playerid] = 999;
				return 1;
			}
			else if(response)
			{
				GetPlayerPos(playerid,fx,fy,fz);
                preview[playerid] = CreateDynamicObject(Tables[listitem][tid],fx,fy+2,fz,0,0,0,0,-1,-1,15);
				objectmodel[playerid] = Tables[listitem][tid];
				objectprice[playerid] = Tables[listitem][tableprice];
			    format(string,sizeof(string),""COL_WHITE"Are you sure that you want to buy "COL_YELLOW"%s"COL_WHITE" for"COL_YELLOW" $%d?",Tables[listitem][tablename],Tables[listitem][tableprice]);
				ShowPlayerDialog(playerid,DIALOG_BUY,DIALOG_STYLE_MSGBOX,""COL_YELLOW"Buying object...",string,"Yes","No");
			}
		}
		case DIALOG_CHAIR:
		{
			new string[128];
			new Float:fx,Float:fy,Float:fz;
			if(!response)
			{
				usingslot[playerid] = 999;
				return 1;
			}
			else if(response)
			{
				GetPlayerPos(playerid,fx,fy,fz);
			    preview[playerid] = CreateDynamicObject(Tables[listitem][tid],fx,fy+2,fz,0,0,0,0,-1,-1,15);
				objectmodel[playerid] = Chairs[listitem][cid];
				objectprice[playerid] = Chairs[listitem][chairprice];
			    format(string,sizeof(string),""COL_WHITE"Are you sure that you want to buy "COL_YELLOW"%s"COL_WHITE" for"COL_YELLOW" $%d?",Chairs[listitem][chairname],Chairs[listitem][chairprice]);
				ShowPlayerDialog(playerid,DIALOG_BUY,DIALOG_STYLE_MSGBOX,""COL_YELLOW"Buying object...",string,"Yes","No");
			}
		}
		case DIALOG_BEDS:
		{
			new string[128];
			new Float:fx,Float:fy,Float:fz;
			if(!response)
			{
				usingslot[playerid] = 999;
				return 1;
			}
			else if(response)
			{
				GetPlayerPos(playerid,fx,fy,fz);
                preview[playerid] = CreateDynamicObject(Beds[listitem][bid],fx,fy+2,fz,0,0,0,0,-1,-1,15);
				objectmodel[playerid] = Beds[listitem][bid];
				objectprice[playerid] = Beds[listitem][bedprice];
			    format(string,sizeof(string),""COL_WHITE"Are you sure that you want to buy "COL_YELLOW"%s"COL_WHITE" for"COL_YELLOW" $%d?",Beds[listitem][bedname],Beds[listitem][bedprice]);
				ShowPlayerDialog(playerid,DIALOG_BUY,DIALOG_STYLE_MSGBOX,""COL_YELLOW"Buying object...",string,"Yes","No");
			}
		}
		case DIALOG_SOFAS:
		{
			new string[128];
			new Float:fx,Float:fy,Float:fz;
			if(!response)
			{
				usingslot[playerid] = 999;
				return 1;
			}
			else if(response)
			{
				GetPlayerPos(playerid,fx,fy,fz);
                preview[playerid] = CreateDynamicObject(Sofas[listitem][sid],fx,fy+2,fz,0,0,0,0,-1,-1,15);
				objectmodel[playerid] = Sofas[listitem][sid];
				objectprice[playerid] = Sofas[listitem][sofaprice];
			    format(string,sizeof(string),""COL_WHITE"Are you sure that you want to buy "COL_YELLOW"%s"COL_WHITE" for"COL_YELLOW" $%d?",Sofas[listitem][sofaname],Sofas[listitem][sofaprice]);
				ShowPlayerDialog(playerid,DIALOG_BUY,DIALOG_STYLE_MSGBOX,""COL_YELLOW"Buying object...",string,"Yes","No");
			}
		}
	    case DIALOG_DECORATIONS:
		{
			new string[128];
			new Float:fx,Float:fy,Float:fz;
			if(!response)
			{
				usingslot[playerid] = 999;
				return 1;
			}
			else if(response)
			{
				GetPlayerPos(playerid,fx,fy,fz);
                preview[playerid] = CreateDynamicObject(Decorations[listitem][did],fx,fy+2,fz,0,0,0,0,-1,-1,15);
				objectmodel[playerid] = Decorations[listitem][did];
				objectprice[playerid] = Decorations[listitem][decprice];
			    format(string,sizeof(string),""COL_WHITE"Are you sure that you want to buy "COL_YELLOW"%s"COL_WHITE" for"COL_YELLOW" $%d?",Decorations[listitem][decname],Decorations[listitem][decprice]);
				ShowPlayerDialog(playerid,DIALOG_BUY,DIALOG_STYLE_MSGBOX,""COL_YELLOW"Buying object...",string,"Yes","No");
			}
		}
        case DIALOG_APPLIANCES:
		{
			new string[128];
			new Float:fx,Float:fy,Float:fz;
			if(!response)
			{
				usingslot[playerid] = 999;
				return 1;
			}
			else if(response)
			{
				GetPlayerPos(playerid,fx,fy,fz);
                preview[playerid] = CreateDynamicObject(Appliances[listitem][appid],fx,fy+2,fz,0,0,0,0,-1,-1,15);
				objectmodel[playerid] = Appliances[listitem][appid];
				objectprice[playerid] = Appliances[listitem][appprice];
			    format(string,sizeof(string),""COL_WHITE"Are you sure that you want to buy "COL_YELLOW"%s"COL_WHITE" for"COL_YELLOW" $%d?",Appliances[listitem][appname],Appliances[listitem][appprice]);
				ShowPlayerDialog(playerid,DIALOG_BUY,DIALOG_STYLE_MSGBOX,""COL_YELLOW"Buying object...",string,"Yes","No");
			}
		}
		case DIALOG_BUY:
		{
		    if(!response)
			{
				usingslot[playerid] = 999;
                DestroyDynamicObject(preview[playerid]);
				preview[playerid] = 0;
				objectmodel[playerid] = 0;
				objectprice[playerid] = 0;
				return 1;
			}
			else if(response)
			{
				if(GetPlayerMoney(playerid) < objectprice[playerid])
				{
					SendClientMessage(playerid,-1,""COL_RED"You don't have enough money to buy this item!");
					usingslot[playerid] = 999;
                	DestroyDynamicObject(preview[playerid]);
					preview[playerid] = 0;
					objectmodel[playerid] = 0;
					objectprice[playerid] = 0;
					return 1;
				}
				new Float:oX,Float:oY,Float:oZ;
				new Float:rX,Float:rY,Float:rZ;
				GetDynamicObjectRot(preview[playerid],rX,rY,rZ);
				new wid = GetPlayerVirtualWorld(playerid);
				new pint = GetPlayerInterior(playerid);
				GetDynamicObjectPos(preview[playerid],oX,oY,oZ);
				FurnitureInfo[playerid][Slot][usingslot[playerid]] = preview[playerid];
				ObjectInfo[preview[playerid]][id] = preview[playerid];
				ObjectInfo[preview[playerid]][modelid] = objectmodel[playerid];
				ObjectInfo[preview[playerid]][x] = oX;
				ObjectInfo[preview[playerid]][y] = oY;
				ObjectInfo[preview[playerid]][z] = oZ;
				ObjectInfo[preview[playerid]][rx] = rX;
				ObjectInfo[preview[playerid]][ry] = rY;
				ObjectInfo[preview[playerid]][rz] = rZ;
			    ObjectInfo[preview[playerid]][worldid] = wid;
			    ObjectInfo[preview[playerid]][interiorid] = pint;
			    mysql_format(dbhandle,bigquery,"INSERT INTO `objects` (`id`,`modelid`,`x`,`y`,`z`,`rx`,`ry`,`rz`,`worldid`,`interiorid`) VALUES ('%d','%d','%f','%f','%f','%f','%f','%f','%d','%d')",preview[playerid],objectmodel[playerid],oX,oY,oZ,rX,rY,rZ,wid,pint);
				mysql_function_query(dbhandle,bigquery,false,"","");
                DestroyDynamicObject(preview[playerid]);
          	    object[preview[playerid]] = CreateDynamicObject(ObjectInfo[preview[playerid]][modelid],ObjectInfo[preview[playerid]][x],ObjectInfo[preview[playerid]][y],ObjectInfo[preview[playerid]][z],ObjectInfo[preview[playerid]][rx],ObjectInfo[preview[playerid]][ry],ObjectInfo[preview[playerid]][rz],ObjectInfo[preview[playerid]][worldid],ObjectInfo[preview[playerid]][interiorid],-1,50.0);
				preview[playerid] = 0;
				objectmodel[playerid] = 0;
				objectprice[playerid] = 0;
				SendClientMessage(playerid,-1,""COL_YELLOW"Furniture System:"COL_WHITE" You have bought an object!");
			}
		}
	}
    return 0;
}
//----------------------------------------------------------------------------//
public f_LoadPlayer(playerid)
{
	new rows, fields,name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
	cache_get_data(rows,fields);
	if(!rows)
	{
		mysql_format(dbhandle,bigquery,"INSERT INTO `players` (`name`,`slot1`,`slot2`,`slot3`,`slot4`,`slot5`,`slot6`,`slot7`,`slot8`,`slot9`,`slot10`) VALUES ('%e',0,0,0,0,0,0,0,0,0,0)",name);
	    mysql_function_query(dbhandle,bigquery,false,"","");
	    printf("MySQL: Player %s added to furniture database!",name);
	}
	else if(rows)
	{
		new temp[24],countused;
		cache_get_row(0,0,temp); FurnitureInfo[playerid][id] = strval(temp);
		cache_get_row(0,1,temp); format(FurnitureInfo[playerid][Name],MAX_PLAYER_NAME,"%s",name);
		cache_get_row(0,2,temp); FurnitureInfo[playerid][Slot][0] = strval(temp);
		cache_get_row(0,3,temp); FurnitureInfo[playerid][Slot][1] = strval(temp);
		cache_get_row(0,4,temp); FurnitureInfo[playerid][Slot][2] = strval(temp);
		cache_get_row(0,5,temp); FurnitureInfo[playerid][Slot][3] = strval(temp);
		cache_get_row(0,6,temp); FurnitureInfo[playerid][Slot][4] = strval(temp);
		cache_get_row(0,7,temp); FurnitureInfo[playerid][Slot][5] = strval(temp);
		cache_get_row(0,8,temp); FurnitureInfo[playerid][Slot][6] = strval(temp);
		cache_get_row(0,9,temp); FurnitureInfo[playerid][Slot][7] = strval(temp);
		cache_get_row(0,10,temp); FurnitureInfo[playerid][Slot][8] = strval(temp);
		cache_get_row(0,11,temp); FurnitureInfo[playerid][Slot][9] = strval(temp);
		cache_get_row(0,12,temp); FurnitureInfo[playerid][Slot][10] = strval(temp);
		cache_get_row(0,13,temp); FurnitureInfo[playerid][Slot][11] = strval(temp);
		cache_get_row(0,14,temp); FurnitureInfo[playerid][Slot][12] = strval(temp);
		cache_get_row(0,15,temp); FurnitureInfo[playerid][Slot][13] = strval(temp);
		cache_get_row(0,16,temp); FurnitureInfo[playerid][Slot][14] = strval(temp);
		cache_get_row(0,17,temp); FurnitureInfo[playerid][Slot][15] = strval(temp);
		cache_get_row(0,18,temp); FurnitureInfo[playerid][Slot][16] = strval(temp);
		cache_get_row(0,19,temp); FurnitureInfo[playerid][Slot][17] = strval(temp);
		cache_get_row(0,20,temp); FurnitureInfo[playerid][Slot][18] = strval(temp);
		cache_get_row(0,21,temp); FurnitureInfo[playerid][Slot][19] = strval(temp);
		cache_get_row(0,22,temp); FurnitureInfo[playerid][Slot][20] = strval(temp);
		cache_get_row(0,23,temp); FurnitureInfo[playerid][Slot][21] = strval(temp);
		cache_get_row(0,24,temp); FurnitureInfo[playerid][Slot][22] = strval(temp);
		cache_get_row(0,25,temp); FurnitureInfo[playerid][Slot][23] = strval(temp);
		cache_get_row(0,26,temp); FurnitureInfo[playerid][Slot][24] = strval(temp);
		cache_get_row(0,27,temp); FurnitureInfo[playerid][Slot][25] = strval(temp);
		cache_get_row(0,28,temp); FurnitureInfo[playerid][Slot][26] = strval(temp);
		cache_get_row(0,29,temp); FurnitureInfo[playerid][Slot][27] = strval(temp);
		cache_get_row(0,30,temp); FurnitureInfo[playerid][Slot][28] = strval(temp);
		cache_get_row(0,31,temp); FurnitureInfo[playerid][Slot][29] = strval(temp);
		for(new i = 0; i < 10; i++)
		{
			if(FurnitureInfo[playerid][Slot][i] != 0) countused++;
		}
		printf("MySQL: Player %s loaded from furniture database. Objects used: %d!",name,countused);
	}
	return 1;
}
stock f_SavePlayer(playerid)
{
	mysql_format(dbhandle,bigquery,"UPDATE `players` SET `name` = '%e',`slot1` = '%d',`slot2` = '%d',`slot3` = '%d',`slot4` = '%d',`slot5` = '%d',`slot6` = '%d',`slot7` = '%d',`slot8` = '%d',`slot9` = '%d',`slot10` = '%d' WHERE `id` = '%d' LIMIT 1",
		FurnitureInfo[playerid][Name],
	    FurnitureInfo[playerid][Slot][0],
	    FurnitureInfo[playerid][Slot][1],
	    FurnitureInfo[playerid][Slot][2],
	    FurnitureInfo[playerid][Slot][3],
	    FurnitureInfo[playerid][Slot][4],
	    FurnitureInfo[playerid][Slot][5],
	    FurnitureInfo[playerid][Slot][6],
	    FurnitureInfo[playerid][Slot][7],
	    FurnitureInfo[playerid][Slot][8],
	    FurnitureInfo[playerid][Slot][9],
	    FurnitureInfo[playerid][id]);
	mysql_function_query(dbhandle,bigquery,false,"","");

    mysql_format(dbhandle,bigquery,"UPDATE `players` SET `slot11` = '%d',`slot12` = '%d',`slot13` = '%d',`slot14` = '%d',`slot15` = '%d',`slot16` = '%d',`slot17` = '%d',`slot18` = '%d',`slot19` = '%d',`slot20` = '%d' WHERE `id` = '%d' LIMIT 1",
	    FurnitureInfo[playerid][Slot][10],
	    FurnitureInfo[playerid][Slot][11],
	    FurnitureInfo[playerid][Slot][12],
	    FurnitureInfo[playerid][Slot][13],
	    FurnitureInfo[playerid][Slot][14],
	    FurnitureInfo[playerid][Slot][15],
	    FurnitureInfo[playerid][Slot][16],
	    FurnitureInfo[playerid][Slot][17],
	    FurnitureInfo[playerid][Slot][18],
	    FurnitureInfo[playerid][Slot][19],
	    FurnitureInfo[playerid][id]);
    mysql_format(dbhandle,bigquery,"UPDATE `players` SET `slot21` = '%d',`slot22` = '%d',`slot23` = '%d',`slot24` = '%d',`slot25` = '%d',`slot26` = '%d',`slot27` = '%d',`slot28` = '%d',`slot29` = '%d',`slot30` = '%d' WHERE `id` = '%d' LIMIT 1",
	    FurnitureInfo[playerid][Slot][20],
	    FurnitureInfo[playerid][Slot][21],
	    FurnitureInfo[playerid][Slot][22],
	    FurnitureInfo[playerid][Slot][23],
	    FurnitureInfo[playerid][Slot][24],
	    FurnitureInfo[playerid][Slot][25],
	    FurnitureInfo[playerid][Slot][26],
	    FurnitureInfo[playerid][Slot][27],
	    FurnitureInfo[playerid][Slot][28],
	    FurnitureInfo[playerid][Slot][29],
	    FurnitureInfo[playerid][id]);
	mysql_function_query(dbhandle,bigquery,false,"","");
	printf("MySQL: Player %s has been saved!",FurnitureInfo[playerid][Name]);
	return 1;
}
public f_ObjectsLoad()
{
	new rows,fields;
	cache_get_data(rows,fields);
	if(!rows) return print("Loading Objects: There are no objects in data base to load!");
	else if(rows)
	{
		new temp[24];
		for(new i = 0; i <= rows; i++)
		{
			cache_get_row(i,0,temp); ObjectInfo[i][id] = strval(temp);
			cache_get_row(i,1,temp); ObjectInfo[i][modelid] = strval(temp);
			cache_get_row(i,2,temp); ObjectInfo[i][x] = floatstr(temp);
			cache_get_row(i,3,temp); ObjectInfo[i][y] = floatstr(temp);
			cache_get_row(i,4,temp); ObjectInfo[i][z] = floatstr(temp);
			cache_get_row(i,5,temp); ObjectInfo[i][rx] = floatstr(temp);
			cache_get_row(i,6,temp); ObjectInfo[i][ry] = floatstr(temp);
			cache_get_row(i,7,temp); ObjectInfo[i][rz] = floatstr(temp);
			cache_get_row(i,8,temp); ObjectInfo[i][worldid] = strval(temp);
			cache_get_row(i,9,temp); ObjectInfo[i][interiorid] = strval(temp);
			object[i] = CreateDynamicObject(ObjectInfo[i][modelid],ObjectInfo[i][x],ObjectInfo[i][y],ObjectInfo[i][z],ObjectInfo[i][rx],ObjectInfo[i][ry],ObjectInfo[i][rz],ObjectInfo[i][worldid],ObjectInfo[i][interiorid],-1,50);
		}
		printf("Loading Objects: Loaded %d objects!",rows);
	}
	return 1;
}
stock f_ObjectSave(aid)
{
	mysql_format(dbhandle,bigquery,"UPDATE `objects` SET `x` = '%f',`y` = '%f',`z` = '%f',`rx` = '%f',`ry` = '%f',`rz` = '%f' WHERE `id` = '%d' LIMIT 1",
		ObjectInfo[aid][x],
		ObjectInfo[aid][y],
		ObjectInfo[aid][z],
		ObjectInfo[aid][rx],
		ObjectInfo[aid][ry],
		ObjectInfo[aid][rz],
		aid);
	mysql_function_query(dbhandle,bigquery,false,"","");
	return 1;
}

COMMAND:furniture(playerid, params[])
{
	new string[1250];
	new otext[128];
		for(new i = 0; i < 30; i++)
		{
			if(FurnitureInfo[playerid][Slot][i] != 0) format(otext,sizeof(otext),""COL_WHITE"Slot ID %d "COL_RED"(Used)",i);
			else format(otext,sizeof(otext),""COL_WHITE"Slot ID %d "COL_GREEN"(Not used)",i);
			format(string,sizeof(string),"%s%s\n",string,otext);
		    ShowPlayerDialog(playerid, DIALOG_OBJECTS, DIALOG_STYLE_LIST,""COL_YELLOW"Furniture System",string, "Choose", "Quit");
 	}
	return 1;
}

// End of script
Reply
#2

Alright I have managed to make it work. But whenever I spawn an object its glitched out. It spawns an extra radom object whenever I'm done editing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)