AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   new item shop furien (https://forums.alliedmods.net/showthread.php?t=207646)

Divin12 02-05-2013 03:58

new item shop furien
 
I want to add new item at /shop (furien mod)
For example knife/superknife
I need to add new model at deagle(dualdeagle)
I modificated furien_superknife.amxx but not work, please help me.
Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

#include "furien.inc"
#include "furien_shop.inc"

#define VERSION "0.2.1"

#define FIRST_PLAYER_ID        1

new g_iMaxPlayers
#define IsPlayer(%1)        ( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers )

#define XO_WEAPON 4
#define m_pPlayer 41

#define XO_PLAYER 5
#define m_pActiveItem        373

new g_bHasDualDeagle
#define SetUserDualDeagle(%1)                g_bHasDualDeagle |= 1<<(%1&31)
#define RemoveUserDualDeagle(%1)        g_bHasDualDeagle &= ~(1<<(%1&31))
#define HasUserDualDeagle(%1)                g_bHasDualDeagle & 1<<(%1&31)

new g_iszDualDeagleModel
new Float:g_flDualDeagleDamageFactor

new g_iCost[2]

public plugin_precache()
{
        register_plugin("Furien DualDeagle", VERSION, "Connor")

        new szConfigFile[128]
        get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile))
        format(szConfigFile, charsmax(szConfigFile), "%s/furien/items/deagle.ini", szConfigFile);

        new fp = fopen(szConfigFile, "rt")
        if( !fp )
        {
                return
        }

        new szFurienName[32], szAntiName[32]

        new szDatas[80], szKey[16], szValue[64]
        while( !feof(fp) )
        {
                fgets(fp, szDatas, charsmax(szDatas))
                trim(szDatas)
                if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#' || (szDatas[0] == '/' && szDatas[1] == '/'))
                {
                        continue
                }

                parse(szDatas, szKey, charsmax(szKey), szValue, charsmax(szValue))

                switch( szKey[0] )
                {
                        case 'A':
                        {
                                switch( szKey[7] )
                                {
                                        case 'M':
                                        {
                                                if( equal(szKey, "ANTI_NAME" ) )
                                                {
                                                        copy(szAntiName, charsmax(szAntiName), szValue)
                                                }
                                        }
                                        case 'S':
                                        {
                                                if( equal(szKey, "ANTI_COST" ) )
                                                {
                                                        g_iCost[AntiFurien] = str_to_num(szValue)
                                                }
                                        }
                                }
                        }
                        case 'F':
                        {
                                switch( szKey[9] )
                                {
                                        case 'M':
                                        {
                                                if( equal(szKey, "FURIEN_NAME" ) )
                                                {
                                                        copy(szFurienName, charsmax(szAntiName), szValue)
                                                }
                                        }
                                        case 'S':
                                        {
                                                if( equal(szKey, "FURIEN_COST" ) )
                                                {
                                                        g_iCost[Furien] = str_to_num(szValue)
                                                }
                                        }
                                }
                        }
                        case 'K':
                        {
                                switch( szKey[6] )
                                {
                                        case 'M':
                                        {
                                                if( equal(szKey, "DEAGLE_MODEL" ) )
                                                {
                                                        precache_model(szValue)
                                                        g_iszDualDeagleModel = engfunc(EngFunc_AllocString, szValue)
                                                }
                                        }
                                        case 'D':
                                        {
                                                if( equal(szKey, "DEAGLE_DAMAGE" ) )
                                                {
                                                        g_flDualDeagleDamageFactor = str_to_float(szValue)
                                                }
                                        }
                                }
                        }
                }
        }
        fclose( fp )

        if( g_iCost[Furien] || g_iCost[AntiFurien] )
        {
                furien_register_item(szFurienName, g_iCost[Furien], szAntiName, g_iCost[AntiFurien], "furien_buy_dualdeagle")       

                RegisterHam(Ham_Killed, "player", "Ham_CBasePlayer_Killed_Post", true)
                RegisterHam(Ham_TakeDamage, "player", "CBasePlayer_TakeDamage", false)
                RegisterHam(Ham_Item_Deploy, "weapon_dualdeagle", "CDeagle_Deploy", true)

                g_iMaxPlayers = get_maxplayers()
        }
}

public client_putinserver(id)
{
        RemoveUserDualDeagle(id)
}

public furien_buy_dualdeagle( id )
{
        new iTeam = furien_get_user_team(id)
        if( iTeam == -1 )
        {
                return ShopCloseMenu
        }

        new iItemCost = g_iCost[iTeam]
        if( iItemCost <= 0 )
        {
                return ShopTeamNotAvail
        }

        if( ~HasUserDualDeagle(id) )
        {
                if( furien_try_buy(id, iItemCost) )
                {
                        SetUserDualDeagle(id)
                        if( get_user_weapon(id) == CSW_DEAGLE )
                        {
                                ExecuteHamB(Ham_Item_Deploy, get_pdata_cbase(id, m_pActiveItem, XO_PLAYER))
                        }
                        return ShopBought
                }
                else
                {
                        return ShopNotEnoughMoney
                }
        }
        return ShopAlreadyHaveOne
}

public CDeagle_Deploy( iDeagle )
{
        new id = get_pdata_cbase(iDeagle, m_pPlayer, XO_WEAPON)

        if( HasUserDualDeagle(id) )
        {
                set_pev(id, pev_viewmodel, g_iszDualDeagleModel)
        }
}

public CBasePlayer_TakeDamage(id, iInflictor, iAttacker, Float:flDamage, bitsDamageType)
{
        if( IsPlayer(iInflictor) && HasUserDualDeagle(iAttacker) && get_user_weapon(iAttacker) == CSW_DEAGLE )
        {
                SetHamParamFloat( 4, flDamage * g_flDualDeagleDamageFactor )
        }
}

public Ham_CBasePlayer_Killed_Post(id)
{
        RemoveUserDualDeagle(id)
}

public furien_team_change( /*iFurien */ )
{
        if( !g_iCost[Furien] || !g_iCost[AntiFurien] )
        {
                new iPlayers[32], iNum, id
                get_players(iPlayers, iNum, "a")
                for(new i; i<iNum; i++)
                {
                        id = iPlayers[i]
                        if( HasUserDualDeagle(id) )
                        {
                                RemoveUserDualDeagle(id)
                                if( get_user_weapon(id) == CSW_DEAGLE )
                                {
                                        ExecuteHamB(Ham_Item_Deploy, get_pdata_cbase(id, m_pActiveItem, XO_PLAYER))
                                }
                        }
                }
                g_bHasDualDeagle = 0
        }
}

public furien_round_restart()
{
        g_bHasDualDeagle = 0
}

and deagle.ini in config/furien/items
Code:

FURIEN_NAME "DualDeagle [only ct]"
FURIEN_COST ""

ANTI_NAME "DualDeagle"
ANTI_COST "1000"

DEAGLE_MODEL "models/new/v_elite12.mdl"
DEAGLE_DAMAGE "0.8"

Sorry for my bad english...

Divin12 02-10-2013 08:58

Re: new item shop furien
 
Quote:

Reason: wait 14 days before you bump
maybe 14 years;)

ConnorMcLeod 02-10-2013 11:41

Re: new item shop furien
 
Quote:

Originally Posted by Divin12 (Post 1891545)
maybe 14 years;)

Ok.
Read rules.

And seems that DEAGLE first letter is not K.


All times are GMT -4. The time now is 20:40.

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