AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=43)
-   -   How To: Make a Superhero Admin Only (https://forums.alliedmods.net/showthread.php?t=52254)

Rolnaaba 03-06-2007 12:08

How To: Make a Superhero Admin Only
 
1 Attachment(s)
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:

Rolnaaba 03-19-2007 12:56

Re: How To: Make a Superhero Admin Only
 
sry but bump saw this question AGAIN!!

D4ark 03-19-2007 13:24

Re: How To: Make a Superhero Admin Only
 
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...

Rolnaaba 03-19-2007 14:43

Re: How To: Make a Superhero Admin Only
 
paste errors please

taboo 03-19-2007 15:02

Re: How To: Make a Superhero Admin Only
 
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

D4ark 03-19-2007 15:39

Re: How To: Make a Superhero Admin Only
 
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.. )

Emp` 03-19-2007 19:50

Re: How To: Make a Superhero Admin Only
 
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()

D4ark 03-20-2007 02:55

Re: How To: Make a Superhero Admin Only
 
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?

Rolnaaba 03-20-2007 08:40

Re: How To: Make a Superhero Admin Only
 
ok so my code works was just a typo on your part lol

D4ark 03-20-2007 09:56

Re: How To: Make a Superhero Admin Only
 
Yeah, but u cant pick it, even when ur admin.... i have abcdefghijklmnopqrstu, so why cant i use it? when i pick it it says: ***admin only*** then i drop the hero....

U know how to change it??

( ur code wroks, but change gHEROName to gHeroName :D )


All times are GMT -4. The time now is 17:58.

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