AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=109)
-   -   [DEV] *DEAD* TF2ItemsInfo v1.8.17.7 (21 Nov 2013) (https://forums.alliedmods.net/showthread.php?t=182918)

Leonardo 04-15-2012 06:02

[DEV] *DEAD* TF2ItemsInfo v1.8.17.7 (21 Nov 2013)
 
4 Attachment(s)
Announcement!
Since I have no free time, also due to lack of interest, I cannot support this plugin anymore. I hope someone would make a mem-hacking version.

MEMORY LEAK FIX
https://forums.alliedmods.net/showpost.php?p=2177564


============================================= =============================================

What is it?
List of natives that could be useful for plugin devs.
What uses this?
* [TF2Items] Bot Weapon Randomizer
* [TF2Items] Give Weapon
* Many private plugins
Who is credit to team?
* Mecha The Slag - original idea;
* FlaminSarge - bug fixes,
* 11530 - bug reports.
How to install?
* Download files from Links section (below)
* Put tf2itemsinfo.smx in /addons/sourcemod/plugins/
* Put tf2itemsinfo.txt in /addons/sourcemod/data/
* Put tf2itemsinfo.sp in /addons/sourcemod/scripting/
* Put tf2itemsinfo.inc in /addons/sourcemod/scripting/includes/
Optional:
Updater plugin.
How to configure?
Is not possible.
Known issues?
1/ Memory leak error. Temporary fix - manually load plugin back. Fixed!
2/ High memory usage (22MiB). Fixed (?).
ToDo list:
* Add function that returns a KeyValues per item;
* Add function that returns item model;
* Add function that returns item styles.
CVars & CMDs:
PHP Code:

// variables
sm_tf2ii_version // version
sm_tf2ii_logs 1 // Enable/disable logs
sm_tf2ii_db "" // DB name (from databases.cfg)
sm_tf2ii_fix01 0 // Fix items with 'string' attributes
sm_tf2ii_updater 1 // enable/disable autoupdate
// commands
sm_tf2ii_refresh // rescan items_game.txt
sm_tf2ii_reload // same as above
sm_si <name> [pagenum// find items ids by name
sm_fi <name> [pagenum// same as above
sm_sic <classname> [pagenum// find items ids by classname
sm_fic <classname> [pagenum// same as above
sm_ii <id> [extra// print item info (extra value - anything except 0)
sm_pi [id] [extra// print item info (extra value - anything except 0)
sm_sa <id|name> [pagenum// find attributes ids by id or name
sm_fa <id|name> [pagenum// same as above
sm_sac <classname> [pagenum// find attributes ids by classname
sm_fac <classname> [pagenum// same as above 

Natives, functions, etc:
Basic data getting functions
Validating functions
Getting item data
Getting attribute data
Additional functions
Other stuff
Raw item/attribute data
Getting lists
Fowrards (events)
Stock functions


Changelogs:
Spoiler

Leonardo 04-15-2012 06:12

Re: [DEV] TF2 Item Info v1.2 (15.04.12)
 
Getting item information
PHP Code:

// example: Baseball Bat
new iItemDefID 44;

TF2II_IsValidItemIDiItemDefID );
// result: true (item exists in items_game.txt)

decl String:strName[32];
TF2II_GetItemNameiItemDefIDstrNamesizeof(strName) );
// result: "The Sandman"
// note: name from items_game.txt and in-game name may be different

decl String:strClassname[64];
TF2II_GetItemClassiItemDefIDstrClassnamesizeof(strClassname) );
// result: "tf_weapon_bat_wood"

decl String:strSlot[16];
TF2II_GetItemSlotNameiItemDefIDstrSlotsizeof(strSlot) );
// result: "melee"

TF2II_IsItemUsedByClassiItemDefIDTFClass_Scout );
// result: true
TF2II_IsItemUsedByClassiItemDefIDTFClass_Spy );
// result: false

// correct method to get item level
new iMinLeveliMaxLeveliLevel;
iMinLevel TF2II_GetItemMinLeveliItemDefID );
// result: 15
iMaxLevel TF2II_GetItemMaxLeveliItemDefID );
// result: 15
iLevel GetRandomIntiMinLeveliMaxLevel );
// result: 15

decl String:strQuality[16];
TF2II_GetItemSlotNameiItemDefIDstrQualitysizeof(strQuality) );
// result: "unique"
new iQuality TF2II_GetQualityByNamestrQuality );
// result: TF2ItemQuality_Unique (6)

// getting attributes
new iNumAttributesiAIndexes[16], Float:flAValues[16];
iNumAttributes TF2II_GetItemNumAttributesiItemDefID );
if( 
iNumAttributes )
{
    for( new 
0< ( iNumAttributes 16 16 iNumAttributes ); a++ )
    {
        
iAIndexes[a] = TF2II_GetItemAttributeIDiItemDefID);
        
flAValues[a] = TF2II_GetItemAttributeValueiItemDefID);
    }
}
// result:
// 38: 1.0 -- mod bat launches balls
// 125: -15.0 -- max health additive penalty 

Qualities
PHP Code:

decl String:strQualityName[16];
TF2II_GetQualityName11strQualityNamesizeof(strQualityName) );
// result: "strange"

new iQualityNum TF2II_GetQualityByNamestrQualityName );
// result: 11 

Attributes
PHP Code:

new iAttributeIndex TF2II_GetAttributeIDByName"damage penalty" );
// result: 1

decl String:strAttributeName[32];
TF2II_GetAttributeNameByID2strAttributeNamesizeof(strAttributeName) );
// result: "damage bonus" 

Holiday restriction
PHP Code:

// Mildly Disturbing Halloween Mask
new iItemDefID 115;

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_Birthday );
// result: false

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_Christmas );
// result: false

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_Halloween );
// result: true

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_FullMoon );
// result: true

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_HalloweenOrFullMoon );
// result: true 

Equip regions
PHP Code:

// Spine-Chilling Skull
new iItemDefID 287;

decl String:strItemEquipRegion[16];
new 
Handle:hEquipReqions TF2II_GetItemEquipRegionsiItemDefID );

GetArrayStringhItemEquipRegions0strItemEquipRegionsizeofstrItemEquipRegion ) );
PrintToServer"Item %d - region 1 - '%s'"iItemDefIDstrItemEquipRegionstrItemEquipRegion );
// result: Item 287 - reqgion 1 - 'hat'

GetArrayStringhItemEquipRegions1strItemEquipRegionsizeofstrItemEquipRegion ) );
PrintToServer"Item %d - region 2 - '%s'"iItemDefIDstrItemEquipRegionstrItemEquipRegion );
// result: Item 287 - reqgion 2 - 'face'

// also, conflicts

TF2II_IsConflictRegions"arms""face" );
// result: false

TF2II_IsConflictRegions"whole_head""face" );
// result: true 

Getting items by conditions
PHP Code:

new Handle:hArray TF2II_FindItems();
// result: array with ALL items (even with keys, crates, and gifts)

TF2II_FindItems"tf_weapon_sword" );
// get items with 'tf_weapon_sword' classname only

TF2II_FindItemsIDsByCond_"melee" );
// melee only

new iUsedByClasses TF2II_CLASS_NONE// Used by nobody
iUsedByClasses TF2II_CLASS_ENGINEER; -- Used by engineer only
iUsedByClasses 
TF2II_CLASS_DEMOMAN TF2II_CLASS_SOLDIER; -- Used by soldier and demoman only
iUsedByClasses 
TF2II_CLASS_ALL; -- Used by any class
TF2II_FindItemsIDsByCond__iUsedByClasses );
// get items that can be used by selected classes

TF2II_FindItems___"paint_can" );
// get paint cans only

// you also can combine conditions

TF2II_FindItemsIDsByCond_"melee"TF2II_CLASS_SOLDIER );
// get soldier's melee weapons only 


FlaminSarge 04-15-2012 19:00

Re: [DEV] TF2 Item Info v1.3 (15.04.12)
 
Will be implemented in Randomizer/GiveWeapon soon! Awesome job! Better than ItemsGame manager.

Flacketeer 04-22-2012 21:51

Re: [DEV] TF2 Item Info v1.5 (19.04.12)
 
Hello, I've been getting a problem with the Bot Weapon Randomizer Mod. I noticed someone in the thread (which you asked to discuss it here instead) had the same problem were in the bots had only stock weapons and my console was spammed with this message:

Code:

L 04/22/2012 - 20:42:38: [SM] Native "TF2Items_SetQuality" reported: Quality out
 of bounds: 13 [-1 ... 11]
