Page 1 of 1

[CS:GO] Giving knives

Posted: Sat Nov 17, 2018 11:27 pm
by velocity

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?

Re: [CS:GO] Giving knives

Posted: Sun Nov 18, 2018 12:28 am
by L'In20Cible
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/

Re: [CS:GO] Giving knives

Posted: Sun Nov 18, 2018 1:38 am
by velocity
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.

Re: [CS:GO] Giving knives

Posted: Sun Nov 18, 2018 4:17 am
by L'In20Cible
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.