Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.

  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

[TF2] Items Schema Cache/API


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 Adminek AMXX.PL

    Admin :)

  • Bot

Reputacja: 156
Profesjonalista

  • Postów:7179
  • Lokalizacja:AMXX.PL
Offline

Napisano 22.05.2013 22:28

<!-- BEGIN TEMPLATE: postbit_external -->
<div>This plugins fetches the item schema from the <a href="http://wiki.teamfort...ebAPI/GetSchema" target="_blank">Steam WEB API</a> using your supplied <a href="http://steamcommunity.com/dev/apikey" target="_blank">API key</a>. Some information from the items can then be obtained from natives.<br /><br /><font size="5"><b><u>CVARs:</u></b></font><br /><!-- BEGIN TEMPLATE: bbcode_code_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><b>itemsapi_version</b>: version number, for tracking (don't change)<br /><b>itemsapi_key</b>: Your Steam API Key. This is yours, do not share this<br /><b>itemsapi_ival</b>: (60) Minimum time to update the schema in minutes</code><hr />
</div>
<!-- END TEMPLATE: bbcode_code_printable -->You must supply an API key to fetch the schema, you can get one here: <a href="http://steamcommunity.com/dev/apikey" target="_blank">http://steamcommunity.com/dev/apikey</a><br /><br /><font size="5"><b><u>Natives/Types:</u></b></font>:<br /><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">enum&nbsp;TFiaSlotType<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_unknown</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;items&nbsp;will&nbsp;never&nbsp;be&nbsp;put&nbsp;in&nbsp;this&nbsp;category,&nbsp;but&nbsp;it&nbsp;may&nbsp;have&nbsp;uses<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_head</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;this&nbsp;is&nbsp;the&nbsp;most&nbsp;important&nbsp;item&nbsp;class,&nbsp;so&nbsp;it&nbsp;comes&nbsp;first&nbsp;:)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_misc</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_action</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_primary</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_secondary</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_melee</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_building</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_pda</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_pda2</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">TFia_Slot_wearable</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;items&nbsp;will&nbsp;never&nbsp;be&nbsp;put&nbsp;in&nbsp;this&nbsp;category,&nbsp;but&nbsp;it&nbsp;may&nbsp;overridden&nbsp;to&nbsp;this&nbsp;category&nbsp;(ItemsApi_GetSlotEx)<br /></span><span style="color: #007700">};<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Returns&nbsp;true&nbsp;if&nbsp;the&nbsp;items&nbsp;schema&nbsp;is&nbsp;cached&nbsp;and&nbsp;available<br />&nbsp;*<br />**/<br /></span><span style="color: #0000BB">native&nbsp;bool</span><span style="color: #007700">:</span><span style="color: #0000BB">ItemsApi_Ready</span><span style="color: #007700">();<br /><br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Returns&nbsp;the&nbsp;item&nbsp;equip&nbsp;slot&nbsp;of&nbsp;an&nbsp;item,&nbsp;unknown&nbsp;on&nbsp;failure<br />&nbsp;*<br />&nbsp;*&nbsp;@param&nbsp;num1&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;Item&nbsp;Definition&nbsp;Index<br />**/<br /></span><span style="color: #0000BB">native&nbsp;TFiaSlotType</span><span style="color: #007700">:</span><span style="color: #0000BB">ItemsApi_GetSlot</span><span style="color: #007700">(</span><span style="color: #0000BB">index</span><span style="color: #007700">);<br /><br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Returns&nbsp;the&nbsp;item&nbsp;equip&nbsp;slot&nbsp;of&nbsp;an&nbsp;item,&nbsp;unknown&nbsp;on&nbsp;failure<br />&nbsp;*&nbsp;Use&nbsp;this&nbsp;to&nbsp;filter&nbsp;out&nbsp;"tf_wearable"&nbsp;items&nbsp;which&nbsp;may&nbsp;be&nbsp;returned&nbsp;as&nbsp;weapons&nbsp;otherwise&nbsp;(items&nbsp;like&nbsp;the&nbsp;razorback&nbsp;or&nbsp;buff&nbsp;banner)<br />&nbsp;*<br />&nbsp;*&nbsp;@param&nbsp;num1&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;Item&nbsp;Definition&nbsp;Index<br />&nbsp;*&nbsp;@param&nbsp;num2&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;TFiaSlotType&nbsp;to&nbsp;override&nbsp;the&nbsp;return&nbsp;slot&nbsp;index&nbsp;if&nbsp;it&nbsp;is&nbsp;a&nbsp;"tf_werable"&nbsp;but&nbsp;not&nbsp;a&nbsp;TFia_Slot_head&nbsp;or&nbsp;TFia_Slot_misc&nbsp;type&nbsp;(usually&nbsp;a&nbsp;weapon&nbsp;wearable)<br />**/<br /></span><span style="color: #0000BB">native&nbsp;TFiaSlotType</span><span style="color: #007700">:</span><span style="color: #0000BB">ItemsApi_GetSlotEx</span><span style="color: #007700">(</span><span style="color: #0000BB">index</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">TFiaSlotType</span><span style="color: #007700">:</span><span style="color: #0000BB">weapon_wearable&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">TFia_Slot_wearable</span><span style="color: #007700">);<br /><br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Returns&nbsp;true&nbsp;if&nbsp;an&nbsp;item&nbsp;is&nbsp;paintable<br />&nbsp;*<br />&nbsp;*&nbsp;@param&nbsp;num1&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;Item&nbsp;Definition&nbsp;Index<br />**/<br /></span><span style="color: #0000BB">native&nbsp;bool</span><span style="color: #007700">:</span><span style="color: #0000BB">ItemsApi_Paintable</span><span style="color: #007700">(</span><span style="color: #0000BB">index</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Returns&nbsp;true&nbsp;if&nbsp;an&nbsp;item&nbsp;is&nbsp;wearable&nbsp;(tf_wearable)<br />&nbsp;*<br />&nbsp;*&nbsp;@param&nbsp;num1&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;Item&nbsp;Definition&nbsp;Index<br />**/<br /></span><span style="color: #0000BB">native&nbsp;bool</span><span style="color: #007700">:</span><span style="color: #0000BB">ItemsApi_Wearable</span><span style="color: #007700">(</span><span style="color: #0000BB">index</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Returns&nbsp;length&nbsp;of&nbsp;string&nbsp;written&nbsp;to&nbsp;buffer,&nbsp;0&nbsp;on&nbsp;failure.<br />&nbsp;*<br />&nbsp;*&nbsp;@param&nbsp;num1&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;Item&nbsp;Definition&nbsp;Index<br />&nbsp;*&nbsp;@param&nbsp;num2&nbsp;&nbsp;&nbsp;&nbsp;buffer&nbsp;to&nbsp;write&nbsp;item&nbsp;name.<br />**/<br /></span><span style="color: #0000BB">native&nbsp;ItemsApi_GetName</span><span style="color: #007700">(</span><span style="color: #0000BB">index</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">String</span><span style="color: #007700">:</span><span style="color: #0000BB">name</span><span style="color: #007700">[]);&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><font size="5"><b><u>Commands:</u></b></font><ul><li><b>sm_itemsapi_reload</b>: (Rcon) Force manual update of the item schema. </li>
</ul><br /><!-- BEGIN TEMPLATE: bbcode_code_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<hr /><code style="margin:0px" dir="ltr" style="text-align:left">2013-5-22 (v1.0.0)<br />* Initial Release</code><hr />
</div>
<!-- END TEMPLATE: bbcode_code_printable --><font size="5"><b><u>Requirements:</u></b></font><ul><li><a href="http://forums.allied...ead.php?t=67640" target="_blank">Socket</a></li>
</ul><br /><font size="5"><b><u>Notes:</u></b></font><br />The names of STOCK ITEMS have been altered (by me) to be more display friendly. I have removed the classes, &quot;TF_WEAPON&quot; and converted &quot;Upgradable&quot; to &quot;Strange&quot; for example &quot;Upgradable TF_WEAPON_PIPEBOMBLAUNCHER&quot; will be returned as &quot;Strange Pipebomblauncher&quot; when the name is requested. Likewise &quot;TF_WEAPON_BAT&quot; is returned simply as &quot;Bat&quot;. I'll probably add a convar to disable this later.<br /><br />The item schema will only be refreshed on map change, even if the interval ends. This is just the minimum time at which to allow for updates (file time). If you force the schema to update manually, it will.. however it may spike the server for a split second or so.<br /><br />If the schema fails to update (for whatever reason), it should fall back to using the cached file. All attempts to generate a new one are made on a temporary file. This *should* ensure that you will always have some working version of something. I still suggest you call ItemsApi_Ready from your plugin to make sure that info is available at least somewhere before you start doling out items and attributes, or all of your calls will return empty/failed values if it's not.<br /><br />I made this because I needed an easy way to classify weapons into slots for applying effects via tf2items. When parsing items_game, the format would often change, and I would have to go in and edit out the mistake, make exceptions, or other such nonsense. For example, I have a plugin that grants players increased rate of fire, attack speed, and build rate with OnGiveNamedItem. Using ItemsApi_GetSlotEx, I can safely filter out werables (razorback, buff banner, etc) and apply melee attack speed to all TFia_Slot_melee, and rate of fire to all TFia_Slot_primary and TFia_Slot_secondary, without having to worry about the random hat/item getting superfluous effects.<br /><br />With this it is trivial to build menus to display item names, check if items can be made paintable, etc. It would be possible for me to add more item information, but I believe this is the most important/useful. If anyone could think of other stuff that is vital, go ahead and comment. If there is a lot of stuff, I could probably pack the information into a deliminated string and store it that way.. for now I tried to keep it somewhat fast/simple :/<br /><br />I borrowed most of the socket code from McKay's SMDJ because I know it works, and I couldn't find much info around to show exactly how to fetch just one file, which is all I needed to do o: <a href="http://forums.allied...ad.php?t=172258" target="_blank">http://forums.allied...ad.php?t=172258</a><br /><br /><font size="5"><b><u>Plans:</u></b></font><ul><li>Add an option to fetch an externally cached version of the schema so that users do not need to use an API Key</li>
<li>Add a ConVar to enable/disable display friendly names on stock items</li>
</ul></div>


<br /> <div style="padding:6px">








<fieldset class="fieldset">
<legend>Attached Files</legend>
<table cellpadding="0" cellspacing="3" border="0">
<!-- BEGIN TEMPLATE: postbit_attachment -->
<tr>
<td><img class="inlineimg" src="https://forums.allie...s/attach/sp.gif" alt="File Type: sp" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>


<a href="http://www.sourcemod...?file_id=120165"><strong>Get Plugin</strong></a> or
<a href="https://forums.allie...38;d=1369257938">Get Source</a> (itemsapi.sp - 13.3 KB)


</td>
</tr>
<!-- END TEMPLATE: postbit_attachment --><!-- BEGIN TEMPLATE: postbit_attachment -->
<tr>
<td><img class="inlineimg" src="https://forums.allie.../attach/inc.gif" alt="File Type: inc" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>


<a href="https://forums.allie...38;d=1369257941">itemsapi.inc</a> (2.3 KB)


</td>
</tr>
<!-- END TEMPLATE: postbit_attachment -->
</table>
</fieldset>


</div>

<!-- END TEMPLATE: postbit_external -->

Wyświetl pełny artykuł




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych