Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <reapi>
- #include <shopapi>
- #include <paint_marker_api>
- #pragma semicolon 1
- new const PLUGIN_VERSION[] = "1.1";
- #define GetCvarDesc(%0) fmt("%L", LANG_SERVER, %0)
- new ShopItem:g_iItem;
- enum (<<= 1)
- {
- RESET_FLAG_DISCONNECTED = 1,
- RESET_FLAG_KILLED = 2,
- RESET_FLAG_ROUND_START
- };
- new g_iResetFlags = (RESET_FLAG_DISCONNECTED|RESET_FLAG_KILLED|RESET_FLAG_ROUND_START);
- public plugin_init()
- {
- register_plugin("Shop: Paint Marker", PLUGIN_VERSION, "w0w");
- register_dictionary("shop_paint_marker.txt");
- RegisterHookChain(RG_CSGameRules_RestartRound, "refwd_NewRound_Post", true);
- RegisterHookChain(RG_CBasePlayer_Killed, "refwd_PlayerKilled_Post", true);
- new pCvarCost = create_cvar("shop_paint_marker_cost", "50", FCVAR_NONE, GetCvarDesc("SHOP_CVAR_PAINT_MARKER_COST"), true, 0.0);
- new pCvarFlags = create_cvar("shop_paint_marker_reset_flags", "abc", FCVAR_NONE, GetCvarDesc("SHOP_CVAR_PAINT_MARKER_RESET_FLAGS"));
- hook_cvar_change(pCvarFlags, "hook_CvarChange_ResetFlags");
- AutoExecConfig(true, "shop_paint_marker", "shop");
- g_iItem = ShopPushItem(
- .name = GetCvarDesc("SHOP_PAINT_MARKER"),
- .cost = get_pcvar_num(pCvarCost),
- .access = ADMIN_ALL,
- .flags = IF_OnlyAlive,
- .discount = 0,
- .inventory = true,
- .strkey = "paint_marker",
- .cmd = "shop_paint_marker"
- );
- ShopRegisterEvent(Shop_ItemBuy, "func_BuyItem", .this = true);
- }
- public client_putinserver(id)
- {
- if(ShopHasUserItem(id, g_iItem))
- paint_marker_user_manage(id, true);
- }
- public client_disconnected(id)
- {
- if(g_iResetFlags & RESET_FLAG_DISCONNECTED)
- ShopRemoveUserItem(id, g_iItem);
- }
- public refwd_NewRound_Post()
- {
- if(g_iResetFlags & RESET_FLAG_ROUND_START)
- {
- new iPlayers[MAX_PLAYERS], iPlayerCount, iPlayer;
- get_players_ex(iPlayers, iPlayerCount, GetPlayers_ExcludeBots|GetPlayers_ExcludeHLTV);
- for(new i; i < iPlayerCount; i++)
- {
- iPlayer = iPlayers[i];
- if(ShopHasUserItem(iPlayer, g_iItem))
- {
- ShopRemoveUserItem(iPlayer, g_iItem);
- paint_marker_user_manage(iPlayer, false);
- }
- }
- }
- }
- public refwd_PlayerKilled_Post(iVictim, iKiller, iGib)
- {
- if(g_iResetFlags & RESET_FLAG_KILLED && ShopHasUserItem(iVictim, g_iItem))
- {
- ShopRemoveUserItem(iVictim, g_iItem);
- paint_marker_user_manage(iVictim, false);
- }
- }
- public func_BuyItem(id, ShopItem:iItem, BuyState:iBuyState)
- {
- if(iBuyState == Buy_OK)
- {
- client_print(id, print_center, "%l", "SHOP_BOUGHT_PAINT_MARKER");
- paint_marker_user_manage(id, true);
- }
- return SHOP_CONTINUE;
- }
- public func_ItemEnablePressing(id, ShopItem:iItem)
- {
- if(!ShopHasUserItem(id, iItem) && paint_marker_has_user(id))
- return SHOP_BREAK;
- return SHOP_CONTINUE;
- }
- public hook_CvarChange_ResetFlags(pCvar, const szOldValue[], const szNewValue[])
- {
- g_iResetFlags = read_flags(szNewValue);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement