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

[THC RPG] Total HardCore RPG


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
TryNoob
BANNED
Join Date: Aug 2011
Old 01-29-2012 , 15:47   Re: [THC RPG] Total HardCore RPG
Reply With Quote #10

Skill returns the weapon in the early rounds.

Code:
/*
 * ============================================================================
 *
 *  [THC RPG] Total HardCore RPG
 *
 *  File:          recovery.inc
 *  Type:          Upgrade
 *  Description:   
 *  Author:        
 *
 *  Copyright (C) 
 *
 *  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/>.
 *
 * ============================================================================
 */
  
#include <sdkhooks>
new Handle:Weapons[MAXPLAYERS+1];
/**
 * This module's identifier.
 */
new Module:g_modulerecovery;

new g_recoveryUpgradeConfigCache[UpgradeConfigs];

/**
 * Register this module.
 */
recovery_Register()
{
    // Define all the module's data as layed out by enum ModuleData in project.inc.
    new moduledata[ModuleData];
    
    moduledata[ModuleData_Disabled] = false;
    moduledata[ModuleData_Hidden] = false;
    strcopy(moduledata[ModuleData_FullName], MM_DATA_FULLNAME, "[OBT] Recovery Weapon");
    strcopy(moduledata[ModuleData_ShortName], MM_DATA_SHORTNAME, "recovery");
    strcopy(moduledata[ModuleData_Description], MM_DATA_DESCRIPTION, "Recovery Weapon");
    
    new Module:dependencies[MM_DATA_DEPENDENCIES];
    dependencies[0] = g_moduleCore;
    dependencies[1] = INVALID_MODULE;
    moduledata[ModuleData_Dependencies] = dependencies;

    new Module:interlocks[MM_DATA_INTERLOCKS];
    interlocks[0] = INVALID_MODULE;
    moduledata[ModuleData_Interlocks] = interlocks;

    moduledata[ModuleData_TeamLock] = 0;
    moduledata[ModuleData_MaxLevel] = 1;
    moduledata[ModuleData_Cost] = 25;
    moduledata[ModuleData_iCost] = 10;

    // Send this array of data to the module manager.
    g_modulerecovery = ModuleMgr_Register(moduledata);

    // Now register the events we're going to use.
    #if defined EVENT_MANAGER
        EventMgr_RegisterEvent(g_modulerecovery, "Event_OnEventsRegister", "recovery_OnEventsRegister");
    #endif  
  
    // Register config file(s) that this module will use.
    #if defined CONFIG_MANAGER
        ConfigMgr_Register(g_modulerecovery, "recovery_OnConfigReload", "configs/thc_rpg/recovery.txt");
    #endif
}

/**
 * Register all events here.
 */
public recovery_OnEventsRegister()
{
    // Register all the events needed for this module.
    EventMgr_RegisterEvent(g_modulerecovery, "Event_OnMapStart",             "recovery_OnMapStart");
    EventMgr_RegisterEvent(g_modulerecovery, "Event_OnClientDisconnect",      "recovery_OnClientDisconnect");
    EventMgr_RegisterEvent(g_modulerecovery, "Event_OnConfigsExecuted",       "recovery_OnConfigsExecuted");
    EventMgr_RegisterEvent(g_modulerecovery, "Event_OnClientPutInServer",     "recovery_OnClientPutInServer");
    #if defined PROJECT_GAME_CSS
        //EventMgr_RegisterEvent(g_modulerecovery, "Event_PlayerDeath",             "recovery_PlayerDeath");
        //EventMgr_RegisterEvent(g_modulerecovery, "Event_PlayerHurt",             "recovery_PlayerHurt");
        EventMgr_RegisterEvent(g_modulerecovery, "Event_RoundEnd",                "recovery_RoundEnd");
        EventMgr_RegisterEvent(g_modulerecovery, "Event_PlayerSpawn",           "recovery_PlayerSpawn");
    #endif
}

/**
 * All modules and events have been registered by this point.  Event priority can be changed here.
 */
public recovery_OnEventsReady()
{
}

#if defined CONFIG_MANAGER
/**
 * Called when a registered config file (by this module) is manually reloaded.
 */
public recovery_OnConfigReload(configindex)
{
    #if defined LOG_MANAGER
        LogMgr_Print(g_modulerecovery, LogType_Normal, "recoveryConfigReload", "Reloaded recovery module's config (index %d)", configindex);
    #endif

    ConfigMgr_CacheKv(g_modulerecovery, CM_CONFIGINDEX_FIRST, "recoveryModule_ConfigCache");
}

/**
  * Read config values
  */
