Mysql load problem.
#1

Hello all, I have a mysql script to load players data and and of course save players data. My problem is i cant get varchar fields to load. I have a weapon ownership with a license and i have to register who owns the weapon*. It registers. I can save it when i leave them in cars, houses or leave them on player themselves**. But when it comes to load it just loads a clear string with nothing in it.

*owner is decided by who purchased the gun or if it was shipped illegally. If its illegal it writes unknown.

**I have "weapon1 owner" "weapon2 owner" etc in my mysql as i said it gets updated the way i want but i cant get them back to game.

MySql version(R33):
Код:
	cache_get_field_content(0,"GUN1OWNER",USER[playerid][GUN1OWNER]);
	cache_get_field_content(0,"GUN2OWNER",USER[playerid][GUN2OWNER]);
	cache_get_field_content(0,"GUN3OWNER",USER[playerid][GUN3OWNER]);
	cache_get_field_content(0,"SGUNOWNER",USER[playerid][SGUNOWNER]);
	cache_get_field_content(0,"EMAIL",USER[playerid][EMAIL]);
All of these return as an empty string.
Reply
#2

Why are you saving GUN(n)OWNER as a varchar? Simply compare the ID's of the owner ID, to the apparent gun owner.
Reply
#3

Then i would have to open a cache everytime a police checks who is that gun owned by. Also there is email too as you have seen. It doesnt get loaded too.
Reply
#4

You need to provide the enum's string size GUN(n)OWNER in each case.
Also, everything is correctly saved in your database? if not, do you have any error message?
Reply
#5

No, you would not. Simply comparing both ID's stored in the array would suffice.

As for your issue, you need to specify a destination size, since you're storing the info in an array. Like so:
edit: didn't read Dayrion's reply properly. I see he provided the answer now i've read back.

pawn Код:
cache_get_field_content(0,"GUN1OWNER",USER[playerid][GUN1OWNER], MAX_PLAYER_NAME);
I used MAX_PLAYER_NAME since that's the maximum the value will ever be, since it will be storing a players name. Email will be 254.
Reply
#6

Код:
enum USER_MODEL{
 	ID,
	NAME[24],
	PASS[24],
	ADMIN,
	MONEY,
	KILLS,
	DEATHS,
	SKIN,
	Float:POS_X,
	Float:POS_Y,
	Float:POS_Z,
	Float:ANGLE,
 	Float:HP,
 	Float:AM,
	EXP,
	CUFFED,
	JAILED,
	JAILTIME,
	AJAILED,
	AJAILTIME,
	PREEXPIRE,
	LEVEL,
	SAVINGS,
	BANK,
	PHONE,
	DONOR,
	MASK,
	MMASK,
	FACTION,
	FACRANK,
	DICE,
	CIGAR,
	WEED,
	COCAIN,
	PCP,
	HEROINE,
	LSD,
	SMOKING,
 	COKEADD,
 	DLIC,
	WLIC,
	GLIC,
	CARSPAWNED,
	ONMIS,
	ONTEST,
	ACCEPTHELP,
	FISHAMOUNT,
	FISHED,
	GANG,
	GANGRANK,
	GANGINVITE,
	ACTIVE,
	GUN1,
	GUN2,
	GUN3,
	SGUN,
	AMMO1,
	AMMO2,
	AMMO3,
	SGUNAMMO,
	GUN1OWNER[24],
	GUN2OWNER[24],
	GUN3OWNER[24],
	SGUNOWNER[24],
	EMAIL[50],
	JOBITEM1,
	JOBITEM2,
	JOBITEM3,
	HOUSEID,
	TOOLKIT,
	DAMAGE1,
	DAMAGE2,
	DAMAGE3,
	DAMAGE4,
	DAMAGE5,
	DAMAGE6,
	DAMAGE7,
	DAMAGE8,
	DAMAGE9
};
This is my enum for a player*. If my enumerations were problem when i put my gun in a vehicle it wouldnt save in car too and when i get it back it wouldnt update player enum. It succesfully happens.

*I know it is not very good designed but does the job for me so id rather not hear about how neat are my enumerations.

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
No, you would not. Simply comparing both ID's stored in the array would suffice.

As for your issue, you need to specify a destination size, since you're storing the info in an array. Like so:
edit: didn't read Dayrion's reply properly. I see he provided the answer now i've read back.

pawn Код:
cache_get_field_content(0,"GUN1OWNER",USER[playerid][GUN1OWNER], MAX_PLAYER_NAME);
I used MAX_PLAYER_NAME since that's the maximum the value will ever be, since it will be storing a players name. Email will be 254.
Yes this is what i asked.

For all who is interested, correct usage of cache get field content in mysql r33 is also adding handle name before text lenght. So the thing that fixed my problem totally was using the lines as:

Код:
cache_get_field_content(0,"GUN1OWNER",USER[playerid][GUN1OWNER], mymsqlhandlename, 24);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)