Added cs_get_no_knives, cs_set_no_knives
This commit is contained in:
parent
0660f872eb
commit
1af005a047
@ -178,10 +178,10 @@ static cell AMX_NATIVE_CALL cs_set_user_deaths(AMX *amx, cell *params) // cs_set
|
|||||||
// Update scoreboard here..?
|
// Update scoreboard here..?
|
||||||
MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "ScoreInfo", NULL));
|
MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "ScoreInfo", NULL));
|
||||||
WRITE_BYTE(params[1]);
|
WRITE_BYTE(params[1]);
|
||||||
WRITE_SHORT((int)pPlayer->v.frags);
|
WRITE_SHORT((int)pPlayer->v.frags); // should these be byte?
|
||||||
WRITE_SHORT(params[2]);
|
WRITE_SHORT(params[2]); // should these be byte?
|
||||||
WRITE_SHORT(0); // dunno what this parameter is (doesn't seem to be vip)
|
WRITE_SHORT(0); // dunno what this parameter is (doesn't seem to be vip) // should these be byte?
|
||||||
WRITE_SHORT(*((int *)pPlayer->pvPrivateData + OFFSET_TEAM));
|
WRITE_SHORT(*((int *)pPlayer->pvPrivateData + OFFSET_TEAM)); // should these be byte?
|
||||||
MESSAGE_END();
|
MESSAGE_END();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -1326,6 +1326,20 @@ static cell AMX_NATIVE_CALL cs_get_user_hasprimary(AMX *amx, cell *params) // cs
|
|||||||
return *((int *)pPlayer->pvPrivateData + OFFSET_PRIMARYWEAPON);
|
return *((int *)pPlayer->pvPrivateData + OFFSET_PRIMARYWEAPON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL cs_get_no_knives(AMX *amx, cell *params) // cs_get_no_knives(); = 0 params
|
||||||
|
{
|
||||||
|
// Returns 1 when g_noknives is true, else 0
|
||||||
|
return g_noknives ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL cs_set_no_knives(AMX *amx, cell *params) // cs_set_no_knives(noknives = 0); = 1 param
|
||||||
|
{
|
||||||
|
// Sets noknives mode on/off. When params[1] is 1, g_noknives goes true and no weapon_knife:s will from there be created until switch off again.
|
||||||
|
g_noknives = params[1] == 0 ? false : true;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO cstrike_Exports[] = {
|
AMX_NATIVE_INFO cstrike_Exports[] = {
|
||||||
{"cs_set_user_money", cs_set_user_money},
|
{"cs_set_user_money", cs_set_user_money},
|
||||||
{"cs_get_user_money", cs_get_user_money},
|
{"cs_get_user_money", cs_get_user_money},
|
||||||
@ -1357,10 +1371,31 @@ AMX_NATIVE_INFO cstrike_Exports[] = {
|
|||||||
{"cs_set_weapon_ammo", cs_set_weapon_ammo},
|
{"cs_set_weapon_ammo", cs_set_weapon_ammo},
|
||||||
{"cs_get_weapon_ammo", cs_get_weapon_ammo},
|
{"cs_get_weapon_ammo", cs_get_weapon_ammo},
|
||||||
{"cs_get_user_hasprim", cs_get_user_hasprimary},
|
{"cs_get_user_hasprim", cs_get_user_hasprimary},
|
||||||
|
{"cs_get_no_knives", cs_get_no_knives},
|
||||||
|
{"cs_set_no_knives", cs_set_no_knives},
|
||||||
//------------------- <-- max 19 characters!
|
//------------------- <-- max 19 characters!
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
edict_s* FN_CreateNamedEntity(int classname) {
|
||||||
|
if (g_noknives && !strcmp(STRING(classname), "weapon_knife")) {
|
||||||
|
if (g_precachedknife) {
|
||||||
|
// Knife is creating
|
||||||
|
RETURN_META_VALUE(MRES_SUPERCEDE, NULL);
|
||||||
|
}
|
||||||
|
// Let it create a knife first time; this seems to keep it precached properly in case anyone give_items a knife later.
|
||||||
|
g_precachedknife = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_META_VALUE(MRES_IGNORED, CREATENAMEDENTITY(classname));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FN_ServerDeactivate() {
|
||||||
|
g_precachedknife = false;
|
||||||
|
|
||||||
|
RETURN_META(MRES_IGNORED);
|
||||||
|
}
|
||||||
|
|
||||||
/***GetEngineFunctions******************/
|
/***GetEngineFunctions******************/
|
||||||
void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {
|
void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {
|
||||||
// Reset player model a short while (MODELRESETTIME) after this if they are using an edited model.
|
// Reset player model a short while (MODELRESETTIME) after this if they are using an edited model.
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#define GETINFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
|
#define GETINFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
|
||||||
#define SETCLIENTKEYVALUE (*g_engfuncs.pfnSetClientKeyValue)
|
#define SETCLIENTKEYVALUE (*g_engfuncs.pfnSetClientKeyValue)
|
||||||
#define GETCLIENTKEYVALUE (*g_engfuncs.pfnInfoKeyValue)
|
#define GETCLIENTKEYVALUE (*g_engfuncs.pfnInfoKeyValue)
|
||||||
|
#define CREATENAMEDENTITY (*g_engfuncs.pfnCreateNamedEntity)
|
||||||
|
|
||||||
#if defined __linux__
|
#if defined __linux__
|
||||||
#define EXTRAOFFSET 5 // offsets 5 higher in Linux builds
|
#define EXTRAOFFSET 5 // offsets 5 higher in Linux builds
|
||||||
@ -201,5 +202,6 @@ enum CS_Internal_Models {
|
|||||||
// cstrike-specific defines above
|
// cstrike-specific defines above
|
||||||
|
|
||||||
CCstrikePlayer g_players[33];
|
CCstrikePlayer g_players[33];
|
||||||
//bool g_initialized = false;
|
bool g_precachedknife = false;
|
||||||
|
bool g_noknives = false;
|
||||||
// Globals above
|
// Globals above
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
|
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
|
||||||
#define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
|
#define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
|
||||||
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
|
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
|
||||||
// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
||||||
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
|
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
|
||||||
#define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
|
#define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
|
||||||
// #define FN_StartFrame StartFrame /* pfnStartFrame() */
|
// #define FN_StartFrame StartFrame /* pfnStartFrame() */
|
||||||
@ -180,7 +180,7 @@
|
|||||||
// #define FN_AngleVectors AngleVectors
|
// #define FN_AngleVectors AngleVectors
|
||||||
// #define FN_CreateEntity CreateEntity
|
// #define FN_CreateEntity CreateEntity
|
||||||
// #define FN_RemoveEntity RemoveEntity
|
// #define FN_RemoveEntity RemoveEntity
|
||||||
// #define FN_CreateNamedEntity CreateNamedEntity
|
#define FN_CreateNamedEntity CreateNamedEntity
|
||||||
// #define FN_MakeStatic MakeStatic
|
// #define FN_MakeStatic MakeStatic
|
||||||
// #define FN_EntIsOnFloor EntIsOnFloor
|
// #define FN_EntIsOnFloor EntIsOnFloor
|
||||||
// #define FN_DropToFloor DropToFloor
|
// #define FN_DropToFloor DropToFloor
|
||||||
|
@ -175,4 +175,14 @@ native cs_get_weapon_ammo(index);
|
|||||||
|
|
||||||
/* Set amount of ammo in weapon's clip.
|
/* Set amount of ammo in weapon's clip.
|
||||||
*/
|
*/
|
||||||
native cs_set_weapon_ammo(index, newammo);
|
native cs_set_weapon_ammo(index, newammo);
|
||||||
|
|
||||||
|
/* Returns 1 if no knives mode is enabled, else 0.
|
||||||
|
*/
|
||||||
|
native cs_get_no_knives();
|
||||||
|
|
||||||
|
/* Enabled no knives mode by calling this with value 1. Disabled with 0.
|
||||||
|
* No knives mode means that player will not be given a knife when spawning.
|
||||||
|
* You can still give knives (ie through fun's give_item).
|
||||||
|
*/
|
||||||
|
native cs_set_no_knives(noknives = 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user