Raised This Month: $51 Target: $400
 12% 

Hulk level limit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rodrigo
Senior Member
Join Date: Jul 2010
Location: Brasil
Old 02-17-2011 , 16:45   Hulk level limit
Reply With Quote #1

Hi ..
Someone can help me on this ?
I want put a limit on max level who player could use the hero, because some players with level 20 it's using Hulk, I think he it's appeal..

PS : I wanna like the hero Noob does.

Thanks..
__________________
rodrigo is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 02-18-2011 , 02:26   Re: Hulk level limit
Reply With Quote #2

http://forums.alliedmods.net/showthr...ght=robin+hood

PHP Code:
// ROBIN HOOD! - Steal money from rich players

/* CVARS - copy and paste to shconfig.cfg

//Robin Hood
robinhood_level 0
robinhood_pctstealmoney 0.15        //What percent of money to give back per shot on player
robinhood_maxlevel 7            //max level allowed to use this power

*/

/*
* v1.1 - Fr33m@n - 8/7/10
*      - cvars name changed due to robin_level already used in Robin hero
*      - Updated to be SH 1.2.0 compliant, removed amx compatibility.
*      - Code cleaned up.
*/

#include <superheromod>

// GLOBAL VARIABLES
new gHeroID
new const gHeroName[] = "Robin Hood"
new bool:gHasRobinHood[SH_MAXSLOTS+1]
new 
bool:gMustDrop[SH_MAXSLOTS+1]
new 
gPcvarPctStealMoneygPcvarMaxLvl
//----------------------------------------------------------------------------------------------
public plugin_init()
{
    
// Plugin Info
    
register_plugin("SUPERHERO Robin Hood""1.1""Fr33m@n")

    
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
    
new pcvarLevel register_cvar("robinhood_level""0")
    
gPcvarPctStealMoney register_cvar("robinhood_pctstealmoney""0.15")
    
gPcvarMaxLvl register_cvar("robinhood_maxlevel""7")

    
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"Steal money from rich players""Take a percent of victim's money by attacking it")
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return

    switch(
mode) {
        case 
SH_HERO_ADD: {
            
gHasRobinHood[id] = true
            robinhood_checklevel
(id)
        }

        case 
SH_HERO_DROP: {
            
gHasRobinHood[id] = false
            gMustDrop
[id] = false
        
}
    }

    
sh_debug_message(id1"%s %s"gHeroNamemode "ADDED" "DROPPED")
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
    
gHasRobinHood[id] = false
    gMustDrop
[id] = false
}
//----------------------------------------------------------------------------------------------
public sh_client_spawn(id)
{
    
robinhood_checklevel(id)
}
//----------------------------------------------------------------------------------------------
robinhood_checklevel(id)
{
    new 
iMaxLvl get_pcvar_num(gPcvarMaxLvl)
    if ( (
gHasRobinHood[id] && sh_get_user_lvl(id) > iMaxLvl) || gMustDrop[id] ) {
        
gMustDrop[id] = true
        gHasRobinHood
[id] = false
        sh_chat_message
(idgHeroID"You must be level %d or lower to use this hero"iMaxLvl)
        
client_cmd(id"say drop %s"gHeroName)
    }
}
//----------------------------------------------------------------------------------------------
public client_damage(attackervictimdamagewpnindex)
{
    if ( !
sh_is_active() ) return
    if ( !
is_user_connected(victim) || !is_user_alive(attacker) ) return

    
// Should nades not count? maybe remove them later
    
if ( gHasRobinHood[attacker] && CSW_P228 <= wpnindex <= CSW_P90 ) {
        
robinhood_stealmoney(attackervictim)
    }
}
//----------------------------------------------------------------------------------------------
// Leave this public so it can be called with a forward from Longshot
public robinhood_stealmoney(attackervictim)
{
    if ( 
sh_is_active() && gHasRobinHood[attacker] && is_user_alive(attacker) )
    {
        new 
iVictimMoney cs_get_user_money(victim)
        new 
iStealMoney floatround(iVictimMoney get_pcvar_float(gPcvarPctStealMoney))

        
// Remove the money from the victim
        
cs_set_user_money(victimiVictimMoney iStealMoney1)
        
        
// Give the money to the attacker
        
cs_set_user_money(attackercs_get_user_money(attacker) + iStealMoney1)
    }
}
//---------------------------------------------------------------------------------------------- 
Look at the
Code:
robinhood_checklevel(id)
forward, where he has placed the
Code:
robinhood_checklevel(id)
forward calls (for example in sh_client_spawn(id))

