Raised This Month: $32 Target: $400
 8% 

Zephyrus store axe, hammer etc.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 03-14-2019 , 07:57   Zephyrus store axe, hammer etc.
Reply With Quote #1

Can you make this plugin compatible for zephyrus store?

PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools_entinput>
#include <sdktools_functions>
#include <shop>

public Plugin myinfo =
{
    
name "[Shop] New weapons",
    
author "Drumanid",
    
version "1.0.2",
    
url ""
};

char    g_sBuffer[MAXPLAYERS +1][32];
float    g_fDamage;

#define VE(%0) view_as<EventHook>(%0)
#define LC(%0) for(int %0 = 1; %0 <= MaxClients; ++%0) if(IsClientInGame(%0))
public void OnPluginStart()
{
    
LoadTranslations("shop_new_weapons.phrases.txt");

    
LC(iClient)
        
OnClientPostAdminCheck(iClient);

    
HookEvent("round_start"VE(RoundStart), EventHookMode_Pre);
    
HookEvent("player_spawn"VE(PlayerSpawn));
}

public 
void OnPluginEnd()
{
    
Shop_UnregisterMe();
}

#define SZF(%0) %0, sizeof(%0)
public void OnMapStart()
{
    if(!
Shop_IsStarted())
        return;
    else 
Shop_UnregisterMe();

    
char sPath[64];
    
Shop_GetCfgFile(SZF(sPath), "new_weapons.txt");

    
KeyValues hKeyValues CreateKeyValues("new_weapons");
    if(!
FileToKeyValues(hKeyValuessPath))
        
SetFailState("No found file: %s"sPath);

    
char sName[32], sDescription[64];
    
hKeyValues.GetString("name"SZF(sName));
    
hKeyValues.GetString("description"SZF(sDescription));
    
g_fDamage hKeyValues.GetFloat("damage"30.0);

    
CategoryId category_id Shop_RegisterCategory("new_weapons"sNamesDescription);
    if(
hKeyValues.GotoFirstSubKey())
    {
        do
        {
            if(
hKeyValues.GetSectionName(SZF(sName)) && Shop_StartItem(category_idsName))
            {
                
hKeyValues.GetString("name"SZF(sName));

                
Shop_SetInfo(sNameNULL_STRING,    hKeyValues.GetNum("price", -1),
                                                    
hKeyValues.GetNum("sellprice", -1),
                                                    
Item_Togglable,
                                                    
hKeyValues.GetNum("duration"604800));

                
Shop_SetCallbacks(_OnEquipItem);
                
Shop_EndItem();
            }
        }
        while(
hKeyValues.GotoNextKey());
    }

    
delete hKeyValues;
}

#define CHECKBLOCK(%0) StrEqual(g_sBuffer[%0], "Block")
public ShopAction OnEquipItem(int iClientCategoryId category_id,
const 
char[] sCategoryItemId item_id, const char[] sItembool bIsOnbool bElapsed)
{
    if(
CHECKBLOCK(iClient))
    {
        
PrintToChat(iClient"%t""Block change weapon");
        return 
Shop_UseOff;
    }

    if(
bIsOn || bElapsed)
    {
        
DeleteWeapon(iClient);
        
g_sBuffer[iClient] = "Block";
        
        return 
Shop_UseOff;
    }

    
Shop_ToggleClientCategoryOff(iClientcategory_id);

    
strcopy(g_sBuffer[iClient], sizeof(g_sBuffer[]), sItem);
    
GiveWeapon(iClient);
    
    return 
Shop_UseOn;
}

public 
void OnClientPostAdminCheck(int iClient)
{
    
g_sBuffer[iClient][0] = 0;
    
SDKHook(iClientSDKHook_OnTakeDamageOnTakeDamageAlive);
}

void RoundStart()
{
    
LC(iClient)
    {
        if(
CHECKBLOCK(iClient))
            
g_sBuffer[iClient][0] = 0;
    }
}

void PlayerSpawn(Event hEvent)
{
    
RequestFrame(PlayerSpawnFramehEvent.GetInt("userid"));
}

void PlayerSpawnFrame(int iClient)
{
    if((
iClient GetClientOfUserId(iClient)) > && IsClientInGame(iClient))
        
GiveWeapon(iClient);
}

void GiveWeapon(int iClient)
{
    if(
g_sBuffer[iClient][0] && DeleteWeapon(iClient))
        
EquipPlayerWeapon(iClientGivePlayerItem(iClientg_sBuffer[iClient]));
}

#define ISVALIDCLIENT(%0) (0 < %0 <= MaxClients)
Action OnTakeDamageAlive(int iVictimint &iAttackerint &iInflictorfloat &fDamage,
int &iDamageType,int &iWeaponfloat fDamageForce[3], float fDamagePosition[3])
{
    if(!
ISVALIDCLIENT(iVictim) || !ISVALIDCLIENT(iAttacker) ||
    
g_sBuffer[iAttacker][0] == || iDamageType != 4224)
        return 
Plugin_Continue;

    
fDamage g_fDamage;
    return 
Plugin_Changed;
}

bool DeleteWeapon(int iClient)
{
    if(!
IsPlayerAlive(iClient))
        return 
false;

    
int iWeapon;
    while((
iWeapon GetPlayerWeaponSlot(iClient2)) != -1)
    {
        
RemovePlayerItem(iClientiWeapon);
        
AcceptEntityInput(iWeapon"Kill");
    }

    
GivePlayerItem(iClient"weapon_knife");
    return 
true;

PHP Code:
"Phrases"
{
    
"Block change weapon"
    
{
        
"en"        "You will be able to change weapons only in the new round."
    
}

PHP Code:
"New_Weapons"
{
    
"name"                "New Weapons"
    "description"        ""
    "damage"            "30.0"
    "weapon_fists"
    
{
        
"name"            "Fists"
        "price"            "2000"
        "sellprice"        "1000"
        "duration"        "0"
    
}
    
"weapon_axe"
    
{
        
"name"            "Axe"
        "price"            "2000"
        "sellprice"        "1000"
        "duration"        "0"
    
}
    
"weapon_hammer"
    
{
        
"name"            "Hammer"
        "price"            "2000"
        "sellprice"        "1000"
        "duration"        "0"
    
}
    
"weapon_spanner"
    
{
        
"name"            "Spanner"
        "price"            "2000"
        "sellprice"        "1000"
        "duration"        "0"
    
}

__________________

Last edited by alphaearth; 03-14-2019 at 07:58.
alphaearth is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode