Raised This Month: $51 Target: $400
 12% 

JETPACK


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supreeda
Senior Member
Join Date: Jul 2015
Old 09-21-2015 , 04:58   JETPACK
Reply With Quote #1

Somebody can help my

I want limit Client to use Jetpack only 5 sec for 1 round

this is plugin : https://forums.alliedmods.net/showthread.php?t=56374
supreeda is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 09-21-2015 , 05:22   Re: [PAY 1KEY] Jetpack Timer
Reply With Quote #2

And you gotta pay for that ?
Let me drop a piece of code for you here. You decide if you still want to pay or not.

EDIT:
Wich game ?

EDIT2:
Not tested
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.1.0"

#define MOVETYPE_WALK            2
#define MOVETYPE_FLYGRAVITY        5
#define MOVECOLLIDE_DEFAULT        0
#define MOVECOLLIDE_FLY_BOUNCE    1

#define LIFE_ALIVE    0

// ConVars
new Handle:sm_jetpack            INVALID_HANDLE;
new 
Handle:sm_jetpack_sound        INVALID_HANDLE;
new 
Handle:sm_jetpack_speed        INVALID_HANDLE;
new 
Handle:sm_jetpack_volume    INVALID_HANDLE;

// SendProp Offsets
new g_iLifeState    = -1;
new 
g_iMoveCollide    = -1;
new 
g_iMoveType        = -1;
new 
g_iVelocity        = -1;

// Soundfile
new String:g_sSound[255]    = "vehicles/airboat/fan_blade_fullthrottle_loop1.wav";

// Is Jetpack Enabled
new bool:g_bJetpacks[MAXPLAYERS 1]    = {false,...};

// Timer For GameFrame
new Float:g_fTimer    0.0;

// MaxClients
new g_iMaxClients    0;

//Jetpack restrictions
new Float:jetPackTime 5.0;
new 
Float:g_allowJetpackTime[MAXPLAYERS 1];
new 
Float:g_removedAmmount[MAXPLAYERS 1];
new 
Handle:g_timerClient[MAXPLAYERS 1];


public 
Plugin:myinfo =
{
    
name "Jetpack",
    
author "Knagg0",
    
description "",
    
version PLUGIN_VERSION,
    
url "http://www.mfzb.de"
};

public 
OnPluginStart()
{
    
AutoExecConfig();
    
    
// Create ConVars
    
CreateConVar("sm_jetpack_version"PLUGIN_VERSION""FCVAR_PLUGIN FCVAR_REPLICATED FCVAR_NOTIFY);
    
sm_jetpack CreateConVar("sm_jetpack""1"""FCVAR_PLUGIN FCVAR_REPLICATED FCVAR_NOTIFY);
    
sm_jetpack_sound CreateConVar("sm_jetpack_sound"g_sSound""FCVAR_PLUGIN);
    
sm_jetpack_speed CreateConVar("sm_jetpack_speed""100"""FCVAR_PLUGIN);
    
sm_jetpack_volume CreateConVar("sm_jetpack_volume""0.5"""FCVAR_PLUGIN);

    
// Create ConCommands
    
RegConsoleCmd("+sm_jetpack"JetpackP""FCVAR_GAMEDLL);
    
RegConsoleCmd("-sm_jetpack"JetpackM""FCVAR_GAMEDLL);
    
    
// Find SendProp Offsets
    
if((g_iLifeState FindSendPropOffs("CBasePlayer""m_lifeState")) == -1)
        
LogError("Could not find offset for CBasePlayer::m_lifeState");
        
    if((
g_iMoveCollide FindSendPropOffs("CBaseEntity""movecollide")) == -1)
        
LogError("Could not find offset for CBaseEntity::movecollide");
        
    if((
g_iMoveType FindSendPropOffs("CBaseEntity""movetype")) == -1)
        
LogError("Could not find offset for CBaseEntity::movetype");
        
    if((
g_iVelocity FindSendPropOffs("CBasePlayer""m_vecVelocity[0]")) == -1)
        
LogError("Could not find offset for CBasePlayer::m_vecVelocity[0]");
        
    
HookEvent("round_start"Event_RoundStart);
}

