AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Forward string (https://forums.alliedmods.net/showthread.php?t=63149)

hackziner 11-13-2007 08:52

Forward string
 
Hi,

Is there a way to pass a pointer to string in a multiforward ?
I call a multiforward with strings in parameter from plugin1, plugin2 has the function and modify theses strings ... and i would like to get modifyed string in plugin1.

It doesn't work with string, I've always the same string in plugin1 ...


Quote:

plugin1:

g_MultiForward = CreateMultiForward("forward_fnc", ET_IGNORE, FP_STRING, FP_STRING, FP_STRING, FP_CELL);
...
ExecuteForward(g_MultiForward, g_MultiForwardResult, stringa, stringc,stringb, exist_flag);
...
Quote:

plugin2:

public forward_fnc(stringa, stringc, stringb,exist_flag)
{...
format(stringa,123,"something ...")
...
}

thks

purple_pixie 11-13-2007 09:33

Re: Forward string
 
Can't use use FM's EngFunc_AllocString, and pass it as a cell?

So long as anyone using your forward knows it's an allocated string ...

No, wait. Think I slightly missed your point.

PAWN doesn't really do pointers, so I doubt you'll have any real luck there.

Alka 11-13-2007 10:23

Re: Forward string
 
The only thing i can think and tested, is to call a forward to main plugin and send the modified string :D...here is an e.g (Works):

Main:
Code:

#include <amxmodx>
 
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Alka"
 
new g_MultiForward;
new g_MultiForwardResult;
 
public plugin_init() {
 
 register_plugin(PLUGIN, VERSION, AUTHOR);
 
 g_MultiForward = CreateMultiForward("Function_Show_Msg", ET_IGNORE, FP_CELL, FP_STRING, FP_STRING, FP_STRING);
 
 register_clcmd("say /test", "TestMultiForward");
}
 
public plugin_end()
 DestroyForward(g_MultiForward);
 
public TestMultiForward(id)
{
 static String[32], String1[32], String2[32];
 static Cell;
 
 formatex(String, sizeof String - 1, "wow");
 formatex(String1, sizeof String1 - 1, "is working!");
 formatex(String2, sizeof String2 - 1, "Woot :D");
 
 Cell = id;
 
 ExecuteForward(g_MultiForward, g_MultiForwardResult, Cell, String, String1, String2);
}
 
public Function_Show_Msg_Main(id, String1[], String2[], String3[])
{
 client_print(id, print_chat, "%s %s%s", String1, String2, String3);
}

Sample:
Code:

#include <amxmodx>
 
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Alka"
 
new g_MultiForward;
new g_MultiForwardResult;
 
public plugin_init() {
 
 register_plugin(PLUGIN, VERSION, AUTHOR);
 
 g_MultiForward = CreateMultiForward("Function_Show_Msg_Main", ET_IGNORE, FP_CELL, FP_STRING, FP_STRING, FP_STRING);
}
 
public plugin_end()
 DestroyForward(g_MultiForward);
 
public Function_Show_Msg(id, String1[], String2[], String3[])
{
 client_print(id, print_chat, "%s %s%s", String1, String2, String3);
 
 static String1m[32], String2m[32], String3m[32];
 
 format(String1m, sizeof String1m - 1, "%s[Modified]", String1);
 format(String2m, sizeof String2m - 1, "%s[Modified]", String2);
 format(String3m, sizeof String3m - 1, "%s[Modified]", String3);
 
 static Cell;
 Cell = id;
 
 ExecuteForward(g_MultiForward, g_MultiForwardResult, Cell, String1m, String2m, String3m);
}

Maybe someone know a better way ?! :)

Orangutanz 11-14-2007 22:17

Re: Forward string
 
Take a look at ATAC 3.0.0 source code:
exec_PunishName function is what you want to look at, this is the core for handling the punishment titles.

The only thing is you must encode the string to send it back to plugin 1.
Look at any punishment scripts for function: public atac_punishment_name( id ).

Brad 11-14-2007 22:29

Re: Forward string
 
Yer site ain't loading thar Monkey boy.

Emp` 11-14-2007 22:54

Re: Forward string
 
Code:

native set_string(param, dest[], maxlen);

hackziner 11-15-2007 07:53

Re: Forward string
 
Thank you guys, I'll try asap.

Orangutanz 11-15-2007 10:51

Re: Forward string
 
Quote:

Originally Posted by Brad (Post 552931)
Yer site ain't loading thar Monkey boy.

Yes I know ATAC 3.0.0 is over here anyhow. We're in a dispute with our server provider at the moment, site will hopefully be back up and running sometime in the future else we'll have to find a new host.


All times are GMT -4. The time now is 01:23.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.