Raised This Month: $ Target: $400
 0% 

HookMod X


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ts2do
Senior Member
Join Date: Mar 2004
Old 04-05-2004 , 21:43  
Reply With Quote #7

revised::: but Im still having trouble at the hilighted part....
the error Im gettin is like PM getting NaN velocity on 1 or 0.....ne1 can explain why it doesnt like my numbers
Code:
#define STS_CHNL    6 #define STS_FLAG11 11 //Bomb planting #define STS_FLAG12 12 //Bomb defusing #include<amxmodx> #include<fun> #include<engine> #define TE_BEAMENTS 8 #define TE_KILLBEAM 99 #define BEAMLIFE 100 #define DELTA_T 0.1 new Float:beamcreated[33] new grabbed[33] new hooxtarget[33] new oldtargorigin[33][3] new targethit[33] new oldentorigin[33][3] new beam /* cvars -> local variables that will be synced in a timer */ new sv_hooksound,sv_hook,sv_hook_notify_when_active //new sv_hookwidth //new sv_hooknoise,sv_hookcolor,sv_hookbrightness,sv_hookspeed new sv_hookforce //new sv_hook_beamlife new Float:sv_hook_syncspeed public hookgrab(id) {    if (!(get_cvar_float("mp_freezetime"))&&(get_gametime()<=get_cvar_float("mp_freezetime")))       return 1    new cvar = sv_hook    if (cvar == 1)    {       if(!is_user_alive(id))          return 1       set_user_gravity(id,0.1)       set_user_maxspeed(id,0.1)       new lookx[3]       get_user_origin(id,lookx,3)       entity_set_vector(hooxtarget[id],EV_VEC_origin,Float:lookx)       set_hookgrabbed(id)    }    return 1 } public report(id)     server_cmd("say %d",id) public notify_hook_status(svIndex[]) {     if(sv_hook_notify_when_active == 1 && sv_hook ==1)     {         client_print(0,print_chat,"[AMX] HookGrab mod is active!  say /hook for more info.")     }     new sId[32]     sId[0] = 0     set_task(380.0,"notify_hook_status",0,sId,31)     return 0 } public sync_cvars(sId[]) {  /* optimization: sync cvars in a timer to avoid stressful cvar lookups. */    /* if you add cvars, please follow this method to maintain speed */    /* floats */    sv_hook_syncspeed=get_cvar_float("sv_hook_syncspeed")+0.1    /* non floats */    sv_hooksound=get_cvar_num("sv_hooksound")    sv_hook=get_cvar_num("sv_hook")    sv_hook_notify_when_active=get_cvar_num("sv_hook_notify_when_active")    //sv_hookwidth=get_cvar_num("sv_hookwidth")    //sv_hooknoise=get_cvar_num("sv_hooknoise")    //sv_hookcolor=get_cvar_num("sv_hookcolor")    //sv_hookbrightness=get_cvar_num("sv_hookbrightness") //   sv_hookspeed=get_cvar_num("sv_hookspeed") //   sv_hook_beamlife=get_cvar_num("sv_hook_beamlife")    //sv_hook_allow_admin=get_cvar_num("sv_hook_allow_admin")    sv_hookforce=get_cvar_num("sv_hookforce")    set_task(sv_hook_syncspeed-0.1,"sync_cvars",0,sId[0],31)    return 0 } public set_hookgrabbed(id) {    new Float:origin[3]    entity_get_vector(hooxtarget[id],EV_VEC_origin,origin)    FVecIVec(origin,oldentorigin[id])    if(sv_hook == 0)       return 0    new origin1[3]    get_user_origin(id, origin1)    new soundcvar = sv_hooksound    if (soundcvar == 1)    {       emit_sound(id, CHAN_STATIC, "weapons/xbow_hit1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)    }    new body,hooktarget    get_user_aiming(id,hooktarget,body)    if(hooktarget){       targethit[id] = hooktarget       entity_get_vector(hooktarget,EV_VEC_origin,origin)       FVecIVec(origin,oldtargorigin[id])    }    grabbed[id] = id    set_beam(id)    new parm[2]    parm[0] = id    set_task(DELTA_T, "hookgrabtask", 101+id, parm, 1, "b")    return 0 } public set_beam(id)//,type) {     if(is_user_bot(id)){         message_begin(MSG_ONE, 98, {0,0,0},id)//ScreenFade =98         write_short( 1<<15 )         write_short( 1<<10 )         write_short( 1<<12 )         write_byte( 255 )         write_byte( 255 )         write_byte( 255 )         write_byte( 255 )         message_end()     }     //new color = sv_hookcolor     message_begin( MSG_BROADCAST,SVC_TEMPENTITY,{0,0,0} )     write_byte ( TE_BEAMENTS )       write_short ( hooxtarget[id] )     // ent     write_short( id )     write_short( beam )     write_byte( 1 ) // framestart     write_byte( 1 ) // framerate     write_byte( 0 ) // life     write_byte( 50 ) // width     write_byte( 32 ) // noise     write_byte( 255 ) //     write_byte( 255 ) // r, g, b     write_byte( 255 ) //     write_byte( 255 ) // brightness     write_byte( 100 ) // speed     message_end()     new aimvec[3],Float:origin[3]         entity_get_vector(hooxtarget[id],EV_VEC_origin,origin)     FVecIVec(origin,aimvec)     message_begin( MSG_PVS, SVC_TEMPENTITY)     write_byte( 9 )     write_coord( aimvec[0] )     write_coord( aimvec[1] )     write_coord( aimvec[2] )     message_end()         beamcreated[id] = get_gametime()         return 0 }
public hookgrabtask(parm[])
{
new id = parm[0]
if(grabbed[id])
{
new origin[3], moveto[3], velocity[3], length
if (!is_user_alive(grabbed[id]))
{
unhook(id)
return 0
}
new Float:forigin[3]
entity_get_vector(hooxtarget[id],EV_VEC_origin,forigin)
get_user_origin(id, origin)//, 1)
new speed = sv_hookforce
new dist1[3]
for(new p=0;p<3;p++){
dist1[p] = floatround(forigin[p])
}
length = get_distance(dist1,origin)
if(length<=20)
return 0
for(new p = 0;p<3;p++){
moveto[p]=origin[p]+(floatround(forigin[p])-origin[p])*speed/length
velocity[p]=(moveto[p]-origin[p])
}
entity_set_vector(id, EV_VEC_velocity, Float:velocity)
if(targethit[id]){
new diff[3]
entity_get_vector(targethit[id],EV_VEC_origin,forigin)
for(new l = 0; l < 3; l++){
diff[l] = floatround(forigin[l]) - oldtargorigin[id][l] + oldentorigin[id][l]
oldtargorigin[id][l] = floatround(forigin[l])
oldentorigin[id][l]=diff[l]
}
entity_set_vector(hooxtarget[id],EV_VEC_origin,Float:diff)
}
}
return 0
}