public 
OnMapStart()
{
    
g_fTimer 0.0;
    
g_iMaxClients GetMaxClients();
    for(new 
1<= g_iMaxClientsi++)
        
g_allowJetpackTime[i] = jetPackTime;
}

public 
OnConfigsExecuted()
{
    
GetConVarString(sm_jetpack_soundg_sSoundsizeof(g_sSound));
    
PrecacheSound(g_sSoundtrue);
}

public 
OnGameFrame()
{
    if(
GetConVarBool(sm_jetpack) && g_fTimer GetGameTime() - 0.075)
    {
        
g_fTimer GetGameTime();
        
        for(new 
1<= g_iMaxClientsi++)
        {
            if(
g_bJetpacks[i])
            {
                if(!
IsAlive(i)) StopJetpack(i);
                else 
AddVelocity(iGetConVarFloat(sm_jetpack_speed));
            }
        }
    }
}

public 
OnClientDisconnect(client)
{
    
StopJetpack(client);
}

public 
Action:Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    for(new 
1<= g_iMaxClientsi++)
    {
        
g_allowJetpackTime[i] = jetPackTime;
    }
}

public 
Action:JetpackP(clientargs)
{
    if(
GetConVarBool(sm_jetpack) && !g_bJetpacks[client] && IsAlive(client) && g_allowJetpackTime[client] > 0.0)
    {
        new 
Float:vecPos[3];
        
GetClientAbsOrigin(clientvecPos);
        
EmitSoundToAll(g_sSoundclientSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGSGetConVarFloat(sm_jetpack_volume), SNDPITCH_NORMAL, -1vecPosNULL_VECTORtrue0.0);
        
SetMoveType(clientMOVETYPE_FLYGRAVITYMOVECOLLIDE_FLY_BOUNCE);
        if(
g_allowJetpackTime[client] <= 0.0)
        {
            
g_bJetpacks[client] = false;
            
StopJetpack(client);
           }
           else
           {
            
g_bJetpacks[client] = true;
            if(
g_timerClient[client] == INVALID_HANDLE)
                
g_timerClient[client] = CreateTimer(0.1TMR_RemoveTimeclientTIMER_REPEAT);
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action:TMR_RemoveTime(Handle:timerany:client)
{
    
g_allowJetpackTime[client]-= 0.1;
    
g_removedAmmount[client] += 0.1;
    
PrintHintText(client"Jetpack fuel %.3f liters"g_allowJetpackTime[client]);    
}

public 
Action:JetpackM(clientargs)
{
    
StopJetpack(client);
    return 
Plugin_Continue;
}

StopJetpack(client)
{
    if(
g_bJetpacks[client])
    {
        if(
IsAlive(client)) SetMoveType(clientMOVETYPE_WALKMOVECOLLIDE_DEFAULT);
        
StopSound(clientSNDCHAN_AUTOg_sSound);
        
g_bJetpacks[client] = false;
    }
    if(
g_timerClient[client] != INVALID_HANDLE)
    {
        
KillTimer(g_timerClient[client]);
        
g_timerClient[client] = INVALID_HANDLE;
    }
}

SetMoveType(clientmovetypemovecollide)
{
    if(
g_iMoveType == -1) return;
    
SetEntData(clientg_iMoveTypemovetype);
    if(
g_iMoveCollide == -1) return;
    
SetEntData(clientg_iMoveCollidemovecollide);
}

AddVelocity(clientFloat:speed)
{
    if(
g_iVelocity == -1) return;
    
    new 
Float:vecVelocity[3];
    
GetEntDataVector(clientg_iVelocityvecVelocity);
    
    
vecVelocity[2] += speed;

    
TeleportEntity(clientNULL_VECTORNULL_VECTORvecVelocity);
}

bool:IsAlive(client)
{
    if(
g_iLifeState != -&& GetEntData(clientg_iLifeState1) == LIFE_ALIVE)
        return 
true;

    return 
false;

__________________
Want to check my plugins ?

Last edited by Arkarr; 09-21-2015 at 06:09.
Arkarr is offline
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 09-21-2015 , 06:43   Re: [PAY 1KEY] Jetpack Timer
Reply With Quote #3

This is my version, It works, but it waste performance.

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.1.60"

#define MOVETYPE_WALK            2
#define MOVETYPE_FLYGRAVITY        5
#define MOVECOLLIDE_DEFAULT        0
#define MOVECOLLIDE_FLY_BOUNCE    1

#define LIFE_ALIVE    0

// ConVars
new Handle:sm_jetpack            INVALID_HANDLE;
new 
Handle:sm_jetpack_sound        INVALID_HANDLE;
new 
Handle:sm_jetpack_speed        INVALID_HANDLE;
new 
Handle:sm_jetpack_volume    INVALID_HANDLE;

// SendProp Offsets
new g_iLifeState    = -1;
new 
g_iMoveCollide    = -1;
new 
g_iMoveType        = -1;
new 
g_iVelocity        = -1;

// Soundfile
new String:g_sSound[255]    = "vehicles/airboat/fan_blade_fullthrottle_loop1.wav";

// Is Jetpack Enabled
new bool:g_bJetpacks[MAXPLAYERS 1]    = {false,...};

// Timer For GameFrame
new Float:g_fTimer    0.0;

// MaxClients
new g_iMaxClients    0;

float jetpackTime[MAXPLAYERS 1];

public 
Plugin:myinfo =
{
    
name "Jetpack",
    
author "Knagg0",
    
description "",
    
version PLUGIN_VERSION,
    
url "http://www.mfzb.de"
};

public 
OnPluginStart()
{
    
AutoExecConfig();
    
    
// Create ConVars
    
CreateConVar("sm_jetpack_version"PLUGIN_VERSION""FCVAR_PLUGIN FCVAR_REPLICATED FCVAR_NOTIFY);
    
sm_jetpack CreateConVar("sm_jetpack""1"""FCVAR_PLUGIN FCVAR_REPLICATED FCVAR_NOTIFY);
    
sm_jetpack_sound CreateConVar("sm_jetpack_sound"g_sSound""FCVAR_PLUGIN);
    
sm_jetpack_speed CreateConVar("sm_jetpack_speed""100"""FCVAR_PLUGIN);
    
sm_jetpack_volume CreateConVar("sm_jetpack_volume""0.5"""FCVAR_PLUGIN);

    
// Create ConCommands
    
RegConsoleCmd("+sm_jetpack"JetpackP""FCVAR_GAMEDLL);
    
RegConsoleCmd("-sm_jetpack"JetpackM""FCVAR_GAMEDLL);
    
    
// Find SendProp Offsets
    
if((g_iLifeState FindSendPropOffs("CBasePlayer""m_lifeState")) == -1)
        
LogError("Could not find offset for CBasePlayer::m_lifeState");
        
    if((
g_iMoveCollide FindSendPropOffs("CBaseEntity""movecollide")) == -1)
        
LogError("Could not find offset for CBaseEntity::movecollide");
        
    if((
g_iMoveType FindSendPropOffs("CBaseEntity""movetype")) == -1)
        
LogError("Could not find offset for CBaseEntity::movetype");
        
    if((
g_iVelocity FindSendPropOffs("CBasePlayer""m_vecVelocity[0]")) == -1)
        
LogError("Could not find offset for CBasePlayer::m_vecVelocity[0]");

    
HookEvent("round_start"Event_RoundStart);
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    for(new 
1<= g_iMaxClientsi++)
    {
        
jetpackTime[i] = 0.0;
    }
}

public 
OnMapStart()
{
    
g_fTimer 0.0;
    
g_iMaxClients GetMaxClients();
}

public 
OnConfigsExecuted()
{
    
GetConVarString(sm_jetpack_soundg_sSoundsizeof(g_sSound));
    
PrecacheSound(g_sSoundtrue);
}

public 
OnGameFrame()
{
    if(
GetConVarBool(sm_jetpack))
    {
        for(new 
1<= g_iMaxClientsi++)
        {
            if(
g_bJetpacks[i])
            {
                if (
jetpackTime[i] > 5.0) {StopJetpack(i); return;}
                
jetpackTime[i] += GetTickInterval();
                
PrintHintTextToAll("%f"jetpackTime[i]);
            }
        }

        if (
g_fTimer GetGameTime() - 0.075)
        {
            
g_fTimer GetGameTime();
            
            for(new 
1<= g_iMaxClientsi++)
            {
                if(
g_bJetpacks[i])
                {
                    if(!
IsAlive(i)) StopJetpack(i);
                    else 
AddVelocity(iGetConVarFloat(sm_jetpack_speed));
                }
            }
        }
    }
}

public 
OnClientDisconnect(client)
{
    
StopJetpack(client);
}

public 
Action:JetpackP(clientargs)
{
    if (
jetpackTime[client] > 5.0)
    {
        
PrintToChat(client"wait for the next round to get fuel");
        return 
Plugin_Continue;
    }

    if(
GetConVarBool(sm_jetpack) && !g_bJetpacks[client] && IsAlive(client))
    {
        new 
Float:vecPos[3];
        
GetClientAbsOrigin(clientvecPos);
        
EmitSoundToAll(g_sSoundclientSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGSGetConVarFloat(sm_jetpack_volume), SNDPITCH_NORMAL, -1vecPosNULL_VECTORtrue0.0);
        
SetMoveType(clientMOVETYPE_FLYGRAVITYMOVECOLLIDE_FLY_BOUNCE);
        
g_bJetpacks[client] = true;
    }
    
    return 
Plugin_Continue;
}

public 
Action:JetpackM(clientargs)
{
    
StopJetpack(client);
    return 
Plugin_Continue;
}

StopJetpack(client)
{
    if(
g_bJetpacks[client])
    {
        if(
IsAlive(client)) SetMoveType(clientMOVETYPE_WALKMOVECOLLIDE_DEFAULT);
        
StopSound(clientSNDCHAN_AUTOg_sSound);
        
g_bJetpacks[client] = false;
    }
}

SetMoveType(clientmovetypemovecollide)
{
    if(
g_iMoveType == -1) return;
    
SetEntData(clientg_iMoveTypemovetype);
    if(
g_iMoveCollide == -1) return;
    
SetEntData(clientg_iMoveCollidemovecollide);
}

AddVelocity(clientFloat:speed)
{
    if(
g_iVelocity == -1) return;
    
    new 
Float:vecVelocity[3];
    
GetEntDataVector(clientg_iVelocityvecVelocity);
    
    
vecVelocity[2] += speed;

    
TeleportEntity(clientNULL_VECTORNULL_VECTORvecVelocity);
}

bool:IsAlive(client)
{
    if(
g_iLifeState != -&& GetEntData(clientg_iLifeState1) == LIFE_ALIVE)
        return 
true;

    return 
false;

lingzhidiyu is offline
supreeda
Senior Member
Join Date: Jul 2015
Old 09-21-2015 , 08:45   Re: [PAY 1KEY] Jetpack Timer
Reply With Quote #4

Quote:
Originally Posted by Arkarr View Post
And you gotta pay for that ?
Let me drop a piece of code for you here. You decide if you still want to pay or not.

EDIT:
Wich game ?

EDIT2:
Not tested
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.1.0"

#define MOVETYPE_WALK            2
#define MOVETYPE_FLYGRAVITY        5
#define MOVECOLLIDE_DEFAULT        0
#define MOVECOLLIDE_FLY_BOUNCE    1

#define LIFE_ALIVE    0

// ConVars
new Handle:sm_jetpack            INVALID_HANDLE;
new 
Handle:sm_jetpack_sound        INVALID_HANDLE;
new 
Handle:sm_jetpack_speed        INVALID_HANDLE;
new 
Handle:sm_jetpack_volume    INVALID_HANDLE;

// SendProp Offsets
new g_iLifeState    = -1;
new 
g_iMoveCollide    = -1;
new 
g_iMoveType        = -1;
new 
g_iVelocity        = -1;

// Soundfile
new String:g_sSound[255]    = "vehicles/airboat/fan_blade_fullthrottle_loop1.wav";

// Is Jetpack Enabled
new bool:g_bJetpacks[MAXPLAYERS 1]    = {false,...};

// Timer For GameFrame
new Float:g_fTimer    0.0;

// MaxClients
new g_iMaxClients    0;

//Jetpack restrictions
new Float:jetPackTime 5.0;
new 
Float:g_allowJetpackTime[MAXPLAYERS 1];
new 
Float:g_removedAmmount[MAXPLAYERS 1];
new 
Handle:g_timerClient[MAXPLAYERS 1];


public 
Plugin:myinfo =
{
    
name "Jetpack",
    
author "Knagg0",
    
description "",
    
version PLUGIN_VERSION,
    
url "http://www.mfzb.de"
};

public 
OnPluginStart()
{
    
AutoExecConfig();
    
    
// Create ConVars
    
CreateConVar("sm_jetpack_version"PLUGIN_VERSION""FCVAR_PLUGIN FCVAR_REPLICATED FCVAR_NOTIFY);
    
sm_jetpack CreateConVar("sm_jetpack""1"""FCVAR_PLUGIN FCVAR_REPLICATED FCVAR_NOTIFY);
    
sm_jetpack_sound CreateConVar("sm_jetpack_sound"g_sSound""FCVAR_PLUGIN);
    
sm_jetpack_speed CreateConVar("sm_jetpack_speed""100"""FCVAR_PLUGIN);
    
sm_jetpack_volume CreateConVar("sm_jetpack_volume""0.5"""FCVAR_PLUGIN);

    
// Create ConCommands
    
RegConsoleCmd("+sm_jetpack"JetpackP""FCVAR_GAMEDLL);
    
RegConsoleCmd("-sm_jetpack"JetpackM""FCVAR_GAMEDLL);
    
    
// Find SendProp Offsets
    
if((g_iLifeState FindSendPropOffs("CBasePlayer""m_lifeState")) == -1)
        
LogError("Could not find offset for CBasePlayer::m_lifeState");
        
    if((
g_iMoveCollide FindSendPropOffs("CBaseEntity""movecollide")) == -1)
        
LogError("Could not find offset for CBaseEntity::movecollide");
        
    if((
g_iMoveType FindSendPropOffs("CBaseEntity""movetype")) == -1)
        
LogError("Could not find offset for CBaseEntity::movetype");
        
    if((
g_iVelocity FindSendPropOffs("CBasePlayer""m_vecVelocity[0]")) == -1)
        
LogError("Could not find offset for CBasePlayer::m_vecVelocity[0]");
        
    
HookEvent("round_start"Event_RoundStart);
}

public 
OnMapStart()
{
    
g_fTimer 0.0;
    
g_iMaxClients GetMaxClients();
    for(new 
1<= g_iMaxClientsi++)
        
g_allowJetpackTime[i] = jetPackTime;
}

public 
OnConfigsExecuted()
{
    
GetConVarString(sm_jetpack_soundg_sSoundsizeof(g_sSound));
    
PrecacheSound(g_sSoundtrue);
}

public 
OnGameFrame()
{
    if(
GetConVarBool(sm_jetpack) && g_fTimer GetGameTime() - 0.075)
    {
        
g_fTimer GetGameTime();
        
        for(new 
1<= g_iMaxClientsi++)
        {
            if(
g_bJetpacks[i])
            {
                if(!
IsAlive(i)) StopJetpack(i);
                else 
AddVelocity(iGetConVarFloat(sm_jetpack_speed));
            }
        }
    }
}

public 
OnClientDisconnect(client)
{
    
StopJetpack(client);
}

public 
Action:Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    for(new 
1<= g_iMaxClientsi++)
    {
        
g_allowJetpackTime[i] = jetPackTime;
    }
}

public 
Action:JetpackP(clientargs)
{
    if(
GetConVarBool(sm_jetpack) && !g_bJetpacks[client] && IsAlive(client) && g_allowJetpackTime[client] > 0.0)
    {
        new 
Float:vecPos[3];
        
GetClientAbsOrigin(clientvecPos);
        
EmitSoundToAll(g_sSoundclientSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGSGetConVarFloat(sm_jetpack_volume), SNDPITCH_NORMAL, -1vecPosNULL_VECTORtrue0.0);
        
SetMoveType(clientMOVETYPE_FLYGRAVITYMOVECOLLIDE_FLY_BOUNCE);
        if(
g_allowJetpackTime[client] <= 0.0)
        {
            
g_bJetpacks[client] = false;
            
StopJetpack(client);
           }
           else
           {
            
g_bJetpacks[client] = true;
            if(
g_timerClient[client] == INVALID_HANDLE)
                
g_timerClient[client] = CreateTimer(0.1TMR_RemoveTimeclientTIMER_REPEAT);
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action:TMR_RemoveTime(Handle:timerany:client)
{
    
g_allowJetpackTime[client]-= 0.1;
    
g_removedAmmount[client] += 0.1;
    
PrintHintText(client"Jetpack fuel %.3f liters"g_allowJetpackTime[client]);    
}

public 
Action:JetpackM(clientargs)
{
    
StopJetpack(client);
    return 
Plugin_Continue;
}

StopJetpack(client)
{
    if(
g_bJetpacks[client])
    {
        if(
IsAlive(client)) SetMoveType(clientMOVETYPE_WALKMOVECOLLIDE_DEFAULT);
        
StopSound(clientSNDCHAN_AUTOg_sSound);
        
g_bJetpacks[client] = false;
    }
    if(
g_timerClient[client] != INVALID_HANDLE)
    {
        
KillTimer(g_timerClient[client]);
        
g_timerClient[client] = INVALID_HANDLE;
    }
}

SetMoveType(clientmovetypemovecollide)
{
    if(
g_iMoveType == -1) return;
    
SetEntData(clientg_iMoveTypemovetype);
    if(
g_iMoveCollide == -1) return;
    
SetEntData(clientg_iMoveCollidemovecollide);
}

AddVelocity(clientFloat:speed)
{
    if(
g_iVelocity == -1) return;
    
    new 
Float:vecVelocity[3];
    
GetEntDataVector(clientg_iVelocityvecVelocity);
    
    
vecVelocity[2] += speed;

    
TeleportEntity(clientNULL_VECTORNULL_VECTORvecVelocity);
}

bool:IsAlive(client)
{
    if(
g_iLifeState != -&& GetEntData(clientg_iLifeState1) == LIFE_ALIVE)
        return 
true;

    return 
false;

it bug number is minus when you use
example
5
4
3
2
1
-1
-2
-3
-4
and i dont use it and use agin it right can't use but if i use it
5
4
3
2
1
-1
-2
....
....
....
....
-100
supreeda is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 09-21-2015 , 09:09   Re: [PAY 1KEY] Jetpack Timer
Reply With Quote #5

Well... I have to test it, not fully understood, will do that later OR you could use the other version above.
__________________
Want to check my plugins ?
Arkarr is offline
supreeda
Senior Member
Join Date: Jul 2015
Old 09-21-2015 , 09:36   Re: [PAY 1KEY] Jetpack Timer
Reply With Quote #6

Quote:
Originally Posted by Arkarr View Post
Well... I have to test it, not fully understood, will do that later OR you could use the other version above.
i can wait u if you make it later tomorrow or .... >_<
supreeda is offline
supreeda
Senior Member
Join Date: Jul 2015
Old 09-23-2015 , 12:55   Re: [PAY 1KEY] Jetpack Timer
Reply With Quote #7

wait for edit and Flags Thank U
supreeda is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 09-28-2015 , 13:55   Re: [PAY 1KEY] Jetpack Timer
Reply With Quote #8

try this. it worked for me
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.1.0"

#define MOVETYPE_WALK            2
#define MOVETYPE_FLYGRAVITY        5
#define MOVECOLLIDE_DEFAULT        0
#define MOVECOLLIDE_FLY_BOUNCE    1

#define LIFE_ALIVE    0

#define JETPACK_LIMIT 5

// ConVars
new Handle:sm_jetpack            INVALID_HANDLE;
new 
Handle:sm_jetpack_sound        INVALID_HANDLE;
new 
Handle:sm_jetpack_speed        INVALID_HANDLE;
new 
Handle:sm_jetpack_volume    INVALID_HANDLE;

// SendProp Offsets
new g_iLifeState    = -1;
new 
g_iMoveCollide    = -1;
new 
g_iMoveType        = -1;
new 
g_iVelocity        = -1;

// Soundfile
new String:g_sSound[255]    = "vehicles/airboat/fan_blade_fullthrottle_loop1.wav";

// Is Jetpack Enabled
new bool:g_bJetpacks[MAXPLAYERS 1]    = {false,...};
new 
bool:g_bAllowedToUseJetpack[MAXPLAYERS+1] = {false,...};

new 
Float:g_flJetpackLength[MAXPLAYERS+1] = {0.0,...};

// Timer For GameFrame
new Float:g_fTimer    0.0;

// MaxClients
new g_iMaxClients    0;

public 
Plugin:myinfo =
{
    
name "Jetpack",
    
author "Knagg0",
    
description "",
    
version PLUGIN_VERSION,
    
url "http://www.mfzb.de"
};

public 
OnPluginStart()
{
    
AutoExecConfig();
    
    
// Create ConVars
    
CreateConVar("sm_jetpack_version"PLUGIN_VERSION""FCVAR_PLUGIN FCVAR_REPLICATED FCVAR_NOTIFY);
    
sm_jetpack CreateConVar("sm_jetpack""1"""FCVAR_PLUGIN FCVAR_REPLICATED FCVAR_NOTIFY);
    
sm_jetpack_sound CreateConVar("sm_jetpack_sound"g_sSound""FCVAR_PLUGIN);
    
sm_jetpack_speed CreateConVar("sm_jetpack_speed""100"""FCVAR_PLUGIN);
    
sm_jetpack_volume CreateConVar("sm_jetpack_volume""0.5"""FCVAR_PLUGIN);
    
    
HookEvent"player_spawn"EventPlayerSpawn_PostEventHookMode_Post );

    
// Create ConCommands
    
RegConsoleCmd("+sm_jetpack"JetpackP""FCVAR_GAMEDLL);
    
RegConsoleCmd("-sm_jetpack"JetpackM""FCVAR_GAMEDLL);
    
    
// Find SendProp Offsets
    
if((g_iLifeState FindSendPropOffs("CBasePlayer""m_lifeState")) == -1)
        
LogError("Could not find offset for CBasePlayer::m_lifeState");
        
    if((
g_iMoveCollide FindSendPropOffs("CBaseEntity""movecollide")) == -1)
        
LogError("Could not find offset for CBaseEntity::movecollide");
        
    if((
g_iMoveType FindSendPropOffs("CBaseEntity""movetype")) == -1)
        
LogError("Could not find offset for CBaseEntity::movetype");
        
    if((
g_iVelocity FindSendPropOffs("CBasePlayer""m_vecVelocity[0]")) == -1)
        
LogError("Could not find offset for CBasePlayer::m_vecVelocity[0]");
}

public 
Action:EventPlayerSpawn_Post(Handle:event,const String:name[],bool:dontBroadcast)
{
    new 
client_id GetEventInt(event"userid");
    new 
client GetClientOfUserId(client_id);
    
g_bAllowedToUseJetpack[client] = true;
}

public 
OnMapStart()
{
    
g_fTimer 0.0;
    
g_iMaxClients GetMaxClients();
}

public 
OnConfigsExecuted()
{
    
GetConVarString(sm_jetpack_soundg_sSoundsizeof(g_sSound));
    
PrecacheSound(g_sSoundtrue);
}

public 
OnGameFrame()
{
    if(
GetConVarBool(sm_jetpack) && g_fTimer GetGameTime() - 0.075)
    {
        
g_fTimer GetGameTime();
        
        for(new 
1<= g_iMaxClientsi++)
        {
            if(
g_bJetpacks[i])
            {
                if(!
IsAlive(i)) StopJetpack(i);
                else 
                {
                    if( !
g_flJetpackLength[i] )
                        
g_flJetpackLength[i] = GetGameTime() + JETPACK_LIMIT.0;
                    if(
g_flJetpackLength[i] && g_flJetpackLength[i]>GetGameTime())
                        
AddVelocity(iGetConVarFloat(sm_jetpack_speed));
                    else
                        
StopJetpack(i);
                }
            }
        }
    }
}

public 
OnClientDisconnect(client)
{
    
StopJetpack(client);
}

public 
Action:JetpackP(clientargs)
{
    if(
GetConVarBool(sm_jetpack) && !g_bJetpacks[client] && IsAlive(client) && g_bAllowedToUseJetpack[client] )
    {
        new 
Float:vecPos[3];
        
GetClientAbsOrigin(clientvecPos);
        
EmitSoundToAll(g_sSoundclientSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGSGetConVarFloat(sm_jetpack_volume), SNDPITCH_NORMAL, -1vecPosNULL_VECTORtrue0.0);
        
SetMoveType(clientMOVETYPE_FLYGRAVITYMOVECOLLIDE_FLY_BOUNCE);
        
g_bJetpacks[client] = true;
    }
    
    return 
Plugin_Continue;
}

public 
Action:JetpackM(clientargs)
{
    
StopJetpack(client);
    return 
Plugin_Continue;
}

StopJetpack(client)
{
    if(
g_bJetpacks[client])
    {
        if(
IsAlive(client)) SetMoveType(clientMOVETYPE_WALKMOVECOLLIDE_DEFAULT);
        
StopSound(clientSNDCHAN_AUTOg_sSound);
        
g_bJetpacks[client] = false;
    }
    
g_flJetpackLength[client] = 0.0;
    
g_bAllowedToUseJetpack[client] = false;
}

SetMoveType(clientmovetypemovecollide)
{
    if(
g_iMoveType == -1) return;
    
SetEntData(clientg_iMoveTypemovetype);
    if(
g_iMoveCollide == -1) return;
    
SetEntData(clientg_iMoveCollidemovecollide);
}

AddVelocity(clientFloat:speed)
{
    if(
g_iVelocity == -1) return;
    
    new 
Float:vecVelocity[3];
    
GetEntDataVector(clientg_iVelocityvecVelocity);
    
    
vecVelocity[2] += speed;

    
TeleportEntity(clientNULL_VECTORNULL_VECTORvecVelocity);
}

bool:IsAlive(client)
{
    if(
g_iLifeState != -&& GetEntData(clientg_iLifeState1) == LIFE_ALIVE)
        return 
true;

    return 
false;


Last edited by lazarev; 09-28-2015 at 14:02.
lazarev is offline
supreeda
Senior Member
Join Date: Jul 2015
Old 10-01-2015 , 09:22   Re: JETPACK
Reply With Quote #9

thank someone help me already
supreeda is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 10-01-2015 , 14:09   Re: JETPACK
Reply With Quote #10

that is some scary jetpack code
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram 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 04:38.


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