Raised This Month: $ Target: $400
 0% 

limit hero effects to players with >= hero's level


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
genkernel
Junior Member
Join Date: Nov 2004
Old 05-29-2005 , 21:09   limit hero effects to players with >= hero's level
Reply With Quote #1

I am looking for a way to get a players level. So I can do a check and see if that player is greater than or equal to the hero's level.

heres the basic logic I would need
Code:
if (playerslevel >= heroslevel) {
     //do hero stuff to player
}
//else ignore this player
genkernel is offline
bLiNd
Veteran Member
Join Date: Mar 2005
Old 05-29-2005 , 23:19  
Reply With Quote #2

umm... i may not be following you, but why would you need that? if the player has picked the hero it is obviously equal to or greater than...
bLiNd is offline
genkernel
Junior Member
Join Date: Nov 2004
Old 05-29-2005 , 23:31  
Reply With Quote #3

put it in this context

HeroA is a automatic defense hero.

Player B has picked HeroA

Player A attacks Player B

I only want HeroA to effect Players that are equal to or higher level than HeroA's level.

Maybe thats clears it up.
genkernel is offline
bLiNd
Veteran Member
Join Date: Mar 2005
Old 05-29-2005 , 23:34  
Reply With Quote #4

ahh... ok i follow you know. lets use a real example to double check that i follow.

I am level 20
You are level 10
I pick poison ivy
I shoot you
It doesn't affect you
Is that correct?
bLiNd is offline
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 05-30-2005 , 00:06  
Reply With Quote #5

Set this as a Global Variable
Code:
new gPlayerLevels[SH_MAXSLOTS+1]
Set this to get run in the plugin_init so it runs function heroname_levels to check the levels (change heroname to your heroes name)
Code:
	// LEVELS
	register_srvcmd("heroname_levels", "heroname_levels")
	shRegLevels(gHeroName,"heroname_levels")
Set this as a function in the code to obtain a players levels (change heroname to your heroes name)
Code:
public heroname_levels()
{
	new id[5]
	new lev[5]

	read_argv(1,id,4)
	read_argv(2,lev,4)

	gPlayerLevels[str_to_num(id)] = str_to_num(lev)
}
gPlayerLevels[id] now equals the ids level


and to change your code above to: (change heroname to your heroes cvar name)
Code:
	if ( gPlayerLevels[id] >= get_cvar_num("heroname_level")) { 
     	//do hero stuff to player 
	} 
	//you dont need an else if you aren't doing anything on it
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
genkernel
Junior Member
Join Date: Nov 2004
Old 05-30-2005 , 10:51  
Reply With Quote #6

Thanks for help
genkernel 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 18:58.


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