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

Admin Only Script Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
heliumdream
Senior Member
Join Date: Aug 2006
Old 09-02-2006 , 20:11   Admin Only Script Help
Reply With Quote #1

Okay I searched the threads, and found a hero that already had Admin Only *I used Uncle Sam*. I ripped the code and formulated this script. Initially I thought it was working, but some players ended up bypassing the admin only tag by mashing over and over again trying to select it and magically they got it. My routines to drop the hero while they are using it do not work! I put the admin_check routine everywhere I could bloody think of and still no dice! I would appreciate anyones ideas as to how I could fix this:

-edit- I appologize for not commenting my code properly

Code:
#include <amxmod>
#include <superheromod>

// Juggernaut - made by Mydas

/* CVARS
juggernaut_level 9 - his level
*/

#define HPNO 2048
// GLOBAL VARIABLES
new gHeroName[]="Juggernaut Part II"
new bool:gHasJuggernautPowers[SH_MAXSLOTS+1]
new bool:gJuggernautSelected [SH_MAXSLOTS+1]
new playerhealth[SH_MAXSLOTS+1]
new bool:tocheck[SH_MAXSLOTS+1]
new bool:protection[SH_MAXSLOTS+1]

public plugin_init()
{
  // Plugin Info
    register_plugin("SUPERHERO Juggernaut part II","1.0","Mydas")

    register_cvar("juggernaut_level", "9")
    register_cvar("juggernaut_adminflag","a")
    shCreateHero(gHeroName, "Invulnerability", "Almost permanent resistance to damage not caused by weapons (fall damage, lasers)", false, "juggernaut_level" )
    register_srvcmd("juggernaut_init", "juggernaut_init")
    shRegHeroInit(gHeroName, "juggernaut_init")

    register_event("ResetHUD","newRound","b")
    register_event("Damage", "juggernaut_damage", "b", "2!0")
    register_event("ResetHUD", "newSpawn", "b")
    register_event("DeathMsg", "newDeath", "a")

    set_task(0.1,"juggernaut_loop",0,"",0,"b" )
}

public juggernaut_init() 
{ 
    new temp[6] 

    read_argv(1, temp, 5) 
    new id = str_to_num(temp) 

    read_argv(2, temp, 5) 
    new hasPowers = str_to_num(temp) 
    gHasJuggernautPowers[id] = (hasPowers!=0)
    gJuggernautSelected[id]=gHasJuggernautPowers[id]
    
    juggernaut_admincheck(id)

    if (gHasJuggernautPowers[id]) {
        client_print(id, print_center, "You will get Juggernaut next time you spawn")
        tocheck[id]=true
    } else {
        tocheck[id]=false
        protection[id]=false
        if (get_user_health(id) >= HPNO) set_user_health(id, get_user_health(id)-HPNO)
    }
} 

public newRound(id)
{
  juggernaut_admincheck(id)
  if (!gHasJuggernautPowers[id]) return
  if (tocheck[id]) tocheck[id]=false
  new parm[1]
  parm[0]=id
  //set_user_health(id, 100)
  set_task(1.0,"sethealth",id,parm,1)
}

public newSpawn(id)
{
        juggernaut_admincheck(id)
}

public newDeath()
{
    new id = read_data(2)

    // In case server does not allow drop alive check on death
    juggernaut_admincheck(id)
}

public sethealth(parm[])
{
    new id=parm[0]
    playerhealth[id]=get_user_health(id)+HPNO
    protection[id]=true
    set_user_health(id, playerhealth[id])
}

public juggernaut_loop()
{
    for (new id = 1; id <= SH_MAXSLOTS; id++) {
        if (gHasJuggernautPowers[id] && protection[id] && is_user_alive(id) && hasRoundStarted() && !tocheck[id]){
            juggernaut_admincheck(id)
            //client_print(id,print_center,"life : %i-%i",get_user_health(id), playerhealth[id]) //debugging purposes
            //if ((get_user_health(id) <= HPNO) && (get_user_health(id) > playerhealth[id]-HPNO)) playerhealth[id] = get_user_health(id)+HPNO
            if (get_user_health(id) < playerhealth[id]) set_user_health(id, playerhealth[id])
            
          }
    }
}

