//------------------------------------------------------------------------------
// GPL LISENCE (short)
//------------------------------------------------------------------------------
/*
* Copyright (c) 2014 R1KO
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ChangeLog:
1.0 - Релиз
*/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
#include <shop>
new bool:g_bHasDJ[MAXPLAYERS+1];
new Handle:g_hPrice,
Handle:g_hSellPrice,
Handle:g_hDuration,
ItemId:id;
static const char sMapNames[][] =
{
"mg_race_long_road",
"mg_office_coursee_2012_fixed",
"mg_simpson_road_course",
"mg_draw_course_v1_final",
"mg_jump_obstacles_2012_CSGO",
"mg_100traps_v4_1",
"surf_greatriver_2015",
"mg_lego_course_2_csgo_v2",
"surf_4fun_2016_v1",
"surf_old_sand",
"surf_4fun_2015_v2",
"surf_greatriver_remix_csgo_r2",
"surf_dust2_2008_csgo_rfix",
"surf_machine4_go_snf",
"surf_ski_2_GO",
"surf_greatriver_xdre4m_d",
"surf_mastermind_a1_1",
"surf_11x_kaboom_hdr",
"mg_escape_castle_v3_fix",
"mg_pharaohs_tomb2_go",
"mg_neon_go_course",
"mg_office45_course",
"surf_cram"
};
public Plugin:myinfo =
{
name = "[Shop] Double Jump",
author = "R1KO",
version = "1.1"
};
bool bEnable;
public void OnMapStart()
{
bEnable = false;
char sMap[32];
GetCurrentMap(sMap, sizeof(sMap));
for(int i; i < sizeof(sMapNames); i++)
{
if(!StrContains(sMap, sMapNames[i]))
{
bEnable = true;
break;
}
}
}
public OnPluginStart()
{
g_hPrice = CreateConVar("sm_shop_doublejump_price", "1000", "Стоимость покупки двойного прыжка.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_doublejump_sellprice", "800", "Стоимость продажи двойного прыжка.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hDuration = CreateConVar("sm_shop_doublejump_duration", "86400", "Длительность двойного прыжка в секундах.");
HookConVarChange(g_hDuration, OnConVarChange);
AutoExecConfig(true, "shop_doublejump", "shop");
if (Shop_IsStarted()) Shop_Started();
}
public OnConVarChange(Handle:hCvar, const String:oldValue[], const String:newValue[])
{
if(id != INVALID_ITEM)
{
if(hCvar == g_hPrice) Shop_SetItemPrice(id, GetConVarInt(hCvar));
else if(hCvar == g_hSellPrice) Shop_SetItemSellPrice(id, GetConVarInt(hCvar));
else if(hCvar == g_hDuration) Shop_SetItemValue(id, GetConVarInt(hCvar));
}
}
public OnPluginEnd() Shop_UnregisterMe();
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory("ability", "Способности", "");
if (Shop_StartItem(category_id, "doublejump"))
{
Shop_SetInfo("Двойной прыжок", "", GetConVarInt(g_hPrice), GetConVarInt(g_hSellPrice), Item_Togglable, GetConVarInt(g_hDuration));
Shop_SetCallbacks(OnItemRegistered, OnItemUsed);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) id = item_id;
public Shop_OnClientAuthorized(iClient) g_bHasDJ[iClient] = (Shop_IsClientHasItem(iClient, id) && Shop_IsClientItemToggled(iClient, id)) ? true:false;
public ShopAction:OnItemUsed(iClient, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], bool:isOn, bool:elapsed)
{
if (isOn || elapsed)
{
g_bHasDJ[iClient] = false;
return Shop_UseOff;
}
g_bHasDJ[iClient] = true;
return Shop_UseOn;
}
public Action:OnPlayerRunCmd(iClient, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
if (g_bHasDJ[iClient] && IsPlayerAlive(iClient))
{
static g_fLastButtons[MAXPLAYERS+1], g_fLastFlags[MAXPLAYERS+1], g_iJumps[MAXPLAYERS+1], fCurFlags, fCurButtons;
fCurFlags = GetEntityFlags(iClient);
fCurButtons = GetClientButtons(iClient);
if (g_fLastFlags[iClient] & FL_ONGROUND && !(fCurFlags & FL_ONGROUND) && !(g_fLastButtons[iClient] & IN_JUMP) && fCurButtons & IN_JUMP) g_iJumps[iClient]++;
else if(fCurFlags & FL_ONGROUND) g_iJumps[iClient] = 0;
else if(!(g_fLastButtons[iClient] & IN_JUMP) && fCurButtons & IN_JUMP && g_iJumps[iClient] == 1)
{
g_iJumps[iClient]++;
decl Float:vVel[3];
GetEntPropVector(iClient, Prop_Data, "m_vecVelocity", vVel);
vVel[2] = 250.0;
TeleportEntity(iClient, NULL_VECTOR, NULL_VECTOR, vVel);
}
g_fLastFlags[iClient] = fCurFlags;
g_fLastButtons[iClient] = fCurButtons;
}
return Plugin_Continue;
}