Raised This Month: $169 Target: $400
 42% 

how to change this (add item into a menu)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gfxchris
Member
Join Date: Feb 2016
Old 11-21-2020 , 21:49   how to change this (add item into a menu)
Reply With Quote #1

alright,so i have this plugin

and theres the case 4 where i have a jetpack,the plugin that is based on is syn surfjetpack
https://forums.alliedmods.net/showthread.php?p=378086
this one

now i want to know how can i edit the syn surfjetpack to use the case4 jetpack

i already have syn surfjetpack on my server,with some cvars and a speed put by me
this one i want to edit with some more speed,a different model and a different sprite,basically a vip version of the og one

the command to get it is client_cmd(id, "jpvip" , "Jetpack") but i dont know what to edit in the jetpack plugin...
[also i dont need the commands such as /buyjetpack or else,cause its gonna be free from a vip menu]
Attached Files
File Type: sma Get Plugin or Get Source (vip_idea_1.sma - 43 views - 16.1 KB)
gfxchris is offline
gfxchris
Member
Join Date: Feb 2016
Old 11-25-2020 , 11:30   Re: how to change this (add item into a menu)
Reply With Quote #2

bump,some help here?
gfxchris is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-26-2020 , 02:25   Re: how to change this (add item into a menu)
Reply With Quote #3

Quote:
Originally Posted by gfxchris View Post
the command to get it is client_cmd(id, "jpvip" , "Jetpack")
First thing to note is that this is not valid code. Second thing is that the "jpvip" does not exist anywhere.

So, are you trying to keep the original jetpack plugin functionality and add a VIP jetpack (that can only be triggered via your VIP plugin)? If so, it will take a bit of modification of the jetpack plugin.

If you just want to invoke the current jetpack plugin (even if just for a test or partial solution) with the VIP menu, you would use:

