So, 3 months have passed since I touched any SM project. I basically forgot it all...
I have a few newbish-like questions for you guys, if someone can reply to me, it'd be just great.
If I want to store multiple int/float values in different array indexes, how should I create the variable, how should I store them inside that array, and how should I use them in the array?
( reading those values from a keyvalue. )
For example, if I wanted to fix this... ugly example:
Code:
public void readconfigs()
{
char path_cfgs[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path_cfgs, sizeof(path_cfgs), "configs/traderoom/roompos.cfg");
Handle kv = CreateKeyValues("roomPos");
char buffer[PLATFORM_MAX_PATH];
FileToKeyValues(kv, path_cfgs);
if (!KvGotoFirstSubKey(kv))
{
LogError("[!] roompos .CFG File not found: %s", path_cfgs);
CloseHandle(kv);
return;
}
do {
KvGetSectionName(kv, buffer, sizeof(buffer));
if (StrEqual(buffer, "room1"))
{
r1tposx = KvGetFloat(kv, "tposx");
r1tposy = KvGetFloat(kv, "tposy");
r1tposz = KvGetFloat(kv, "tposz");
r1ctposx = KvGetFloat(kv, "ctposx");
r1ctposy = KvGetFloat(kv, "ctposy");
r1ctposz = KvGetFloat(kv, "ctposz");
}
if (StrEqual(buffer, "room2"))
{
r2tposx = KvGetFloat(kv, "tposx");
r2tposy = KvGetFloat(kv, "tposy");
r2tposz = KvGetFloat(kv, "tposz");
r2ctposx = KvGetFloat(kv, "ctposx");
r2ctposy = KvGetFloat(kv, "ctposy");
r2ctposz = KvGetFloat(kv, "ctposz");
}
if (StrEqual(buffer, "room3"))
{
r3tposx = KvGetFloat(kv, "tposx");
r3tposy = KvGetFloat(kv, "tposy");
r3tposz = KvGetFloat(kv, "tposz");
r3ctposx = KvGetFloat(kv, "ctposx");
r3ctposy = KvGetFloat(kv, "ctposy");
r3ctposz = KvGetFloat(kv, "ctposz");
}
if (StrEqual(buffer, "room4"))
{
r4tposx = KvGetFloat(kv, "tposx");
r4tposy = KvGetFloat(kv, "tposy");
r4tposz = KvGetFloat(kv, "tposz");
r4ctposx = KvGetFloat(kv, "ctposx");
r4ctposy = KvGetFloat(kv, "ctposy");
r4ctposz = KvGetFloat(kv, "ctposz");
}
} while (KvGotoNextKey(kv));
CloseHandle(kv);
}
Also, would it be a way to add custom commands from a config? for example, I have a keyvalue with alot of commands, my plugin would read the commands and add them.
Thanks for reading my topic, have fun coding
__________________