and how he registers the cvar and so on.
__________________
The Art of War is offline
rodrigo
Senior Member
Join Date: Jul 2010
Location: Brasil
Old 02-18-2011 , 09:59   Re: Hulk level limit
Reply With Quote #3

I will do, thnks .
Btw, I know this it's correct topic but, I see my chucky keeps don't reborn, I didn't see anything like 50%, can you help me here ?
__________________
rodrigo is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 02-18-2011 , 12:26   Re: Hulk level limit
Reply With Quote #4

PHP Code:
#include <superheromod>

// GLOBAL VARIABLES
new gHeroID
new const gHeroName[] = "Chucky"
new bool:gHasChucky[SH_MAXSLOTS+1]
new const 
gModelKnife[] = "models/shmod/chucky_knife.mdl"
new const gReviveSound[] = "ambience/port_suckin1.wav"
new gPcvarCooldown
//----------------------------------------------------------------------------------------------
public plugin_init()
{
    
// Plugin Info
    
register_plugin("SUPERHERO Chucky""1.1""The Art of War")

    
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
    
new pcvarLevel register_cvar("chucky_level""15")
    new 
pcvarSpeed register_cvar("chucky_knifespeed""400")
    new 
pcvarKnifeMult register_cvar("chucky_mult""4.0")
    
gPcvarCooldown register_cvar("chucky_cooldown""400")

    
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"Voodoo Powers""Rise again from the dead! Get a Bloody Knife that does more damage, which you are faster with.")
    
sh_set_hero_speed(gHeroIDpcvarSpeed, {CSW_KNIFE})
    
sh_set_hero_dmgmult(gHeroIDpcvarKnifeMultCSW_KNIFE)

    
// REGISTER EVENTS THIS HERO WILL RESPOND TO!
    
register_event("CurWeapon""weapon_change""be""1=1")
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
    
precache_model(gModelKnife)
    
precache_sound(gReviveSound)
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(idheroIDmode)
{
    
//if no power, return
    
if (gHeroID != heroID) return

    
//Checks if user gets or loses power
    
switch(mode)
    {
        
//if user gets power
        
case SH_HERO_ADD:
        {
            
gHasChucky[id] = true
            switch_model
(id)
        }

        
//if they lose power
        
case SH_HERO_DROP:
        {
            
gHasChucky[id] = false
        
}
    }
}
//----------------------------------------------------------------------------------------------
public sh_round_new()
{
    new 
players[SH_MAXSLOTS], numplayersplayer
    get_players
(playersnumplayers"h")

    for ( new 
0numplayersi++ ) {
        
player players[i]

        
remove_task(player)
        
gPlayerInCooldown[player] = false
    
}
}
//----------------------------------------------------------------------------------------------
public sh_client_death(victimattacker)
{
    if ( !
sh_is_active() || !sh_is_inround() ) return
    if ( !
is_user_connected(victim) || is_user_alive(victim) || !gHasChucky[victim] || gPlayerInCooldown[victim]) return
    if ( 
victim == attacker ) return // avoid the call on change team, use of kill command...

    
set_task(0.7"chucky_respawn"victim)
}
//----------------------------------------------------------------------------------------------
public chucky_respawn(id)
{
    if ( !
is_user_connected(id) || is_user_alive(id) || !sh_is_inround() ) return

    
ExecuteHamB(Ham_CS_RoundRespawnid)

    
emit_sound(idCHAN_STATICgReviveSoundVOL_NORMATTN_NORM0PITCH_NORM)

    
sh_chat_message(idgHeroID"You used Chucky's Voodoo powers to revive yourself.")

    new 
Float:cooldown get_pcvar_float(gPcvarCooldown)
    if ( 
cooldown 0.0 ) {
        
gPlayerInCooldown[id] = true
        set_task
(cooldown"enable_chucky"id)
    }
}
//----------------------------------------------------------------------------------------------
public enable_chucky(id)
{
    
gPlayerInCooldown[id] = false
}
//----------------------------------------------------------------------------------------------
switch_model(id)
{
    
//if client does not have hero, is dead, or sh is off do nothing
    
if ( !sh_is_active() || !is_user_alive(id) || !gHasChucky[id] ) return
    
    
//if client has power set model
    
if ( get_user_weapon(id) == CSW_KNIFE)
    {
        
set_pev(idpev_viewmodel2gModelKnife)
    }
}
//----------------------------------------------------------------------------------------------
public weapon_change(id)
{
    
//do nothing if client does not have hero or sh is off
    
if ( !sh_is_active() || !gHasChucky[id] ) return

    
//weaponID = read_data(2)
    
if ( read_data(2) != CSW_KNIFE) return

    
//switch model
    
switch_model(id)
}
//---------------------------------------------------------------------------------------------- 
__________________
The Art of War is offline
rodrigo
Senior Member
Join Date: Jul 2010
Location: Brasil
Old 02-18-2011 , 15:17   Re: Hulk level limit
Reply With Quote #5

