Is it even possible? - 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: Is it even possible? (
/showthread.php?tid=607474)
Is it even possible? -
Sjn - 20.05.2016
Just wondering if it's possible to fetch all the created command list. I mean, for example I have 80 commands created in the script so, without having to write every single created commands in the commands list dialog, it would automatically fetch the newly added command in the script and update the list.
Is there any ways to do it?
Re: Is it even possible? -
oMa37 - 20.05.2016
Try this:
-By Konstantinos
PHP код:
#include <YSI\y_amx>
...
static
list[512], // change its value depending on how many commands you got
buffer[32],
count;
while ((count = AMX_GetName(AMX_TABLE_PUBLICS, count, buffer, "cmd_")))
{
if (!strcmp(buffer, "zcmd_OnGameModeInit") || !strcmp(buffer, "zcmd_OnFilterScriptInit")) continue;
strmid(buffer, buffer, 4, strlen(buffer), sizeof buffer);
strins(buffer, "/", 0, sizeof buffer);
strcat(list, buffer, sizeof list);
strcat(list, "\n", sizeof list);
}
print(list);
Re: Is it even possible? -
Sjn - 20.05.2016
Okay, but can this code be modified so I don't have to use y_amx?
I know it would be faster but I don't have YSI library and I don't plan to use it either regarding it's size.
Re: Is it even possible? -
Nero_3D - 20.05.2016
A simple GetPublicName function
PHP код:
stock GetPublicName(idx, buffer[32]) {
if(idx >= 0) {
new
publics,
natives
;
#emit lctrl 1
#emit const.alt 32
#emit sub.alt
#emit stor.s.pri publics
#emit add.c 4
#emit stor.s.pri natives
#emit lref.s.pri natives
#emit stor.s.pri natives
#emit lref.s.pri publics
#emit load.s.alt idx
#emit shl.c.alt 3
#emit add
#emit stor.s.pri publics
if(publics < natives) {
#emit lctrl 1
#emit move.alt
#emit load.s.pri publics
#emit add.c 4
#emit sub
#emit stor.s.pri publics
#emit lref.s.pri publics
#emit sub
#emit stor.s.pri natives
for(idx = 0; ; natives += 4) {
#emit lref.s.pri natives
#emit stor.s.pri publics
if((buffer[idx++] = publics & 0xFF) == EOS || (buffer[idx++] = publics >> 8 & 0xFF) == EOS || (buffer[idx++] = publics >> 16 & 0xFF) == EOS || (buffer[idx++] = publics >>> 24) == EOS) {
return idx;
}
}
}
}
return 0;
}
PHP код:
// global
new
gCmdList[512] // change its value depending on how many commands you got
;
// OnGameModeInit
new
i,
buffer[32]
;
while(GetPublicName(i, buffer)) {
if(strcmp(buffer, "cmd_", false, 4) == 0) {
buffer[2] = '\n';
buffer[3] = '/';
strcat(gCmdList, buffer[2]);
}
i++;
}
print(gCmdList[1]);