[CS:GO] Giving knives

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

[CS:GO] Giving knives

Postby velocity » Sat Nov 17, 2018 11:27 pm

Syntax: Select all

#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma semicolon 1

new String:gS_Knives[][] =
{
"weapon_bayonet",
"weapon_knife_gut",
"weapon_knife_flip",
"weapon_knife_m9_bayonet",
"weapon_knife_karambit"
};

public Plugin:myinfo =
{
name = "CS:GO knives example",
author = "shavit",
version = "1.0"
}

public OnPluginStart()
{
HookEvent("item_pickup", Item_Pickup);
}

public Action:Item_Pickup(Handle:event, const String:name[], bool:dB)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));

if(!IsValidClient(client))
{
return Plugin_Continue;
}

new String:weapon[32];
GetEventString(event, "item", weapon, 32);

if(StrContains(weapon, "knife", false) != -1)
{
new currentknife = GetPlayerWeaponSlot(client, 2);

if(currentknife != INVALID_ENT_REFERENCE)
{
RemovePlayerItem(client, currentknife);
}

new knife = GivePlayerItem(client, gS_Knives[GetRandomInt(0, sizeof(gS_Knives))]);

EquipPlayerWeapon(client, knife);
}

return Plugin_Continue;
}

// Stocks
stock bool:IsValidClient(client, bool:alive = false)
{
return (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)));
}


I'm trying to give different knives in csgo, it wont work to remove knife and and spawn another.
This method should work. I wonder how to do it in SP?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [CS:GO] Giving knives

Postby L'In20Cible » Sun Nov 18, 2018 12:28 am

This is against their guidelines and will get your account hosting these servers into trouble for doing so: http://blog.counter-strike.net/index.ph ... uidelines/
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: [CS:GO] Giving knives

Postby velocity » Sun Nov 18, 2018 1:38 am

Oh didn't know. I won't be doing that anytime soon then.

Edit:
I could have guessed it since it was difficult to do anyway, but I was caught up by all those servers running plugins that allow you to change your knife.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [CS:GO] Giving knives

Postby L'In20Cible » Sun Nov 18, 2018 4:17 am

velocity wrote:I could have guessed it since it was difficult to do anyway, but I was caught up by all those servers running plugins that allow you to change your knife.

These servers are most likely using some kind of token updater that they purchases from shady sites that register fake accounts, etc. As far as I know, the detection is made in their client build, that detect the networked skins and flag the servers so you cannot bypass the detection server-side (not that I would recommend doing so either way) and need to constantly update your token which requires a phone number to register in order to keep your servers running.

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 16 guests