From f4eb06d210840705bd9f7aefd18025a35f6c0434 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Sun, 30 Aug 2009 11:47:01 -0700 Subject: [PATCH] Small fix in voice.inc to stop changing voice permissions with a client's self. Added the API functions for shoppinglist.inc but they don't do anything, they are just a sneak-peak into the way it will work, any feedback on your opinion would be nice. --- src/zombiereloaded.sp | 1 + src/zr/shoppinglist.inc | 109 ++++++++++++++++++++++++++++++++++ src/zr/soundeffects/voice.inc | 6 ++ 3 files changed, 116 insertions(+) create mode 100644 src/zr/shoppinglist.inc diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 405db59..14fea07 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -64,6 +64,7 @@ #include "zr/cookies" #include "zr/paramtools" #include "zr/paramparser" +#include "zr/shoppinglist" #include "zr/models" #include "zr/downloads" #include "zr/overlays" diff --git a/src/zr/shoppinglist.inc b/src/zr/shoppinglist.inc new file mode 100644 index 0000000..9f92f7f --- /dev/null +++ b/src/zr/shoppinglist.inc @@ -0,0 +1,109 @@ +/* + * ============================================================================ + * + * Zombie:Reloaded + * + * File: shoppinglist.inc + * Type: Core + * Description: Module to handle shopping list style lists. + * + * Copyright (C) 2009 Greyscale, Richard Helgeby + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * ============================================================================ + */ + +/** + * This file is meant for formatting a given string into a list formatted around the style of a shopping + * list. + * Example: + * String: "Bacon, Egg, Egg, Milk, Butter" + * Shopping List: "Bacon, Eggx2, Milk, Butter" + * Function parameters will include options to change the "," to any character. As well as the "x2" format. + * + * More complex examples: + * String: "Red - Green - Blue-Red- Green -Green - Yellow -Grey" Note: Horribly formatted, but we can handle it. + * Shopping List: "Red(2)\nGreen(3)\nBlue\nYellow\nGrey" Note: We can change what to separate each item with, as well as how to display the quantity. + * + * List Options: + * + * Parse: Take a string and dump out a list. Simple. + * Set: Easy to do without this API, but maybe we can simplify it a little. + * Add: Should be a simple format. May be in the API just to simplify it a bit. + * Remove: Removes an item from the list. Must remove from the end to preserve list order. + * + * Scenario: + * String: "Apple, Orange, Mango, Orange" + * Shopping List: "Apple, Orange x2, Mango" + * Remove: "Orange" + * Remove first orange: "Apple, Mango, Orange" Different order. + * Remove last orange: "Apple, Orange, Mango" Yay. + * + */ + +/** + * Takes a given string and outputs a re-formatted shopping list styled list. See description above. + * Note: This is for display purposes only, meaning there will be no API made to format the output of this function. + * If you plan on the list being dynamic, store the raw string and use the API to edit those. + * + * @param list Raw string to be formatted. + * @param list_maxlen The maximum length of the raw string. + * @param shoppinglist Outputted shopping list. + * @param slist_maxlen The maximum length of the shopping list. + * @param in_token The token used to separate each item in the raw string. Ex: "Apple, Orange" Token: "," + * @param out_token What to separate each item with in the shopping list. Ex: Token: "\n" List: "Apple\nOrange" + * @param quantityformat How to show the quantity of an item for multi-listed items. %d is the number. Ex: "Apples x2" quantityformat: " x%d" + */ +stock ShoppingListFormat(const String:list[], list_maxlen, String:shoppinglist[], slist_maxlen, const String:in_token[] = ",", const String:out_token[] = ",", const String:quantityformat[] = " x%d") +{ +} + +/** + * Set the list to a given string array of items. + * + * @param list The variable to store new list in. + * @param maxlen The maximum length of the finished list. + * @param items The items to construct into the list. + * @param maxitems The number of array indexes from 0 to process for the list. + * @param token The token to use to append the item. Set to "" to auto-detect an existing token, if + * there is only one item in the list, this parameter won't be used. + */ +stock ShoppingListConstruct(String:list[], maxlen, const String:items[][], maxitems, const String:token) +{ +} + +/** + * Add an item to the list. + * + * @param list The list to add item to. + * @param maxlen The maximum length of the finished list. + * @param item The item to add to the list. + * @param token The token to use to append the item. Set to "" to auto-detect an existing token, if + * this is the first item in the list, this parameter won't be used. + */ +stock ShoppingListAppend(String:list[], maxlen, const String:item[], const String:token) +{ +} + +/** + * Add an item to the list. + * + * @param list The list to remove item from. + * @param maxlen The maximum length of the finished list. + * @param item The item to remove from the list. + */ +stock ShoppingListRemove(String:list[], maxlen, const String:item[]) +{ +} \ No newline at end of file diff --git a/src/zr/soundeffects/voice.inc b/src/zr/soundeffects/voice.inc index 9a6fec9..f846956 100644 --- a/src/zr/soundeffects/voice.inc +++ b/src/zr/soundeffects/voice.inc @@ -167,6 +167,12 @@ stock VoiceSetClientTeam(client, bool:zombie) continue; } + // No need to alter listening/speaking flags between one client. + if (client == x) + { + continue; + } + // Client can only listen/speak if the sender is on their team. new bool:canlisten = (zombie == InfectIsClientInfected(x));