Raised This Month: $ Target: $400
 0% 

Help with RuneMod plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KaPaTeJIb
Member
Join Date: Oct 2012
Location: Tbilisi
Old 06-23-2013 , 01:54   Help with RuneMod plugin
Reply With Quote #1

Hi all, my server is using RuneMod plugin and in runemod_ninja is error:

Code:
L 03/25/2011 - 01:43:09: [AMXX] Run time error 4: index out of bounds 
L 03/25/2011 - 01:43:09: [AMXX]    [0] runemod_ninja.sma::client_PreThink (line 225)
L 03/25/2011 - 01:43:10: [AMXX] Displaying debug trace (plugin "runemod_ninja.amxx")
L 03/25/2011 - 01:43:10: [AMXX] Run time error 4: index out of bounds 
L 03/25/2011 - 01:43:10: [AMXX]    [0] runemod_ninja.sma::client_PreThink (line 213)
L 03/25/2011 - 01:43:10: [AMXX] Displaying debug trace (plugin "runemod_ninja.amxx")
PHP Code:
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <fun>
#include "runemod.inc"        // We need to include this file, as it contains info we need. Like #define`s and stocks

#define ROPE_DELAY 0.5
#define TE_BEAMENTPOINT 1
#define TE_KILLBEAM 99
#define Time_UpdateHook 0.1        // seconds
#define BEAMLIFE 100        // deciseconds
#define MOVEACCELERATION 150    // units per second^2
#define REELSPEED 200        // units per second

