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

script help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tedaimlocks
Member
Join Date: Jan 2024
Old 02-01-2024 , 11:50   script help
Reply With Quote #1

so i need help finishing my menu ,

i will send a pic of the menu under , i need help making the respawn and buy terrorist, if you guys can , get the points code from this (and also if possible, i want a player to get 3 points everytime they get kills or when they finish the map, idk if you need the timer code but if you do lmk )

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

#define PREFIX "SPK-Deathrun"

#define PLUGIN "USP SHOP"
#define VERSION "1.0"
#define AUTHOR "Bu!ld3r"

native get_user_points(id)
native set_user_points(idamount)

enum _eData 
{
    
szName[32],
    
szVmodel[64],
    
szPmodel[64],
    
cost
}

new const 
szUsps[][eData]  =
{
    
//NAME//        //V_MODEL//          //P_MODEL//     //COST//
    
    
"Green Usp""models/usp/v_usp_green.mdl""models/usp/p_usp_green.mdl"150 },
    { 
"Dragon Usp""models/usp/v_usp_dragon.mdl""models/usp/p_usp_dragon.mdl"200 }//,
    
    //{ "USP #3", "models/usp/v_usp3.mdl", "models/usp/p_usp3.mdl", 350 },
    //{ "USP #4", "", "", 700 },
    
}


new 
current[33];
new 
boolszData[33][sizeof(szUsps)];

new const 
g_vault[] = "USP_SHOP";

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say /usp""cmd_main");
    
register_event("CurWeapon""Event_CurWeapon""be","1=1");
}

public 
plugin_precache()
{
    for(new 
i=0i<sizeof(szUsps); i++)
    {
        
precache_model(szUsps[i][szVmodel]);
        
precache_model(szUsps[i][szPmodel]);
    }
}

//SET A MODEL
public set_model(id)
{
    if( 
current[id] >= )
    {
        
entity_set_string(idEV_SZ_viewmodelszUsps[current[id]][szVmodel]);
        
entity_set_string(idEV_SZ_weaponmodelszUsps[current[id]][szPmodel]);
    }
}

//CONNECT
public client_putinserver(id)
{
    
current[id] = -1;
    
cmd_load(id);
}

//DISCONNECT
public client_disconnect(id)
{
    
cmd_save(id);
}

