AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Multijump (https://forums.alliedmods.net/showthread.php?t=89414)

TitANious 04-06-2009 02:13

Multijump
 
Whats the easyist way to make a multijump? (I hope i can understand it)

hleV 04-06-2009 06:42

Re: Multijump
 
Search for Multijump plugin and then view the code.

TitANious 04-06-2009 06:45

Re: Multijump
 
Its not the most simple :P I think some1 can make it more simple ;)

hleV 04-06-2009 07:06

Re: Multijump
 
Actually it is simple. Here's FM way (not tested though):
Code:
#include <amxmodx> #include <fakemeta>   #define FLAG_ADMIN ADMIN_LEVEL_A   new g_iJumpCount[33], bool:g_bJumped[33]; new g_pMaxJumps, g_pAdminOnly;   public plugin_init() {         register_plugin("Multi Jump", "1.2", "twistedeuphoria (port to FM by hleV)");         g_pMaxJumps = register_cvar("mj_maxjumps", "1"); // 1 normal jump + amount in CVAR         g_pAdminOnly = register_cvar("mj_adminonly", "0");         register_forward(FM_PlayerPreThink, "fwPreThink");         register_forward(FM_PlayerPostThink, "fwPostThink"); }   public client_disconnect(iCl) {         g_iJumpCount[iCl] = 0;         g_bJumped[iCl] = false; }   public fwPreThink(iCl) {         if (!is_user_alive(iCl) || (get_pcvar_num(g_pAdminOnly) && !(get_user_flags(iCl) & FLAG_ADMIN)))                 return;           static iButton, iOldButton, iFlags;         iButton = pev(iCl, pev_button);         iOldButton = pev(iCl, pev_oldbuttons);         iFlags = pev(iCl, pev_flags);           if ((iButton & IN_JUMP) && !(iFlags & FL_ONGROUND) && !(iOldButton & IN_JUMP))                 if (g_iJumpCount[iCl] < get_pcvar_num(g_pMaxJumps))                 {                         g_iJumpCount[iCl]++;                         g_bJumped[iCl] = true;                         return;                 }           if ((iButton & IN_JUMP) && (iFlags & FL_ONGROUND))                 g_iJumpCount[iCl] = 0; }   public fwPostThink(iCl) {         if (!is_user_alive(iCl) || (get_pcvar_num(g_pAdminOnly) && !(get_user_flags(iCl) & FLAG_ADMIN)))                 return;           if (g_bJumped[iCl])         {                 static Float:fVel[3];                 pev(iCl, pev_velocity, fVel);                 fVel[2] = random_float(265.0, 285.0); // IMO it should be lesser                 set_pev(iCl, pev_velocity, fVel);                 g_bJumped[iCl] = false;         } }
Though I wonder if CmdStart worked well instead of PreThink.

Arkshine 04-06-2009 07:08

Re: Multijump
 
Explain why it can be more simple ? I mean you ask the most simple way and you are able to say if such way is simple or not... So I guess you have some knowledge to explain why you think there is a better way than playing with player's velocity.

TitANious 04-06-2009 07:12

Re: Multijump
 
@Arkshine: I just think :)

@hleV: What does g_(n) mean?

hleV 04-06-2009 07:53

Re: Multijump
 
Quote:

Originally Posted by TitANious (Post 798675)
@Arkshine: I just think :)

@hleV: What does g_(n) mean?

Global <type>. In this case - global pointer. It's just a matter of coding style though.

TitANious 04-06-2009 08:08

Re: Multijump
 
I want to delete the admin only

Here is when i had deleted:

PHP Code:

#include <amxmodx>
#include <fakemeta>
 
#define FLAG_ADMIN ADMIN_LEVEL_A
 
new g_iJumpCount[33], bool:g_bJumped[33];
new 
g_pMaxJumps;
 
public 
plugin_init()
{
        
register_plugin("Multi Jump""1.2""twistedeuphoria (port to FM by hleV)");
        
g_pMaxJumps register_cvar("mj_maxjumps""1"); // 1 normal jump + amount in CVAR
        
register_forward(FM_PlayerPreThink"fwPreThink");
        
register_forward(FM_PlayerPostThink"fwPostThink");
}
 
public 
client_disconnect(iCl)
{
        
g_iJumpCount[iCl] = 0;
        
g_bJumped[iCl] = false;
}
 
public 
fwPreThink(iCl)
{
        if (!
is_user_alive(iCl) || (get_pcvar_num (get_user_flags(iCl) & FLAG_ADMIN)))
                return;
 
        static 
iButtoniOldButtoniFlags;
        
iButton pev(iClpev_button);
        
iOldButton pev(iClpev_oldbuttons);
        
iFlags pev(iClpev_flags);
 
        if ((
iButton IN_JUMP) && !(iFlags FL_ONGROUND) && !(iOldButton IN_JUMP))
                if (
g_iJumpCount[iCl] < get_pcvar_num(g_pMaxJumps))
                {
                        
g_iJumpCount[iCl]++;
                        
g_bJumped[iCl] = true;
                        return;
                }
 
        if ((
iButton IN_JUMP) && (iFlags FL_ONGROUND))
                
g_iJumpCount[iCl] = 0;
}
 
public 
fwPostThink(iCl)
{
        if (!
is_user_alive(iCl) || (get_pcvar_num (get_user_flags(iCl) & FLAG_ADMIN)))
                return;
 
        if (
g_bJumped[iCl])
        {
                static 
Float:fVel[3];
                
pev(iClpev_velocityfVel);
                
fVel[2] = random_float(265.0285.0); // IMO it should be lesser
                
set_pev(iClpev_velocityfVel);
                
g_bJumped[iCl] = false;
        }



fysiks 04-06-2009 08:25

Re: Multijump
 
Ok, are you trying to say it didn't work?

Admin only was turned off by default. I don't see a good reason to remove it from the code.

TitANious 04-06-2009 08:40

Re: Multijump
 
Well i dont want to do it bigger, if no reason to :) Its look better :o


All times are GMT -4. The time now is 02:27.

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