Raised This Month: $ Target: $400
 0% 

Help with Forwarding Strings


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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