Playerdata doesn't load correcly
#5

Just a few questions..
1, (Not a question, A statement) Your SQL Syn-taxing is fucking horrendous..

2, Silly question really but worth an ask.. - Are you sure it's sending the correct "Username"
Код:
 mysql_queryF("SELECT * FROM `Accounts` WHERE `Username` = '%s' LIMIT 1", GetName(playerid));
Question.
Is your TABLE spelled exactly: "Accounts" or is it "ACCOUNTS" or "accounts" , Some times tables will be spazzy if you don't put the exact name..

-
3, Why the hell are you sending an SQL statement and then responding to that statement in the same function..
Create a seperate function for that SQL to send the information too.
And then you can use the SQL statement in multiple locations and draw the information you need in separate functions, Looking @ that code makes me gag..
I can easily tell you're using multiple statements which do the exact same thing..
I don't have to see it to know it.. (More code = More time compiling = Looks ugly as fuck)

4, Quick observation.
You're putting loop statement in with the default value of 121, < Being max yet you've defined the max rows as 1..

Another observation
You NEVER once call information from the column it's stored in..
You're simply repeating a statement with no variable.. Namely: "Field"
Where does Field get it's data from because you're not telling the script where it's actually coming from
All you've done is throw a ton of enums @ the script with the value of "Field" well "Field has no value and it's not getting any value for that enum.
You're just switching case statements telling it the value = "Field".

That's why your code doesn't work.....


__
Side note:
Here is an EXAMPLE.. Of Clean and working code..

Код:
new SqlQuery[1024];
format(SqlQuery, sizeof(SqlQuery), "SELECT * FROM `Accounts` WHERE `username` = '%s'", Getname(playerid));
mysql_function_query(g_mysql_handle, SqlQuery, true, "LoadAccountInfo", "d",playerid);
Код:
forward LoadAccountInfo(playerid);
public LoadAccountInfo(playerid) {;	
	new accountname[MAX_PLAYER_NAME+1];
	new level, ph;
	new rows,fields;
	cache_get_data(rows,fields);
	if(rows < 1) {
		//Do Something if the account isn't found.
		return 1;
	}
	cache_get_row(0, 0, accountname);
	PlayerInfo[playerid][AccountName] = accountname;
	cache_get_row(0, 1, level);
	PlayerInfo[playerid][PlayerLevel] = level;
	cache_get_row(0, 2, ph);
	PlayerInfo[playerid][PlayingHours] = ph;
	return 1;
}
Obviously if we were Lazy we could just set a function Var to do all the work instead of individual names like accountname etc..
We could just create
Код:
new string[1024];
< and just call that for each row - assign it and then reuse it.
Reply


Messages In This Thread
Playerdata doesn't load correcly - by lulo356 - 17.01.2016, 03:46
Re: Playerdata doesn't load correcly - by Riddick94 - 17.01.2016, 10:07
Re: Playerdata doesn't load correcly - by lulo356 - 18.01.2016, 23:41
Re: Playerdata doesn't load correcly - by Pottus - 19.01.2016, 00:33
Re: Playerdata doesn't load correcly - by Prokill911 - 19.01.2016, 00:58

Forum Jump:


Users browsing this thread: 1 Guest(s)