Raised This Month: $32 Target: $400
 8% 

String to function :o


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 09-14-2007 , 09:12   String to function :o
Reply With Quote #1

Is there any way to convert a string to function and call the function with parameters?
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
dalto
Veteran Member
Join Date: Jul 2007
Old 09-14-2007 , 09:41   Re: String to function :o
Reply With Quote #2

Quote:
Originally Posted by Shaman View Post
Is there any way to convert a string to function and call the function with parameters?
There sure is.

http://wiki.alliedmods.net/Function_...d_Scripting%29
dalto is offline
BAILOPAN
Join Date: Jan 2004
Old 09-14-2007 , 16:41   Re: String to function :o
Reply With Quote #3

What you can't do is stuff like this:

Code:
new String:crab[] = "hello(a, b, 5);"; crab();
^--- nonsense
__________________
egg
BAILOPAN is offline
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 09-15-2007 , 07:29   Re: String to function :o
Reply With Quote #4

I wasn't trying to do something like that. I have functions that return menu handles:
Code:
public Handle:Menu_Main...
public Handle:Menu_Options...
public Handle:Menu_Skills...
and I wanted to make a simple function like "ShowMenu(client, menu_name, time)" to make this simpler:
PHP Code:
stock ShowMenu(client, const String:menu_name[], time=MENU_TIME_FOREVER)
    {
    
//Format the function name
    
new String:func_name[32];
    
Format(func_name32"Menu_%s"menu_name)
    
//Get the function id
    
new Function:func=GetFunctionByName(INVALID_HANDLEfunction_name);
    
//Return if the function is invalid
    
if(func==INVALID_FUNCTION)
        return;
    
//Start the call
    
Call_StartFunction(INVALID_HANDLEfunc);
    
//Push variable 'client'
    
Call_PushCell(client);
    
//Get the menu handle
    
new Handle:menuINVALID_HANDLE;
    
Call_Finish(menu);
    
//Return if the menu handle is invalid
    
if(menu==INVALID_HANDLE)
        return;
    
//Display the menu
    
DisplayMenu(menuclienttime);
    } 
I don't know it works or not. I have to do more coding before I test the plugin.
__________________

Last edited by Shaman; 09-15-2007 at 07:39.
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
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 05:44.


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