SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/01/2020, 01:05 PM   #1
TheLeech
Big Clucker
 
Join Date: Aug 2015
Location: Under your bed
Posts: 173
Reputation: 6
Default Factions aren't loading

Factions aren't loading it's giving me this in pawn compiler and this in server console. It only does it if I have Faction_Load in the script if I remove it it doesn't do the header stuff in pawn compiler or server console.

Code:
Pawn Compiler:
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(1839) : warning 203: symbol is never used: "ATM_Nearest"
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(568) : warning 203: symbol is never used: "BizEmployeeName"
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(567) : warning 203: symbol is never used: "BizMInfo"
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(567 -- 1839) : warning 203: symbol is never used: "Report_Add"
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(567 -- 1839) : warning 203: symbol is never used: "Report_GetCount"
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(16) : warning 204: symbol is assigned a value that is never used: "TutorialTimer"
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(769) : warning 203: symbol is never used: "VehicleMInfo"
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(150) : warning 204: symbol is assigned a value that is never used: "restockpickup"
C:\Users\nathan\Desktop\2Real Roleplay\gamemodes\Compile.pwn(151) : warning 204: symbol is assigned a value that is never used: "restocktext"
Pawn compiler 3.10.8	 	 	Copyright (c) 1997-2006, ITB CompuPhase

Header size:          11772 bytes
Code size:           975040 bytes
Data size:         87043196 bytes
Stack/heap size:      16384 bytes; estimated max. usage=4154 cells (16616 bytes)
Total requirements:88046392 bytes

9 Warnings.

Server Console: 
[13:04:16] [debug] Run time error 3: "Stack/heap collision (insufficient stack size)"
[13:04:16] [debug]  Stack pointer (STK) is 0x5302C3C, heap pointer (HEA) is 0x5302C7C
[13:04:16] [debug] AMX backtrace:
[13:04:16] [debug] #0 ???????? in public Faction_Load () from Compile.amx
Faction code
Code:
forward Faction_Load();
public Faction_Load()
{
    static
	    rows,
	    fields;

	cache_get_data(rows, fields, g_iHandle);

	for (new i = 0; i < rows; i ++) if (i < MAX_FACTIONS)
	{
		new fetch[2048];

		new id = cache_get_field_int(i, "ID");

		FactionInfo[id][fDBID] = cache_get_field_int(i, "ID");

		cache_get_field_content(i, "Name", fetch);
		format(FactionInfo[id][fName], 128, fetch);

		cache_get_field_content(i, "MOTD", fetch);
		format(FactionInfo[id][fMOTD], 128, fetch);

		FactionInfo[id][fRights] = cache_get_field_int(i, "Rights");
		FactionInfo[id][fTagRights] = cache_get_field_int(i, "TagRights");
		FactionInfo[id][fFactionChat] = cache_get_field_int(i, "FactionChat");

		new RankName[MAX_FACTION_RANKS][64];
		new RankBonus[MAX_FACTION_RANKS][32];

		cache_get_field_content(i, "RankNames", fetch);
		split(fetch, RankName, ',');

		cache_get_field_content(i, "RankBonuses", fetch);
		split(fetch, RankBonus, ',');

		for(new i2 = 1; i2 < MAX_FACTION_RANKS; i2++)
		{
			format(FactionRankInfo[id][i2][fRank], 64, RankName[i2 - 1]);
			FactionRankInfo[id][i2][fRankBonus] = strval(RankBonus[i2 - 1]);
		}

		FactionInfo[id][fWarehouseX] = cache_get_field_float(i, "WarehouseX");
		FactionInfo[id][fWarehouseY] = cache_get_field_float(i, "WarehouseY");
		FactionInfo[id][fWarehouseZ] = cache_get_field_float(i, "WarehouseZ");
		FactionInfo[id][fWarehouseInterior] = cache_get_field_int(i, "WarehouseInterior");
		FactionInfo[id][fWarehouseVirtualWorld] = cache_get_field_int(i, "WarehouseVirtualWorld");

		FactionInfo[id][fDailyPackages] = cache_get_field_int(i, "DailyPackages");
		FactionInfo[id][fAvailablePackages] = cache_get_field_int(i, "AvailablePackages");

		if(FactionInfo[id][fWarehouseX] != 0 || FactionInfo[id][fWarehouseY] != 0 || FactionInfo[id][fWarehouseZ] != 0)
		{
			FactionCP[id] = CreateDynamicCP(FactionInfo[id][fWarehouseX], FactionInfo[id][fWarehouseY], FactionInfo[id][fWarehouseZ],
				1.0, FactionInfo[id][fWarehouseVirtualWorld], FactionInfo[id][fWarehouseInterior]);
		}

		printf("Faction %i loaded! (Name: %s)", id, FactionInfo[id][fName]);
	}
	return 1;
}
__________________
R.i.p Sa-mp.

#Save DL

