AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   CSGO Items API (https://forums.alliedmods.net/showthread.php?t=279187)

SM9 02-21-2016 19:49

Re: CSGO Items API
 
Heres the first example plugin guys, https://bitbucket.org/SM91337/csgo-i...e-view-default

This is a dynamic weapon menu which is always up to date with new weapons valve may add to the game, could be very useful for a Deathmatch plugin or something. I am still working on improving and extending internals of the Item Core so Natives and Forwards may get changed, added and removed. Just a heads up one that one :P

asherkin 02-28-2016 17:38

Re: CSGO Items API
 
Quote:

Originally Posted by xCoderx (Post 2393783)
similar to TF2Item

Quote:

Originally Posted by xCoderx (Post 2393783)
lets bring TF2Items to CSGO, Its about time eh?!

This literally doesn't have a single piece of functionality in common with TF2Items (which is good, because a TF2Items-equivalent would trigger the auto-ban detection), you're probably thinking of plugins like "TF2 Item DB" and TF2ItemsInfo.

8guawong 08-03-2016 05:22

Re: CSGO Items API
 
can't compile the code on first post...

//// test3.sp
//
// C:\Users\xxx\Dropbox\sm 1.8\test3.sp(1) : error 010: invalid function or decl
aration
// C:\Users\xxx\Dropbox\sm 1.8\test3.sp(30) : error 017: undefined symbol "CSGOI
tems_GetActiveWeaponDefIndex"
// C:\Users\xxx\Dropbox\sm 1.8\test3.sp(31) : error 017: undefined symbol "CSGOI
tems_GetWeaponClipAmmoByDefIndex"
//
// 3 Errors.
//
// Compilation Time: 0.12 sec
// ----------------------------------------

root88 08-08-2016 06:22

Re: CSGO Items API
 
#include <csgoitems>

Neuro Toxin 08-08-2016 06:50

Re: CSGO Items API
 
Does this still read all the items data after Valve split the keys over multiple sections of games_items.txt?

Mitchell 08-10-2016 19:53

Re: CSGO Items API
 
will this ever support reading weapon's spread values etc?

8guawong 08-10-2016 21:45

Re: CSGO Items API
 
Quote:

Originally Posted by root88 (Post 2443242)
#include <csgoitems>

already included

SM9 08-11-2016 07:12

Re: CSGO Items API
 
Quote:

Originally Posted by Neuro Toxin (Post 2443248)
Does this still read all the items data after Valve split the keys over multiple sections of games_items.txt?

Indeed

Quote:

Originally Posted by Mitchell (Post 2443970)
will this ever support reading weapon's spread values etc?

Sure, I can get round to doing that at some point.

Quote:

Originally Posted by 8guawong (Post 2443995)
already included

Thats odd, you must be doing something wrong since it works fine on my end, can you show me contents of the csgoitems.inc you have?

Also just pushed an update to fix some stuff which valve broke in last csgo update.

8guawong 08-11-2016 10:09

Re: CSGO Items API
 
Quote:

Originally Posted by xCoderx (Post 2444085)
Indeed


Sure, I can get round to doing that at some point.


Thats odd, you must be doing something wrong since it works fine on my end, can you show me contents of the csgoitems.inc you have?

Also just pushed an update to fix some stuff which valve broke in last csgo update.

PHP Code:

#if defined _csgoitems_included_
#endinput
#endif
#define _csgoitems_included_

native int CSGOItems_GetWeaponCount();
native int CSGOItems_GetMusicKitCount();
native int CSGOItems_GetSkinCount();
native int CSGOItems_GetActiveWeaponCount(const char[] chClassNameint iTeam 0);

// WEAPONS
native int CSGOItems_GetWeaponNumByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponNumByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponDefIndexByWeaponNum(int iWeaponNum);
native bool CSGOItems_GetWeaponDefIndexByClassName(const char[] chClassName);
native bool CSGOItems_GetWeaponClassNameByWeaponNum(int iWeaponNumchar[] chBufferint iLengh);
native bool CSGOItems_GetWeaponClassNameByDefIndex(int iDefIndexchar[] chBufferint iLengh);
native bool CSGOItems_GetWeaponDisplayNameByDefIndex(int iDefIndexchar[] chBufferint iLengh);
native bool CSGOItems_GetWeaponDisplayNameByClassName(const char[] chClassNamechar[] chBufferint iLengh);
native bool CSGOItems_GetWeaponDisplayNameByWeaponNum(int iWeaponNumchar[] chBufferint iLengh);
native bool CSGOItems_IsDefIndexKnife(int iDefIndex);
native int CSGOItems_GetWeaponDefIndexByWeapon(int iWeapon);
native bool CSGOItems_GetWeaponClassNameByWeapon(int iWeaponchar[] chBufferint iLengh);
native int CSGOItems_GetActiveWeapon(int iClient);
native int CSGOItems_GetActiveWeaponDefIndex(int iClient);
native bool CSGOItems_GetActiveClassName(int iClientchar[] chBufferint iLengh);
native bool CSGOItems_IsSkinnableDefIndex(int iDefIndex);
native int CSGOItems_FindWeaponByClassName(int iClient, const char[] chClassName);
native int CSGOItems_GetActiveWeaponNum(int iClient);
native int CSGOItems_GetWeaponSlotByWeaponNum(int iWeaponNum);
native int CSGOItems_GetWeaponSlotByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponSlotByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponTeamByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponTeamByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponTeamByWeaponNum(int iWeaponNum);
native int CSGOItems_GetWeaponClipAmmoByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponClipAmmoByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponClipAmmoByWeaponNum(int iWeaponNum);
native int CSGOItems_GetWeaponReserveAmmoByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponReserveAmmoByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponReserveAmmoByWeaponNum(int iWeaponNum);
native int CSGOItems_GetWeaponKillAwardByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponKillAwardByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponKillAwardByWeaponNum(int iWeaponNum);
native bool CSGOItems_GetItemSetNumByClassName(const char[] chClassNamechar[] chBufferint iLengh);
native bool CSGOItems_GetItemSetDisplayNameByClassName(const char[] chClassNamechar[] chBufferint iLengh);
native bool CSGOItems_GetItemSetDisplayNameByItemSetNum(int iSetNumchar[] chBufferint iLengh);
native bool CSGOItems_RefillClipAmmo(int iWeapon);
native bool CSGOItems_RefillReserveAmmo(int iWeapon);
native bool CSGOItems_IsValidWeapon(int iWeapon);
native int CSGOItems_GiveWeapon(int iClient, const char[] chClassNameint iReserveAmmo = -1int iClipAmmo = -1int iSwitchTo = -1);
native bool CSGOItems_RemoveKnife(int iClient);
native bool CSGOItems_RemoveWeapon(int iClientint iWeapon);
native int CSGOItems_RemoveAllWeapons(int iClientint iSkipSlot = -1);
native bool CSGOItems_SetWeaponAmmo(int iWeaponint iReserveAmmo = -1int iClipAmmo = -1);
native int CSGOItems_SetAllWeaponsAmmo(const char[] chClassNameint iReserveAmmo = -1int iClipAmmo = -1);
native bool CSGOItems_SetActiveWeapon(int iClientint iWeapon);
native int CSGOItems_GetActiveWeaponSlot(int iClient);
native bool CSGOItems_AreItemsSynced();
native bool CSGOItems_AreItemsSyncing();
native bool CSGOItems_ReSync();
native int CSGOItems_GetRandomSkin();

// SKINS
native int CSGOItems_GetSkinNumByDefIndex(int iDefIndex);
native int CSGOItems_GetSkinDefIndexBySkinNum(int iSkinNum);
native bool CSGOItems_GetSkinDisplayNameByDefIndex(int iDefIndexchar[] chBufferint iLengh);
native bool CSGOItems_GetSkinDisplayNameBySkinNum(int iSkinNumchar[] chBufferint iLengh);

// MUSIC KITS
native int CSGOItems_GetMusicKitNumByDefIndex(int iDefIndex);
native int CSGOItems_GetMusicKitDefIndexByMusicKitNum(int iMusicKitNum);
native bool CSGOItems_GetMusicKitDisplayNameByDefIndex(int iDefIndexchar[] chBufferint iLengh);
native bool CSGOItems_GetMusicKitDisplayNameByMusicKitNum(int iMusicKitNumchar[] chBufferint iLengh); 

the test code
PHP Code:

#include <csgoitems>

public Plugin myinfo 
{
    
name "Test Plugin"
    
author "SM9"
    
version "0.1"
    
url "http://www.fragdeluxe.com"
};

public 
void OnPluginStart()
{
    if (
GetEngineVersion() != Engine_CSGO) {
        
SetFailState("This plugin is for CSGO only.");
    }
    
//AddCommandListener(EventCommandHook, "buyammo1");
    //AddCommandListener(EventCommandHook, "buyammo2");
}

public 
Action:EventCommandHook(client, const String:command[], args
{
    if(
StrEqual(command"buyammo1") || StrEqual(command"buyammo2"))
    {
        
PrintToChat(client"default ammo: %d"GetActiveDefaultClipAmmo(client));
    }
}

stock int GetActiveDefaultClipAmmo(int iClient
{
    
int iDefIndex CSGOItems_GetActiveWeaponDefIndex(iClient);
    return 
CSGOItems_GetWeaponClipAmmoByDefIndex(iDefIndex);
}

stock bool RefillActiveWeapon(int iClient
{
    
int iWeapon CSGOItems_GetActiveWeaponIndex(iClient);
    return 
CSGOItems_RefillClipAmmo(iWeapon); // true on success.



SM9 08-11-2016 13:44

Re: CSGO Items API
 
Quote:

Originally Posted by 8guawong (Post 2444109)
PHP Code:

#if defined _csgoitems_included_
#endinput
#endif
#define _csgoitems_included_

native int CSGOItems_GetWeaponCount();
native int CSGOItems_GetMusicKitCount();
native int CSGOItems_GetSkinCount();
native int CSGOItems_GetActiveWeaponCount(const char[] chClassNameint iTeam 0);

// WEAPONS
native int CSGOItems_GetWeaponNumByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponNumByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponDefIndexByWeaponNum(int iWeaponNum);
native bool CSGOItems_GetWeaponDefIndexByClassName(const char[] chClassName);
native bool CSGOItems_GetWeaponClassNameByWeaponNum(int iWeaponNumchar[] chBufferint iLengh);
native bool CSGOItems_GetWeaponClassNameByDefIndex(int iDefIndexchar[] chBufferint iLengh);
native bool CSGOItems_GetWeaponDisplayNameByDefIndex(int iDefIndexchar[] chBufferint iLengh);
native bool CSGOItems_GetWeaponDisplayNameByClassName(const char[] chClassNamechar[] chBufferint iLengh);
native bool CSGOItems_GetWeaponDisplayNameByWeaponNum(int iWeaponNumchar[] chBufferint iLengh);
native bool CSGOItems_IsDefIndexKnife(int iDefIndex);
native int CSGOItems_GetWeaponDefIndexByWeapon(int iWeapon);
native bool CSGOItems_GetWeaponClassNameByWeapon(int iWeaponchar[] chBufferint iLengh);
native int CSGOItems_GetActiveWeapon(int iClient);
native int CSGOItems_GetActiveWeaponDefIndex(int iClient);
native bool CSGOItems_GetActiveClassName(int iClientchar[] chBufferint iLengh);
native bool CSGOItems_IsSkinnableDefIndex(int iDefIndex);
native int CSGOItems_FindWeaponByClassName(int iClient, const char[] chClassName);
native int CSGOItems_GetActiveWeaponNum(int iClient);
native int CSGOItems_GetWeaponSlotByWeaponNum(int iWeaponNum);
native int CSGOItems_GetWeaponSlotByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponSlotByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponTeamByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponTeamByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponTeamByWeaponNum(int iWeaponNum);
native int CSGOItems_GetWeaponClipAmmoByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponClipAmmoByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponClipAmmoByWeaponNum(int iWeaponNum);
native int CSGOItems_GetWeaponReserveAmmoByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponReserveAmmoByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponReserveAmmoByWeaponNum(int iWeaponNum);
native int CSGOItems_GetWeaponKillAwardByDefIndex(int iDefIndex);
native int CSGOItems_GetWeaponKillAwardByClassName(const char[] chClassName);
native int CSGOItems_GetWeaponKillAwardByWeaponNum(int iWeaponNum);
native bool CSGOItems_GetItemSetNumByClassName(const char[] chClassNamechar[] chBufferint iLengh);
native bool CSGOItems_GetItemSetDisplayNameByClassName(const char[] chClassNamechar[] chBufferint iLengh);
native bool CSGOItems_GetItemSetDisplayNameByItemSetNum(int iSetNumchar[] chBufferint iLengh);
native bool CSGOItems_RefillClipAmmo(int iWeapon);
native bool CSGOItems_RefillReserveAmmo(int iWeapon);
native bool CSGOItems_IsValidWeapon(int iWeapon);
native int CSGOItems_GiveWeapon(int iClient, const char[] chClassNameint iReserveAmmo = -1int iClipAmmo = -1int iSwitchTo = -1);
native bool CSGOItems_RemoveKnife(int iClient);
native bool CSGOItems_RemoveWeapon(int iClientint iWeapon);
native int CSGOItems_RemoveAllWeapons(int iClientint iSkipSlot = -1);
native bool CSGOItems_SetWeaponAmmo(int iWeaponint iReserveAmmo = -1int iClipAmmo = -1);
native int CSGOItems_SetAllWeaponsAmmo(const char[] chClassNameint iReserveAmmo = -1int iClipAmmo = -1);
native bool CSGOItems_SetActiveWeapon(int iClientint iWeapon);
native int CSGOItems_GetActiveWeaponSlot(int iClient);
native bool CSGOItems_AreItemsSynced();
native bool CSGOItems_AreItemsSyncing();
native bool CSGOItems_ReSync();
native int CSGOItems_GetRandomSkin();

// SKINS
native int CSGOItems_GetSkinNumByDefIndex(int iDefIndex);
native int CSGOItems_GetSkinDefIndexBySkinNum(int iSkinNum);
native bool CSGOItems_GetSkinDisplayNameByDefIndex(int iDefIndexchar[] chBufferint iLengh);
native bool CSGOItems_GetSkinDisplayNameBySkinNum(int iSkinNumchar[] chBufferint iLengh);

// MUSIC KITS
native int CSGOItems_GetMusicKitNumByDefIndex(int iDefIndex);
native int CSGOItems_GetMusicKitDefIndexByMusicKitNum(int iMusicKitNum);
native bool CSGOItems_GetMusicKitDisplayNameByDefIndex(int iDefIndexchar[] chBufferint iLengh);
native bool CSGOItems_GetMusicKitDisplayNameByMusicKitNum(int iMusicKitNumchar[] chBufferint iLengh); 

the test code
PHP Code:

#include <csgoitems>

public Plugin myinfo 
{
    
name "Test Plugin"
    
author "SM9"
    
version "0.1"
    
url "http://www.fragdeluxe.com"
};

public 
void OnPluginStart()
{
    if (
GetEngineVersion() != Engine_CSGO) {
        
SetFailState("This plugin is for CSGO only.");
    }
    
//AddCommandListener(EventCommandHook, "buyammo1");
    //AddCommandListener(EventCommandHook, "buyammo2");
}

public 
Action:EventCommandHook(client, const String:command[], args
{
    if(
StrEqual(command"buyammo1") || StrEqual(command"buyammo2"))
    {
        
PrintToChat(client"default ammo: %d"GetActiveDefaultClipAmmo(client));
    }
}

stock int GetActiveDefaultClipAmmo(int iClient
{
    
int iDefIndex CSGOItems_GetActiveWeaponDefIndex(iClient);
    return 
CSGOItems_GetWeaponClipAmmoByDefIndex(iDefIndex);
}

stock bool RefillActiveWeapon(int iClient
{
    
int iWeapon CSGOItems_GetActiveWeaponIndex(iClient);
    return 
CSGOItems_RefillClipAmmo(iWeapon); // true on success.



Compiles fine on my end, are you sure you have the include file in the right directory?


All times are GMT -4. The time now is 07:42.

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