Raised This Month: $ Target: $400
 0% 

How To: Make a Superhero Admin Only


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rolnaaba
Veteran Member
Join Date: May 2006
Old 03-06-2007 , 12:08   How To: Make a Superhero Admin Only
Reply With Quote #1

Because I have seen it too many times! (please excuse my semicolons )

This is the Method I recomend:
Code:
  public HERO_init() {     new temp[6];     read_argv(1,temp,5);     new id = str_to_num(temp); //get players index         read_argv(2,temp,5);     new hasPowers = str_to_num(temp); //check if they have your power         gHasHEROPower[id] = (hasPowers != 0); //set have power     gHEROSelected[id] = gHasHEROPower[id];       if(gHasHEROPower[id] && is_user_connected(id)) { //if they have your power and are connected do admin check           HERO_admincheck(id);     } } public HERO_admincheck(id) { //admin check function     new accessLevel[10] = "a" //set you admin check level to what you want     /* or make it a cvar:     get_cvar_string("HERO_adminflag", accessLevel, 9)     */       if ( gHEROSelected[id] &&  !(get_user_flags(id)&read_flags(accessLevel)) ) {           client_print(id, print_chat, "[SH](%s) **Admin Only** You are not authorized to use this hero", gHEROName)           gHasHEROPower[id] = false           client_cmd(id, "say drop %s", gHEROName)     } }
of course you change "HERO" in all these to your hero's name also you need to register things I didnt in this script.

can this be stickied so i will stop seeing this question please lol

Below is an example script of a hero that just checks if you are admin or not:
Attached Files
File Type: sma Get Plugin or Get Source (sh_admin_check.sma - 1645 views - 1.2 KB)
__________________
DO NOT PM me about avp mod.

Last edited by Rolnaaba; 03-22-2007 at 10:32.
Rolnaaba is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 03-19-2007 , 12:56   Re: How To: Make a Superhero Admin Only
Reply With Quote #2

sry but bump saw this question AGAIN!!
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
D4ark
Senior Member
Join Date: Feb 2007
Old 03-19-2007 , 13:24   Re: How To: Make a Superhero Admin Only
Reply With Quote #3

I cant Get It To Work.... I Added Exactly What U Said, And It Dont Compile....Actually I Get Errors With The Admincheck Thing, But Also With Things That Were Fine Before...
D4ark is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 03-19-2007 , 14:43   Re: How To: Make a Superhero Admin Only
Reply With Quote #4

paste errors please
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
taboo
New Member
Join Date: Mar 2007
Old 03-19-2007 , 15:02   Re: How To: Make a Superhero Admin Only
Reply With Quote #5

Sorry but can someone reupload or reattach the glugin?
He just say stupid error and no more, but sma file downloads perfectly gut i need first plugin, so reupload it
taboo is offline
D4ark
Senior Member
Join Date: Feb 2007
Old 03-19-2007 , 15:39   Re: How To: Make a Superhero Admin Only
Reply With Quote #6

what plugin? this isnt a plugin, it is a way to make heroes admin only... u need to edit the HERO sma, then recompile it..isnt it?.. and the errors, yeah, ill get them, just let me find them.. hmm, let me c...

Here they are:

Code:
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(67) : warning 217: loose indentation
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(70) : error 017: undefined symbol "mindbender_admincheck"
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(72) : warning 217: loose indentation
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(78) : warning 217: loose indentation
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(78) : error 029: invalid expression, assumed zero
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(78) : error 017: undefined symbol "mindbender_damage"
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(91) : error 017: undefined symbol "playSound"
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(92) : error 017: undefined symbol "playSound"
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(93) : error 017: undefined symbol "mindbender_switch"
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(100) : warning 225: unreachable code
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(100) : error 029: invalid expression, assumed zero
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(100) : error 017: undefined symbol "mindbender_switch"
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(105) : error 017: undefined symbol "lightning_effect"
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(105) : warning 215: expression has no effect
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(105) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(105) : error 029: invalid expression, assumed zero
C:\Documents and Settings\HP_Eier\Skrivebord\Compiler\TPHeroes\sh_mindbend\sh_mi
ndbend.sma(105) : fatal error 107: too many error messages on one line
And the sma...

Code:
#include <amxmod.inc>
#include <xtrafun>
#include <superheromod.inc>

// Dr. Mindbender

// CVARS
// mindbender_level
// mindbender_cooldown  -- How long time between each time if is used
//mindbender_admincheck

// VARIABLES
new gHeroName[]="Dr. Mindbender"
new bool:gHasMindbenderPowers[SH_MAXSLOTS+1]
new bool:gMindbenderSelected[SH_MAXSLOTS+1]
new gSpriteLightning
//----------------------------------------------------------------------------------------------
public plugin_init()
{
  // Plugin Info
  register_plugin("SUPERHERO Dr. Mindbender","1.14.4","Necroscope")
 
  // FIRE THE EVENT TO CREATE THIS SUPERHERO!
  if ( isDebugOn() ) server_print("Attempting to create Mindbender")
  register_cvar("mindbender_level", "5" )
  shCreateHero(gHeroName, "Mental Control", "Make player switch to knife", false, "mindbender_level" )
  
  // REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
  // INIT
  register_srvcmd("mindbender_init", "mindbender_init")
  shRegHeroInit(gHeroName, "mindbender_init")
  // GET MORE GUNZ!
  register_event("ResetHUD","newRound","b")
  register_event("Damage", "mindbender_damage", "b", "2!0")

  // DEFAULT THE CVARS
  register_cvar("mindbender_cooldown", "15" )
  register_cvar("mindbender_stuntime", "5" )
  register_cvar("mindbender_stunspeed", "50" )
  register_cvar("mindbender_admincheck", "a" )
} 
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
  precache_sound("ambience/deadsignal1.wav")
  gSpriteLightning = precache_model("sprites/lgtning.spr")
}
//----------------------------------------------------------------------------------------------
public newRound(id)
{
  gPlayerUltimateUsed[id]=false
  return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public mindbender_init()
{
  new temp[128]
  // First Argument is an id
  read_argv(1,temp,5)
  new id=str_to_num(temp)
  
  // 2nd Argument is 0 or 1 depending on whether the id has wolverine skills
  read_argv(2,temp,5)
  new hasPowers=str_to_num(temp)

  gHasMindbenderPowers[id] = (hasPowers != 0); //set have power
   gMindbenderSelected[id] = gHasMindbenderPowers[id];
  
   if(gHasMindbenderPowers[id] && is_user_connected(id)) { //if they have your power and are connected do admin check
         mindbender_admincheck(id)

  if ( hasPowers )
   gHasMindbenderPowers[id]=true
  else
   gHasMindbenderPowers[id]=false  
}
//----------------------------------------------------------------------------------------------
public mindbender_damage(id)
{
  if (!shModActive() || !gHasMindbenderPowers[id] || gPlayerUltimateUsed[id] ) return PLUGIN_CONTINUE

  new damage = read_data(2)
  new weapon, bodypart, attacker = get_user_attacker(id,weapon,bodypart)
  
  if ( is_user_alive(id) && id != attacker )
  {
    // Start Timer
    new MindbenderCooldown=get_cvar_num("mindbender_cooldown")
    ultimateTimer(id, MindbenderCooldown * 1.0)
    // Forceweapon Switch
    playSound(id)
    playSound(attacker)
    mindbender_switch(id,attacker)
  }
  setScreenFlash(attacker, 200, 200, 200, 10, damage )  //Screen Flash
    
  return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public mindbender_switch(id,victim)
{ 
  new name[32]
  new BenderStunTime=get_cvar_num("mindbender_stuntime")
  new BenderStunSpeed=get_cvar_num("mindbender_stunspeed")
  lightning_effect(id, victim, 10)
  engclient_cmd(victim,"weapon_knife")
  shStun(victim, BenderStunTime)
  set_user_maxspeed(victim, BenderStunSpeed * 1.0)
  
  get_user_name(victim,name,31)
}
//----------------------------------------------------------------------------------------------
public lightning_effect(id, targetid, linewidth)
{
  	message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
	write_byte( 8 );
	write_short(id);	// start entity
	write_short(targetid);	// entity
	write_short(gSpriteLightning );	// model
	write_byte( 0 ); // starting frame
	write_byte( 15 );  // frame rate
	write_byte( 8 );  // life
	write_byte( linewidth );  // line width
	write_byte( 10 );  // noise amplitude
	write_byte( 100 );	// r, g, b
	write_byte( 100 );	// r, g, b
	write_byte( 255 );	// r, g, b
	write_byte( 255 );	// brightness
	write_byte( 0 );	// scroll speed
	message_end();
}
//----------------------------------------------------------------------------------------------
public playSound(id)
{
  new parm[1]
  parm[0]=id
  
  emit_sound(id, CHAN_AUTO, "ambience/deadsignal1.wav", 1.0, ATTN_NORM, 0, PITCH_HIGH)
  set_task(1.5,"stopSound", 0, parm, 1)
} 
//----------------------------------------------------------------------------------------------
public stopSound(parm[])
{
  new sndStop=(1<<5)
  emit_sound(parm[0], CHAN_AUTO, "ambience/deadsignal1.wav", 1.0, ATTN_NORM, sndStop, PITCH_NORM)
}
//----------------------------------------------------------------------------------------------
public mindbender_admincheck(id) { //admin check function
    new accessLevel[10] = ADMIN_LEVEL_A //set you admin check level to what you want
    /* or make it a cvar
    get_cvar_string("mindbender_adminflag", accessLevel, 9)
    */
 
    if ( gMindbenderSelected[id] &&  !(get_user_flags(id)&read_flags(accessLevel)) ) {
          client_print(id, print_chat, "[SH](%s) **Admin Only** You are not authorized to use this hero", gHEROName)
          gHasMindbenderPower[id] = false
          client_cmd(id, "say drop %s", gHEROName)
    }
}
//----------------------------------------------------------------------------------------------
So.. hope u can tell me what i did wrong.. ( didnt change anything from the original mindbender, just added, so i got no idea why i get the mindbender_damaga etc errors.. )
D4ark is offline
killer2100
Member
Join Date: Apr 2010
Location: Ireland (Not Irish)
Old 11-20-2011 , 11:57   Re: How To: Make a Superhero Admin Only
Reply With Quote #7

This Is My Hero Code:
Code:
:
// SHADOWCAT! from the X-men, Kitty Pryde can walk thu walls.
// Hero Originally named NightCrawler, changed since powers did not fit.

/* CVARS - copy and paste to shconfig.cfg

//Shadowcat
shadowcat_level 0
shadowcat_cooldown 30		//# of seconds before Shadowcat can NoClip Again
shadowcat_cliptime 6		//# of seconds Shadowcat has in noclip mode.

*/

#include <superheromod>

// GLOBAL VARIABLES
new gHeroID
new const gHeroName[] = "Shadowcat"
new bool:gHasShadowcat[SH_MAXSLOTS+1]
new gShadowcatTimer[SH_MAXSLOTS+1]
new const gSoundShadowcat[] = "ambience/alien_zonerator.wav"
new gPcvarCooldown, gPcvarClipTime
new gMsgSync
//----------------------------------------------------------------------------------------------
public plugin_init()
{
	// Plugin Info
	register_plugin("SUPERHERO Shadowcat", SH_VERSION_STR, "{HOJ} Batman")

	// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
	new pcvarLevel = register_cvar("shadowcat_level", "8")
	gPcvarCooldown = register_cvar("shadowcat_cooldown", "180")
	gPcvarClipTime = register_cvar("shadowcat_cliptime", "4")

	// FIRE THE EVENTS TO CREATE THIS SUPERHERO!
	gHeroID = sh_create_hero(gHeroName, pcvarLevel)
	sh_set_hero_info(gHeroID, "Walk Through Walls", "Can Walk Through Walls for Short Time - GET STUCK AND YOU'LL BE AUTO-SLAIN!")
	sh_set_hero_bind(gHeroID)

	// LOOP
	set_task(1.0, "shadowcat_loop", _, _, _, "b")

	gMsgSync = CreateHudSyncObj()
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
	precache_sound(gSoundShadowcat)
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(id, heroID, mode)
{
	if ( gHeroID != heroID ) return

	switch(mode) {
		case SH_HERO_ADD: {
			gHasShadowcat[id] = true

			// Make sure looop doesn't fire for them
			gShadowcatTimer[id] = -1
		}

		case SH_HERO_DROP: {
			gHasShadowcat[id] = false

			if ( gShadowcatTimer[id] >= 0 ) shadowcat_endnoclip(id)
		}
	}

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

	gShadowcatTimer[id]= -1

	if ( gHasShadowcat[id] ) {
		shadowcat_endnoclip(id)
	}
}
//----------------------------------------------------------------------------------------------
public sh_hero_key(id, heroID, key)
{
	if ( gHeroID != heroID || sh_is_freezetime() || !is_user_alive(id) ) return

	if ( key == SH_KEYDOWN ) {
		// Make sure they're not in the middle of clip already
		// Let them know they already used their ultimate if they have
		if ( gPlayerInCooldown[id] || gShadowcatTimer[id] >= 0 ) {
			sh_sound_deny(id)
			return
		}

		//If the user already has noclip (prob from another hero) cancel this keydown
		if ( get_user_noclip(id) ) {
			sh_chat_message(id, gHeroID, "You are already using noclip")
			sh_sound_deny(id)
			return
		}

		gShadowcatTimer[id] = get_pcvar_num(gPcvarClipTime)

		set_user_noclip(id, 1)

		// Shadowcat Messsage
		set_hudmessage(255, 0, 0, -1.0, 0.3, 0, 0.25, 1.2, 0.0, 0.0, -1)
		ShowSyncHudMsg(id, gMsgSync, "Entered %s Mode^nDon't get Stuck or you will die", gHeroName)

		emit_sound(id, CHAN_STATIC, gSoundShadowcat, 0.2, ATTN_NORM, 0, PITCH_LOW)
	}
}
//----------------------------------------------------------------------------------------------
public shadowcat_loop()
{
	static players[SH_MAXSLOTS], playerCount, player, i
	static Float:cooldown, noclipTime
	cooldown = get_pcvar_float(gPcvarCooldown)
	get_players(players, playerCount, "ah")

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

		if ( gHasShadowcat[player] ) {
			noclipTime = gShadowcatTimer[player]
			if ( noclipTime > 0 ) {
				set_hudmessage(255, 0, 0, -1.0, 0.3, 0, 1.0, 1.2, 0.0, 0.0, -1)
				ShowSyncHudMsg(player, gMsgSync, "%d second%s left of %s Mode^nDon't get Stuck or you will Die", noclipTime, noclipTime == 1 ? "" : "s", gHeroName)

				gShadowcatTimer[player]--
			}
			else if ( noclipTime == 0 ) {
				if ( cooldown > 0.0 ) sh_set_cooldown(player, cooldown)

				gShadowcatTimer[player]--

				shadowcat_endnoclip(player)
			}
		}
	}
}
//----------------------------------------------------------------------------------------------
shadowcat_endnoclip(id)
{
	if ( !is_user_connected(id) ) return

	gShadowcatTimer[id] = -1

	// Stop noclip sound
	emit_sound(id, CHAN_STATIC, gSoundShadowcat, 0.0, ATTN_NORM, SND_STOP, PITCH_LOW)

	if ( !is_user_alive(id) ) return

	if ( get_user_noclip(id) ) {
		// Turn off no-clipping and kill user if stuck
		set_user_noclip(id, 0)

		// If player is stuck kill them
		new Float:origin[3], hulltype
		pev(id, pev_origin, origin)
		hulltype = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
		if ( !sh_hull_vacant(id, origin, hulltype) ) {
			user_kill(id)
		}
	}
}
//----------------------------------------------------------------------------------------------
public sh_client_death(victim)
{
	gPlayerInCooldown[victim] = false

	gShadowcatTimer[victim]= -1

	if ( gHasShadowcat[victim] ) {
		shadowcat_endnoclip(victim)
	}
}
//----------------------------------------------------------------------------------------------
public shadowcat_init() 
{
    new temp[6];
    read_argv(1,temp,5);
    new id = str_to_num(temp); //get players index
   
    read_argv(2,temp,5);
    new hasPowers = str_to_num(temp); //check if they have your power
   
    gHasshadowcatPower[id] = (hasPowers != 0); //set have power
    gshadowcatSelected[id] = gHasshadowcatPower[id];
  
    if(gHasshadowcatPower[id] && is_user_connected(id)) { //if they have your power and are connected do admin check
          shadowcat_admincheck(id);
    }
}
public shadowcat_admincheck(id) { //admin check function
    new accessLevel[10] = "a" //set you admin check level to what you want
    /* or make it a cvar:
    get_cvar_string("shadowcat_adminflag", accessLevel, 9)
    */
 
    if ( gshadowcatSelected[id] &&  !(get_user_flags(id)&read_flags(accessLevel)) ) {
          client_print(id, print_chat, "[SH](%s) **VIP Only** Get Vip To Use This Hero.", gshadowcatName)
          gHasshadowcatPower[id] = false
          client_cmd(id, "say drop %s", gshadowcatName)
    }
}
I Dont know how to post the compile errors but just put in .sma and compile yourself and you will see errors.
__________________
Im New To Cs Zombie Mode, Making My Own Server, Always Accept Help

Last edited by killer2100; 11-20-2011 at 12:01.
killer2100 is offline
Send a message via Skype™ to killer2100
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-19-2007 , 19:50   Re: How To: Make a Superhero Admin Only
Reply With Quote #8

you're missing a } after
Code:
   if(gHasMindbenderPowers[id] && is_user_connected(id)) { //if they have your power and are connected do admin check
         mindbender_admincheck(id)
in the mindbender_init()
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
D4ark
Senior Member
Join Date: Feb 2007
Old 03-20-2007 , 02:55   Re: How To: Make a Superhero Admin Only
Reply With Quote #9

Thanks, the hero compiled now ( i changed that, and gHEROName to gHeroName, and it compiled without errors or warnings..)

I tryed it, and it is admin only... the only problem is, it cant find out whos admin, so i cant use it... srry for the english, let me try again.. i have full access, but when i try to pick this hero, it says admin only, and i drop it.....

Is there anything wrong with the sma, which does that?
D4ark is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 03-20-2007 , 08:40   Re: How To: Make a Superhero Admin Only
Reply With Quote #10

ok so my code works was just a typo on your part lol
__________________
DO NOT PM me about avp mod.
Rolnaaba 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:50.


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