Code:
public playerhit_sound(id) {    new soundcvar2 = sv_hooksound    if (soundcvar2 == 1)    {       emit_sound(id, CHAN_STATIC, "common/bodydrop4.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)    }    return 0 } public unhook(id) {    if(grabbed[id]){       killbeam(id)       targethit[id]=0       grabbed[id]=false }    if(task_exists(101+id))       remove_task(101+id)    set_user_gravity(id,1.0)    set_user_maxspeed(id,280.0)    return 1 } public killbeam(id) {    message_begin( MSG_BROADCAST, SVC_TEMPENTITY )    write_byte( TE_KILLBEAM )    write_short( hooxtarget[id] )    message_end()    return 0 } public new_round(id) {    if (grabbed[id])    {       unhook(id)    }    return 0 } public plugin_precache() {    beam=precache_model("sprites/rope.spr")    precache_sound("weapons/xbow_hit1.wav")    precache_sound("common/bodydrop4.wav")    return 0 } public help_motd(id) {    new hook_motd[1300]    new text[768]    text = "There are two different types of hooks, one lets you \       swing (+hook), and the other will pull you directly towards the \       location you hooked onto. \       To bind the keys follow these directions: "    add(hook_motd,1299,text)    text = "- First open your console with the tilde ` key \       - Choose the keys that you want to use for the hooks \       - Type in bind ^"The key you chose^" ^"+hook^" \       - Press enter to complete the bind, It should look like this \       examples: bind ^"f^" ^"+hook^" "    add(hook_motd,1299,text)    text = "It takes some time to get used to the speed, momentum and \       swing. After a few minutes you should start getting the \       hang of it. \       Have Fun!!"    add(hook_motd,1299,text)    show_motd(id,hook_motd,"Hook Help:")    return 0 } public bot_interface(){     new sid[8],id2,clip,ammo     read_argv(1,sid,7)     id2 = str_to_num(sid)         new gunid         gunid = get_user_weapon(id2,clip,ammo)     new teamname[3]     get_user_team(id2,teamname,2)     new teambool = containi(teamname,"CT")     if((grabbed[id2]!=id2)||(gunid!=CSW_C4)||((get_user_flags(0,STS_CHNL)&(1<<STS_FLAG12))&&(teambool==1))||(( get_user_flags(0,STS_CHNL)&(1<<STS_FLAG11))&&(teambool==0))||(!(get_cvar_float("mp_freezetime"))&&(get_gametime()<= get_cvar_float("mp_freezetime")))){         unhook(id2)         hookgrab(id2)         new parm[2]         parm[0]=id2         set_task(2.0,"unhookbot",0,parm,1)     } } public unhookbot(parm[]){         new id=parm[0]     server_cmd("botunhook %i",id) } public bot_unhook(){     new sid[8],id2     read_argv(1,sid,7)     id2 = str_to_num(sid)     unhook(id2) } public plugin_init() {    register_plugin("Hook Grab w/ Bot Support","0.9.8","{W`C}Bludy|GeekGod|Ivn-Software|ts2do")    register_cvar("sv_hook","1")    register_cvar("sv_hook_beamlife","0.0") /* around 11 seconds by default. 0 disables. */    register_cvar("sv_hook_notify_when_active","1")    register_cvar("sv_hook_allow_admin","1")    register_cvar("sv_hook_syncspeed","5.0") /* speed at which the sync routing will be called */    register_cvar("sv_hookforce","600")    //register_cvar("sv_hookwidth","5")    //register_cvar("sv_hooknoise","32")    //register_cvar("sv_hookcolor","0")    //register_cvar("sv_hookbrightness","100")    register_cvar("amx_autohook_bots_freq","3.0")    register_cvar("sv_hookspeed","1") /* speed of hook being deployed. */    register_cvar("sv_hookmsgs","0")    register_cvar("sv_hooksound","1")    register_clcmd("+hook","hookgrab")    register_clcmd("-hook","unhook")    register_srvcmd("bothook","bot_interface")    register_srvcmd("botunhook","bot_unhook")    register_clcmd("say /hook","help_motd")    register_clcmd("say hook","help_motd")    register_event("ResetHUD", "new_round", "b")    new sId[32]    sId[0] = 0    set_task(380.0,"notify_hook_status",0,sId,31)    sync_cvars(sId[0]) /* sync cvars now! */    set_task(5.0,"pluginstart") } public pluginstart(){     set_task(get_cvar_float("amx_autohook_bots_freq"),"chk_hook")     return 0    } round_start(){     remove_task(34028)     set_task(get_cvar_float("amx_autohook_bots_freq"),"chk_hook") } public client_putinserver(id){    hooxtarget[id] = create_entity("info_target")    DispatchSpawn(hooxtarget[id]) } public chk_hook(){     new players[32],inum     new maxpl = get_maxplayers()     for(new a = 1; a < maxpl; a++) {         if(is_user_connected(a)){             if(is_user_bot(a)){                 if(is_user_alive(a)){                     players[inum] = a                     inum++                 }             }         }     }     new guy = random_num(0,inum-1)     if(!players[guy])         return 0     server_cmd("bothook %i",players[guy])     set_task(get_cvar_float("amx_autohook_bots_freq"),"chk_hook")     return 0 } public plugin_log(){     new args = read_logargc()     if(!(args == 2))         return 0     new msg[32]     read_logargv(1,msg,31)     if(msg[6] == 'S')         round_start()     return 0 }
ts2do is offline
Send a message via AIM to ts2do
 



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 21:18.


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