[HELP] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS
#1

Код:
SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team

[22:13:13] filterscripts = ""  (string)
[22:13:13] 
[22:13:13] Server Plugins
[22:13:13] --------------
[22:13:13]  Loading plugin: streamer
[22:13:13] 

*** Streamer Plugin v2.7.9 by Incognito loaded ***

[22:13:13]   Loaded.
[22:13:13]  Loading plugin: sscanf
[22:13:13] 

[22:13:13]  ===============================

[22:13:13]       sscanf plugin loaded.     

[22:13:13]          Version:  2.8.1        

[22:13:13]    © 2012 Alex "******" Cole  

[22:13:13]  ===============================

[22:13:13]   Loaded.
[22:13:13]  Loading plugin: mysql
[22:13:13]  >> plugin.mysql: R39-5 successfully loaded.
[22:13:13]   Loaded.
[22:13:13]  Loaded 3 plugins.

[22:13:13] 
[22:13:13] Ban list
[22:13:13] --------
[22:13:13]  Loaded: samp.ban
[22:13:13] 
[22:13:13] 
[22:13:13] Filterscripts
[22:13:13] ---------------
[22:13:13]   Loaded 0 filterscripts.

[22:13:13]  
[22:13:13]  
[22:13:13]  
[22:13:13]  ======================================= 
[22:13:13]  |                                     | 
[22:13:13]  |        YSI version 3.09.0684        | 
[22:13:13]  |        By Alex "******" Cole        | 
[22:13:13]  |                                     | 
[22:13:13]  ======================================= 
[22:13:13]  
[22:13:13]  
[22:13:13]  
[22:13:13] SUNUCU MAPLARI BASARIYLA YЬKLENDİ.
[22:13:13]   Filterscript 'AlaturkaMap.amx' loaded.
[22:13:13] ======================================================
[22:13:13] -- DİNAMİK EV SİSTEMİ BASARIYLA YЬKLENDİ.(141ms.)
[22:13:14] -- DİNAMİK İSYERİ SİSTEMİ BASARIYLA YЬKLENDİ.MİKTAR:(5/100)
[22:13:14] -- 29 ADET DİNAMİK İSYERİ İNTERRİOR'U EKLENDİ.
[22:13:14] -- DİNAMİK ARAC SİSTEMİ BASARIYLA YЬKLENDİ.
[22:13:14] -- DİNAMİK BANKA SİSTEMİ BASARIYLA YЬKLENDİ.
[22:13:14] -- DİNAMİK TELEPORT SİSTEMİ BASARIYLA YЬKLENDİ.TOPLAM[13]
[22:13:14]   [Gun Vending Machines] Initializing...
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
[22:13:14]   [Gun Vending Machines] Loading data...
[22:13:14]   [Gun Vending Machines] Loaded 6 gun vending machines.
[22:13:14] -- DİNAMİK BİRLİK-CETE SİSTEMİ BASARIYLA YЬKLENDİ.
[22:13:14] ==================================================================
[22:13:14] » Sunucu Adı: AlaturkaFR Turkiye[TR] - 2016 [V.1.2]
[22:13:14] » Oyun Modu: Alaturka-2016
[22:13:14] » Versiyon:  Version 1.2  
[22:13:14] » Harita: Turkiye
[22:13:14] » İnternet Sitesi:  www.gtaturk.com 
[22:13:14] » Geliştirici: Judy_Moody
[22:13:14] ==================================================================
[22:13:14] Number of vehicle models: 1
Код:
#define 	FILTERSCRIPT
#include 	<a_samp>
#include    <streamer>      // by Incognito - https://sampforum.blast.hk/showthread.ph...66#include    <sqlitei>       // by Slice - https://sampforum.blast.hk/showthread.ph...66#include    <izcmd>         // by Yashas - https://sampforum.blast.hk/showthread.ph...466#define     MAX_MACHINES	(30)

enum    E_MACHINE
{
	// saved
	Float: mPosX,
	Float: mPosY,
	Float: mPosZ,
	Float: mRotX,
	Float: mRotY,
	Float: mRotZ,
	// temp
	mObjID,
	mIconID,
	Text3D: mLabel,
	bool: mExists
}

enum    _:E_MACHINE_DIALOG
{
	DIALOG_WEAPONS_MENU = 9750,
	DIALOG_WEAPONS_BUY,
	DIALOG_WEAPONS_BUY_FINAL,
	// admin dialogs
	DIALOG_CREATE_CATEGORY,
	DIALOG_REMOVE_CATEGORY,
	DIALOG_RENAME_CATEGORY,
	DIALOG_RENAME_CATEGORY_FINAL,
	DIALOG_ADD_WEAPON_1,
	DIALOG_ADD_WEAPON_2,
	DIALOG_ADD_WEAPON_3,
	DIALOG_ADD_WEAPON_FINAL,
	DIALOG_REMOVE_WEAPON_1,
	DIALOG_REMOVE_WEAPON_FINAL
}