new g_HasRune[MAXPLAYERS+1// This is the Array used to store if the user is holding a rune.(Remember the base plugin informs this plugin once he picks up a rune.)
new g_WeaponIndex[MAXPLAYERS+1]
new 
g_HookLocation[MAXPLAYERS+1][3]
new 
g_HookLength[MAXPLAYERS+1]
new 
g_ActiveHook[MAXPLAYERS+1]
new 
g_Ready2Use[MAXPLAYERS+1]
new 
Float:g_BeamCreated[MAXPLAYERS+1]

new 
g_Gravity
new g_SpriteIndex
new g_MaxPlayers
new g_MaxEnts
new g_iMsgSayText

#define    FL_WATERJUMP    (1<<11)    // player jumping out of water
#define    FL_ONGROUND        (1<<9)    // At rest / on the ground

public plugin_init() 
{
    
register_plugin("Runemod Ninja""1.0.0""Cheesy Peteza & SpaceDude/JTP10181")
    
RegisterPlugin("NinjaName","NinjaDisc",{12,10,10},API_EVENTCHANGEWEAPON+API_ROUNDSTARTED+API_NEWROUND+API_USELANGSYSTEM)
    
g_Gravity get_cvar_num("sv_gravity")    
    
g_MaxPlayers get_maxplayers()
    
g_MaxEnts get_global_int(GL_maxEntities)
        
g_iMsgSayText     get_user_msgid("SayText")
}
public 
API_CurWeaponChange(id,WeaponIndex)
{
    
g_WeaponIndex[id] = WeaponIndex
    
if(!is_meleeweapon(WeaponIndex) && g_ActiveHook[id] == 1)
    {
        
RelaseHook(id)
    }
    return 
PLUGIN_CONTINUE
}
stock AddHook(id)
{
    new 
HitEnt,Body
    get_user_aiming
(id,HitEnt,Body)
    
    if(
HitEnt 0)
    {
        if(
is_user_alive(HitEnt) && HitEnt <= g_MaxPlayers && get_user_team(id) != get_user_team(HitEnt))
        {
            new 
weapons[32],num
            get_user_weapons
(id,weapons,num)
            for(new 
i=0;i<=num;i++) if(IsPrimarlyWeapon(weapons[i]))
            {
                
ChatColor(id,"%L",LANG_PLAYER,"NinjaCantSteal")
                
                
g_Ready2Use[id] = 0
                        
                set_task
(1.0,"Task_ReEnableHook",id,_,_,"a",1)
                return 
PLUGIN_CONTINUE
            
}
            new 
Name[32]
            
get_user_name(HitEnt,Name,31)
            
            new 
WIndex get_user_curweaponindex(HitEnt)
            if(
IsPrimarlyWeapon(WIndex))
            {
                new 
WPName[32]
                
get_wpname(WIndexWPName31)
                
                
//give_item(id,WPName)            
                
ChatColor(id,"%L",LANG_PLAYER,"NinjaStole",WPName,Name)
                
client_cmd(HitEnt,"drop")
                
                new 
parm[2]
                
parm[0] = id
                parm
[1] = HitEnt
                
                remove_task
(id)            
                
set_task(0.1,"Task_MoveWeapon",id,parm,2,"a",1)
                
                
emit_sound(id,CHAN_STATIC,"weapons/xbow_hit1.wav",1.0,ATTN_NORM,0,PITCH_NORM)
                
//format(gs_WeaponName[id],31,"weapon_%s",WPName)        // We now give the stolen weapon, to the guy with the rune
            
}
            else
            {
                
ChatColor(id,"%L",LANG_PLAYER,"NinjaNoPrimary",Name)
            }
            
g_Ready2Use[id] = 0
        
}
    }
    else if(
HitEnt == || HitEnt g_MaxPlayers)
    {
        new 
user_origin[3]
        
g_ActiveHook[id] = 1
        get_user_origin
(iduser_origin)
        
get_user_origin(idg_HookLocation[id], 3)
        
g_HookLength[id] = get_distance(g_HookLocation[id],user_origin)
    
        
set_user_gravity(id,0.001)
        
AddBeamPoint(id)
        
emit_sound(idCHAN_STATIC"weapons/xbow_hit2.wav"1.0ATTN_NORM0PITCH_NORM)
        
set_task(Time_UpdateHook"Task_UpdateHook",id,_,_"b")
        
Task_UpdateHook(id)
    }
    return 
PLUGIN_CONTINUE
}
public 
Task_MoveWeapon(parm[])
{
    new 
id parm[0]
    new 
Target parm[1]

    new 
WEntNum FindEntNum(Target)    // We are getting the Entnum for the weapon just droped

    
if(WEntNum == 0)
        return 
PLUGIN_CONTINUE
    MoveEntNum
(id,WEntNum,1500)
    
killbeam(id)
    return 
PLUGIN_CONTINUE
}
stock MoveEntNum(id,EntNum,speed)
{
    new 
Float:velocity[3]
    
VelocityByAim(idspeed velocity)
    
    if(!
velocity[0])
        
floatabs(velocity[0])
    else if(
velocity[0])
        
velocity[0] = velocity[0] - velocity[0]    - velocity[0]

    if(!
velocity[1])
        
floatabs(velocity[1])    
    else if(
velocity[1])
        
velocity[1] = velocity[1] - velocity[1]    - velocity[1]            

    if(!
velocity[2])
        
floatabs(velocity[2])
    else if(
velocity[2])
        
velocity[2] = velocity[2] - velocity[2] - velocity[2]
    
entity_set_vector(EntNum,EV_VEC_velocity,velocity)    
}
stock FindEntNum(id)
{
    new Class[
24]
    for(new 
i=g_MaxPlayers;i<=g_MaxEnts;i++) 
    {
        if(
is_valid_ent(i) && entity_get_edict(iEV_ENT_owner) == id)
        {
            
entity_get_string(i,EV_SZ_classname,Class,23)
            if(
equal("weaponbox",Class) && entity_range(id,i) <= 100)
            {
                return 
i
            
}
        }
    }
    return 
0
}
public 
plugin_precache()
{
    
g_SpriteIndex precache_model("sprites/rope.spr")
    
precache_sound("weapons/xbow_hit2.wav")
    
precache_sound("weapons/xbow_hit1.wav")
}
new 
OrZ[32]
public 
client_PreThink(id
{
    if(
g_HasRune[id] == 0) return PLUGIN_CONTINUE

    entity_set_float
(idEV_FL_fuser20.0)        // Disable slow down after jumping
    
new flags entity_get_int(idEV_INT_flags)
    new 
buttons entity_get_int(id,EV_INT_button)

    
// Code from CBasePlayer::Jump (player.cpp)        Make a player jump automatically
    
if(buttons IN_JUMP)
    {
        if (!(
flags FL_WATERJUMP) && entity_get_int(idEV_INT_waterlevel) < && flags FL_ONGROUND)
        {
            new 
Float:velocity[3]
            
entity_get_vector(idEV_VEC_velocityvelocity)
            
            new 
Float:Speed floatabs(velocity[0] + velocity[1])
            new 
Float:MSpeed entity_get_float(id,EV_FL_maxspeed)
            
            new 
Origin[3]
            
get_user_origin(id,Origin)
            if(
Speed MSpeed 10.0)
            {
                if(
Origin[2] >  OrZ[id])
                {
                    
velocity[0] = velocity[0] * 0.98 
                    velocity
[1] = velocity[1] * 0.98                     
                
}
                if(
Origin[2] ==  OrZ[id])
                {
    
                    
velocity[0] = velocity[0] * 0.98 
                    velocity
[1] = velocity[1] * 0.98 
                
}
            }
            
OrZ[id] = Origin[2]

            
velocity[2] += 250.0
            entity_set_vector
(idEV_VEC_velocityvelocity)
    
            
entity_set_int(idEV_INT_gaitsequence6)    // Play the Jump Animation
        
}
    }
    if(
buttons IN_ATTACK && is_meleeweapon(g_WeaponIndex[id]))
    {
        if(
g_ActiveHook[id] == && g_Ready2Use[id] == 1)     // We are adding the hook
        
{
            
AddHook(id)
            
g_Ready2Use[id] = 0
        
}
        else if(
g_Ready2Use[id] == 1)
        {
            
RelaseHook(id)
            
g_Ready2Use[id] = 0
        
}
    }
    else if(
g_Ready2Use[id] == && !(buttons IN_ATTACK))
        
g_Ready2Use[id] = 1
    
return PLUGIN_HANDLED
}
public 
Task_ReEnableHook(id)
{
    
g_Ready2Use[id] = 1
}
public 
API_DropedRune(id,Reason//This function is called by the base plugin to inform about the user droped his rune for whatever reason ( he could have used droprune or died )
{
    
g_HasRune[id] = 0
    remove_task
(id)
    if(
g_ActiveHook[id] >= 1)
        
RelaseHook(id)
}
public 
API_RoundStarted()
{
    for(new 
i=1;i<=g_MaxPlayers;i++) if(g_HasRune[i])
    {
        
g_Ready2Use[i] = 1
    
}
}
public 
API_NewRound()
{
    for(new 
i=1;i<=g_MaxPlayers;i++) if(g_HasRune[i])
    {
        if(
g_ActiveHook[i] == 1)
            
RelaseHook(i)

        
g_Ready2Use[i] = -1
    
}
}
public 
API_PickUpRune(id
{
    
g_Ready2Use[id] = 1
    g_HasRune
[id] = 1
}
public 
Task_UpdateHook(id
{
    new 
Flags get_user_button(id)
    new 
user_origin[3], user_look[3], user_direction[3], move_direction[3]
    new 
A[3], D[3], buttonadjust[3]
    new 
accelerationvelocity_TAdesired_velocity_TA
    
new velocity[3], null[3]
    new 
Float:tmpVector[3]

    if (
g_BeamCreated[id] + BEAMLIFE/10 <= get_gametime()) 
    {
        
AddBeamPoint(id)
    }
    
    
null[0] = 0
    null
[1] = 0
    null
[2] = 0

    get_user_origin
(iduser_origin)
    
get_user_origin(iduser_look,2)
    
    
entity_get_vector(idEV_VEC_velocitytmpVector)
    
FVecIVec(tmpVectorvelocity)

    
buttonadjust[0]=0
    buttonadjust
[1]=0

    
if (Flags IN_FORWARD
    {
        
buttonadjust[0]+=1
    
}
    if (
Flags IN_BACK
    {
        
buttonadjust[0]-=1
    
}
    if (
Flags IN_MOVERIGHT)
    {
        
buttonadjust[1]+=1
    
}
    if (
Flags IN_MOVELEFT
    {
        
buttonadjust[1]-=1
    
}
    if (
Flags IN_JUMP
    {
        
buttonadjust[2]+=1
    
}
    if (
Flags IN_DUCK
    {
        
buttonadjust[2]-=1
    
}

    if (
buttonadjust[0] || buttonadjust[1]) {
        
user_direction[0] = user_look[0] - user_origin[0]
        
user_direction[1] = user_look[1] - user_origin[1]

        
move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
        
move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
        
move_direction[2] = 0

        velocity
[0] += floatround(move_direction[0] * MOVEACCELERATION Time_UpdateHook get_distance(null,move_direction))
        
velocity[1] += floatround(move_direction[1] * MOVEACCELERATION Time_UpdateHook get_distance(null,move_direction))
    }
    if (
buttonadjust[2]) 
    {
        
g_HookLength[id] -= floatround(buttonadjust[2] * REELSPEED Time_UpdateHook)
    }
    if (
g_HookLength[id] < 100
    {
        (
g_HookLength[id]) = 100
    
}

    
A[0] = g_HookLocation[id][0] - user_origin[0]
    
A[1] = g_HookLocation[id][1] - user_origin[1]
    
A[2] = g_HookLocation[id][2] - user_origin[2]

    
D[0] = A[0]*A[2] / get_distance(null,A)
    
D[1] = A[1]*A[2] / get_distance(null,A)
    
D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)

    new 
aDistance get_distance(null,D) ? get_distance(null,D) : 1
    acceleration 
= - g_Gravity D[2] / aDistance

    velocity_TA 
= (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
    
desired_velocity_TA = (get_distance(user_origin,g_HookLocation[id]) - g_HookLength[id/*- 10*/) * 4

    
if (get_distance(null,D)>10
    {
        
velocity[0] += floatround((acceleration Time_UpdateHook D[0]) / get_distance(null,D))
        
velocity[1] += floatround((acceleration Time_UpdateHook D[1]) / get_distance(null,D))
        
velocity[2] += floatround((acceleration Time_UpdateHook D[2]) / get_distance(null,D))
    }

    
velocity[0] += ((desired_velocity_TA velocity_TA) * A[0]) / get_distance(null,A)
    
velocity[1] += ((desired_velocity_TA velocity_TA) * A[1]) / get_distance(null,A)
    
velocity[2] += ((desired_velocity_TA velocity_TA) * A[2]) / get_distance(null,A)

    
IVecFVec(velocitytmpVector)
    
entity_set_vector(idEV_VEC_velocitytmpVector)
}
stock AddBeamPoint(id)
{
    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_BEAMENTPOINT )
    
write_shortid )
    
write_coordg_HookLocation[id][0] )
    
write_coordg_HookLocation[id][1] )
    
write_coordg_HookLocation[id][2] )
    
write_shortg_SpriteIndex )    // sprite index
    
write_byte)        // start frame
    
write_byte)        // framerate
    
write_byteBEAMLIFE )    // life
    
write_byte)    // width
    
write_byte)        // noise
    
write_byte250 )    // r, g, b
    
write_byte250 )    // r, g, b
    
write_byte250 )    // r, g, b
    