Hello x).
I try make what you say in Hulk, here is (I didn't test yet, I am in my notebook)

Code:
/* CVARS - copy and paste to shconfig.cfg

//Hulk
hulk_level 0
hulk_radius 1800		//Radius of people affected
hulk_cooldown 7			//# of seconds before Hulk can ReStun
hulk_stuntime 3			//# of seconds Hulk Stuns Everybody
hulk_stunspeed 70		//Speed of stunned players
hulk_maxlevel 10		//level máximo que um player pode ter para usa Hulk

*/

#include <superheromod>

// GLOBAL VARIABLES
new gHeroID
new const gHeroName[] = "The Hulk"
new bool:gHasHulk[SH_MAXSLOTS+1]
new bool:gMustDrop[SH_MAXSLOTS+1]
new gPcvarRadius, gPcvarCooldown, gPcvarStunTime, gPcvarStunSpeed, gPcvarMaxLvl

#define gHulkSoundCount 3
new const gStompSound[gHulkSoundCount][] = {
	"debris/bustconcrete1.wav",
	"debris/bustcrate1.wav",
	"debris/bustcrate3.wav"
}
//----------------------------------------------------------------------------------------------
public plugin_init()
{
	// Plugin Info
	register_plugin("SUPERHERO Hulk", SH_VERSION_STR, "{HOJ} Batman")

	// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
	new pcvarLevel = register_cvar("hulk_level", "0")
	gPcvarRadius = register_cvar("hulk_radius", "1800")
	gPcvarCooldown = register_cvar("hulk_cooldown", "7")
	gPcvarStunTime = register_cvar("hulk_stuntime", "3")
	gPcvarStunSpeed = register_cvar("hulk_stunspeed", "70")
	gPcvarMaxLvl = register_cvar("hulk_maxlevel", "10")
	
	// FIRE THE EVENTS TO CREATE THIS SUPERHERO!
	gHeroID = sh_create_hero(gHeroName, pcvarLevel)
	sh_set_hero_info(gHeroID, "Power Stomp", "Immobilizes Self and Nearby Enemies")
	sh_set_hero_bind(gHeroID)
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
	// TBD - SOUNDS!
	for ( new x = 0; x < gHulkSoundCount; x++ ) {
		precache_sound(gStompSound[x])
	}
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(id, heroID, mode)
{
    if ( gHeroID != heroID ) return

    switch(mode) {
        case SH_HERO_ADD: {
            gHasHulk[id] = true
            hulk_checklevel(id)
        }

        case SH_HERO_DROP: {
            gHasHulk[id] = false
            gMustDrop[id] = false
        }
    }

    sh_debug_message(id, 1, "%s %s", gHeroName, mode ? "ADDED" : "DROPPED")
}
//----------------------------------------------------------------------------------------------
public sh_client_spawn(id)
{
	hulk_checklevel(id)
	gPlayerInCooldown[id] = false

	remove_task(id)
}
//----------------------------------------------------------------------------------------------
hulk_checklevel(id)
{
    new iMaxLvl = get_pcvar_num(gPcvarMaxLvl)
    if ( (gHasHulk[id] && sh_get_user_lvl(id) > iMaxLvl) || gMustDrop[id] ) {
        gMustDrop[id] = true
        gHasHulk[id] = false
        sh_chat_message(id, gHeroID, "You must be level %d or lower to use this hero", iMaxLvl)
        client_cmd(id, "say drop %s", gHeroName)
    }
}
//----------------------------------------------------------------------------------------------
public sh_client_death(victim)
{
	if ( victim < 1 || victim > sh_maxplayers() ) return

	remove_task(victim)
}
//----------------------------------------------------------------------------------------------
public sh_hero_key(id, heroID, key)
{
	if ( gHeroID != heroID || !sh_is_inround() ) return
	if ( !is_user_alive(id) || !gHasHulk[id] ) return

	if ( key == SH_KEYDOWN ) {
		new Float:velocity[3]
		pev(id, pev_velocity, velocity)

		// Hulk should technically be standing still to do this...  (i.e. no jump or air)
		// Let them know they already used their ultimate if they have
		if ( velocity[2] < -10.0 || velocity[2] > 10.0 || gPlayerInCooldown[id] ) {
			sh_sound_deny(id)
			return
		}

		// OK Power stomp enemies closer than x distance
		new Float:userOrigin[3], Float:victimOrigin[3], Float:distanceBetween
		new Float:hulkRadius = get_pcvar_float(gPcvarRadius)
		new Float:hulkStunTime = get_pcvar_float(gPcvarStunTime)
		new Float:hulkStunSpeed = get_pcvar_float(gPcvarStunSpeed)
		new CsTeams:idTeam = cs_get_user_team(id)

		new Float:cooldown = get_pcvar_float(gPcvarCooldown)
		if ( cooldown > 0.0 ) sh_set_cooldown(id, cooldown)

		pev(id, pev_origin, userOrigin)

		new players[SH_MAXSLOTS]
		new playerCount, player
		get_players(players, playerCount, "ah")

		for ( new i = 0; i < playerCount; i++ ) {
			player = players[i]

			if ( player == id || idTeam != cs_get_user_team(player) ) {
				pev(player, pev_origin, victimOrigin)

				distanceBetween = get_distance_f(userOrigin, victimOrigin)

				if ( distanceBetween < hulkRadius ) {
					sh_set_stun(player, hulkStunTime, hulkStunSpeed)
					sh_screen_shake(player, 4.0, (hulkStunTime + 1.0), 8.0)
				}
			}
		}

		// Dependent on the hulkStunTime - Set some Stomp Sounds
		new count = 0, parm[2]
		parm[0] = id
		for ( new i = 0; i < 2 * hulkStunTime; i++ ) {
			parm[1] = count++
			if ( count >= gHulkSoundCount ) count = 0
			set_task((i * 1.0) / 2.0, "stomp_sound", id, parm, 2)
		}
	}
}
//----------------------------------------------------------------------------------------------
public stomp_sound(const parm[2])
{
	emit_sound(parm[0], CHAN_STATIC, gStompSound[parm[1]], VOL_NORM, ATTN_NORM, 0, PITCH_HIGH)
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
	gHasHulk[id] = false
}
//----------------------------------------------------------------------------------------------
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1046\\ f0\\ fs16 \n\\ par }
*/
__________________

Last edited by rodrigo; 02-18-2011 at 15:20. Reason: I forget put the cvar
rodrigo is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 02-18-2011 , 18:23   Re: Hulk level limit
Reply With Quote #6

Seems about right, though I have no idea why you have the variable gMustDrop.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
rodrigo
Senior Member
Join Date: Jul 2010
Location: Brasil
Old 02-18-2011 , 19:02   Re: Hulk level limit
Reply With Quote #7

Hmmm...
I test and see he isn't drop, so I make some changes, now he try drop with the player alive or dead.
By what I see, the variable it's needed to make the call, to drop the hero..
Without she, he just try drop alive..
(sorry if I say shit).
__________________
rodrigo is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 02-18-2011 , 19:05   Re: Hulk level limit
Reply With Quote #8

Then activate it so people can drop heroes alive.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
rodrigo
Senior Member
Join Date: Jul 2010
Location: Brasil
Old 02-18-2011 , 19:12   Re: Hulk level limit
Reply With Quote #9

Isn't needed, I fixed...
Players "bug" if I put to them can drop alive, like lose the gun by magneto and catch batman....
__________________
rodrigo is offline
rodrigo
Senior Member
Join Date: Jul 2010
Location: Brasil
Old 02-18-2011 , 19:12   Re: Hulk level limit
Reply With Quote #10

here is :

(ps : I forget use edit button)
Attached Files
File Type: sma Get Plugin or Get Source (sh_hulk.sma - 649 views - 5.8 KB)
__________________
rodrigo 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 03:27.


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