PHP Code:
client_cmd(id"buyjetpack"
or

PHP Code:
amxclient_cmd(id"buyjetpack"
The last version requires AMX Mod X 1.9.0+.
__________________
fysiks is offline
gfxchris
Member
Join Date: Feb 2016
Old 11-26-2020 , 17:34   Re: how to change this (add item into a menu)
Reply With Quote #4

Quote:
So, are you trying to keep the original jetpack plugin functionality and add a VIP jetpack (that can only be triggered via your VIP plugin)? If so, it will take a bit of modification of the jetpack plugin.
that's exactly what im trying to do,what do i need to modify exactly?
gfxchris is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-26-2020 , 20:19   Re: how to change this (add item into a menu)
Reply With Quote #5

From a high level, you're going to need to modify the jetpack plugin so that it will support multiple jetpacks (this is quite a big task). Then, you need to create a mechanism for another plugin to give them the second type of jetpack probably using a dynamic native.

Adding a second jetpack type will involve precaching the additional model, sprite, sound (depending on what is reused or not). Then, you have to implement the type such that when you give a jetpack via the normal method you would give them the first type and if given via the new dynamic native, it will set the jetpack to the second type. Then, you would update the places that are different between the types using the type variable to implement the differences between the two types.

Since we're in the Scripting section, try modifying it and see if you can get it to work. If you run into issues, please attach your version of the plugin (even if it's not working) and we can try to help you out.
__________________
fysiks is offline
gfxchris
Member
Join Date: Feb 2016
Old 11-27-2020 , 13:34   Re: how to change this (add item into a menu)
Reply With Quote #6

i wanna ask something,i know how to edit and add minor things,im not an experienced scripter

new g_HasJetpack[33]
new g_JetpackEnt[33]

if i change those with

new g_VipHasJetpack[33]
new_g_VipJetpackEnt[33]
would it work ? and changing the entire script with the new vip line in front

also changing the sjp_givejp and sjp_stripjp with sjp_givejpvip and sjp_stripjpvip
and also the cvars with a vip in front,would that work ?
gfxchris is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-27-2020 , 15:37   Re: how to change this (add item into a menu)
Reply With Quote #7

if you have no idea about scripting post in the suggestion request section.
__________________
@Jailbreak Main Mod v2.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
gfxchris
Member
Join Date: Feb 2016
Old 11-27-2020 , 16:21   Re: how to change this (add item into a menu)
Reply With Quote #8

then can a moderator move the topic there?
gfxchris is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-28-2020 , 07:05   Re: how to change this (add item into a menu)
Reply With Quote #9

Quote:
Originally Posted by gfxchris View Post
i wanna ask something,i know how to edit and add minor things,im not an experienced scripter

new g_HasJetpack[33]
new g_JetpackEnt[33]

if i change those with

new g_VipHasJetpack[33]
new_g_VipJetpackEnt[33]
would it work ? and changing the entire script with the new vip line in front
I don't think that that would be the best way to approach this. When giving a VIP jetpack, I would simply set g_HasJetpack to 2 (instead of the normal 1) to indicate that it's the VIP version of the jetpack. This basically wouldn't require changing any current uses of the g_hasJetpack variable which makes thing so much simpler.

Then for g_JetpackEnt, you would simply use a different model in entity_set_model() when you create the entity if g_hasJetpack is 2. For example:

PHP Code:
entity_set_model(g_JetpackEnt[id], g_HasJetpack[id] == JETPACK_PMODEL_VIP JETPACK_PMODEL
where you define JETPACK_PMODEL_VIP as the VIP model (make sure to precache this too).

Quote:
Originally Posted by gfxchris View Post
also changing the sjp_givejp and sjp_stripjp with sjp_givejpvip and sjp_stripjpvip
and also the cvars with a vip in front,would that work ?
If you want the VIP jetpack to have their own cvars, that is certainly possible and actually would be quite simple to implement. Wherever the cvars are used in the original plugin, you would use the VIP versions of the cvars if g_HasJetpack is 2. For example:

PHP Code:
get_pcvar_num(cvar_max_speed
would change to:
PHP Code:
get_pcvar_numg_HasJetpack[id] == cvar_maxspeed_vip cvar_max_speed 
assuming cvar_maxspeed_vip is the cvar pointer for the VIP version of that cvar.


I think that if you have a little experience and want to learn more, this is something that you can do. To test it, you can simply copy the _give_Jetpack() function and name this new function something else and set the g_HasJetpack variable to 2 and then have it called via a new client command with register_clcmd() (just for testing). Then, once you have the new jetpack working, you can add in the ability to invoke it from another plugin.
__________________
fysiks is offline
gfxchris
Member
Join Date: Feb 2016
Old 11-28-2020 , 11:46   Re: how to change this (add item into a menu)
Reply With Quote #10

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <engine>

new JETPACK_PMODEL_VIP[]     = "models/p_longjump.mdl"
new JETPACK_GOTSOUND[]     = "items/ammopickup2.wav"

new cvar_cost
new cvar_thrust
new cvar_min_speed
new cvar_max_speed

new g_HasJetpack2[33]
new g_JetpackEnt[33]

static const PLUGIN_NAME[]     = "SyN Vip Jetpack"
static const PLUGIN_AUTHOR[]     = "Cheap_Suit"
static const PLUGIN_VERSION[]    = "1.5"

public plugin_init()
{
    new mapName[33]
    get_mapname(mapName, 32)
    
    if(!equali(mapName, "surf_", 5))
    {
        new pluginName[33]
        format(pluginName, 32, "[Disabled] %s", PLUGIN_NAME)
        register_plugin(pluginName, PLUGIN_VERSION, PLUGIN_AUTHOR)
        pause("ade")
    }
    else
    {
        register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
        register_cvar(PLUGIN_NAME, PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER)
        
        register_clcmd("sjp_givesj" ,         "cmd_GiveSJ",         ADMIN_IMMUNITY, "<userid> - Gives free surf jetpack")
        register_clcmd("sjp_stripsj" ,         "cmd_StripSJ",         ADMIN_IMMUNITY, "<userid> - Strips users surf jetpack")
        
        register_clcmd("say /buyjetpack",     "cmd_BuySurfJetpack", 0, "Buys surf jetpack")
        register_clcmd("say buy_jetpack",     "cmd_BuySurfJetpack", 0, "Buys surf jetpack")
        register_concmd("buy_jetpack",         "cmd_BuySurfJetpack", 0, "Buys surf jetpack")
        register_concmd("buyjetpack",         "cmd_BuySurfJetpack", 0, "Buys surf jetpack")
        
        cvar_cost    = register_cvar("sjp_cost", "5000")
        cvar_thrust     = register_cvar("sjp_thrust", "10")
        cvar_min_speed     = register_cvar("sjp_min_speed", "400")
        cvar_max_speed     = register_cvar("sjp_max_speed", "1200")
        
        register_event("DeathMsg",         "Event_DeathMsg", "a")
    }
}

public plugin_precache()
{
    precache_sound(JETPACK_GOTSOUND)
    precache_model(JETPACK_PMODEL_VIP)
}

public client_connect(id)
{
    g_HasJetpack[id] = 0
    _removeJetpackEnt(id)
}
    
public client_disconnect(id)
{
    g_HasJetpack[id] = 0
    _removeJetpackEnt(id)
}

public Event_DeathMsg()
{
    new id = read_data(2)

    g_HasJetpack[id] = 0
    _removeJetpackEnt(id)

    return PLUGIN_CONTINUE
}

public cmd_BuySurfJetpack(id)
{
    new iMoney = cs_get_user_money(id)
    new iCost = get_pcvar_num( g_HasJetpack[id] == 2 ? cvar_cost_vip : cvar_cost )
    
    if(!is_user_alive(id)) 
        client_print(id, print_center, "You cant buy when your dead!")
    else if(g_HasJetpack[id])
        client_print(id, print_center, "You already own a surf jetpack.")
    else if(iMoney < iCost)
        client_print(id, print_center, "Insufficient funds! ($%d)", iCost)
    else
    {
        _give_Jetpack(id)
        cs_set_user_money(id, iMoney - iCost, 1)
      }
    return PLUGIN_HANDLED
}

public cmd_GiveSJ(id , level , cid) 
{
    if(!cmd_access(id , level , cid , 2))
        return PLUGIN_HANDLED
        
    new arg1[33]
    read_argv(1 , arg1 , 32)

    new target = cmd_target(id , arg1 , 0)
    if(!is_user_connected(target))
    {
        console_print(id, "Player does not exist")
        return PLUGIN_HANDLED
    }

    if(g_HasJetpack[target])
    {
        console_print(id, "Player already has a surf jetpack")
        return PLUGIN_HANDLED
    }
    
    _give_Jetpack(target)

    new Name[33], Name2[33]
    get_user_name(id, Name, 32)
    get_user_name(target, Name2, 32)
    
    console_print(id, "You gave %s a surf jetpack", Name2)
    client_print(target, print_chat, "ADMIN: %s gave you a surf jetpack", Name)
    
    return PLUGIN_HANDLED
}

public cmd_StripSJ(id , level , cid) 
{
    if(!cmd_access(id , level , cid , 2))
        return PLUGIN_HANDLED
        
    new arg1[33]
    read_argv(1 , arg1 , 32)

    new target = cmd_target(id , arg1 , 0)
    if(!is_user_connected(target))
    {
        console_print(id, "Player does not exist")
        return PLUGIN_HANDLED
    }

    if(!g_HasJetpack[target])
    {
        console_print(id, "Player does not have a surf jetpack")
        return PLUGIN_HANDLED
    }
    
    g_HasJetpack[id] = 0
    _removeJetpackEnt(id)

    new Name[33], Name2[33]
    get_user_name(id, Name, 32)
    get_user_name(target, Name2, 32)
    
    console_print(id, "You stripped %s a surf jetpack", Name2)
    client_print(target, print_chat, "ADMIN: %s stripped your surf jetpack", Name)
    
    return PLUGIN_HANDLED
}

public _give_Jetpack(id)
{
    g_HasJetpack[id] = 2
    client_cmd(id, "spk %s", JETPACK_GOTSOUND)
    client_print(id, print_chat, "You've got a surf jetpack! :: HOW TO USE :: ~ Just Surf ~ ")
    
    if(g_JetpackEnt[id] < 1)
    {
        g_JetpackEnt[id] = create_entity("info_target")
        if(is_valid_ent(g_JetpackEnt[id]))
        {
            entity_set_model(g_JetpackEnt[id], g_HasJetpack[id] == 2 ? JETPACK_PMODEL_VIP : JETPACK_PMODEL)
            entity_set_int(g_JetpackEnt[id], EV_INT_movetype, MOVETYPE_FOLLOW)
            entity_set_edict(g_JetpackEnt[id], EV_ENT_aiment, id)
        }
    }
}

public _removeJetpackEnt(id)
{
    if(g_JetpackEnt[id] > 0)
        remove_entity(g_JetpackEnt[id])
    g_JetpackEnt[id] = 0
}

public client_PreThink(id)
{
    if(!is_user_alive(id) || !g_HasJetpack[id])
        return PLUGIN_CONTINUE
        
    if(get_user_speed(id) < get_pcvar_num( g_HasJetpack[id] == 2 ? cvar_minspeed_vip : cvar_min_speed))
        return PLUGIN_CONTINUE    
        
    new Button = get_user_button(id)
    if(Button & IN_MOVELEFT || Button & IN_MOVERIGHT)
    {           
        _jetThrust(id)
    }
    return PLUGIN_CONTINUE
}

public _jetThrust(id)
{    
    new Float:fVelocity[3]
    entity_get_vector(id, EV_VEC_velocity, fVelocity)

    new Float:fAngle[3]
    entity_get_vector(id, EV_VEC_angles, fAngle)
    engfunc(EngFunc_MakeVectors, fAngle)
                
    new Float:fForward[3]
    get_global_vector(GL_v_forward, fForward)
                
    fVelocity[0] += fForward[0] * get_pcvar_num( g_HasJetpack[id] == 2 ? cvar_thrust_vip :cvar_thrust )
    fVelocity[1] += fForward[1] * get_pcvar_num( g_HasJetpack[id] == 2 ? cvar_thrust_vip :cvar_thrust )
            
    if(get_user_speed(id) < get_pcvar_num( g_HasJetpack[id] == 2 ? cvar_maxspeed_vip : cvar_max_speed ))
        entity_set_vector(id, EV_VEC_velocity, fVelocity)
        
    return PLUGIN_CONTINUE
}

stock get_user_speed(id)
{
    new Float:fVelocity[3]
    entity_get_vector(id, EV_VEC_velocity, fVelocity)
    
    new iVelocity[3]
    FVecIVec(fVelocity, iVelocity)
    
    new iVelocity0 = iVelocity[0] * iVelocity[0]
    new iVelocity1 = iVelocity[1] * iVelocity[1]
    
    return sqroot(iVelocity0 + iVelocity1)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
i edited it like this (i dont know if i thats what u meant by setting g_HasJetpack to 2)
it gives me error on line 64

this one :
Code:
    g_HasJetpack[id] = 0
i edited pretty much all the things u told me to,i prechached the model too,can u tell me what's wrong here?
gfxchris is offline
Reply


Thread Tools
Display Modes

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 10:10.


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