Raised This Month: $12 Target: $400
 3% 

[CSGO] CSGO items - plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 06-28-2014 , 10:27   [CSGO] CSGO items - plugin
Reply With Quote #1

Here's some dumb plugin, which should help you get CSGO weapon "item" name,
which are listed in ...scripts/items/items_game.txt

What this MAIN plugin do:
- It read items_game.txt file and copy "items" list in own global KeyValue structure.
You can see plugin "items" collection on server console when type command
sm_csgo_items_game_show_items

- Create two natives, which can be use in your own plugin.
CSGO items Natives



Installation:
- Load csgo_items.smx in your server.

Scripting:
- Move csgo_items.inc in your ...sourcemod/scripting/include folder.
- In your own plugin, #include that file
Code:

#include <csgo_items>

public OnPluginStart()
{
	new String:buffer[50];
	CSGO_GetItemDefinitionNameByIndex(63, buffer, sizeof(buffer));
	PrintToServer("CSGO_GetItemDefinitionNameByIndex(\"%s\")", buffer);

	new value = CSGO_GetItemDefinitionIndexByName("weapon_knife_m9_bayonet");
	PrintToServer("CSGO_GetItemDefinitionIndexByName(\"weapon_knife_m9_bayonet\") = %i", value);
}
Compile and load beside main plugin (csgo_items.smx)


More:
This ain't perfect tough
Attached Thumbnails
Click image for larger version

Name:	csgo_items_12181_bytes.png
Views:	5389
Size:	6.8 KB
ID:	135071  
Attached Files
File Type: inc csgo_items.inc (948 Bytes, 967 views)
File Type: sp Get Plugin or Get Source (csgo_items.sp - 1855 views - 3.8 KB)
File Type: sp Get Plugin or Get Source (test_plugin.sp - 401 views - 848 Bytes)

Last edited by Bacardi; 06-30-2014 at 13:38. Reason: 12181 Bytes
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-01-2014 , 19:13   Re: [CSGO] CSGO items - plugin
Reply With Quote #2

Quote:
Originally Posted by SynRobin View Post
I found that "weapon_knife_default_ct" does not work, it returns item index 0.


edit
--
I just looked into the items_game-file and saw that the ct knife is called weapon_knife and not weapon_knife_default_ct. // my bad.
yes, you maybe mixed with models names.
Code:
 			"model_player"		"models/weapons/v_knife_default_ct.mdl"
 			"model_world"		"models/weapons/w_knife_default_ct.mdl"
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-03-2014 , 07:22   Re: [CSGO] CSGO items - plugin
Reply With Quote #3

Quote:
Originally Posted by SynRobin View Post
The big problem is I thought I could just add "weapon_" in front of what "GetEventString(event, "weapon", weapon_name, sizeof(weapon_name));" returns.

I have an idea on how to solve problems dynamically. Do you think you could check my code and tell me what you think? I see that you know what you're doing. I just need some kind of minor guidance.

Excuse me if I write a lot of irrelevant stuff on your thread.
Inside csgo VPK file it have ...resource/modevents.res file
There is mod own event player_death with outputs
There is your answer.

csgo modevents.res player_death
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-03-2014 , 13:36   Re: [CSGO] CSGO items - plugin
Reply With Quote #4

Quote:
Originally Posted by SynRobin View Post
I'm using player_death already and there is no weapon_itemid available.
url: https://wiki.alliedmods.net/Counter-...fensive_Events
I tested and it exist but return as 0 always.
But seems after previous(es) csgo updates, "weapon" string return already with weapon right item name.
I tough it still return with default entity classname (or what was that proplem...)

I get confused and I assume now you want weapon item index from event weapon name ?
PHP Code:
#include <csgo_items>

public OnPluginStart()
{
    
HookEventEx("player_death"event);
}

public 
event(Handle:event,const String:name[],bool:dontBroadcast)
{
    new 
String:weapon[100];
    
GetEventString(event"weapon"weaponsizeof(weapon));
    
Format(weaponsizeof(weapon), "weapon_%s"weapon);
    
PrintToServer("weapon %s"weapon);

    
PrintToServer("weapon item index %i"CSGO_GetItemDefinitionIndexByName(weapon));


Last edited by Bacardi; 07-03-2014 at 13:38.
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-03-2014 , 17:45   Re: [CSGO] CSGO items - plugin
Reply With Quote #5

Quote:
Originally Posted by SynRobin View Post
The thing is that I'm trying to categories all knives as 1 knife so my code will be dynamic when new knifes comes to the game (I'm doing a rank system). The problem comes when you are trying to use ct's knife.
*Okej I can create a state that in the code that checks if the knife is ct_default_knife (hard coded - ugly)
*I could check if the variable contains word knife (all knife doesnt contains that word)
*I could check if the word contains the word knife if no then check knifeinventroy index and weapon victim died from with your plugin.
Ok, finally I get it
Didn't understand first where you did get that ct knife name.
Yes, seems not all event weapon name match with item name, bug.
Code:
event knife_t csgo items weapon_knife_t item_index 59
event knife_default_ct csgo items weapon_knife item_index 42
Here snip if you like use.
Spoiler

Last edited by Bacardi; 07-03-2014 at 17:46.
Bacardi is offline
paulo_crash
AlliedModders Donor
Join Date: May 2016
Location: Brazil
Old 01-05-2018 , 16:54   Re: [CSGO] CSGO items - plugin
Reply With Quote #6

Are giving the following error in the server error log:
Quote:
L 12/28/2017 - 02:165: [SM] Exception reported: Script execution timed out
L 12/28/2017 - 02:165: [SM] Blaming: CSGO_Items.smx
L 12/28/2017 - 02:165: [SM] Call stack trace:
L 12/28/2017 - 02:165: [SM] [1] Line 505, C:\Users\Paulo\Google Drive\' HARD SKILL GAMING\Addons\Counter Strike Global Offensive\Editar Plugins\addons\sourcemod\scripting\include\st ring.inc::ExplodeString
L 12/28/2017 - 02:165: [SM] [2] Line 1131, C:\Users\Paulo\Google Drive\' HARD SKILL GAMING\Addons\Counter Strike Global Offensive\Editar Plugins\addons\sourcemod\scripting\CSGO_Items .sp::SyncItemData
L 12/28/2017 - 02:165: [SM] [3] Line 814, C:\Users\Paulo\Google Drive\' HARD SKILL GAMING\Addons\Counter Strike Global Offensive\Editar Plugins\addons\sourcemod\scripting\CSGO_Items .sp::Timer_SyncSchema
What could it be, could it be corrected?

Last edited by paulo_crash; 01-05-2018 at 16:56.
paulo_crash is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-05-2018 , 23:52   Re: [CSGO] CSGO items - plugin
Reply With Quote #7

That might be whole different version

You maybe use this one
CSGO Items API

Quote:
Originally Posted by paulo_crash View Post
Are giving the following error in the server error log:

What could it be, could it be corrected?
__________________
Do not Private Message @me
Bacardi 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 15:50.


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