new
	MachineData[MAX_MACHINES][E_MACHINE];

new
	DB: MachineDatabase;

new
	DBStatement: LoadMachines,
	DBStatement: AddMachine,
	DBStatement: UpdateMachine,
	DBStatement: RemoveMachine;
	
new
	DBStatement: ListCategories,
	DBStatement: AddCategory,
	DBStatement: ReturnCategoryID,
	DBStatement: ReturnCategoryName,
	DBStatement: RenameCategory,
	DBStatement: RemoveCategory;

new
	DBStatement: ListWeapons,
	DBStatement: LoadWeapon,
	DBStatement: AddWeapon,
	DBStatement: RemoveWeapon,
	DBStatement: RemoveCategoryWeapons;
	
new
	CurCategoryID[MAX_PLAYERS] = {-1, ...},
	CurItemIndex[MAX_PLAYERS] = {-1, ...},
    EditingMachineID[MAX_PLAYERS] = {-1, ...};

formatInt(intVariable, iThousandSeparator = ',', iCurrencyChar = '$')
{
    /*
		By Kar
		https://gist.github.com/Kar2k/bfb0eafb2c...5.98258466	*/
	static
		s_szReturn[ 32 ],
		s_szThousandSeparator[ 2 ] = { ' ', EOS },
		s_szCurrencyChar[ 2 ] = { ' ', EOS },
		s_iVariableLen,
		s_iChar,
		s_iSepPos,
		bool:s_isNegative
	;

	format( s_szReturn, sizeof( s_szReturn ), "%d", intVariable );

	if(s_szReturn[0] == '-')
		s_isNegative = true;
	else
		s_isNegative = false;

	s_iVariableLen = strlen( s_szReturn );

	if ( s_iVariableLen >= 4 && iThousandSeparator)
	{
		s_szThousandSeparator[ 0 ] = iThousandSeparator;

		s_iChar = s_iVariableLen;
		s_iSepPos = 0;

		while ( --s_iChar > _:s_isNegative )
		{
			if ( ++s_iSepPos == 3 )
			{
				strins( s_szReturn, s_szThousandSeparator, s_iChar );

				s_iSepPos = 0;
			}
		}
	}
	if(iCurrencyChar) {
		s_szCurrencyChar[ 0 ] = iCurrencyChar;
		strins( s_szReturn, s_szCurrencyChar, _:s_isNegative );
	}
	return s_szReturn;
}

IsPlayerNearAGVM(playerid)
{
	for(new i; i < MAX_MACHINES; i++)
	{
	    if(!MachineData[i][mExists]) continue;
	    if(IsPlayerInRangeOfPoint(playerid, 3.0, MachineData[i][mPosX], MachineData[i][mPosY], MachineData[i][mPosZ])) return 1;
	}
	
	return 0;
}

ShowCategories(playerid, mode = 0)
{
	new name[24];
	stmt_bind_result_field(ListCategories, 0, DB::TYPE_STRING, name, sizeof(name));

	if(stmt_execute(ListCategories))
	{
	    new string[512], dialogid, action_string[16], cancel_string[16];
	    switch(mode)
	    {
	        case 1:
	        {
	            dialogid = DIALOG_REMOVE_CATEGORY;
				format(action_string, sizeof(action_string), "Remove");
				format(cancel_string, sizeof(cancel_string), "Close");
	        }
	        
	        case 2:
	        {
	            dialogid = DIALOG_RENAME_CATEGORY;
				format(action_string, sizeof(action_string), "Rename");
				format(cancel_string, sizeof(cancel_string), "Close");
	        }
	        
	        case 3:
	        {
	            dialogid = DIALOG_ADD_WEAPON_FINAL;
				format(action_string, sizeof(action_string), "Add Weapon");
				format(cancel_string, sizeof(cancel_string), "Back");
	        }
	        
	        case 4:
	        {
	            dialogid = DIALOG_REMOVE_WEAPON_1;
				format(action_string, sizeof(action_string), "Choose");
				format(cancel_string, sizeof(cancel_string), "Close");
	        }
	        
	        default:
	        {
				dialogid = DIALOG_WEAPONS_MENU;
				format(action_string, sizeof(action_string), "Choose");
				format(cancel_string, sizeof(cancel_string), "Close");
	        }
	    }
	    
	    while(stmt_fetch_row(ListCategories)) format(string, sizeof(string), "%s%s\n", string, name);
	    ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "{F1C40F}GVM: {FFFFFF}Choose a Category", string, action_string, cancel_string);
	}
	
	return 1;
}

