Raised This Month: $ Target: $400
 0% 

Help with Forwarding Strings


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lobopack23
Senior Member
Join Date: Jun 2009
Location: California , United Stat
Old 01-11-2014 , 02:16   Help with Forwarding Strings
Reply With Quote #1

So I read the Tutorial on Forwards. I know how to return integer/float based forwards but I can't seem to figure out how to do it for functions.

1st Goal:
Return a string from a function. (This has been one of my other issues)

2nd Goal: Forward that string, and use that string in another plugin.

For This Example, let us pretend someone wrote /increment twice.

Code:
#include <amxmodx>

new location[33]

enum LOCATION
{
        MYHOUSE = 0,
        FRIEND1,
        FRIEND2
}
 new const locationNames[LOCATION][] =
 {
        "My House",
        "First Friend House",
        "Second Friend House"
}

public plugin_init() 
{
    register_plugin("Forward String Test", "1.0", "Lobopack23") 
    register_concmd("say /mylocation","checklocation");
    register_concmd("say /increment","incrementlocation");  // just to make this more "realistic"
}

public incrementlocation(id)
{
    location[id]++
}

public checklocation(id)
{
    // TEST 1
    new iLocation = location[id]
    return locationNames[iLocation]

    /*
    // TEST 2, another way i tried to return it but failed..
    new iLocation = location[id]
    new temp[1024];
    formatex(temp, charsmax(temp), "%s", locationNames[iLocation] );
    return temp
    */
}
And this is how I was trying to forward the value to another plugin.

Code:
 locationForward(id)
 {
    new temp_return, temp_forward = CreateMultiForward( "checklocation", ET_STOP, FP_STRING );
    ExecuteForward( temp_forward, temp_return, id );
    DestroyForward( temp_forward );
    return temp_return;
 }
Any help, suggestions or etc would be appreciated.
__________________
- Steam: Lobopack23 - Link
Contact me if you need any help with Pokemod.
- 2nd Generation Pokemod - Link
(new skills, items, and pokemons)
- Buy Xp - Link

Last edited by lobopack23; 01-11-2014 at 02:17.
lobopack23 is offline
lobopack23
Senior Member
Join Date: Jun 2009
Location: California , United Stat
Old 01-11-2014 , 02:31   Re: Help with Forwarding Strings
Reply With Quote #2

I just wanted to add this because it was funny..
https://forums.alliedmods.net/showpo...87&postcount=1

and this..
https://forums.alliedmods.net/showpo...33&postcount=6
__________________
- Steam: Lobopack23 - Link
Contact me if you need any help with Pokemod.
- 2nd Generation Pokemod - Link
(new skills, items, and pokemons)
- Buy Xp - Link

Last edited by lobopack23; 01-11-2014 at 02:33. Reason: It's Funny Because It's True
lobopack23 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 01-11-2014 , 02:41   Re: Help with Forwarding Strings
Reply With Quote #3

Sounds like Dynamic Natives may be of better use here.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
lobopack23
Senior Member
Join Date: Jun 2009
Location: California , United Stat
Old 01-11-2014 , 05:41   Re: Help with Forwarding Strings
Reply With Quote #4

id prefer if someone taught me how to use the string method using COPY, that would be helpful
__________________
- Steam: Lobopack23 - Link
Contact me if you need any help with Pokemod.
- 2nd Generation Pokemod - Link
(new skills, items, and pokemons)
- Buy Xp - Link
lobopack23 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-11-2014 , 06:56   Re: Help with Forwarding Strings
Reply With Quote #5

You can't, you have to use dynamic native as hornet said, then in the plugin api use set_string to set the string in the calling plugin.

There is a tutorial by Hawk552 about dynamic natives, i can't remember if strings are covered but this is a good place to start to understand how dynamic natives work.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
lobopack23
Senior Member
Join Date: Jun 2009
Location: California , United Stat
Old 01-11-2014 , 14:40   Re: Help with Forwarding Strings
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
You can't, you have to use dynamic native as hornet said, then in the plugin api use set_string to set the string in the calling plugin.
Ah for sure. And I took a look at dynamic natives, im not sure how to use set_string though in my cas.
__________________
- Steam: Lobopack23 - Link
Contact me if you need any help with Pokemod.
- 2nd Generation Pokemod - Link
(new skills, items, and pokemons)
- Buy Xp - Link
lobopack23 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 01-12-2014 , 05:10   Re: Help with Forwarding Strings
Reply With Quote #7

Try having a look here https://forums.alliedmods.net/showthread.php?t=189454.
It's a short example on returning a string that I wrote some time ago - Scroll down to my first post.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 01-12-2014 at 05:11.
hornet is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:07.


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