Raised This Month: $ Target: $400
 0% 

Extra Lives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iknowiz58
Member
Join Date: Sep 2006
Old 12-20-2008 , 22:37   Extra Lives
Reply With Quote #1

Could someone please help add a cvar to make this team specific?

For example I would like to add just 1 more cvar

EL_team 1 = ct , 2 = ter , 3 = both


Code:
#include <amxmodx>
#include <fun>
#include <cstrike>

new enabled, num_of_lives

new player_lives[32]

new plugin[] = "Extra lives"
new version[] = "0.1"
new author[] = "Doombringer"

public plugin_init()
{
    register_plugin(plugin, version, author)
    
    enabled = register_cvar("EL_Enabled","1")
    
    num_of_lives = register_cvar("EL_Lives","5")
    
    register_event("DeathMsg","hook_death","a")
    
    register_logevent ("hook_newround",2,"1=Round_Start")
}

public client_putinserver(id)
{
    if(get_pcvar_num(enabled) < 1)
    return PLUGIN_CONTINUE
    
    player_lives[id] = get_pcvar_num(num_of_lives)
    
    return PLUGIN_CONTINUE
}

public give_weapons(id)
{
    new CsTeams:team = cs_get_user_team(id)
    
    if(team == CS_TEAM_T)
    {
        give_item(id, "weapon_glock18")
        give_item(id, "weapon_knife")
    }
    else if(team == CS_TEAM_CT)
    {
        give_item(id, "weapon_usp")
        give_item(id, "weapon_knife")
    }
}

public respawn(id) spawn(id);

public hook_death()
{
    if(get_pcvar_num(enabled) < 1)
    return PLUGIN_CONTINUE
    
    new victim = read_data(2)     
    
    if(player_lives[victim] > 0)
    {
        set_task(0.1,"respawn",victim)
        set_task(0.3,"respawn",victim)
        set_task(0.5,"give_weapons",victim)
        
        player_lives[victim]--
        
        client_print(victim, print_chat,"You have %d %s left",player_lives[victim], player_lives[victim] == 1 ? "extra life":"extra lives")
        
        return PLUGIN_CONTINUE
    }
    else
    {
        client_print(victim, print_chat,"You have run out of extra lives!")
        return PLUGIN_CONTINUE
    }
    
    return PLUGIN_CONTINUE
}

public hook_newround() 
{ 
     if(get_pcvar_num(enabled) < 1) 
     return PLUGIN_CONTINUE 
     
     new players[32], playercount 
     get_players(players,playercount,"h") 
     
     new id
     
     for (new playernum = 0; playernum < playercount; playernum++) 
     { 
          id = players[playernum]
      
          player_lives[id] = get_pcvar_num(num_of_lives) 
      
          client_print(id, print_chat,"You have %d %s, be careful...",player_lives[id], player_lives[id] == 1 ? "extra life":"extra lives") 
     } 
      
     return PLUGIN_CONTINUE 
}

http://forums.alliedmods.net/showthread.php?t=40311


Reason:
I wanted cts to have 1 extra life on deathrun maps.
__________________


Last edited by iknowiz58; 12-21-2008 at 08:22. Reason: to be more specifc
iknowiz58 is offline
iknowiz58
Member
Join Date: Sep 2006
Old 12-21-2008 , 16:23   Re: Extra Lives
Reply With Quote #2

is anyone able to do this?
__________________

iknowiz58 is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-21-2008 , 16:55   Re: Extra Lives
Reply With Quote #3

Are you able to read rules, so you could know when you can bump?
SnoW is offline
Send a message via MSN to SnoW
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-21-2008 , 17:20   Re: Extra Lives
Reply With Quote #4

Set EL_Team to 0 to disable the plugin.
Attached Files
File Type: sma Get Plugin or Get Source (xtra_lives.sma - 705 views - 1.3 KB)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-22-2008 at 06:06.
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 12-22-2008 , 05:50   Re: Extra Lives
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new bool:g_bRoundEnd;
new 
bool:g_usedLife;

public 
plugin_init() {
    
register_plugin("CT Extra Live""1.0""xPaw");
    
RegisterHam(Ham_Killed"player""fwPlayerKilled");

    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
    
register_logevent("Logevent_Round_End"2"1=Round_End")
}

public 
fwPlayerKilledid ) {
    if( 
get_user_team(id) == && !g_usedLife && !g_bRoundEnd ) {
        
g_usedLife true;
        
ExecuteHam(Ham_Spawnid);
        
client_print(idprint_chat"* You have respawned due you had one extra live.");
    }
}

public 
Event_HLTV_New_Round() {
    
g_usedLife    false;
    
g_bRoundEnd    false;
}

public 
Logevent_Round_End()
    
g_bRoundEnd true
__________________
xPaw is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-22-2008 , 05:59   Re: Extra Lives
Reply With Quote #6

WTF ?!

Also, i forgot to Post register, updated.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-22-2008 at 06:07.
ConnorMcLeod is offline
Reply



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 01:26.


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