ShowWeapons(playerid, removing = 0)
{
    new id, ammo, price;
	stmt_bind_value(ListWeapons, 0, DB::TYPE_INTEGER, CurCategoryID[playerid]);
	stmt_bind_result_field(ListWeapons, 0, DB::TYPE_INTEGER, id);
	stmt_bind_result_field(ListWeapons, 1, DB::TYPE_INTEGER, ammo);
	stmt_bind_result_field(ListWeapons, 2, DB::TYPE_INTEGER, price);

	if(stmt_execute(ListWeapons) && stmt_rows_left(ListWeapons) > 0) {
	    new string[256], w_name[24];
		format(string, sizeof(string), "Weapon\tAmmo\tPrice\n");

    	while(stmt_fetch_row(ListWeapons))
		{
		    GetWeaponName(id, w_name, 24);
		    format(string, sizeof(string), "%s%s\t%s\t{2ECC71}%s\n", string, w_name, formatInt(ammo, .iCurrencyChar = '\0'), formatInt(price));
		}

		new title[64];
		format(title, sizeof(title), "{F1C40F}GVM: {FFFFFF}%s", Machine_GetCategoryName(CurCategoryID[playerid]));
		ShowPlayerDialog(playerid, (removing) ? DIALOG_REMOVE_WEAPON_FINAL : DIALOG_WEAPONS_BUY, DIALOG_STYLE_TABLIST_HEADERS, title, string, (removing) ? ("Remove") : ("Buy"), "Back");
	}else{
	    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}No weapons on this category.");
	    ShowCategories(playerid, (removing) ? 4 : 0);
	}
	
	return 1;
}

ShowWeaponList(playerid)
{
	new string[666], w_name[24];
    for(new i = 1; i <= 46; i++)
	{
		GetWeaponName(i, w_name, sizeof(w_name));
		format(string, sizeof(string), "%s%d - %s\n", string, i, w_name);
	}

	ShowPlayerDialog(playerid, DIALOG_ADD_WEAPON_1, DIALOG_STYLE_LIST, "{F1C40F}GVM: {FFFFFF}Add Weapon", string, "Next", "Cancel");
	return 1;
}

Machine_FindFreeID()
{
	for(new i; i < MAX_MACHINES; i++) if(!MachineData[i][mExists]) return i;
	return -1;
}

Machine_GetCategoryID(name[])
{
	new id = -1;
    stmt_bind_value(ReturnCategoryID, 0, DB::TYPE_STRING, name, 24);
    stmt_bind_result_field(ReturnCategoryID, 0, DB::TYPE_INTEGER, id);
    
	if(stmt_execute(ReturnCategoryID) && stmt_rows_left(ReturnCategoryID) > 0) stmt_fetch_row(ReturnCategoryID);
	return id;
}

Machine_GetCategoryName(id)
{
	new name[24];
    stmt_bind_value(ReturnCategoryName, 0, DB::TYPE_INTEGER, id);
    stmt_bind_result_field(ReturnCategoryName, 0, DB::TYPE_STRING, name, 24);

	if(stmt_execute(ReturnCategoryName) && stmt_rows_left(ReturnCategoryName) > 0) stmt_fetch_row(ReturnCategoryName);
	return name;
}

Machine_GetWeaponData(catid, index, &weapon, &ammo, &price)
{
    stmt_bind_value(LoadWeapon, 0, DB::TYPE_INTEGER, catid);
    stmt_bind_value(LoadWeapon, 1, DB::TYPE_INTEGER, index);
    stmt_bind_result_field(LoadWeapon, 0, DB::TYPE_INTEGER, weapon);
    stmt_bind_result_field(LoadWeapon, 1, DB::TYPE_INTEGER, ammo);
    stmt_bind_result_field(LoadWeapon, 2, DB::TYPE_INTEGER, price);
    
	if(stmt_execute(LoadWeapon) && stmt_rows_left(LoadWeapon) > 0)
	{
		stmt_fetch_row(LoadWeapon);
		return 1;
	}
	
	return 0;
}

