Pacman admin only script help

hello can some 1 help me i got error with scripting pacman i want to make him admin only. This is my first time so i'm a noob in this :shock:




PHP Code:







#include <amxmod.inc>

#include <xtrafun>

#include <superheromod.inc>



// PacMan - UbErNeSS hero..



// CVARS

// PacMan_bullets - How many explosive bullets does he get each round

// PacMan_getM4A1 - Does he get a free M4A1 on respawn.

// PacMan_health - How much hp he has

// PacMan_armor - How much ap he has

// PacMan_gravity - How much gravity he has

// PacMan_speed - How fast he is





// VARIABLES

new gHeroName[]="PacMan (ADMIN ONLY)"

new gHasPacManPower[SH_MAXSLOTS+1]

new 
M4A1sFired[33] = 0

// Test

new gLastWeapon[33]=0

new gLastClipCount[33]=0

new lastammo[33

new 
lastweap[33]



// sprites! 

new spr_laser 

new spr_laser_impact 

new spr_blast_shroom 



//----------------------------------------------------------------------------------------------

public plugin_init()

{

  
// Plugin Info

  
register_plugin("SUPERHERO PacMan","1.2","PacMan")

 

  
// FIRE THE EVENT TO CREATE THIS SUPERHERO!

  
if ( isDebugOn() ) server_print("Attempting to create PacMan Hero")

  if ( !
cvar_exists("PacMan_level") ) register_cvar("PacMan_level""20")

  
shCreateHero(gHeroName"UBERNESS!!!""You get explosive M4A1 bullets/hp/grav/ap/m4a1"false"PacMan_level" )

  

  
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)

  // INIT

  
register_srvcmd("PacMan_init""PacMan_init")

  
shRegHeroInit(gHeroName"PacMan_init")

  
register_event("ResetHUD","newRound","b")

  
// M4A1 DAMAGE

  
register_event("Damage""M4A1_damage""b""2!0")

  
// COUTING BULLETS

  
register_event("CurWeapon","changeWeapon","be","1=1")

  
// MAKE A TRAIL OF THE BULLETS

  
register_event("CurWeapon","make_tracer""be""1=1""3>0"



  
register_cvar("pacman_admin""b");



  
// DEFAULT THE CVARS

  
if ( !cvar_exists("PacMan_bullets") ) register_cvar("PacMan_bullets""30")

  if ( !
cvar_exists("PacMan_getM4A1") ) register_cvar("PacMan_getM4A1""1")

  if ( !
cvar_exists("PacMan_gravity") ) register_cvar("PacMan_gravity""0.40" )

  if ( !
cvar_exists("PacMan_armor") ) register_cvar("PacMan_armor""1000")

  if ( !
cvar_exists("PacMan_health" ) ) register_cvar("PacMan_health""1000")

  if ( !
cvar_exists("PacMan_speed") ) register_cvar("PacMan_speed""1000" )



  
// variable thingys =D

  
shSetMaxHealth(gHeroName"PacMan_health" )

  
shSetMinGravity(gHeroName"PacMan_gravity" )

  
shSetMaxArmor(gHeroName"PacMan_armor" )

  
shSetMaxSpeed(gHeroName"PacMan_speed""[0]" )



}

//----------------------------------------------------------------------------------------------

public PacMan_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 PacMan

  
read_argv(2,temp,5)

  new 
hasPowers=str_to_num(temp)

  
gHasPacManPower[id]=(hasPowers!=0)



if(
gHaspacmanPower[id] && is_user_connected(id))

        
pacman_admincheck(id)

}



public 
pacman_admincheck(id) {

    new 
accessLevel[10]

    
get_cvar_string("pacman_admin"accessLevel10);

    if(
gHaspacmanPower[id] &&  !(get_user_flags(id)&read_flags(accessLevel))) {

        
client_print(idprint_chat"[SH](%s) **Admin Only** You are not authorized to use this hero"gHeroName)

        
gHaspacmanPower[id] = false

        client_cmd
(id"say drop %s"gHeroName)

    }

}

//----------------------------------------------------------------------------------------------

