Raised This Month: $ Target: $400
 0% 

Wallhang/walljump


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bloody806
Member
Join Date: Jun 2012
Location: Czech Republic
Old 03-15-2013 , 14:40   Wallhang/walljump
Reply With Quote #1

I did it this way from tut.. and show error Please Help me.

Error: Array sizes do not match, or destination array is too small on line 71

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "xxx"

new crawlspeed;


new 
g_bfStuckToWall;
new 
Float:g_flWallOrigin[33];


#define stickPlayer(%1)            g_bfStuckToWall |= (1 << (%1 & 31))
#define unstickPlayer(%1)        g_bfStuckToWall &= ~(1 << (%1 & 31))
#define isStuck(%1)                g_bfStuckToWall & (1 << (%1 & 31))  

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_touch("worldspawn","player","Touch_Climb");
    
register_touch("func_brush","player","Touch_Climb");
    
register_touch("func_breakable","player","Touch_Climb");
    
    
register_forward(FM_PlayerPreThink"Forward_PlayerPreThink"0);  
    
}

public 
Touch_Climb(Ent,id)
{
    
//If player is touching a wall then we find it's origin

    
pev(id,pev_origin,g_flWallOrigin[id]);
        
    return 
PLUGIN_HANDLED;
}  

public 
Forward_PlayerPreThink(id)
{
    
//If player is dead then ignore.
    
    
if(!is_user_alive(id))
        return;
        
    static 
iButton[33], iCrawlSpeed;
    
    
//Get button that player is using as well as the speed he is supposed to move on the wall.
    //I left iCrawlSpeed as a get_pcvar_num so you can register a cvar for that.
    
    
iButton[id] = get_user_button(id);
    
iCrawlSpeed get_pcvar_num(crawlspeed);

    if(
iButton[id] & IN_USE)
    {
        
//Here we have three matrices holding the origin of the player, previous origin and velocity.
        
        
static Float:fOrigin[33][3];
        static 
Float:fOriginOld[33][3];
        static 
Float:fVelocity[33][3];
        
        
//Get user origin.
        
        
pev(id,pev_origin,fOrigin[id]);
        
        
//If he is far from the wall then return.
        
        
if(get_distance_f(fOrigin[id],g_flWallOrigin[id]) > 10.0//<----HERE IS ERROR
            
return;
        
        
//If holding iButton and moving forward
        
        
if(iButton[id] & IN_FORWARD)
        {
            
//Check if player is stuck to wall.
            
switch(isStuck(id)){
                
                
//If not them make him move.
                
case 0:{
                    
velocity_by_aim(id,iCrawlSpeed,fVelocity[id]);
                    
set_pev(id,pev_velocity,fVelocity[id]);
                }
                
                
//If yes then unstuck him.
                
default:{
                    
unstickPlayer(id);
                }
            }
        }
        
        
//If holding iButton and moving back
        
        
else if(iButton[id] & IN_BACK)
        {
            switch(
isStuck(id)){
                case 
0:{
                    
velocity_by_aim(id,-iCrawlSpeed,fVelocity[id]);
                    
set_pev(id,pev_velocity,fVelocity[id]);
                }
                            
                default:{
                    
unstickPlayer(id);
                }
            }
        }
        
        else if(
iButton[id])
        {
            
//If Player is holding iButton but not moving, then g_bStuckToWall = true
            //and previous origin will now always be equal to current.
            
            
switch(isStuck(id)){
                case 
0:{
                    
fOriginOld[id] = fOrigin[id];
                    
stickPlayer(id);
                }
            }
            
            
//Set his velocity to zero.
            
velocity_by_aim(id,0,fVelocity[id]);
            
set_pev(id,pev_velocity,fVelocity[id]);
            
            
//if the diference between previous and current origins are small, then set
            //set player's new origin as previous
            
            
if(get_distance_f(fOrigin[id],fOriginOld[id]) <= 10){
                
set_pev(id,pev_origin,fOriginOld[id]);
            }
        }
    }

__________________
bloody806 is offline
Send a message via Skype™ to bloody806
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-15-2013 , 14:45   Re: Wallhang/walljump
Reply With Quote #2

PHP Code:
/* Gets distance between two origins (float). */
native Float:get_distance_f(const Float:Origin1[3], const Float:Origin2[3]); 
You are using get_distance_f incorrectly, look at the header above again
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
XAT
Member
Join Date: Jul 2011
Old 03-15-2013 , 15:46   Re: Wallhang/walljump
Reply With Quote #3

PHP Code:
new Float:g_flWallOrigin[33]; 
->

PHP Code:
new Float:g_flWallOrigin[33][3]; 
XAT is offline
bloody806
Member
Join Date: Jun 2012
Location: Czech Republic
Old 03-15-2013 , 18:24   Re: Wallhang/walljump
Reply With Quote #4

Thank you.
__________________
bloody806 is offline
Send a message via Skype™ to bloody806
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-16-2013 , 04:08   Re: Wallhang/walljump
Reply With Quote #5

I can't understand why you use switch statements with only 1 or 2 cases, just use <if>, and <if> <else> (not <else if> because your value is only 0 or 1).

Also, you may have better results using PostThink rather than PreThink.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 21:39.


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