|
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
|
05-12-2014
, 12:46
Re: Knife API
|
#2
|
Examples topExample #1: Default CS knife with custom sprite - don't use without #define DEFAULT_HANDS (Tested, works)
PHP Code:
#include <amxmodx> #include <knifeapi> #include <cstrike>
new g_Knife
new const VMODEL[] = "models/v_knife.mdl" new const PMODEL[] = "models/p_knife.mdl"
const KNIFE_PRICE = 300
public plugin_precache() { precache_model(VMODEL) precache_model(PMODEL) // we precache the custom sprite .txt and .spr files precache_generic("sprites/weapon_superknife.txt") precache_generic("sprites/superknife.spr") // ALWAYS precache your files. If you don't, the server will crash, knife API doesn't do it for you }
public plugin_init() { register_plugin("Knife API example", "1.0", "idiotstrike") g_Knife = Knife_Register( .WeaponName = "Default Knife", .VModel = VMODEL, .PModel = PMODEL ) // additional properties (for a list of all properties, see knifeapi.inc): // we make the knife droppable Knife_SetProperty(g_Knife, KN_CLL_Droppable, true) // since we want to use a custom sprite, we set this to the .txt filename without extension. // if you don't want to use a custom sprite, don't change the KN_STR_SpriteName property! Knife_SetProperty(g_Knife, KN_STR_SpriteName, "weapon_superknife") // we can also change the primary range to 60.0 to make it more unrealistic //Knife_SetProperty(g_Knife, KN_CLL_PrimaryRange, 60.0) register_clcmd("say /buyknife", "CmdBuyKnife") }
public CmdBuyKnife(id) { if(!is_user_alive(id)) { client_print(id, print_chat, "You need to be alive.") } else if(Knife_PlayerHas(id, g_Knife)) { client_print(id, print_chat, "You already have this knife. Switch to knife and press R to see it.") } else { new Money = cs_get_user_money(id) if(Money < KNIFE_PRICE) { client_print(id, print_center, "You have insufficient funds.") } else { Knife_PlayerGive(id, g_Knife) cs_set_user_money(id, Money - KNIFE_PRICE) } } return PLUGIN_HANDLED }
weapon_superknife.txt:
Plugins using this top
Support me topIf you think that my work is worth something, I certainly wouldn't mind any kind of a donation
Or, add me on Steam and give me some trading cards or a TF2 key
__________________
Currently busy working on a very large scale anime database project.
Last edited by Backstabnoob; 07-16-2014 at 20:31.
|
|
|
|