public juggernaut_damage(id) 
{
    new damage = read_data(2)
    new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
    if (attacker <= 0 || attacker > SH_MAXSLOTS || !gHasJuggernautPowers[id] || !is_user_alive(id) || !protection[id]) return 
    if (attacker!=id && !tocheck[id]) playerhealth[id] -= damage
    if (playerhealth[id] <= HPNO+10) {
        set_user_health(id, random_num(1,10))
        protection[id]=false
    }
}

public juggernaut_admincheck(id)
{    
    new accessLevel[10]
    get_cvar_string("juggernaut_adminflag", accessLevel, 9)

    if ( gJuggernautSelected[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)
        gJuggernautSelected[id] = false
        client_cmd(id, "say drop %s", gHeroName)
    }
}
Thanks in Advance
-hd

Last edited by heliumdream; 09-02-2006 at 20:14.
heliumdream is offline
newbie1233
BANNED
Join Date: Jul 2006
Old 09-07-2006 , 06:40   Re: Admin Only Script Help
Reply With Quote #2

Code:
/* CVARS
juggernaut_level 9 - his level
*/
to
Code:
juggernaut_level 9 - his level
juggernaut_adminflag a
in ur shero.cfg


+karma if i helped u
newbie1233 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-07-2006 , 09:14   Re: Admin Only Script Help
Reply With Quote #3

newbie, your a complete moron.

helium, if what i think your saying is what im thinking, then there pretty much is no way around it.
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`
heliumdream
Senior Member
Join Date: Aug 2006
Old 09-07-2006 , 13:30   Re: Admin Only Script Help
Reply With Quote #4

No this was not this instance, i added the cvar_adminlevel a lines to my shero.cfg so that was not the problem...however I fixed my problem by just recoding it different ways till I found one that actually worked. FYI - I would consider this a flaw in the code possibly, I joined some random server and was easily able to replicate this. I picked their admin only level 0 heroes by spamming the heroselect key until it let me pick it. There were no calls being made to drop the hero once I was using it either. Wierd =/
heliumdream is offline
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 09-07-2006 , 23:33   Re: Admin Only Script Help
Reply With Quote #5

Quote:
Originally Posted by heliumdream View Post
No this was not this instance, i added the cvar_adminlevel a lines to my shero.cfg so that was not the problem...however I fixed my problem by just recoding it different ways till I found one that actually worked. FYI - I would consider this a flaw in the code possibly, I joined some random server and was easily able to replicate this. I picked their admin only level 0 heroes by spamming the heroselect key until it let me pick it. There were no calls being made to drop the hero once I was using it either. Wierd =/
Well that's the scripters fault not ours since we didn't make those flawed heroes have admin only code. And yes I am well aware of that issue, but it doesn't affect the only hero with that code because people don't realize there is a block checked before the use is allowed.
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 09-08-2006 , 09:32   Re: Admin Only Script Help
Reply With Quote #6

you could try adding
Code:
client_cmd(id, "slot10")
after the client_cmd(id, "say drop %s", gHeroName) so that it exits the hero select menu after they drop the hero so that they can't keep repicking the hero.
FYI reason repicking it over and over works is eventualy the antiflood plugin blocks the say drop hero cmd, so another solution could be to set amx_flood_time to 0.0
__________________
If at first you don't succeed, then skydiving isn't for you.
G-Dog is offline
Send a message via AIM to G-Dog
aptmeatwad
New Member
Join Date: Sep 2006
Old 09-10-2006 , 14:07   Re: Admin Only Script Help
Reply With Quote #7

Hey Im kinda a newbie on this coding stuff, so can anyone tell me what to put where to make my heros admin only. without the problem of the anti flood thing. I will be very happy if anyoine can do this for me.
aptmeatwad is offline
Send a message via AIM to aptmeatwad Send a message via MSN to aptmeatwad Send a message via Yahoo to aptmeatwad
heliumdream
Senior Member
Join Date: Aug 2006
Old 09-13-2006 , 15:24   Re: Admin Only Script Help
Reply With Quote #8

The routine I added ended up working for heroes with a keydown function, I made a seperate call on the keydown to make nonadmins drop it. However, I tried to make a passive hero - Juggernaut II - where you invul to lasers...well I put the call in the +life loop and would cause overflow errors to anyone who picked it and crash the server. I haven't rewritten it yet, so I just disabled the hero...I'll post later if I update the admin only script and get it working the way we intend.
heliumdream 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 05:08.


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