Created
April 8, 2015 15:03
-
-
Save rootindex/fed64daaed027fad0abc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sourcemod> | |
#include <sdktools> | |
#include <sdkhooks> | |
#include <colours> | |
#pragma semicolon 1 | |
public Plugin:myinfo = | |
{ | |
name = "sm_knife", | |
author = "RootIndex & bawNg", | |
description = "Give or take a knife", | |
version = "0.0.2", | |
url = "http://intoxicated.co.za/" | |
}; | |
public OnPluginStart() | |
{ | |
RegConsoleCmd("sm_knife", OnPlayerToggleKnife); | |
HookEvent("player_spawn", OnPlayerSpawn); | |
} | |
public Action:OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) | |
{ | |
new client = GetClientOfUserId(GetEventInt(event, "userid")); | |
SDKHook(client, SDKHook_SpawnPost, OnPlayerSpawnLocal); | |
} | |
public Action:OnPlayerSpawnLocal(client, entity){ | |
if (!IsValidEntity(GetPlayerWeaponSlot(client, 2))) { | |
GivePlayerItem(client, "weapon_knife"); | |
CPrintToChat(client, "{white}[{lime}Intoxicated{white}] Remove knife by typing {red}!knife"); | |
} | |
} | |
public Action:OnPlayerToggleKnife(client, args){ | |
if (client && IsClientInGame(client) && 1 < GetClientTeam(client) <= 3 && IsPlayerAlive(client)){ | |
new knife = GetPlayerWeaponSlot(client, 2); | |
if (!IsValidEntity(knife)) { | |
GivePlayerItem(client, "weapon_knife"); | |
CPrintToChat(client, "{white}[{lime}Intoxicated{white}] Remove knife by typing {red}!knife"); | |
}else{ | |
RemovePlayerItem(client, knife); | |
AcceptEntityInput(knife, "Kill"); | |
CPrintToChat(client, "{white}[{lime}Intoxicated{white}] Receive knife by typing {red}!knife"); | |
} | |
} | |
return Plugin_Continue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment