Jump to content
  • 0

problema functie loadfaction


Question

Posted (edited)

Salutare am si eu o problema cu asceasta functie.

Nici cand pornesc serverul nu imi apar cate factiuni am in baza de date (in baza de date am 6 factiuni).

In gamemode nu imi apare nici-o eroare ,dar in notepad-ul errors din logs primesc aceste erori:

[08:45:45] [plugins/mysql] mysql_query: invalid connection handle '0'
[08:45:45] [plugins/mysql] cache_get_row_count: no active cache
[08:45:45] [plugins/mysql] cache_delete: invalid cache id '0'

Functia este aceasta:

function LoadFactions()
{
	new Cache: db = mysql_query (g_Sql, "SELECT * FROM `factions` ORDER BY `factions`.`ID` ASC");
	new
		x,
		szLabelString[500],
		result[256],
		rows;

 	for (new i, j = cache_get_row_count (rows); i != j; ++i)
	{
	    factions ++;
       	cache_get_value_name(i, "ID", result); 					x = strval(result);
		cache_get_value_name(i, "Name", result);				format(FactionInfo[x][fName], 32, result);

		cache_get_value_name(i, "InteriorPosX", result);		FactionInfo[x][fInteriorPos][0] = floatstr(result);
		cache_get_value_name(i, "InteriorPosY", result);		FactionInfo[x][fInteriorPos][1] = floatstr(result);
		cache_get_value_name(i, "InteriorPosZ", result);		FactionInfo[x][fInteriorPos][2] = floatstr(result);
		cache_get_value_name(i, "ExteriorPosX", result);		FactionInfo[x][fExteriorPos][0] = floatstr(result);
		cache_get_value_name(i, "ExteriorPosY", result);		FactionInfo[x][fExteriorPos][1] = floatstr(result);
		cache_get_value_name(i, "ExteriorPosZ", result);		FactionInfo[x][fExteriorPos][2] = floatstr(result);
		cache_get_value_name(i, "Rank1", result);				format(FactionInfo[x][fRank1Name], 64, result);
		cache_get_value_name(i, "Rank2", result);				format(FactionInfo[x][fRank2Name], 64, result);
		cache_get_value_name(i, "Rank3", result);				format(FactionInfo[x][fRank3Name], 64, result);
		cache_get_value_name(i, "Rank4", result);				format(FactionInfo[x][fRank4Name], 64, result);
		cache_get_value_name(i, "Rank5", result);				format(FactionInfo[x][fRank5Name], 64, result);
		cache_get_value_name(i, "Rank6", result);				format(FactionInfo[x][fRank6Name], 64, result);
		cache_get_value_name(i, "Level", result);				FactionInfo[x][fLevel] = strval(result);
		cache_get_value_name(i, "Applications", result);		FactionInfo[x][fApplications] = strval(result);
		cache_get_value_name(i, "Slots", result);				FactionInfo[x][fSlots] = strval(result);
		cache_get_value_name(i, "Interior", result);			FactionInfo[x][fInteriorID] = strval(result);
		cache_get_value_name(i, "Virtual", result);				FactionInfo[x][fVirtualID] = strval(result);
		cache_get_value_name(i, "Locked", result);				FactionInfo[x][fLocked] = strval(result);
		cache_get_value_name(i, "Motd", result);				format(FactionInfo[x][fMotd], 128, result);
		cache_get_value_name(i, "Icon", result);				FactionInfo[x][fIcon] = strval(result);

		if(FactionInfo[x][fIcon] != -1) {
		    CreateDynamicMapIcon(FactionInfo[x][fExteriorPos][0], FactionInfo[x][fExteriorPos][1], FactionInfo[x][fExteriorPos][2], FactionInfo[x][fIcon],0,-1,-1,-1,1000.0);		// Banka
		}
		format(szLabelString, 256, "%s's faction (ID: %d).\nPress 'F' to enter in HQ!", FactionInfo[x][fName], x);
		FactionInfo[x][fLabelID] = CreateDynamic3DTextLabel(szLabelString, 0x3F76B5FF, FactionInfo[x][fExteriorPos][0], FactionInfo[x][fExteriorPos][1], FactionInfo[x][fExteriorPos][2], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
		FactionInfo[x][fPickupID] = CreateDynamicPickup(1239, 23, FactionInfo[x][fExteriorPos][0], FactionInfo[x][fExteriorPos][1], FactionInfo[x][fExteriorPos][2], 0, 0, -1, 250);
	}
	printf("[MySQL INFO]: %d factions loaded.", factions);
	cache_delete(db);
	return 1;
}

 

Edited by Ale CSu

7 answers to this question

Recommended Posts

  • 0
Posted
3 hours ago, nobilzeus said:

Verifica g_Sql daca face conexiunea cu baza

In momentul cand pornesc serverul imi apare in consola "Conexiunea la mysql sa facut cu succes" .

  • 0
Posted
52 minutes ago, Ale CSu said:

In momentul cand pornesc serverul imi apare in consola "Conexiunea la mysql sa facut cu succes" .

La mysql_connect verifica 

  • 0
Posted (edited)

EDIT:Am rezolvat problema ,multumesc de ajutor :)

 

