AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CSGO] CSGO items - plugin (https://forums.alliedmods.net/showthread.php?t=243009)

Bacardi 06-28-2014 10:27

[CSGO] CSGO items - plugin
 
4 Attachment(s)
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 :bee:
https://forums.alliedmods.net/attach...1&d=1404149918

Bacardi 07-01-2014 19:13

Re: [CSGO] CSGO items - plugin
 
Quote:

Originally Posted by SynRobin (Post 2160490)
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 07-03-2014 07:22

Re: [CSGO] CSGO items - plugin
 
Quote:

Originally Posted by SynRobin (Post 2161249)
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 07-03-2014 13:36

Re: [CSGO] CSGO items - plugin
 
Quote:

Originally Posted by SynRobin (Post 2161430)
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 :roll: (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));



Bacardi 07-03-2014 17:45

Re: [CSGO] CSGO items - plugin
 
Quote:

Originally Posted by SynRobin (Post 2161463)
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 :D
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

paulo_crash 01-05-2018 16:54

Re: [CSGO] CSGO items - plugin
 
Are giving the following error in the server error log:
Quote:

L 12/28/2017 - 02:16:35: [SM] Exception reported: Script execution timed out
L 12/28/2017 - 02:16:35: [SM] Blaming: CSGO_Items.smx
L 12/28/2017 - 02:16:35: [SM] Call stack trace:
L 12/28/2017 - 02:16:35: [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:16:35: [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:16:35: [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?

Bacardi 01-05-2018 23:52

Re: [CSGO] CSGO items - plugin
 
That might be whole different version

You maybe use this one
CSGO Items API

Quote:

Originally Posted by paulo_crash (Post 2570010)
Are giving the following error in the server error log:

What could it be, could it be corrected?



All times are GMT -4. The time now is 17:44.

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