public plugin_precache() { 

    
spr_laser precache_model("sprites/laserbeam.spr"

    
spr_laser_impact precache_model("sprites/zerogxplode.spr"

    
spr_blast_shroom precache_model("sprites/mushroom.spr")

precache_model("models/v_m4a1.mdl")

 

    return 
PLUGIN_CONTINUE 



//----------------------------------------------------------------------------------------------

public PacMan_giveweapons(id)

{

  if ( !
is_user_alive(id) ) return

  
shGiveWeapon(id,"CSW_M4A1")



  return



}

//----------------------------------------------------------------------------------------------

public newRound(id)

{

  new 
parm[1]

  
parm[0]=id

  M4A1sFired
[id] = 0

  gPlayerUltimateUsed
[id]=false

  gLastWeapon
[id]=-1  



  
if (gHasPacManPower[id] && get_cvar_num("PacMan_getM4A1")==1) {

    
shGiveWeapon(id,"weapon_M4A1"

    }

}

//----------------------------------------------------------------------------------------------

public M4A1_damage(id)

{

    if (!
shModActive()) return PLUGIN_CONTINUE



    
new damage read_data(2)

    new 
weaponbodypartattacker_id get_user_attacker(id,weapon,bodypart)

    

    if ( 
attacker_id <=|| attacker_id>SH_MAXSLOTS ) return PLUGIN_CONTINUE

  

    
if ( gHasPacManPower[attacker_id] && weapon == CSW_M4A1 && is_user_alive(id) && (!gPlayerUltimateUsed[attacker_id]))



    new 
health get_user_health(id



    
// mah nigga $id wasn't attacked by another player 

    
if (!is_user_connected(attacker_id)) return PLUGIN_CONTINUE 

    
if (attacker_id == id) return PLUGIN_CONTINUE 



    
// damage is less than 10% 

    
if (((1.0 damage) / (1.0 * (health damage))) < 0.01) return PLUGIN_CONTINUE 



    
new origin[3

    new 
attacker_team[2], victim_team[2



    
get_user_origin(idorigin



    
// player fades.. 

    
set_user_rendering(idkRenderFxFadeSlow255255255kRenderTransColor4); 



    
// beeeg explody! 

    
message_begin(MSG_ALLSVC_TEMPENTITY

    
write_byte(3)            // TE_EXPLOSION 

    
write_coord(origin[0]) 

    
write_coord(origin[1]) 

    
write_coord(origin[2]-22

    
write_short(spr_blast_shroom)    // mushroom cloud 

    
write_byte(40)            // scale in 0.1u 

    
write_byte(12)            // frame rate 

    
write_byte(12)            // TE_EXPLFLAG_NOpARTICLES & TE_EXPLFLAG_NOSOUND 

    
message_end() 





    
// do turn down that awful racket 



    // ..to be replaced by a blood spurt! 

    
message_begin(MSG_ALLSVC_TEMPENTITY

    
write_byte(10)        // TE_LAVASPLASH 

    
write_coord(origin[0]) 

    
write_coord(origin[1]) 

    
write_coord(origin[2]-26

    
message_end() 



    
// kill victim

    
user_kill(id,1)

    
message_beginMSG_ALLget_user_msgid("DeathMsg"),{0,0,0},0)

    
write_byte(attacker_id)

    
write_byte(id)

    
write_byte(0)

    
write_string("M4A1")

    
message_end()

    
//Save Hummiliation

   
new namea[24],namev[24],authida[20],authidv[20],teama[8],teamv[8

   
//Info On Attacker

   
get_user_name(attacker_id,namea,23

   
get_user_team(attacker_id,teama,7

   
get_user_authid(attacker_id,authida,19

   
//Info On Victim

   
get_user_name(id,namev,23

   
get_user_team(id,teamv,7

   
get_user_authid(id,authidv,19)

    
//Log This Kill

    
log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"M4A1^""

    
namea,get_user_userid(attacker_id),authida,teama,namev,get_user_userid(id),authidv,teamv)          



    
/* set_user_health(id, 0) */ 



    // team check! 

    
get_user_team(attacker_idattacker_team1

    
get_user_team(idvictim_team1



    
// for some reason this doesn't update in the hud until the next round.. whatever. 

    
if (!equali(attacker_teamvictim_team)) { 

        
// diff. team;    $attacker_id gets credited for the kill and $250 and XP.

        //        $id gets their suicidal -1 frag back. 

        
set_user_frags(attacker_idget_user_frags(attacker_id)+1

        
set_user_money(attacker_idget_user_money(attacker_id)+150)

        
shAddXP(attacker_idid1)

    } 

    else { 

        
// same team;    $attacker loses a frag and $500 and XP.

        
set_user_frags(attacker_idget_user_frags(attacker_id)-1

        
set_user_money(attacker_idget_user_money(attacker_id)-5000)

        
shAddXP(attacker_idid, -1)

        } 

    return 
PLUGIN_CONTINUE 

    


return 
PLUGIN_CONTINUE

}

//----------------------------------------------------------------------------------------------,

public make_tracer(id) { 



    if (!
shModActive()) return PLUGIN_CONTINUE 

        

    

    
new weap read_data(2)        // id of the weapon 

    
new ammo read_data(3)        // ammo left in clip 



if ( gHasPacManPower[id] && weap == CSW_M4A1 && is_user_alive(id) && (!gPlayerUltimateUsed[id]) ) {



    if (
lastweap[id] == 0lastweap[id] = weap 



    
if ((lastammo[id] > ammo) && (lastweap[id] == weap)) { 



        new 
vec1[3], vec2[3

        
get_user_origin(idvec11// origin; where you are 

        
get_user_origin(idvec24// termina; where your bullet goes 



        // tracer beam 

        
message_begin(MSG_PASSVC_TEMPENTITYvec1

        
write_byte(0)        // TE_BEAMPOINTS 

        
write_coord(vec1[0]) 

        
write_coord(vec1[1]) 

        
write_coord(vec1[2]) 

        
write_coord(vec2[0]) 

        
write_coord(vec2[1]) 

        
write_coord(vec2[2]) 

        
write_short(spr_laser)    // laserbeam sprite 

        
write_byte(0)        // starting frame 

        
write_byte(10)        // frame rate 

        
write_byte(2)        // life in 0.1s 

        
write_byte(4)        // line width in 0.1u 

        
write_byte(1)        // noise in 0.1u 

        
write_byte(0)        // red

        
write_byte(153)      // green 

        
write_byte(0)        // blue

        
write_byte(80)        // brightness 

        
write_byte(100)        // scroll speed 

        
message_end() 



        
// bullet impact explosion 

        
message_begin(MSG_PASSVC_TEMPENTITYvec2

        
write_byte(3)        // TE_EXPLOSION 

        
write_coord(vec2[0])    // end point of beam 

        
write_coord(vec2[1]) 

        
write_coord(vec2[2]) 

        
write_short(spr_laser_impact)    // blast sprite 

        
write_byte(10)            // scale in 0.1u 

        
write_byte(30)            // frame rate 

        
write_byte(8)            // TE_EXPLFLAG_NOpARTICLES 

        
message_end()            // ..unless i'm mistaken, nOparticles helps avoid a crash 

    




    
lastammo[id] = ammo 

    lastweap
[id] = weap 



    
return PLUGIN_CONTINUE 

    
}

    return 
PLUGIN_CONTINUE 



//----------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------

public changeWeapon(id)

{

    if ( !
gHasPacManPower[id] || !shModActive() ) return PLUGIN_CONTINUE

    
new  clipammo

    
new wpn_id=get_user_weapon(idclipammo);



    if ( 
wpn_id!=CSW_M4A1 ) return PLUGIN_CONTINUE



    
// This event gets trigger on a switch to a weapon tooClick post title for more details

    // Easy work around

    
if ( wpn_id != gLastWeapon[id] )

    {

      
gLastWeapon[id]=wpn_id  

      
return PLUGIN_CONTINUE // user just switched weapons

    
}



    if ( 
clip >= gLastClipCount[id] )

    {

      
gLastClipCount[id]=clip

      
return PLUGIN_CONTINUE

    
}

    
gLastClipCount[id]=clip



    
// Ok - if it fell through here - you got a user firing the M4A1



    
return PLUGIN_CONTINUE











what do i wrong? please help me.



Thank you.


Orignal From: Pacman admin only script help

No comments

Not a single link is allowed to submit in comment :o