Raised This Month: $ Target: $400
 0% 

DataPack and Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jasonbourne
Senior Member
Join Date: Nov 2011
Location: Sydney , AUS
Old 10-10-2012 , 04:05   DataPack and Menu
Reply With Quote #1

Hey guys

Ive tried using a datapack but i just cant seem to send variables into a menu handler
PHP Code:
db_loltest(client,String:szMapName[MAX_MAP_LENGTH],String:szSteamId[32])
{
    new 
Handle:pack CreateDataPack();
    
WritePackCell(packclient);
    
WritePackString(packszMapName);
    
WritePackString(packszSteamId);
    
    new 
Handle:menu CreateMenu(Menu_Handler);
    
SetMenuTitle(menu"LOL");
    
decl String:buffer[10], i;
    for(new 
0i7i++)
    {
        
Format(buffersizeof(buffer), "%d"i);
        
AddMenuItem(menubufferi);
    }
    
DisplayMenu(menuclientMENU_TIME_FOREVER);
}
public 
Menu_Handler(Handle:menuMenuAction:actionparam1param2){
    if(
action == MenuAction_Select)
    {
        
//new Handle:pack = data;
        
ResetPack(pack);
        new 
client ReadPackCell(pack); //client
        
decl String:szMapName[MAX_MAP_LENGTH];
        
ReadPackString(packszMapNameMAX_NAME_LENGTH);
        
decl String:szSteamId[32];
        
ReadPackString(packszSteamId32);
        
decl String:info[10];
        
GetMenuItem(menuparam2infosizeof(info));

        
db_anotherfunction(param1szSteamIdszMapNameBhopLevel:StringToInt(info));
    }
    else if(
action == MenuAction_End)
        
CloseHandle(menu);


Last edited by Jasonbourne; 10-10-2012 at 04:08.
Jasonbourne is offline
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 10-10-2012 , 05:42   Re: DataPack and Menu
Reply With Quote #2

...How are you sending the pack to the menu?
Datapacks don't magically appear in callbacks, you need to send it somehow.
__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING
minimoney1 is offline
Jasonbourne
Senior Member
Join Date: Nov 2011
Location: Sydney , AUS
Old 10-10-2012 , 05:48   Re: DataPack and Menu
Reply With Quote #3

Thats what i dont know how todo :S
Jasonbourne is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 10-10-2012 , 09:13   Re: DataPack and Menu
Reply With Quote #4

For MenuAction_Select, param1 is client and param2 is the item they selected. Look at the MenuAction enum here for more info on what each parameter is for each case.
bl4nk is offline
Jasonbourne
Senior Member
Join Date: Nov 2011
Location: Sydney , AUS
Old 10-10-2012 , 09:25   Re: DataPack and Menu
Reply With Quote #5

Thanks bl4nk but i was wondering if there was an efficient way of passing variables/data through to the handler
Jasonbourne is offline
Jasonbourne
Senior Member
Join Date: Nov 2011
Location: Sydney , AUS
Old 10-10-2012 , 19:06   Re: DataPack and Menu
Reply With Quote #6

Maybe it just isnt possible with datapacks but there should be a different/better way
Jasonbourne is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 10-10-2012 , 19:33   Re: DataPack and Menu
Reply With Quote #7

It is entirely possible with a datapack, just have i be one of the values in the datapack, then use something to change the datapack's handle to a string, pass it as the info index, then convert it back on the other side.
necavi is offline
Jasonbourne
Senior Member
Join Date: Nov 2011
Location: Sydney , AUS
Old 10-10-2012 , 19:41   Re: DataPack and Menu
Reply With Quote #8

Quote:
Originally Posted by necavi View Post
It is entirely possible with a datapack, just have i be one of the values in the datapack, then use something to change the datapack's handle to a string, pass it as the info index, then convert it back on the other side.
Genius
I'll give it a go now

Last edited by Jasonbourne; 10-10-2012 at 19:42.
Jasonbourne is offline
Jasonbourne
Senior Member
Join Date: Nov 2011
Location: Sydney , AUS
Old 10-10-2012 , 21:30   Re: DataPack and Menu
Reply With Quote #9

Converting datapack into a string and back again is the issue.

Any documentation on it ?
Jasonbourne is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 10-10-2012 , 21:44   Re: DataPack and Menu
Reply With Quote #10

Format(buffer, sizeof(buffer), "%d", <handle to datapack>); new Handle:datapack = StringToInt(buffer);
necavi 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 02:50.


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