i get this stupid error that i cant fix and dont be sceared i wont post this hero if you all dont want to
Code:
//obiwan! .
/* CVARS - copy and paste to shconfig.cfg
//obiwan
obiwan_level 6
obiwan_healpoints 20 // how much shall the force heal you
obiwan_knifespeed 700 // speed of Darth Maul in knife mode
obiwan_knifemult 4.70 // multiplier for knife damage...
obiwan_cooldown 10 // cooldown from keydown
obiwan_grabtime 10 // ammount of grab time
exodus_grabforce 20 // ammount of grab force (def=8 )
exodus_grabteam 0 // can he grab teammates 0=no 1=yes
*/
#include <amxmod>
#include <Vexd_Utilities>
#include <superheromod>
// GLOBAL VARIABLES
new gHeroName[]="obiwan"
new bool:ghasobiwanPowers[SH_MAXSLOTS+1]
new bool:grabmodeon[33]
new grabbed[SH_MAXSLOTS]
new grablength[SH_MAXSLOTS]
new gPlayerMaxHealth[SH_MAXSLOTS+1]
new velocity_multiplier
new gobiwanTimer[SH_MAXSLOTS+1]
new gSpriteLightning
new gobiwanSound[]="ambience/zapmachine.wav"
new gHealPoints
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Obi Wan Kinobi","1.0","Om3gA")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("obiwan_level", "10")
register_cvar("obiwan_healpoints", "20")
register_cvar("obiwan_knifespeed", "700")
register_cvar("obiwan_knifemult", "4.70")
register_cvar("obiwan_cooldown", "10")
register_cvar("obiwan_grabtime","10")
register_cvar("obiwan_grabforce","10")
register_cvar("obiwan_grabteam", "0")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName,"force", "Use the Force to grab your oppenets and use your light saber", false, "obiwan_level" )
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
// INIT
register_srvcmd("obiwan_init", "obiwan_init")
shRegHeroInit(gHeroName, "obiwan_init")
// HEAL LOOP
set_task(1.0,"obiwan_loop",0,"",0,"b")
//NEW ROUND
register_event("ResetHUD","newSpawn","b")
//DEATH
register_event("DeathMsg", "obiwan_death", "a")
// WEAPON CHECK
register_event("CurWeapon","weaponChange","be","1=1")
// EXTRA KNIFE DAMAGE
register_event("Damage", "obiwan_damage", "b", "2!0")
// LOOP
register_srvcmd("exodus_loop", "obiwan_loop")
set_task(1.0,"obiwan_loop",0,"",0,"b")
// Let Server know about obiwan max knife speed
shSetMaxSpeed(gHeroName, "obiwan_knifespeed", "[29]")
//Makes superhero tell obiwan a players max health
register_srvcmd("obiwan_maxhealth", "obiwan_maxhealth")
shRegMaxHealth(gHeroName, "obiwan_maxhealth" )
gHealPoints = get_cvar_num("obiwan_healpoints")
// KEY DOWN
register_srvcmd("obiwan_kd", "obiwan_kd")
shRegKeyDown(gHeroName, "obiwan_kd")
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_model("models/shmod/v_obiwan_knife.mdl")
precache_model("models/shmod/p_obiwan_knife.mdl")
gSpriteLightning = precache_model("sprites/lgtning.spr")
precache_sound(gobiwanSound)
}
//----------------------------------------------------------------------------------------------
public obiwan_init()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id=str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has obiwan power
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
gPlayerMaxHealth[id] = 100
ghasobiwanPowers[id] = (hasPowers != 0)
if ( !is_user_alive(id) ) return
switchmodel(id)
if ( ghasobiwanPowers[id] = true && is_user_connected(id) ) {
release(id)
gobiwanTimer[id] = -1
shRemSpeedPower(id)
}
new parm[1]
parm[0]=id
if ( hasPowers != 0){
set_task( get_cvar_float("obiwan_grabtime"), "obiwan_loop", id, parm, 1, "b")
}
else {
remove_task(id)
}
}
//----------------------------------------------------------------------------------------------
public newSpawn(id)
{
gPlayerUltimateUsed[id] = false
gobiwanTimer[id] = -1
if (grabmodeon[id]) release(id)
if ( ghasobiwanPowers[id] && is_user_alive(id) && shModActive() ) {
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
if (wpnid != CSW_KNIFE && wpnid > 0) {
new wpn[32]
get_weaponname(wpnid,wpn,31)
engclient_cmd(id,wpn)
}
}
}
//----------------------------------------------------------------------------------------------
public obiwan_loop()
{
if (!shModActive()) return
for ( new id = 1; id <= SH_MAXSLOTS; id++ ) {
if ( ghasobiwanPowers[id] && is_user_alive(id) ) {
// Let the server add the hps back since the # of max hps is controlled by it
// I.E. superman has more than 100 hps etc.
shAddHPs(id, gHealPoints, gPlayerMaxHealth[id] )
}
}
}
//----------------------------------------------------------------------------------------------
public client_disconnect(id)
{
gobiwanTimer[id] = -1
gPlayerUltimateUsed[id] = false
remove_task(100+id)
grabmodeon[id] = false
}
//----------------------------------------------------------------------------------------------
// RESPOND TO KEYDOWN
public obiwan_kd()
{
if ( !hasRoundStarted() ) return PLUGIN_HANDLED
// First Argument is an id with Obi Wan Powers!
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
if ( !is_user_alive(id) || !ghasobiwanPowers[id] ) return PLUGIN_HANDLED
if ( gPlayerUltimateUsed[id] || gobiwanTimer[id] >= 0) {
playSoundDenySelect(id)
return PLUGIN_HANDLED
}
gobiwanTimer[id] = get_cvar_num("obiwan_grabtime")
ultimateTimer(id, get_cvar_float("obiwan_cooldown"))
grab(id)
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public obiwan_maxhealth()
{
new id[6]
new health[9]
read_argv(1,id,5)
read_argv(2,health,8)
gPlayerMaxHealth[str_to_num(id)] = str_to_num(health)
for ( new id = 1; id <= SH_MAXSLOTS; id++ ) {
if ( ghasobiwanPowers[id] && is_user_alive(id) ) {
if ( gobiwanTimer[id] > 0 ) {
new message[128]
format(message, 127, "%d seconds left for your force grab", gobiwanTimer[id] )
set_hudmessage(255,255,0,-1.0,0.36,0,1.0,1.0,0.0,0.0,4)
show_hudmessage( id, message)
gobiwanTimer[id]--
continue
}
else if ( gobiwanTimer[id] == 0 ) {
gobiwanTimer[id] = -1
release(id)
stopSound(id)
}
}
}
}
//----------------------------------------------------------------------------------------------
public obiwan_death()
{
new id=read_data(2)
if (is_user_alive(grabbed[id])) {
release(id)
}
gobiwanTimer[id] = -1
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public grabtask(parm[])
{
new id = parm[0]
new targetid, body
if (!grabbed[id]) {
get_user_aiming(id, targetid, body)
if (targetid) {
set_grabbed(id, targetid)
}
}
if (grabbed[id]) {
new origin[3], look[3], direction[3], moveto[3], grabbedorigin[3], velocity[3], length
if (!is_user_alive(grabbed[id])) {
release(id)
return
}
get_user_origin(id, origin, 1)
get_user_origin(id, look, 3)
get_user_origin(grabbed[id], grabbedorigin)
direction[0]=look[0]-origin[0]
direction[1]=look[1]-origin[1]
direction[2]=look[2]-origin[2]
length = get_distance(look,origin)
if (!length) length=1 // avoid division by 0
moveto[0]=origin[0]+direction[0]*grablength[id]/length
moveto[1]=origin[1]+direction[1]*grablength[id]/length
moveto[2]=origin[2]+direction[2]*grablength[id]/length
velocity[0]=(moveto[0]-grabbedorigin[0])*velocity_multiplier
velocity[1]=(moveto[1]-grabbedorigin[1])*velocity_multiplier
velocity[2]=(moveto[2]-grabbedorigin[2])*velocity_multiplier
#if defined AMX_NEW || defined AMXX_VERSION
iSet_set_velocity(grabbed[id], velocity)
#else
set_user_velocity(grabbed[id], velocity)
#endif
}
}
//----------------------------------------------------------------------------------------------
public grab(id)
{
if (!grabmodeon[id]) {
new targetid, body
new parm[1]
parm[0] = id
velocity_multiplier = get_cvar_num("obiwan_grabforce")
grabmodeon[id]=true
set_task(0.1, "grabtask", 100+id, parm, 1, "b")
get_user_aiming(id, targetid, body)
if (targetid) {
set_grabbed(id, targetid)
}
else {
set_hudmessage(255,255,0,-1.0,0.38,0,1.0,4.0,0.0,0.0,6)
show_hudmessage(id,"Searching for someone from the dark side")
}
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public release(id)
{
if (grabmodeon[id]) {
grabmodeon[id]=false
if (grabbed[id]) {
new targname[32]
set_user_gravity(grabbed[id])
set_user_rendering(grabbed[id])
get_user_name(grabbed[id],targname,31)
}
grabbed[id] = 0
gobiwanTimer[id] = -1
remove_task(100+id)
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public spec_event(id)
{
new targetid = read_data(2)
if (targetid < 1 || targetid > 32)
return PLUGIN_CONTINUE
if (grabmodeon[id] && !grabbed[id])
{
set_grabbed(id, targetid)
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public set_grabbed(id, targetid)
{
if( get_cvar_num("obiwan_grabteam") == 0 ){
if( get_user_team(id) == get_user_team(targetid)) return
}
new origin1[3], origin2[3], targname[32], name[32]
get_user_origin(id, origin1)
get_user_origin(targetid, origin2)
lightning_effect(id, targetid, 80)
//emit_sound(id,CHAN_STATIC, gobiwanSound, 1.0, ATTN_NORM, 0, PITCH_LOW)
grabbed[id]=targetid
grablength[id]=get_distance(origin1,origin2)
set_user_gravity(targetid,0.001)
shGlow(targetid, 255, 238, 0)
get_user_name(targetid,targname,31)
get_user_name(id,name,31)
set_hudmessage(255,255,0,-1.0,0.38,0,1.0,4.0,0.0,0.0,6)
show_hudmessage(targetid,"%s has grabbed you", name)
show_hudmessage(id,"You have grabbed onto %s, he is on the dark side")
}
//----------------------------------------------------------------------------------------------
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( 6 ) // life
write_byte( linewidth ) // line width
write_byte( 15 ) // noise amplitude
write_byte( 255 ) // r, g, b
write_byte( 238 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte( 35 ) // brightness
write_byte( 0 ) // scroll speed
message_end()
}
//----------------------------------------------------------------------------------------------
public stopSound(id)
{
new SND_STOP=(1<<5)
emit_sound(id,CHAN_STATIC, gobiwanSound, 1.0, ATTN_NORM, SND_STOP, PITCH_LOW)
}
//----------------------------------------------------------------------------------------------
public switchmodel(id)
{
if ( !is_user_alive(id) || !ghasobiwanPowers[id] ) return
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
if (wpnid == CSW_KNIFE) {
// Weapon Model change thanks to [CCC]Taz-Devil
Entvars_Set_String(id, EV_SZ_viewmodel, "models/shmod/v_obiwan_knife.mdl")
Entvars_Set_String(id, EV_SZ_weaponmodel, "models/shmod/p_obiwan_knife.mdl")
}
}
//----------------------------------------------------------------------------------------------
public weaponChange(id)
{
if ( !ghasobiwanPowers[id] || !shModActive() ) return
new wpnid = read_data(2)
if ( wpnid == CSW_KNIFE ) switchmodel(id)
}
//----------------------------------------------------------------------------------------------
public obiwan_damage(id)
{
if (!shModActive() || !is_user_alive(id)) return
new damage = read_data(2)
new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
new headshot = bodypart == 1 ? 1 : 0
if ( attacker <= 0 || attacker > SH_MAXSLOTS ) return
if ( ghasobiwanPowers[attacker] && weapon == CSW_KNIFE && is_user_alive(id) ) {
// do extra damage
new extraDamage = floatround(damage * get_cvar_float("obiwan_knifemult") - damage)
if (extraDamage > 0) shExtraDamage( id, attacker, extraDamage, "knife", headshot)
}
}
//----------------------------------------------------------------------------------------------