write_byte250 )    // brightness

    
write_byte)        // speed
    
message_end( )
    
g_BeamCreated[id] = get_gametime()
}
stock killbeam(id)
{
    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_KILLBEAM )
    
write_shortid )
    
message_end()
}
stock IsPrimarlyWeapon(WeaponIndex)
{
    if(
WeaponIndex == CSW_SCOUT || WeaponIndex == CSW_XM1014 || WeaponIndex == CSW_MAC10 || WeaponIndex == CSW_AUG || WeaponIndex == CSW_UMP45 || 
    
WeaponIndex == CSW_SG550 || WeaponIndex == CSW_GALI || WeaponIndex == CSW_GALIL || WeaponIndex == CSW_FAMAS || WeaponIndex == CSW_AWP || 
    
WeaponIndex == CSW_MP5NAVY || WeaponIndex == CSW_M249 || WeaponIndex == CSW_M3 || WeaponIndex == CSW_M4A1 || WeaponIndex == CSW_TMP || 
    
WeaponIndex == CSW_G3SG1 || WeaponIndex == CSW_SG552 || WeaponIndex == CSW_AK47 || WeaponIndex == CSW_P90)
        return 
1
    
else
        return 
0
    
return 0
}
stock get_wpname(wpname[], imax)
{
    switch (
wp) {
        case 
CSW_P228:
            
copy(nameimax"p228")
        case 
CSW_SCOUT:
            
copy(nameimax"scout")
        case 
CSW_HEGRENADE:
            
copy(nameimax"hegrenade")
        case 
CSW_XM1014:
            
copy(nameimax"xm1014")
        case 
CSW_C4:
            
copy(nameimax"c4")
        case 
CSW_MAC10:
            
copy(nameimax"mac10")
        case 
CSW_AUG:
            
copy(nameimax"aug")
        case 
CSW_SMOKEGRENADE:
            
copy(nameimax"smokegrenade")
        case 
CSW_ELITE:
            
copy(nameimax"elite")
        case 
CSW_FIVESEVEN:
            
copy(nameimax"fiveseven")
        case 
CSW_UMP45:
            
copy(nameimax"ump45")
        case 
CSW_SG550:
            
copy(nameimax"sg550")
        case 
CSW_GALIL:
            
copy(nameimax"galil")
        case 
CSW_FAMAS:
            
copy(nameimax"famas")
        case 
CSW_USP:
            
copy(nameimax"usp")
        case 
CSW_GLOCK18:
            
copy(nameimax"glock18")
        case 
CSW_AWP:
            
copy(nameimax"awp")
        case 
CSW_MP5NAVY:
            
copy(nameimax"mp5navy")
        case 
CSW_M249:
            
copy(nameimax"m249")
        case 
CSW_M3:
            
copy(nameimax"m3")
        case 
CSW_M4A1:
            
copy(nameimax"m4a1")
        case 
CSW_TMP:
            
copy(nameimax"tmp")
        case 
CSW_G3SG1:
            
copy(nameimax"g3sg1")
        case 
CSW_FLASHBANG:
            
copy(nameimax"flashbang")
        case 
CSW_DEAGLE:
            
copy(nameimax"deagle")
        case 
CSW_SG552:
            
copy(nameimax"sg552")
        case 
CSW_AK47:
            
copy(nameimax"ak47")
        case 
CSW_KNIFE:
            
copy(nameimax"knife")
        case 
CSW_P90:
            
copy(nameimax"p90")
    }
    
    return 
1
}
stock RelaseHook(id)
{
    
g_ActiveHook[id] = 0
    killbeam
(id)
    
set_user_gravity(id)
    
remove_task(id)
}

stock ChatColor(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!n""^1"// Default Color
    
replace_all(msg190"!t""^3"// Team Color

    
    
if (idplayers[0] = id; else get_players(playerscount"ch")
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
            
message_begin(MSG_ONE_UNRELIABLEg_iMsgSayText_players[i])  
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
            }
        }
    }

Also include...
Thanks...
Attached Files
File Type: inc runemod.inc (9.0 KB, 109 views)

Last edited by KaPaTeJIb; 06-23-2013 at 01:55.
KaPaTeJIb is offline
Send a message via Skype™ to KaPaTeJIb
Old 06-23-2013, 09:25
KaPaTeJIb
This message has been deleted by YamiKaitou. Reason: wait 14 days before you bump
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-23-2013 , 11:59   Re: Help with RuneMod plugin
Reply With Quote #2

new OrZ[32]
->
new OrZ[MAXPLAYERS+1]

Avoid to modify if you have not idea what you're doing.
__________________
Arkshine 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 22:35.


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