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

SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011


Post New Thread Reply   
 
Thread Tools Display Modes
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 08-22-2014 , 15:56   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #371

I've found myself reusing some cookie & menu int/bool functions recently.

Example with cookies and ints:
Code:
/**
 * Sets a cookie to an integer value by converting it to a string.
 */
public void SetCookieInt(int client, Handle cookie, int value) {
    char buffer[INTEGER_STRING_LENGTH];
    IntToString(value, buffer, sizeof(buffer));
    SetClientCookie(client, cookie, buffer);
}

/**
 * Fetches the value of a cookie that is an integer.
 */
public int GetCookieInt(int client, Handle cookie) {
    char buffer[INTEGER_STRING_LENGTH];
    GetClientCookie(client, cookie, buffer, sizeof(buffer));
    return StringToInt(buffer);
}

My question is: there is a way to get around doing things like this? The lack of something like this makes me thing I'm doing something wrong.

If not, would something like this be accepted into smlib? (with better naming and not-1.7 syntax of course)
__________________

Last edited by splewis; 08-23-2014 at 00:07.
splewis is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 08-23-2014 , 13:08   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #372

I don't really see much of a use case for them, as they basically do just String to int conversion.
However if you want them in you can create a pull request (follow the contribution guidelines).
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 08-23-2014 , 13:44   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #373

Quote:
Originally Posted by berni View Post
I don't really see much of a use case for them, as they basically do just String to int conversion.
However if you want them in you can create a pull request (follow the contribution guidelines).
I was mainly curious if there was a better way to write menu/cookie logic when things aren't stringy by nature. Since I haven't seem similar functions before I thought maybe I was just doing things a stupid way.

Here's my general use case, giving menu options across an enum:

Code:
enum MapType {
    MapType_Current,
    MapType_Vote,
    MapType_Veto
};

...


    Handle menu = CreateMenu(SetupMenuHandler);
    SetMenuTitle(menu, "How will teams be setup?");
    SetMenuExitButton(menu, false);
    AddMenuInt(menu, _:TeamType_Captains, "Assigned captains pick their teams");
    AddMenuInt(menu, _:TeamType_Random, "Random teams");
    AddMenuInt(menu, _:TeamType_Manual, "Players manually switch teams");
    DisplayMenu(menu, client, MENU_TIME_FOREVER);


...

public SetupMenuHandler(Handle menu, MenuAction action, param1, param2) {
    if (action == MenuAction_Select) {
        int client = param1;
        g_TeamType = TeamType:GetMenuInt(menu, param2);
    } else if (action == MenuAction_End) {
        CloseHandle(menu);
    }
}
__________________
splewis is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 08-23-2014 , 13:48   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #374

looks fine to me.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 10-18-2014 , 08:18   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #375

Does it support CS:GO chat colors?
iGANGNAM is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 10-20-2014 , 04:37   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #376

There is support for CS:GO hex color tags in the GIT master branch. See: https://github.com/bcserv/smlib/issu...mment-13351277
Named CS:GO tags will be maybe added later.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 10-20-2014 at 04:38.
berni is offline
psychonic

BAFFLED
Join Date: May 2008
Old 10-20-2014 , 06:46   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #377

Quote:
Originally Posted by berni View Post
There is support for CS:GO hex color tags in the GIT master branch. See: https://github.com/bcserv/smlib/issu...mment-13351277
Named CS:GO tags will be maybe added later.
CS:GO does not support those.
psychonic is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 10-20-2014 , 15:04   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #378

Then there is no support for special CS:GO colors at the moment, sorry.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 10-20-2014 , 15:16   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #379

Atleast something like this is supported, right? http://pastebin.com/rat0z1Cd

Last edited by iGANGNAM; 10-20-2014 at 15:16.
iGANGNAM is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 10-20-2014 , 16:14   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #380

You can find the table of color tags on the first page of this thread.
I can look into adding support for new color systems when I find some time.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Reply


Thread Tools
Display Modes

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 19:41.


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