public KvCache:recoveryModule_ConfigCache(Handle:kv, sectionindex, const String:sectionname[])
{
    // Read Upgrade config
    if(StrEqual(sectionname, "recovery", false))
    {
        g_recoveryUpgradeConfigCache[UpgradeConfig_Disable] = KvGetNum(kv, "disable");
        g_recoveryUpgradeConfigCache[UpgradeConfig_TeamLock] = KvGetNum(kv, "teamlock");
        g_recoveryUpgradeConfigCache[UpgradeConfig_MaxLevel] = KvGetNum(kv, "maxlevel");
        g_recoveryUpgradeConfigCache[UpgradeConfig_Cost] = KvGetNum(kv, "cost");
        g_recoveryUpgradeConfigCache[UpgradeConfig_iCost] = KvGetNum(kv, "icost");

        if(g_recoveryUpgradeConfigCache[UpgradeConfig_Disable]==1)
            ModuleMgr_Disable(g_modulerecovery);
        
        ModuleMgr_WriteCell(g_modulerecovery, ModuleData_MaxLevel, g_recoveryUpgradeConfigCache[UpgradeConfig_MaxLevel]);
        ModuleMgr_WriteCell(g_modulerecovery, ModuleData_Cost, g_recoveryUpgradeConfigCache[UpgradeConfig_Cost]);
        ModuleMgr_WriteCell(g_modulerecovery, ModuleData_iCost, g_recoveryUpgradeConfigCache[UpgradeConfig_iCost]);
    }
}
#endif

/**
 * The map has started.
 */
public recovery_OnMapStart()
{
    #if defined CONFIG_MANAGER
        ConfigMgr_CacheKv(g_modulerecovery, CM_CONFIGINDEX_FIRST, "recoveryModule_ConfigCache");
    #endif
}

public recovery_PlayerSpawn(client)
{
    new level=GetPlayerUpgradeLevel(client,g_modulerecovery);
    if(level>0)
    {
        new weapons = GetArraySize(Weapons[client]);

        if (!weapons)
            return;
        
        for (new x=0; x < 5; x++)
        {
            new remove_weapon=GetPlayerWeaponSlot(client, x);
            if(IsValidEdict(remove_weapon))
            {
                RemovePlayerItem(client, remove_weapon);
                AcceptEntityInput(remove_weapon, "Kill");
            }
        }
        
        for (new i, String:weapon[128]; i < weapons; i++)
        {            
            GetArrayString(Weapons[client], i, weapon, sizeof(weapon));    
            GivePlayerItem(client, weapon);
        }
        
        ClearArray(Weapons[client]);
    }
}

public Action:Hook_WeaponDrop(client, entity)
{
    if(entity >= 0&&IsValidPlayer(client)&&IsClientInGame(client))
    {
        if(GetClientHealth(client)<=0)
        {
            decl String:weapon[128];
            GetEdictClassname(entity, weapon, sizeof(weapon));
            PushArrayString(Weapons[client], weapon);
        }
    }
}

public OnEntityDestroyed(entity)
{
    if (entity <= MaxClients || !IsValidEdict(entity))
        return;

    decl String:classname[128];
    GetEdictClassname(entity, classname, sizeof classname);

    if (StrContains(classname, "weapon_") == -1)
        return;

    new client = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");

    if (client == -1 || !IsClientInGame(client) || IsPlayerAlive(client))
        return;

    PushArrayString(Weapons[client], classname);
}

/**
 * Round has ended.
 *
 * @param winner    The index of the winning team.
 */
public recovery_RoundEnd(winner)
{
    new Handle:restart_delay=FindConVar("mp_round_restart_delay");
    new Float:convar=GetConVarFloat(restart_delay);
    CreateTimer(convar-0.5, RoundEndPushArray);
}

public Action:RoundEndPushArray(Handle:timer)
{
    for(new client=1;client<=MaxClients;client++)
    {
        if(client < 1 || !IsClientInGame(client) || !IsPlayerAlive(client))
            continue;
        for(new x=0;x<5;x++)
        {
            new weapons = GetPlayerWeaponSlot(client, x);
            if(weapons != -1)
            {
                decl String:weapon[64];
                GetEdictClassname(weapons, weapon, sizeof(weapon));
                PushArrayString(Weapons[client], weapon);
            }
        }
    }
}

public recovery_OnConfigsExecuted()
{
    for (new i = 1; i <= MaxClients; i++)
    {
        Weapons[i] = CreateArray(128);
    }
}

/**
 * Client has joined the server.
 * 
 * @param client    The client index.
 */
public recovery_OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_WeaponDrop, Hook_WeaponDrop);
}

/**
 * Client is disconnecting from the server.
 * 
 * @param client    The client index.
 */
public recovery_OnClientDisconnect(client)
{
    ClearArray(Weapons[client]);
}
And the translation (ru)
Code:
  "recovery_fullname"
  {
    "en" ""
    "de" ""
    "fr" ""
    "no" ""
    "se" ""
    "tr" ""
    "hu" ""
    "pl" ""
    "ru" "Возврат оружия"
    "dk" ""
    "nl" ""
    "lv" ""
  }
  "recovery_description"
  {
    "en" ""
    "de" ""
    "fr" ""
    "no" ""
    "se" ""
    "tr" ""
    "hu" ""
    "pl" ""
    "ru" "Возвращает оружие в следующем раунде"
    "dk" ""
    "nl" ""
    "lv" ""
  }

Last edited by TryNoob; 01-31-2012 at 15:04. Reason: Fix bug.
TryNoob is offline
 



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 17:25.


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