Salut ,scuze de intarziere.

 

mysql_connect de la ongamemodeinit:

    g_Sql = mysql_connect(mysql_host, mysql_user, mysql_pass, mysql_db);
    if(mysql_errno() != 0)
    {
        printf("Connexiunea la baza de date '%s' nu a reusit. ---> Server ShutDown!", mysql_db);
        SendRconCommand("exit"); //daca vor exista erori ne va afisamesajul si va inchide consola
    }
    else
    {
        printf("Conexiunea la baza de date '%s' cu userul '%s' a reusit", mysql_db, mysql_user);// daca nu vor exista erori ne va afisa mesajul
    }
	return 1;
}

server_log:


----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team

[05:19:09] filterscripts = ""  (string)
[05:19:09] 
[05:19:09] Server Plugins
[05:19:09] --------------
[05:19:09]  Loading plugin: sscanf
[05:19:09] 
[05:19:09]  ===============================
[05:19:09] 
[05:19:09]       sscanf plugin loaded.     
[05:19:09] 
[05:19:09]          Version: 2.13.2
[05:19:09] 
[05:19:09]    (c) 2022 Alex "Y_Less" Cole  
[05:19:09] 
[05:19:09]  ===============================
[05:19:09] 
[05:19:09]   Loaded.
[05:19:09]  Loading plugin: streamer
[05:19:09] 

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

[05:19:09]   Loaded.
[05:19:09]  Loading plugin: mysql
[05:19:09]  >> plugin.mysql: R41-4 successfully loaded.
[05:19:09]   Loaded.
[05:19:09]  Loaded 3 plugins.

[05:19:09] 
[05:19:09] Filterscripts
[05:19:09] ---------------
[05:19:09]   Loaded 0 filterscripts.

[05:19:09] AllowAdminTeleport() : function is deprecated. Please see OnPlayerClickMap()
[05:19:09] [MySQL INFO]: 0 factions loaded.
[05:19:09] Conexiunea la baza de date 'lgsdb' cu userul 'root' a reusit
[05:19:09] 
----------------------------------
[05:19:09]   Bare Script

[05:19:09] ----------------------------------

[05:19:09] Number of vehicle models: 0

si erorile de la mysql care le primesc:

[05:19:09] [ERROR] mysql_query: invalid connection handle '0'
[05:19:09] [ERROR] cache_get_row_count: no active cache
[05:19:09] [ERROR] cache_delete: invalid cache id '0'
[05:19:09] [WARNING] mysql_connect: no password specified

 

Edited by Ale CSu
  • 0
Posted
for (new i=1, j = cache_get_row_count (rows); i != j; ++i)
public OnPlayerConnect(playerid)
{
	print("[ERROR] - Unable to establish a connection with the world...");
	SendRconCommand("exit");
	return 1;
}

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.