09.10.2015, 18:47
It's your script itself causing this issue as mine works totally fine (with no prior shooting whatsoever).
pawn Code:
// DEVELOPMENT SCRIPT
// ** INCLUDES
#include <a_samp>
#include <a_mysql>
#include <zcmd>
// ** DEFINES
// *** FUNCTIONS
#define function%0(%1) forward%0(%1); public%0(%1)
// *** DATABASE
#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_PASSWORD ""
#define MYSQL_DATABASE "mysql_weapons"
// *** WEAPONS DATABASE
#define TABLE_WEAPONS "weapons"
#define WEAPONS_USERNAME "username"
#define WEAPONS_WEAPON_ID "weapon_id"
#define WEAPONS_WEAPON_AMMO "weapon_ammo"
// ** VARIABLES
// *** DATABASE
static weapons_database;
// ** MAIN
main()
{
print("Development Mode: mysql_weapons.amx");
}
// ** CALLBACKS
public OnGameModeInit()
{
LoadDatabase();
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerSpawn(playerid)
{
LoadPlayerWeapons(playerid);
return 1;
}
// ** COMMANDS
CMD:weapondata(playerid, params[])
{
new string[144], weapons[13][2];
for(new i = 0; i <= 12; i ++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
format(string, sizeof(string), "Weapon ID: %d - Ammo: %d.", weapons[i][0], weapons[i][1]);
SendClientMessage(playerid, -1, string);
}
return 1;
}
// ** FUNCTIONS
stock LoadDatabase()
{
mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG);
weapons_database = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);
if(mysql_errno(weapons_database) != 0)
{
printf("[MySQL] Couldn't connect to %s.", MYSQL_DATABASE);
}
else
{
printf("[MySQL] Connected to %s.", MYSQL_DATABASE);
new query[500], string[144];
format(string, sizeof(string), "CREATE TABLE IF NOT EXISTS %s(", TABLE_WEAPONS);
strcat(query, string);
format(string, sizeof(string), "%s VARCHAR(%d),", WEAPONS_USERNAME, MAX_PLAYER_NAME);
strcat(query, string);
format(string, sizeof(string), "%s INT(20),", WEAPONS_WEAPON_ID);
strcat(query, string);
format(string, sizeof(string), "%s INT(20))", WEAPONS_WEAPON_AMMO);
strcat(query, string);
mysql_query(weapons_database, query);
}
return 1;
}
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
stock LoadPlayerWeapons(playerid)
{
new query[256], player_name[MAX_PLAYER_NAME];
mysql_escape_string(PlayerName(playerid), player_name);
format(query, sizeof(query), "SELECT `%s`, `%s` FROM `%s` WHERE `%s` = '%s';", WEAPONS_WEAPON_ID, WEAPONS_WEAPON_AMMO, TABLE_WEAPONS, WEAPONS_USERNAME, player_name);
mysql_function_query(weapons_database, query, true, "OnWeaponsLoaded", "i", playerid);
return 1;
}
function OnWeaponsLoaded(playerid)
{
new weaponid, ammo;
for(new i = 0, j = cache_get_row_count(weapons_database); i < j; i ++)
{
weaponid = cache_get_row_int(i, 0, weapons_database);
ammo = cache_get_row_int(i, 1, weapons_database);
GivePlayerWeapon(playerid, weaponid, ammo);
}
return 1;
}