public OnFilterScriptInit()
{
    print("  [Gun Vending Machines] Initializing...");
    
	for(new i; i < MAX_MACHINES; i++)
	{
	    MachineData[i][mObjID] = -1;
	    MachineData[i][mIconID] = -1;
	    MachineData[i][mLabel] = Text3D: -1;
	    MachineData[i][mExists] = false;
	}
	
	MachineDatabase = db_open("gun_vending.db");
	db_query(MachineDatabase, "CREATE TABLE IF NOT EXISTS machines (ID INTEGER, PosX FLOAT, PosY FLOAT, PosZ FLOAT, RotX FLOAT, RotY FLOAT, RotZ FLOAT)");
	db_query(MachineDatabase, "CREATE TABLE IF NOT EXISTS categories (ID INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT UNIQUE)");
	db_query(MachineDatabase, "CREATE TABLE IF NOT EXISTS weapons (WeaponID INTEGER, Ammo INTEGER, Price INTEGER, Category INTEGER)");
	
	// Machine Queries
	LoadMachines = db_prepare(MachineDatabase, "SELECT * FROM machines");
	AddMachine = db_prepare(MachineDatabase, "INSERT INTO machines (ID, PosX, PosY, PosZ, RotX, RotY, RotZ) VALUES (?, ?, ?, ?, ?, ?, ?)");
    UpdateMachine = db_prepare(MachineDatabase, "UPDATE machines SET PosX=?, PosY=?, PosZ=?, RotX=?, RotY=?, RotZ=? WHERE ID=?");
	RemoveMachine = db_prepare(MachineDatabase, "DELETE FROM machines WHERE ID=?");
	
	// Category Queries
	ListCategories = db_prepare(MachineDatabase, "SELECT Name FROM categories");
	AddCategory = db_prepare(MachineDatabase, "INSERT INTO categories (Name) VALUES (?)");
	ReturnCategoryID = db_prepare(MachineDatabase, "SELECT ID FROM categories WHERE Name=?");
	ReturnCategoryName = db_prepare(MachineDatabase, "SELECT Name FROM categories WHERE ID=?");
	RenameCategory = db_prepare(MachineDatabase, "UPDATE categories SET Name=? WHERE ID=?");
	RemoveCategory = db_prepare(MachineDatabase, "DELETE FROM categories WHERE ID=?");
	
	// Weapon Queries
	ListWeapons = db_prepare(MachineDatabase, "SELECT WeaponID, Ammo, Price FROM weapons WHERE Category=? ORDER BY WeaponID ASC");
	LoadWeapon = db_prepare(MachineDatabase, "SELECT WeaponID, Ammo, Price FROM weapons WHERE Category=? ORDER BY WeaponID ASC LIMIT ?, 1");
	AddWeapon = db_prepare(MachineDatabase, "INSERT INTO weapons (WeaponID, Ammo, Price, Category) VALUES (?, ?, ?, ?)");
	RemoveWeapon = db_prepare(MachineDatabase, "DELETE FROM weapons WHERE WeaponID=? AND Ammo=? AND Price=? AND Category=?");
	RemoveCategoryWeapons = db_prepare(MachineDatabase, "DELETE FROM weapons WHERE Category=?");
	
	// Load Machines
	new id, Float: pos[3], Float: rot[3];
	stmt_bind_result_field(LoadMachines, 0, DB::TYPE_INTEGER, id);
	stmt_bind_result_field(LoadMachines, 1, DB::TYPE_FLOAT, pos[0]);
	stmt_bind_result_field(LoadMachines, 2, DB::TYPE_FLOAT, pos[1]);
	stmt_bind_result_field(LoadMachines, 3, DB::TYPE_FLOAT, pos[2]);
	stmt_bind_result_field(LoadMachines, 4, DB::TYPE_FLOAT, rot[0]);
	stmt_bind_result_field(LoadMachines, 5, DB::TYPE_FLOAT, rot[1]);
	stmt_bind_result_field(LoadMachines, 6, DB::TYPE_FLOAT, rot[2]);

	if(stmt_execute(LoadMachines))
	{
	    print("  [Gun Vending Machines] Loading data...");
	
	    new label[64], loaded;
	    while(stmt_fetch_row(LoadMachines))
	    {
            MachineData[id][mPosX] = pos[0];
		 	MachineData[id][mPosY] = pos[1];
		  	MachineData[id][mPosZ] = pos[2];
	        MachineData[id][mRotX] = rot[0];
		 	MachineData[id][mRotY] = rot[1];
		  	MachineData[id][mRotZ] = rot[2];

		    MachineData[id][mObjID] = CreateDynamicObject(18885, MachineData[id][mPosX], MachineData[id][mPosY], MachineData[id][mPosZ], MachineData[id][mRotX], MachineData[id][mRotY], MachineData[id][mRotZ]);
			MachineData[id][mIconID] = CreateDynamicMapIcon(MachineData[id][mPosX], MachineData[id][mPosY], MachineData[id][mPosZ], 18, 0);
			
			format(label, sizeof(label), "Gun Vending Machine (%d)\n\n{FFFFFF}/weapons", id);
			MachineData[id][mLabel] = CreateDynamic3DTextLabel(label, 0xF1C40FFF, MachineData[id][mPosX] - (0.65 * floatsin(-MachineData[id][mRotZ], degrees)), MachineData[id][mPosY] - (0.65 * floatcos(-MachineData[id][mRotZ], degrees)), MachineData[id][mPosZ] - 0.15, 10.0, .testlos = 1);
			MachineData[id][mExists] = true;
			loaded++;
		}
		
		printf("  [Gun Vending Machines] Loaded %d gun vending machines.", loaded);
	}
	
	return 1;
}

public OnFilterScriptExit()
{
	db_close(MachineDatabase);
	
	print("  [Gun Vending Machines] Unloaded.");
	return 1;
}