2Real Roleplay is getting re-made slowly, Discord: https://discord.gg/veaG9bT
2Real Roleplay forums: 2r-rp.com
TheLeech is offline   Reply With Quote
Old 17/01/2020, 02:36 PM   #2
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 958
Reputation: 167
Default Re: Factions aren't loading

- Avoid declaring strings/arrays inside loops. It declares a string of size 2048 in every iteration.
- Assign directly to array using the mysql functions with the last parameter:
pawn Code:
cache_get_field_content(i, "Name", FactionInfo[id][fName], .max_len = 128);
// or
cache_get_field_content(i, "Name", FactionInfo[id][fName], g_iHandle, 128);
- Storing multiple values in one column is wrong database design, you should create a separate table for ranks and bonuses.
- Storing to `FactionInfo[id][fDBID]` is pointless because it has the same value of `id`. In general, the identification column we use in mysql is an auto increment field that its job is only one. Identifying records in the database. Array indexes can have different values, nothing wrong with it.
__________________
Calisthenics is offline   Reply With Quote
Old 17/01/2020, 02:36 PM   #3
d3Pedro
Huge Clucker
 
Join Date: Apr 2012
Location: darkness
Posts: 295
Reputation: 91
Default Re: Factions aren't loading

What mysql version are you running? That looks a mess!
pawn Code:
forward Faction_Load();
public Faction_Load()
{


    new rows = cache_get_row_count(g_iHandle);
    //you do a check here before you loop it, check if there's any row in the table.
    if(rows)
    {
        for(new i = 0; i < rows && i < MAX_FACTIONS; i ++)
        {
            //new fetch[2048]; //what do you need this for?

            new id = cache_get_field_int(i, "ID");

            FactionInfo[id][fDBID] = cache_get_field_int(i, "ID");
            cache_get_field_content(i, "Name", FactionInfo[factionid][fName], g_iHandle, 48); //48 but you gotta change this to the value you've defined fName
            cache_get_field_content(i, "MOTD", FactionInfo[factionid][fMOTD], g_iHandle, 128); //same goes here.
            FactionInfo[id][fRights] = cache_get_field_int(i, "Rights");
            FactionInfo[id][fTagRights] = cache_get_field_int(i, "TagRights");
            FactionInfo[id][fFactionChat] = cache_get_field_int(i, "FactionChat");

            //this is totally a mess! Do a new table just for faction ranks and load them by the faction id!
            /*
            new RankName[MAX_FACTION_RANKS][64];
            new RankBonus[MAX_FACTION_RANKS][32];
            cache_get_field_content(i, "RankNames", fetch);
            split(fetch, RankName, ',');
            cache_get_field_content(i, "RankBonuses", fetch);
            split(fetch, RankBonus, ',');


            for(new i2 = 1; i2 < MAX_FACTION_RANKS; i2++)
            {
                format(FactionRankInfo[id][i2][fRank], 64, RankName[i2 - 1]);
                FactionRankInfo[id][i2][fRankBonus] = strval(RankBonus[i2 - 1]);
            }*/

            //commented this, try run it without loading ranks and see if you'll get the same error!

            FactionInfo[id][fWarehouseX] = cache_get_field_float(i, "WarehouseX");
            FactionInfo[id][fWarehouseY] = cache_get_field_float(i, "WarehouseY");
            FactionInfo[id][fWarehouseZ] = cache_get_field_float(i, "WarehouseZ");
            FactionInfo[id][fWarehouseInterior] = cache_get_field_int(i, "WarehouseInterior");
            FactionInfo[id][fWarehouseVirtualWorld] = cache_get_field_int(i, "WarehouseVirtualWorld");
            FactionInfo[id][fDailyPackages] = cache_get_field_int(i, "DailyPackages");
            FactionInfo[id][fAvailablePackages] = cache_get_field_int(i, "AvailablePackages");

            if(FactionInfo[id][fWarehouseX] != 0 || FactionInfo[id][fWarehouseY] != 0 || FactionInfo[id][fWarehouseZ] != 0)
            {
                FactionCP[id] = CreateDynamicCP(FactionInfo[id][fWarehouseX], FactionInfo[id][fWarehouseY], FactionInfo[id][fWarehouseZ],
                    1.0, FactionInfo[id][fWarehouseVirtualWorld], FactionInfo[id][fWarehouseInterior]);
            }

            printf("Faction %i loaded! (Name: %s)", id, FactionInfo[id][fName]);
        }
    }
    return 1;
}
d3Pedro is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Houses aren't loading again.. div Scripting Help 2 04/07/2018 05:17 PM
gates aren't loading IndependentGaming Scripting Help 1 29/07/2017 12:16 AM
Samp servers aren't loading, if they are loading, the pings are very massive. Gorgeousmaniac Everything and Nothing 3 22/09/2016 09:19 AM
Samp servers aren't loading, if they are loading, the pings are very massive. Gorgeousmaniac Client Support 0 21/09/2016 05:16 PM
Factions aren't showing correctly. EliteApple Scripting Help 0 15/05/2013 07:17 PM


All times are GMT. The time now is 06:14 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.