//CURWEAPON
public Event_CurWeapon(id
{
    if(!
is_user_connected(id))
        return 
PLUGIN_HANDLED;    
    
    if( 
current[id] >= )
    {
        
set_model(id);
    }
    
    return 
PLUGIN_CONTINUE;
}

//DISABLE CALLBACK
public disable_item(idmenuitem)
{
    return 
ITEM_DISABLED;
}

//MAIN MENU
public cmd_main(id)
{

    new 
szText[150];
    
formatex(szTextcharsmax(szText), "\d[ \r%s \d] \yUsp \wSystem \rMain \wMenu^n Your current Points: %i"PREFIXget_user_points(id));
    
    new 
menu menu_create(szText"main_handler");
    new 
cb menu_makecallback("disable_item");
    
    
menu_additem(menu"Buy a Usp");
    
    if(
get_user_usps(id) <= 0)
        
menu_additem(menu"\wSell a Usp \d(No Usps)", .callback cb);
    else
        
menu_additem(menu"\wSell a Usp");
    
    
menu_display(idmenu);
    
    return 
PLUGIN_CONTINUE;

}

public 
main_handler(idmenuitem)
{

    if(
item== MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    switch(
item)
    {
        case 
0cmd_buy(id);
        case 
1cmd_sell(id);
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;

}

//BUY MENU
public cmd_buy(id)
{

    new 
szText[150];
    
formatex(szTextcharsmax(szText), "\d[ \r%s \d] \yUsp Buying - \wmenu\w (%i Usps)^n Your current Points: %i"PREFIXget_user_usps(id), get_user_points(id));
    
    new 
menu menu_create(szText"buy_handler");
    new 
cb menu_makecallback("disable_item");
    
    for(new 
i=0i<sizeof(szUsps); i++)
    {
        if(
szData[id][i])
        {
            
formatex(szTextcharsmax(szText), "\w%s \d( \rPurchased \d)"szUsps[i][szName], szUsps[i][cost]);
            
menu_additem(menuszText, .callback cb);
        }
        else
        {
            
formatex(szTextcharsmax(szText), "\w%s \d( \r%i POINTS \d)"szUsps[i][szName], szUsps[i][cost]);
            
menu_additem(menuszText);
        }
            
    
    }
    
    
menu_display(id,menu);
    return 
PLUGIN_HANDLED;

}

public 
buy_handler(idmenuitem)
{

    if(
item== MENU_EXIT)
    {
        
cmd_main(id);
        
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    if(
szData[id][item])
    {
        
        
ColorChat(id"you ^4already^1 bought this ^3skin^1.");
        
cmd_buy(id);
        
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
get_user_points(id);
    
    if(
szUsps[item][cost])
    {
    
        
ColorChat(id"you ^4are^1 missing ^3%i^1 points."szUsps[item][cost] - p);
        
        
cmd_main(id);
        
menu_destroy(menu);
        
        return 
PLUGIN_HANDLED;
    
    }

    
set_user_points(idp-szUsps[item][cost]);
    
    
ColorChat(id"you bought the ^4%s^1 skin."szUsps[item][szName]);
    
    
current[id] = item;
    
szData[id][item] = true;
    
    
set_model(id);
    
cmd_save(id);
    
    
cmd_buy(id);
    
    return 
PLUGIN_HANDLED;

}

//SELL MENU
public cmd_sell(id)
{
    if(
get_user_usps(id) <= 0)
    {
        
cmd_main(id);
        return 
PLUGIN_HANDLED;
    }
    
    new 
szText[150], szParm[10];
    
formatex(szTextcharsmax(szText), "\d[ \r%s \d] \yUsp Selling - \wmenu\w (50%% off)^nYour current Points: %i"PREFIXget_user_points(id));
    
    new 
menu menu_create(szText"sell_handler");
    
    for(new 
i=0i<sizeof(szUsps); i++)
    {
        if(
szData[id][i])
        {
            
formatex(szTextcharsmax(szText), "\w%s - (%i Points)"szUsps[i][szName], szUsps[i][cost]/2);
            
            
num_to_str(iszParmcharsmax(szParm));
            
menu_additem(menuszTextszParm);
        }
    }
        

    
menu_display(idmenu);
    
    return 
PLUGIN_HANDLED;
}


public 
sell_handler(idmenuitem)
{
    new 
key MenuItem(menuitem);
    
    if(
item == MENU_EXIT)
    {
        
cmd_main(id);
        return 
PLUGIN_HANDLED;
    }
    
    if(!
szData[id][key])
    {
        
        
ColorChat(id"you ^4already^1 sold this ^3skin^1.");
        
        
cmd_sell(id);
        return 
PLUGIN_HANDLED;
    }
    
    
cmd_agree(idkey);
    
    return 
PLUGIN_HANDLED;
}    

//AGREE MENU
public cmd_agree(idkey)
{
    new 
szText[150], szParm[10];
    
formatex(szTextcharsmax(szText), "\d[ \r%s \d] \yDo you want\w to sell your %s? ^nYour current Points: %i"PREFIXszUsps[key][szName], get_user_points(id));
    
    new 
menu menu_create(szText"agree_handler");
    
    
num_to_str(keyszParmcharsmax(szParm));
    
    
menu_additem(menu"Yes, absolutely!"szParm);
    
menu_additem(menu"No, I do not.");
    
    
menu_display(idmenu);
    
    return 
PLUGIN_HANDLED;
}

public 
agree_handler(idmenuitem)
{
    if(
item == MENU_EXIT || item == )
    {
        
cmd_sell(id);
        
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
key  MenuItem(menuitem);
    
    if(!
szData[id][key])
    {
        
        
ColorChat(id"you ^4already^1 sold this ^3skin^1.");
        
        
cmd_sell(id);
        return 
PLUGIN_HANDLED;
    }
    
    
set_user_points(idget_user_points(id) + szUsps[key][cost]/2);
    
    
ColorChat(id"you ^4sold^1 your ^3%s^1 for ^4%i^1 points."szUsps[key][szName], szUsps[key][cost]/2);
    
    
szData[id][key] = false;
    
    
cmd_save(id);
    
    
cmd_sell(id);
    
    return 
PLUGIN_HANDLED;
}

//SAVE USER
public cmd_save(id)
{
    new 
data[250];
    
    
formatex(datacharsmax(data), "%i"szData[id][0] ? 0);

    for(new 
i=1i<sizeof(szUsps); i++)
    {
        
format(datacharsmax(data), "%s %i"dataszData[id][i]? 0);
    }
    
    
fvault_set_data(g_vaultget_authid(id), data);
}

//LOAD USER
public cmd_load(id)
{
    new 
data[250], num[10];
    
    if(
fvault_get_data(g_vaultget_authid(id), datacharsmax(data)))
    {
        for(new 
i=0i<sizeof(szUsps); i++)
        {
            
strbreak(datanumcharsmax(num), datacharsmax(data))
            
            
szData[id][i] =  str_to_num(num)? true false;

        }
        
    }
    else
    {
        
arrayset(szData[id], falsecharsmax(szData));
    }

}

//GET AUTHID
stock get_authid(id)
{
    new 
authid[64];
    
get_user_authid(idauthidcharsmax(authid));
    
    return 
authid;
}

//GET USPS AMOUNT
stock get_user_usps(id)
{
    new 
temp 0;
    
    for(new 
i=0i<sizeof(szUsps); i++)
    {
        if(
szData[id][i])
            
temp++;
    }
    
    return 
temp;
}

//GET MENU ITEM
stock MenuItem(menuitem)
{
    new 
szData[10];
    new 
accesscallback;
    
    
menu_item_getinfo(menuitemaccessszDatacharsmax(szData), __callback);
    
    
menu_destroy(menu);
    
    return 
str_to_num(szData);
}
        
//COLORCHAT
stock ColorChat(const id, const string[], {FloatSqlResul,_}:...) 
{
    new 
msg[191], players[32], count 1;
    
    static 
lenlen formatex(msgcharsmax(msg), "^3[%s]^1 "PREFIX);
    
vformat(msg[len], charsmax(msg) - lenstring3);
    
    if(
id)  players[0] = id;
    else    
get_players(players,count,"ch");
    
    for (new 
0counti++)
    {
        if(
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"),_players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }
    }
    
    return 
PLUGIN_CONTINUE;


and for the menu, i use the simple menu by oxicrom and also can someone make a new line under the title and display the current points of the player aswell)


PHP Code:
[Default Settings]
;
These are the default settings for each menu created.
;
You can add certain options in [Menu Settings] if you want to change them.
;
Please note that every menu needs to have a different MENU_OPEN settingstherefore there's no default one.

MENU_TITLE = SPK - Deathrun | Main Menu
MENU_TITLE_PAGE = %newline%Page:\d
MENU_BACK = \yPrevious Page
MENU_NEXT = \yNext Page
MENU_EXIT = \rExit
;MENU_OPEN = say /menu, say_team /menu, amx_mymenu, chooseteam -- This must be set with a different value on every menu!
MENU_FLAG = 0
MENU_TEAM = 0
MENU_ALIVEONLY = 0
MENU_ITEMS_PER_PAGE = 7
MENU_REOPEN = 0
MENU_ITEM_FORMAT = %item%
MENU_PREFIX = !g[SPK Deathrun]!n
MENU_NOACCESS = You have no access to this menu.
MENU_NOTEAM = Your team isn'
t allowed to use this menu.
MENU_ALIVE You need to be alive to use this menu.
MENU_DEAD You need to be dead to use this menu.
MENU_SOUND =

[New 
Menu Menu Sample]

[
Menu Settings]
;<
settings> = <value>

MENU_OPEN say /menusay_team /menuamx_mymenuchooseteam
MENU_REOPEN 
0

[Menu Items]
;<
Item Name> <Command> [Flag] [Team]

"\yBuy \wRespawn \r[ 7 Points ]" "say /respawn"
"\yBuy \rTerrorist \r[ 10 Points ]" "say /buytr"
"\yBuy \wPrefix \r[ 250 Points ]" "say /prefix"
#blank
"Knife \ySkins" "say /knife"
"USP \ySkins" "say /usp"
#blank
"\wSpec \r[Admins \rOnly]" "say /spec" "c" "ct"
"\rAdmin Menu" "amx_amenu" "e"

[New Menu Admin Menu]

[
Menu Settings]
;<
settings> = <value>

MENU_OPEN say /amsay_team /amamx_amenu,
MENU_REOPEN 0

MENU_TITLE 
SPK Deathrun Admin Menu
MENU_FLAG 
e
[Menu Items]
;<
Item Name> <Command> [Flag] [Team]

" | \rRevive \yPlayers \w| " "amx_rmenu" "g"
" | \rSlap/Slay \yMenu \w| " "amx_slapmenu" "e"
" | \rBan \yMenu \w| " "amx_banmenu" "d"
" | \rGag \yMenu \w| " "amx_gagmenu" "e" 
https://forums.alliedmods.net/showthread.php?t=284324
Attached Thumbnails
Click image for larger version

Name:	image.png.709635f476a5e19777da35aba871964d.png
Views:	17
Size:	23.8 KB
ID:	203081  

Last edited by tedaimlocks; 02-01-2024 at 11:55. Reason: code tag
tedaimlocks is offline
Old 02-01-2024, 11:55
mlibre
This message has been deleted by DarkDeviL. Reason: No longer relevant
Old 02-01-2024, 12:24
tedaimlocks
This message has been deleted by DarkDeviL. Reason: No longer relevant
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-03-2024 , 07:45   Re: script help
Reply With Quote #2

Quote:
Originally Posted by tedaimlocks View Post
i want a player to get 3 points everytime they get kills...
proof

PHP Code:
public client_death(idvictimweapon
{
    if( !
is_user_connected(id) || id == victim 
        return
    
    if(
current[id] > 0)
    {
        
set_user_points(idget_user_points(id) + 3)
    }

__________________
mlibre 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 10:19.


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