AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Engine ----> fakemeta (https://forums.alliedmods.net/showthread.php?t=92953)

_lol_ 05-22-2009 13:07

Engine ----> fakemeta
 
possible?

PHP Code:

public client_PreThink(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
if(get_cvar_num("amx_mjadminonly") && (!access(id,ADMINACCESS))) return PLUGIN_CONTINUE
    
new nbut get_user_button(id)
    new 
obut get_user_oldbutton(id)
    if((
nbut IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut IN_JUMP))
    {
        if(
jumpnum[id] < get_cvar_num("amx_maxjumps"))
        {
            
dojump[id] = true
            jumpnum
[id]++
            return 
PLUGIN_CONTINUE
        
}
    }
    if((
nbut IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
    {
        
jumpnum[id] = 0
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
if(get_cvar_num("amx_mjadminonly") && (!access(id,ADMINACCESS))) return PLUGIN_CONTINUE
    
if(dojump[id] == true)
    {
        new 
Float:velocity[3]    
        
entity_get_vector(id,EV_VEC_velocity,velocity)
        
velocity[2] = random_float(265.0,285.0)
        
entity_set_vector(id,EV_VEC_velocity,velocity)
        
dojump[id] = false
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE



Arkshine 05-22-2009 13:14

Re: Engine ----> fakemeta
 
There is not benefit to use fakemeta instead of engine.

stupok 05-22-2009 13:17

Re: Engine ----> fakemeta
 
Quote:

Originally Posted by _lol_ (Post 832505)
possible?

1. Yes, of course it is possible. Any engine code can be converted to fakemeta.
2. arkshine is right

_lol_ 05-22-2009 13:25

Re: Engine ----> fakemeta
 
i only want to learn fakemeta, could you help me or not...

[X]-RayCat 05-22-2009 13:29

Re: Engine ----> fakemeta
 
There are many Engine to Fakemeta threads. Just use search next time..

You'll find the pev constants here.
set_pev ( index, value, [ ... ] )
pev ( index, value, [ ... ] )

You'll need to use these:
pev_flags
pev_velocity

Spunky 05-22-2009 13:33

Re: Engine ----> fakemeta
 
Engine is faster than fakemeta.

_lol_ 05-22-2009 13:49

Re: Engine ----> fakemeta
 
it doesnt work, what is bad

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new jumpnum[33] = 0
new bool:dojump[33] = false

public plugin_init()
{
    
register_plugin("MultiJump","1.1","MasI")
    
register_cvar("amx_maxjumps","50")
}

public 
client_putinserver(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_disconnect(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id)) 
        return 
PLUGIN_CONTINUE
    
new nbut pev(idpev_button)
    new 
obut pev(idpev_oldbuttons)
    new 
flags pev(idpev_flags)
    if((
nbut IN_JUMP) && !(flags FL_ONGROUND) && !(obut IN_JUMP))
    {
        if(
jumpnum[id] < get_cvar_num("amx_maxjumps"))
        {
            
dojump[id] = true
            jumpnum
[id]++
            return 
PLUGIN_CONTINUE
        
}
    }
    if((
nbut IN_JUMP) && (flags FL_ONGROUND))
    {
        
jumpnum[id] = 0
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id)) 
        return 
PLUGIN_CONTINUE
        
    
if(dojump[id] == true)
    {
        new 
Float:velocity[3]
        
pev(idpev_velocity)
        
velocity[2] = random_float(265.0,285.0)
        
set_pev(idpev_velocityvelocity)
        
dojump[id] = false
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE



ConnorMcLeod 05-22-2009 14:07

Re: Engine ----> fakemeta
 
client_PreThink is an engine forward, you still have to include engine unless it is used by another plugin.

stupok 05-22-2009 14:16

Re: Engine ----> fakemeta
 
Try this:

I might have messed up your checks with the flags, buttons, and oldbuttons when I tried to optimize them.

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> new jumpnum[33] = 0 new bool:dojump[33] = false new cvar_maxjumps public plugin_init() {     register_plugin("MultiJump","1.1","MasI")     cvar_maxjumps = register_cvar("amx_maxjumps","50")         register_forward(FM_PlayerPreThink, "forward_PreThink")     register_forward(FM_PlayerPostThink, "forward_PostThink") } public client_putinserver(id) {     jumpnum[id] = 0     dojump[id] = false } public client_disconnect(id) {     jumpnum[id] = 0     dojump[id] = false } public forward_PreThink(id) {     if(!is_user_alive(id))         return FMRES_IGNORED         new nbut = pev(id, pev_button)     new obut = pev(id, pev_oldbuttons)     new flags = pev(id, pev_flags)     if(nbut & IN_JUMP)     {         if(flags & FL_ONGROUND)         {             jumpnum[id] = 0         }         else if(!(obut & IN_JUMP) && jumpnum[id] < get_pcvar_num(cvar_maxjumps))         {             dojump[id] = true             jumpnum[id]++         }     }         return FMRES_IGNORED } public forward_PostThink(id) {     if(!is_user_alive(id))         return FMRES_IGNORED         if(dojump[id] == true)     {         new Float:velocity[3]         pev(id, pev_velocity, velocity)         velocity[2] = random_float(265.0,285.0)         set_pev(id, pev_velocity, velocity)         dojump[id] = false     }         return FMRES_IGNORED }


All times are GMT -4. The time now is 01:29.

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