Best way to save Server Settings [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: Best way to save Server Settings [MySQL] (
/showthread.php?tid=655305)
Best way to save Server Settings [MySQL] -
GospodinX - 18.06.2018
Hi,
I need to save server settings in MySQL but i don't have idea how to do it.
I have something like this:
Код:
enum Server
{
isRegister,
isAds,
isAsk
isReport
isHappyHours
};
new ServerInfo[Server];
So how to save it?I just have idea with many fields and one row..I don't know is it good.
This:
I think that i need to do it with more rows but i don't have idea how to load/save it on it way..
Re: Best way to save Server Settings [MySQL] -
FailerZ - 18.06.2018
I would go with two columns multi rows,
Example:
settings table has:
Setting column as string
Value column as integer or w/e
Now you just insert rows:
isRegister value 0/1
isAds value 0/1
..etc
Re: Best way to save Server Settings [MySQL] -
GospodinX - 18.06.2018
Quote:
Setting column as string
Value column as integer or w/e
|
I understand it.But how to load it in enum?
I know just on this way with strcmp,but i think it's not good
Код:
mysql_tquery(g_SQL,SELECT * FROM `settings`","LoadSettings");
Код:
forward LoadSettings();
public LoadSettings()
{
new rows = cache_num_rows();
new setting[20],value;
if(rows)
{
for(new i; i<rows; i++)
{
cache_get_value_name(i,"SettingName",setting);
cache_get_value_int(i,"Value",value);
if(strcmp(setting, "isAds") == 0)
{
ServerInfo[isAds] = value;
}
else if(strcmp(setting, "isReport") == 0)
{
ServerInfo[isReport] = value;
}
..
...
}
}
return 1;
}
Re: Best way to save Server Settings [MySQL] -
Calisthenics - 18.06.2018
If the loading is in correct order, this might also work:
pawn Код:
ServerInfo[Server: i] = value;