public OnPlayerConnect(playerid)
{
	CurCategoryID[playerid] = CurItemIndex[playerid] = EditingMachineID[playerid] = -1;
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
	    /* ---------------------------------------------------------------------- */
		case DIALOG_WEAPONS_MENU:
		{
		    if(!response) return 1;
			CurCategoryID[playerid] = Machine_GetCategoryID(inputtext);
			if(CurCategoryID[playerid] == -1)
			{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You've chosen an invalid category.");
			    ShowCategories(playerid);
			    return 1;
			}
			
			ShowWeapons(playerid);
		    return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_WEAPONS_BUY:
		{
			if(!response) return ShowCategories(playerid);
			CurItemIndex[playerid] = listitem;
			
			new weapon, ammo, price;
			if(Machine_GetWeaponData(CurCategoryID[playerid], CurItemIndex[playerid], weapon, ammo, price)) {
				if(price > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't afford this weapon.");
				new string[256];
				GetWeaponName(weapon, string, sizeof(string));
				format(string, sizeof(string), "{FFFFFF}You're about to buy a {F1C40F}%s {FFFFFF}with {F1C40F}%s {FFFFFF}ammo.\n\nPrice: {2ECC71}%s\n\n{FFFFFF}How many times would you like to buy this item?", string, formatInt(ammo, .iCurrencyChar = '\0'), formatInt(price));
				ShowPlayerDialog(playerid, DIALOG_WEAPONS_BUY_FINAL, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Purchase Confirmation", string, "Buy", "Back");
			}else{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You've chosen an invalid weapon.");
			    ShowWeapons(playerid);
			}
			
			return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_WEAPONS_BUY_FINAL:
		{
			if(!response) return ShowWeapons(playerid);
			new times = strval(inputtext);
			if(!(0 < times <= 100)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't purchase less than 1 or more than 100 weapons at once.");

			new weapon, ammo, price;
			if(Machine_GetWeaponData(CurCategoryID[playerid], CurItemIndex[playerid], weapon, ammo, price)) {
			    price = (price * times);
			    ammo = (ammo * times);
			    if(price > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't afford this purchase.");
			    GivePlayerMoney(playerid, -price);
				GivePlayerWeapon(playerid, weapon, ammo);
				
				new string[144];
				GetWeaponName(weapon, string, sizeof(string));
				SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}Purchase complete!");
				
				format(string, sizeof(string), "GUN VENDING MACHINE: {2ECC71}%s {FFFFFF}paid for {F1C40F}%s {FFFFFF}with {F1C40F}%s {FFFFFF}ammo.", formatInt(price), string, formatInt(ammo, .iCurrencyChar = '\0'));
                SendClientMessage(playerid, 0x3498DBFF, string);
			}else{
			    SendClientMessage(playerid, 0x3498DBFF, "ERROR: {FFFFFF}You've chosen an invalid weapon.");
			    ShowWeapons(playerid);
			}
			
			return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_CREATE_CATEGORY:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return 1;
		    if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_CREATE_CATEGORY, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Create Category", "{E74C3C}Category name can't be empty.\n\n{FFFFFF}Choose a category name:", "Create", "Cancel");
		    if(strlen(inputtext) > 24) return ShowPlayerDialog(playerid, DIALOG_CREATE_CATEGORY, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Create Category", "{E74C3C}Category name can't be more than 24 characters.\n\n{FFFFFF}Choose a category name:", "Create", "Cancel");
            
			stmt_bind_value(AddCategory, 0, DB::TYPE_STRING, inputtext, 24);
			if(stmt_execute(AddCategory)) {
			    SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}Category created.");

				new string[64];
				format(string, sizeof(string), "GUN VENDING MACHINE: {FFFFFF}Category ID: %d", db_last_insert_rowid(MachineDatabase));
				SendClientMessage(playerid, 0x3498DBFF, string);
			}else{
		 		SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Category creation failed.");
			}

			return 1;
		}
        /* ---------------------------------------------------------------------- */
		case DIALOG_REMOVE_CATEGORY:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return 1;
			new catid = Machine_GetCategoryID(inputtext);
			if(catid == -1)
			{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You've chosen an invalid category.");
			    ShowCategories(playerid, 1);
			    return 1;
			}

			stmt_bind_value(RemoveCategory, 0, DB::TYPE_INTEGER, catid);
			if(stmt_execute(RemoveCategory) && db_changes(MachineDatabase) > 0) {
			    SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}Category removed.");
			    
			    stmt_bind_value(RemoveCategoryWeapons, 0, DB::TYPE_INTEGER, catid);
			    if(stmt_execute(RemoveCategoryWeapons) && db_changes(MachineDatabase) > 0)
				{
			        new string[72];
			        format(string, sizeof(string), "GUN VENDING MACHINE: {FFFFFF}Removed %d weapons in the category.", db_changes(MachineDatabase));
			        SendClientMessage(playerid, 0x3498DBFF, string);
			    }
			}else{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Category removing failed.");
			}
			
		    return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_RENAME_CATEGORY:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return 1;
			CurCategoryID[playerid] = Machine_GetCategoryID(inputtext);
			if(CurCategoryID[playerid] == -1)
			{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You've chosen an invalid category.");
			    ShowCategories(playerid, 2);
			    return 1;
			}

			ShowPlayerDialog(playerid, DIALOG_RENAME_CATEGORY_FINAL, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Rename Category", "New category name:", "Change", "Back");
		    return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_RENAME_CATEGORY_FINAL:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return ShowCategories(playerid, 2);
		    if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_RENAME_CATEGORY_FINAL, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Rename Category", "{E74C3C}Category name can't be empty.\n\n{FFFFFF}New category name:", "Change", "Back");
		    if(strlen(inputtext) > 24) return ShowPlayerDialog(playerid, DIALOG_RENAME_CATEGORY_FINAL, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Rename Category", "{E74C3C}Category name can't be more than 24 characters.\n\n{FFFFFF}New category name:", "Change", "Back");
            stmt_bind_value(RenameCategory, 0, DB::TYPE_STRING, inputtext, 24);
			stmt_bind_value(RenameCategory, 1, DB::TYPE_INTEGER, CurCategoryID[playerid]);
			if(stmt_execute(RenameCategory) && db_changes(MachineDatabase) > 0) {
			    SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}Category renamed.");
			}else{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Category renaming failed.");
			}

			return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_ADD_WEAPON_1:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return 1;
		    new weaponid = listitem+1;
		    if(weaponid >= 19 && weaponid < 22)
		    {
                SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Invalid weapon.");
                ShowWeaponList(playerid);
		        return 1;
		    }
		    
		    SetPVarInt(playerid, "addingWeaponID", weaponid);
		    ShowPlayerDialog(playerid, DIALOG_ADD_WEAPON_2, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Add Weapon", "Weapon ammo:", "Next", "Back");
		    return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_ADD_WEAPON_2:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return ShowWeaponList(playerid);
		    if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_ADD_WEAPON_2, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Add Weapon", "{E74C3C}Ammo can't be empty.\n\n{FFFFFF}Weapon ammo:", "Next", "Back");
		    SetPVarInt(playerid, "addingWeaponAmmo", strval(inputtext));
		    ShowPlayerDialog(playerid, DIALOG_ADD_WEAPON_3, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Add Weapon", "Weapon price:", "Next", "Back");
		    return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_ADD_WEAPON_3:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return ShowPlayerDialog(playerid, DIALOG_ADD_WEAPON_2, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Add Weapon", "Weapon ammo:", "Next", "Back");
		    if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_ADD_WEAPON_3, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Add Weapon", "{E74C3C}Price can't be empty.\n\n{FFFFFF}Weapon price:", "Next", "Back");
		    SetPVarInt(playerid, "addingWeaponPrice", strval(inputtext));
      		ShowCategories(playerid, 3);
		    return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_ADD_WEAPON_FINAL:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return ShowPlayerDialog(playerid, DIALOG_ADD_WEAPON_3, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Add Weapon", "Weapon price:", "Next", "Back");
			new catid = Machine_GetCategoryID(inputtext);
			if(catid == -1)
			{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You've chosen an invalid category.");
			    ShowCategories(playerid, 3);
			    return 1;
			}

			stmt_bind_value(AddWeapon, 0, DB::TYPE_INTEGER, GetPVarInt(playerid, "addingWeaponID"));
			stmt_bind_value(AddWeapon, 1, DB::TYPE_INTEGER, GetPVarInt(playerid, "addingWeaponAmmo"));
			stmt_bind_value(AddWeapon, 2, DB::TYPE_INTEGER, GetPVarInt(playerid, "addingWeaponPrice"));
			stmt_bind_value(AddWeapon, 3, DB::TYPE_INTEGER, catid);
			if(stmt_execute(AddWeapon)) SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}Weapon added.");
		    return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_REMOVE_WEAPON_1:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
		    if(!response) return 1;
			CurCategoryID[playerid] = Machine_GetCategoryID(inputtext);
			if(CurCategoryID[playerid] == -1)
			{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You've chosen an invalid category.");
			    ShowCategories(playerid, 4);
			    return 1;
			}

			ShowWeapons(playerid, 1);
		    return 1;
		}
		/* ---------------------------------------------------------------------- */
		case DIALOG_REMOVE_WEAPON_FINAL:
		{
		    if(!IsPlayerAdmin(playerid)) return 1;
			if(!response) return ShowCategories(playerid, 4);
			new weapon, price, ammo;
			if(Machine_GetWeaponData(CurCategoryID[playerid], listitem, weapon, ammo, price)) {
				stmt_bind_value(RemoveWeapon, 0, DB::TYPE_INTEGER, weapon);
				stmt_bind_value(RemoveWeapon, 1, DB::TYPE_INTEGER, ammo);
				stmt_bind_value(RemoveWeapon, 2, DB::TYPE_INTEGER, price);
				stmt_bind_value(RemoveWeapon, 3, DB::TYPE_INTEGER, CurCategoryID[playerid]);
				if(stmt_execute(RemoveWeapon)) SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}Weapon removed.");
			}else{
			    SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You've chosen an invalid weapon.");
			    ShowWeapons(playerid, 1);
			}

			return 1;
		}
		/* ---------------------------------------------------------------------- */
	}
	
	return 0;
}

public OnPlayerEditDynamicObject(playerid, STREAMER_TAG_OBJECT objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
	if(EditingMachineID[playerid] != -1 && MachineData[ EditingMachineID[playerid] ][mExists])
	{
	    if(response == EDIT_RESPONSE_FINAL)
	    {
	        new id = EditingMachineID[playerid];
	        MachineData[id][mPosX] = x;
	        MachineData[id][mPosY] = y;
	        MachineData[id][mPosZ] = z;
	        MachineData[id][mRotX] = rx;
	        MachineData[id][mRotY] = ry;
	        MachineData[id][mRotZ] = rz;

	        SetDynamicObjectPos(objectid, MachineData[id][mPosX], MachineData[id][mPosY], MachineData[id][mPosZ]);
	        SetDynamicObjectRot(objectid, MachineData[id][mRotX], MachineData[id][mRotY], MachineData[id][mRotZ]);

			Streamer_SetFloatData(STREAMER_TYPE_MAP_ICON, MachineData[id][mIconID], E_STREAMER_X, MachineData[id][mPosX]);
			Streamer_SetFloatData(STREAMER_TYPE_MAP_ICON, MachineData[id][mIconID], E_STREAMER_Y, MachineData[id][mPosY]);
			Streamer_SetFloatData(STREAMER_TYPE_MAP_ICON, MachineData[id][mIconID], E_STREAMER_Z, MachineData[id][mPosZ]);

			Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, MachineData[id][mLabel], E_STREAMER_X, MachineData[id][mPosX] - (0.65 * floatsin(-MachineData[id][mRotZ], degrees)));
			Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, MachineData[id][mLabel], E_STREAMER_Y, MachineData[id][mPosY] - (0.65 * floatcos(-MachineData[id][mRotZ], degrees)));
			Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, MachineData[id][mLabel], E_STREAMER_Z, MachineData[id][mPosZ] - 0.15);

		    stmt_bind_value(UpdateMachine, 0, DB::TYPE_FLOAT, MachineData[id][mPosX]);
		    stmt_bind_value(UpdateMachine, 1, DB::TYPE_FLOAT, MachineData[id][mPosY]);
		    stmt_bind_value(UpdateMachine, 2, DB::TYPE_FLOAT, MachineData[id][mPosZ]);
		    stmt_bind_value(UpdateMachine, 3, DB::TYPE_FLOAT, MachineData[id][mRotX]);
		    stmt_bind_value(UpdateMachine, 4, DB::TYPE_FLOAT, MachineData[id][mRotY]);
		    stmt_bind_value(UpdateMachine, 5, DB::TYPE_FLOAT, MachineData[id][mRotZ]);
		    stmt_bind_value(UpdateMachine, 6, DB::TYPE_INTEGER, id);
			stmt_execute(UpdateMachine);
			
	        EditingMachineID[playerid] = -1;
	    }

	    if(response == EDIT_RESPONSE_CANCEL)
	    {
	        new id = EditingMachineID[playerid];
	        SetDynamicObjectPos(objectid, MachineData[id][mPosX], MachineData[id][mPosY], MachineData[id][mPosZ]);
	        SetDynamicObjectRot(objectid, MachineData[id][mRotX], MachineData[id][mRotY], MachineData[id][mRotZ]);
	        EditingMachineID[playerid] = -1;
	    }
	}

	return 1;
}

// Player Commands
CMD:weapons(playerid, params[])
{
	if(!IsPlayerNearAGVM(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not near a Gun Vending Machine.");
	ShowCategories(playerid);
	return 1;
}

// Admin Commands
CMD:createmachine(playerid, params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
    new id = Machine_FindFreeID();
	if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Can't create any more machines.");
	
	MachineData[id][mRotX] = MachineData[id][mRotY] = 0.0;
	GetPlayerPos(playerid, MachineData[id][mPosX], MachineData[id][mPosY], MachineData[id][mPosZ]);
	GetPlayerFacingAngle(playerid, MachineData[id][mRotZ]);

	MachineData[id][mPosX] += (2.0 * floatsin(-MachineData[id][mRotZ], degrees));
    MachineData[id][mPosY] += (2.0 * floatcos(-MachineData[id][mRotZ], degrees));
    MachineData[id][mPosZ] += 0.1;

    stmt_bind_value(AddMachine, 0, DB::TYPE_INTEGER, id);
    stmt_bind_value(AddMachine, 1, DB::TYPE_FLOAT, MachineData[id][mPosX]);
    stmt_bind_value(AddMachine, 2, DB::TYPE_FLOAT, MachineData[id][mPosY]);
    stmt_bind_value(AddMachine, 3, DB::TYPE_FLOAT, MachineData[id][mPosZ]);
    stmt_bind_value(AddMachine, 4, DB::TYPE_FLOAT, MachineData[id][mRotX]);
    stmt_bind_value(AddMachine, 5, DB::TYPE_FLOAT, MachineData[id][mRotY]);
    stmt_bind_value(AddMachine, 6, DB::TYPE_FLOAT, MachineData[id][mRotZ]);
    
	MachineData[id][mObjID] = CreateDynamicObject(18885, MachineData[id][mPosX], MachineData[id][mPosY], MachineData[id][mPosZ], MachineData[id][mRotX], MachineData[id][mRotY], MachineData[id][mRotZ]);
    if(stmt_execute(AddMachine) && IsValidDynamicObject(MachineData[id][mObjID]))
    {
        EditingMachineID[playerid] = id;
        EditDynamicObject(playerid, MachineData[id][mObjID]);

		MachineData[id][mIconID] = CreateDynamicMapIcon(MachineData[id][mPosX], MachineData[id][mPosY], MachineData[id][mPosZ], 18, 0);

		new label[64];
		format(label, sizeof(label), "Gun Vending Machine (%d)\n\n{FFFFFF}/weapons", id);
		MachineData[id][mLabel] = CreateDynamic3DTextLabel(label, 0xF1C40FFF, MachineData[id][mPosX] - (0.65 * floatsin(-MachineData[id][mRotZ], degrees)), MachineData[id][mPosY] - (0.65 * floatcos(-MachineData[id][mRotZ], degrees)), MachineData[id][mPosZ] - 0.15, 10.0, .testlos = 1);
		MachineData[id][mExists] = true;
		
		SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}Machine created.");
		SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}You can edit it right now, or cancel editing and edit it some other time.");
	}
	
	return 1;
}

CMD:editmachine(playerid, params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
	if(isnull(params)) return SendClientMessage(playerid, 0xE88732FF, "SYNTAX: {FFFFFF}/editmachine [machine id]");
	new id = strval(params);
	if(!(0 <= id < MAX_MACHINES)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Invalid ID.");
    if(!MachineData[id][mExists]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Machine doesn't exist.");
	if(!IsPlayerInRangeOfPoint(playerid, 30.0, MachineData[id][mPosX], MachineData[id][mPosY], MachineData[id][mPosZ])) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not near the machine you want to edit.");
	if(EditingMachineID[playerid] != -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're already editing a machine.");

	EditingMachineID[playerid] = id;
    EditDynamicObject(playerid, MachineData[id][mObjID]);
	return 1;
}

CMD:removemachine(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
	if(isnull(params)) return SendClientMessage(playerid, 0xE88732FF, "SYNTAX: {FFFFFF}/removemachine [machine id]");
	new id = strval(params);
	if(!(0 <= id < MAX_MACHINES)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Invalid ID.");
	if(!MachineData[id][mExists]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Machine doesn't exist.");
	
	stmt_bind_value(RemoveMachine, 0, DB::TYPE_INTEGER, id);
	if(stmt_execute(RemoveMachine)) {
		if(IsValidDynamicObject(MachineData[id][mObjID])) DestroyDynamicObject(MachineData[id][mObjID]);
		if(IsValidDynamicMapIcon(MachineData[id][mIconID])) DestroyDynamicMapIcon(MachineData[id][mIconID]);
	    if(IsValidDynamic3DTextLabel(MachineData[id][mLabel])) DestroyDynamic3DTextLabel(MachineData[id][mLabel]);
	    MachineData[id][mObjID] = -1;
	    MachineData[id][mIconID] = -1;
	    MachineData[id][mLabel] = Text3D: -1;
	    MachineData[id][mExists] = false;
	    
	    SendClientMessage(playerid, 0x3498DBFF, "GUN VENDING MACHINE: {FFFFFF}Machine removed.");
	}else{
 		SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Machine removing failed.");
	}
	
	return 1;
}

CMD:createcategory(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
	ShowPlayerDialog(playerid, DIALOG_CREATE_CATEGORY, DIALOG_STYLE_INPUT, "{F1C40F}GVM: {FFFFFF}Create Category", "Choose a category name:", "Create", "Cancel");
	return 1;
}

CMD:renamecategory(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
	ShowCategories(playerid, 2);
	return 1;
}

CMD:removecategory(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
	ShowCategories(playerid, 1);
	return 1;
}

CMD:addweapon(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
    ShowWeaponList(playerid);
	return 1;
}

CMD:removeweapon(playerid, params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
    ShowCategories(playerid, 4);
	return 1;
}
Reply
#2

Help...
Reply
#3

Код:
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
What do you think this means? Did you search for DB_MAX_STATEMENTS in the include file?
Reply
#4

Quote:
Originally Posted by Slice
Посмотреть сообщение
Код:
[22:13:14] SQLitei Error: (db_prepare) Unable to find an empty slot for the statement. Increase DB_MAX_STATEMENTS.
What do you think this means? Did you search for DB_MAX_STATEMENTS in the include file?
https://sampforum.blast.hk/showthread.php?tid=606859
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)