L 04/22/2012 - 20:42:38: [SM] Displaying call stack trace for plugin "tf2ibwr.sm
x":
L 04/22/2012 - 20:42:38: [SM]  [0]  Line 386, E:\_DedicatedServers\TF2\orangebo
x\tf\addons\sourcemod\scripting\tf2ibwr.sp::Timer_HookedEvent()

and once in awhile I'd get this:

Code:

L 04/22/2012 - 20:45:35: [SM] Native "TF2Items_SetQuality" reported: Quality out
 of bounds: 13 [-1 ... 11]
L 04/22/2012 - 20:45:35: [SM] Displaying call stack trace for plugin "tf2ibwr.sm
x":
L 04/22/2012 - 20:45:35: [SM]  [0]  Line 386, E:\_DedicatedServers\TF2\orangebo
x\tf\addons\sourcemod\scripting\tf2ibwr.sp::Timer_HookedEvent()
material models/player/items/all_class/all_halo has a normal map and $basealphae
nvmapmask.  Must use $normalmapalphaenvmapmask to get specular.

and these:

Code:

L 04/22/2012 - 20:41:26: [SM] Native "TF2Items_SetQuality" reported: Quality out
 of bounds: 13 [-1 ... 11]
L 04/22/2012 - 20:41:26: [SM] Displaying call stack trace for plugin "tf2ibwr.sm
x":
L 04/22/2012 - 20:41:26: [SM]  [0]  Line 386, E:\_DedicatedServers\TF2\orangebo
x\tf\addons\sourcemod\scripting\tf2ibwr.sp::Timer_HookedEvent()
DataTable warning: env_sprite: Out-of-range value (1.000000) in SendPropFloat 'm
_vecNormal', clamping.

I tried typing sm plugins info tf2itemsinfo and got this:

Code:

sm plugins info tf2itemsinfo
  Filename: tf2itemsinfo.smx
  Title: [DEV] TF2 Items Info (Obtaining item info)
  Author: Leonardo
  Version: 1.5
  URL: http://xpenia.org/
  Status: running
  Reloads: Map Change if Updated
  Timestamp: 04/22/2012 23:55:43

Any help in solving this issue would be great. I think this is a wonderful plugin and would love to enjoy it to its fullest extent.

Leonardo 04-23-2012 03:18

Re: [DEV] TF2 Item Info v1.5 (19.04.12)
 
nope. this error goes here

Powerlord 05-17-2012 12:00

Re: [DEV] TF2 Item Info v1.8 (15.05.12)
 
Is there any particular reason that bUsedByClass doesn't use their TFClassType values as its indexes?

Leonardo 05-17-2012 13:10

Re: [DEV] TF2 Item Info v1.8 (15.05.12)
 
TFClassType begins from 1
'unknown' class isn't allowed here
k?

Powerlord 05-17-2012 13:13

Re: [DEV] TF2 Item Info v1.8 (15.05.12)
 
Quote:

Originally Posted by Leonardo (Post 1710704)
TFClassType begins from 1
'unknown' class isn't allowed here
k?

But you still have a tenth ("Jesus") class as one of the slots, which would neatly fill the empty spot.

Besides which, arrays with the first item empty is fairly common in arrays that use player indexes.

Leonardo 05-17-2012 13:24

Re: [DEV] TF2 Item Info v1.8 (15.05.12)
 
I'll fix it if you tell me how to get size of an enum~

Powerlord 05-17-2012 13:27

Re: [DEV] TF2 Item Info v1.8 (15.05.12)
 
Quote:

Originally Posted by Leonardo (Post 1710712)
I'll fix it if you tell me how to get size of an enum~

Quoting asherkin from another thread:

Quote:

Originally Posted by asherkin (Post 1685437)
An enum = a list of named values, i.e.
Code:

enum AnEnum
{
    AnEnum_FirstValue,
    AnEnum_SecondValue,
    AnEnum_ThirdValue,
    AnEnum_FourthValue,
    AnEnum_FifthValue,
};

Now, if you print the values of each, you get:
AnEnum_FirstValue = 0
AnEnum_SecondValue = 1
AnEnum_ThirdValue = 2
AnEnum_FourthValue = 3
AnEnum_FifthValue = 4

This works with arrays because the name of the enum evaluates to the next number that would be assigned to an entry in it (AnEnum = 5),
so if you do
Code:

new AnArray[AnEnum];
you get an array with 5 members

In fact, this should work regardless because even sparse enums (with skipped values) will have a large enough array to store all values if you use the enum name. I actually just learned this today...


All times are GMT -4. The time now is 05:49.

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