SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 05/03/2017, 02:04 AM   #1
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default MySQL Reading / Saving Problem

So my Faction System has been having problems displaying the Faction Name.
but not initially.

When I create the faction eg: LSPD.
It will show correctly in /f(actionchat, /stats & /factionlist
but after the server gets turned off & retarted it is not reading or displaying correctly.
its just empty.
like this "Faction: | Rank: Cadet"
it should be "Faction: LSPD | Rank: Cadet"

OnGameModeInit
Code:
mysql_tquery(g_SQL, "SELECT * FROM `factions` ORDER BY `id` ASC", "FactionLoad", "");
mysql_tquery(g_SQL, "SELECT * FROM `factionranks` ORDER BY `id` ASC", "LoadFactionRanks", "");
Code:
public FactionLoad()
{
	new rows = cache_num_rows();

	for(new i = 0; i < rows && i < MAX_FACTIONS; i ++)
    {
        new factionid;
        cache_get_value_name_int(i, "id", factionid);
        cache_get_value_name(i, "name", FactionInfo[factionid][Name]);
        cache_get_value_name_int(i, "rank", FactionInfo[factionid][Rank]);
    }
}
Stats Displaying Faction & Rank.
Code:
format(string, sizeof(string), "{00A5FF}** Faction: %s | Rank: %s", FactionInfo[Player[i][Faction]][Name], FactionRanks[Player[i][Faction]][Player[i][FactionRank]]);
	SendClientMessage(i, COLOR_LIGHTBLUE, string);
Anyone know whats wrong here?
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare is offline   Reply With Quote
Old 05/03/2017, 02:07 AM   #2
JessThompson
Huge Clucker
 
JessThompson's Avatar
 
Join Date: Dec 2013
Location: Developer Lodge
Posts: 398
Reputation: 22
Default Re: MySQL Reading / Saving Problem

You must provide a length on the loading,

http://wiki.sa-mp.com/wiki/MySQL/R40...get_value_name (Read the red box)

so

cache_get_value_name(i, "name", FactionInfo[factionid][Name], 30);
cache_get_value_name(i, "leader", FactionInfo[factionid][Leader], 30);
__________________
If I helped you please leave a REP+
Developer ~ Scripter
PHP | HTML | CSS | VB.NET | PAWN
JessThompson is offline   Reply With Quote
Old 05/03/2017, 02:11 AM   #3
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default Re: MySQL Reading / Saving Problem

Ohh, how simple XD thank you very much, fixed it perfectly.
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare is offline   Reply With Quote
Old 05/03/2017, 02:14 AM   #4
JessThompson
Huge Clucker
 
JessThompson's Avatar
 
Join Date: Dec 2013
Location: Developer Lodge
Posts: 398
Reputation: 22
Default Re: MySQL Reading / Saving Problem

No problemo :P
__________________
If I helped you please leave a REP+
Developer ~ Scripter
PHP | HTML | CSS | VB.NET | PAWN
JessThompson 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
PlayerInfo saving/reading the array problem [+REP] Amit1998 Scripting Help 5 14/06/2016 10:08 PM
Problem with reading money from MySQL in "Clean, Simple MySQL GM" by L3th4l Dystans Help Archive 1 31/05/2011 09:19 PM
Best saving/reading system? [L3th4l] Help Archive 7 16/09/2010 01:17 AM
[HELP] File saving and reading dini GreenHammy Help Archive 1 05/04/2010 07:44 AM
Saving as hex (reading with sscanf 2.0) RSX Help Archive 2 31/03/2010 12:56 PM


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


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