Saving string as a symbol.. MySQL - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving string as a symbol.. MySQL (
/showthread.php?tid=479154)
Saving string as a symbol.. MySQL -
Brandon_More - 03.12.2013
So I have this MySQL database everything works fine there's just one problem.. When I look at the variable "playerteam" it saves it as some random symbol..
It is saving the variable value as: я or C (я << Something other than civilian | C < Civ) but I wunna chnage this so It adds the real faction, below I will enter everything
Create the variable in structure:
pawn Код:
mysql_query("ALTER TABLE PlayerInfo ADD playerteam VARCHAR(225) NOT NULL DEFAULT 'CIV'");
When someone logs in:
pawn Код:
mysql_fetch_field_row(savingstring, "playerteam");
strmid(PlayerInfo[playerid][playerteam], savingstring, 0, strlen(savingstring), 50);
When someone edits / logs out:
pawn Код:
format(query, sizeof(query), "UPDATE PlayerInfo SET playerteam='%s' WHERE user='%s'", PlayerInfo[playerid][playerteam], pname);
mysql_query(query);
I thought it would be this:
pawn Код:
PlayerInfo[giveplayerid][playerteam] = team;
<< But when I edited this it crashed the server :/
Re: Saving string as a symbol.. MySQL -
Brandon_More - 04.12.2013
24 hours past - Bump.
Please can someone help me?!
Re: Saving string as a symbol.. MySQL - Emmet_ - 04.12.2013
1) Try using "ADD COLUMN" over "ADD". You can also try removing that column and adding it back.
2) Don't use strmid for copying strings!
pawn Код:
#define strcpy(%0,%1) \
strcat((%0[0] = '\0', %0), %1)
mysql_fetch_field_row(savingstring, "playerteam");
strcpy(PlayerInfo[playerid][playerteam], savingstring, 50);
3) This is the INCORRECT way:
pawn Код:
PlayerInfo[giveplayerid][playerteam] = team;
This is the correct way:
pawn Код:
strcpy(PlayerInfo[playerid][playerteam], team, 50);