AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   can anyone help me? (https://forums.alliedmods.net/showthread.php?t=64865)

aznbeau1121g 12-26-2007 12:33

can anyone help me?
 
can anyone tell me whats wrong with this script? it won't compile

aznbeau1121g 12-26-2007 13:11

Re: can anyone help me?
 
3 Attachment(s)
opps forgot to add plugin...

The NoobShop plugin i want to be fixed

orginal plugin is upgrades5 but the menu doesn't work...

source is the files/ menu items

aznbeau1121g 12-28-2007 11:25

Re: can anyone help me?
 
???

M249-M4A1 12-28-2007 12:09

Re: can anyone help me?
 
Compiles but I cannot guarantee it will work because of the errors already in the plugin.

PHP Code:

// Max items players can carry
#define Max_PlayerItems     3

// Death Lose?
#define Item_Death      1 // Player lose item on death

// More defines
#define Item_Money 1
#define DeniedSound 1

// Item plugins configs
#define MAX_ITEMS       100
#define MAX_MAPITEMS        100
#define MAX_ITEM_NAME_SIZE  64
#define MAX_ITEM_DESC_SIZE  128

// ETC
new BoughtItemSound[]   = { "items/ammopickup1.wav" }
new 
PickUpItemSound[]   = { "items/ammopickup2.wav" }
new 
DropItemSound[] = { "events/enemy_died.wav" }
new 
ItemModel[]     = { "models/w_gaussammo.mdl" }

// Includes
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <vault>
#include <fun>

// New
new g_MapItemNum
new bool:ftimeover
new bool:g_DirExist
new g_ConfigsDir[64]
new 
g_ItemOriginDir[64]
new 
g_MapItemOrgins[MAX_MAPITEMS+1][3]

new 
g_numberofitems
new g_menuPosition[33]
new 
g_itemindex[MAX_ITEMS+1]
new 
g_itemcost[MAX_ITEMS+1]
new 
g_itemname[MAX_ITEMS+1][MAX_ITEM_NAME_SIZE+1]
new 
g_itemdesc[MAX_ITEMS+1][MAX_ITEM_DESC_SIZE+1]
new 
bool:g_iPlayerItem[33][MAX_ITEMS+1]
new 
g_PlayerNumItems[33]
new 
PlayerLevel[33]

// Plugin Description
new PLUGIN_NAME[]   = "NoobShop"
new PLUGIN_VERSION[]    = "1.0"
new PLUGIN_AUTHOR[]     = "TheNoobBox"

public plugin_init() 
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
    if(
get_cvar_num("um_enable"))
    {
        
register_clcmd("um_mapitems""Open_MapItemConfig"ADMIN_IMMUNITY"- Open's Map item configs")
        
register_clcmd("say /shop""open_Shop")
        
register_concmd("shop",     "open_Shop")
        
register_clcmd("say /dropitems","cmd_DropItems")
        
register_concmd("dropitems",    "cmd_DropItems")
        
        
register_touch("UmItem""player""Pickup_Items")
        
        
register_directory()
        
        
register_event("DeathMsg""Event_DeathMsg""a")
        
register_event("ResetHUD""Event_ResetHUD""be")
        
register_event("CurWeapon""Event_CurWeapon""be""1=1")
        
register_event("Damage""Event_Damage""bd""2>0")
        
register_event("StatusValue""Event_StatusValue""bd""1=2")
        
        
register_event("TextMsg""Event_GameRestart""a""2=#Game_will_restart_in""2&#Game_C"
        
register_event("SendAudio""Event_RoundEnd""a""2=%!MRAD_terwin""2=%!MRAD_ctwin""2=%!MRAD_rounddraw")   
        
        
register_logevent("LogEvent_Objectives"3"1=triggered")
        
register_logevent("LogEvent_RoundStart"2"0=World triggered""1=Round_Start")
        
        
register_menucmd(register_menuid("MI Config Menu"), 1023"Action_MapItemConfig")
        
register_menucmd(register_menuid("Noob's Shop"), 1023"Action_Shop")
    }
}

public 
check_cvar()
{
    if(!
get_cvar_num("um_enable"))
    {
        
remove_items()
        
remove_task(12)
        
remove_task(34)
        
        for(new 
1<= get_maxplayers(); ++i) if(is_user_connected(i)) 
        {
            
message_begin(MSG_ONEget_user_msgid("StatusText"), {000}, i
            
write_byte(0
            
write_string("")
            
message_end()
        }
        
        for(new 
0get_pluginsnum(); ++i)
        {
            new 
temp[2], name[64]
            
get_plugin(iname63temp1temp1temp1temp1)
            if(
equali(name"Item_"5)) {
                
server_cmd("amxx pause %s"name)
            }
        }
        
        
server_cmd("amxx pause %s"PLUGIN_NAME)
        
server_print("If enabled again, restart server for upgrades mod to work properly")
    }


register_directory()
{
    
get_configsdir(g_ConfigsDir63)
    
format(g_ItemOriginDir63"%s/itemorigin"g_ConfigsDir)
    
    if(!
dir_exists(g_ItemOriginDir)) 
    {
        
log_amx("itemorigin directory does not exist")
        
g_DirExist false
    

    else 
    {
        
g_DirExist true
        
        
new CurMap[32]
        
get_mapname(CurMap31)
        
Load_Origins(CurMap)
    }
    
}

public 
client_authorized(id)
{
    
g_PlayerNumItems[id] = 0
    
for(new 1<= MAX_ITEMS; ++i) {
        
g_iPlayerItem[id][MAX_ITEMS] = false
    
}
}

public 
LogEvent_RoundStart() 
{
    
ftimeover true
    set_task
(0.6"Spawn_Items")
}

public 
Event_RoundEnd()
{
    
ftimeover false
    
if(get_cvar_num("um_itemsremoved")) {
        
set_task(2.5"remove_items")
    }
}

public 
remove_items()
{
    new 
items find_ent_by_class(-1"UmItem")
    while(
items
        {
        
remove_entity(items)
        
items find_ent_by_class(items"UmItem")
    }
}

public 
Event_GameRestart()
{
    new 
Float:fRestartCvar get_cvar_float("sv_restart")
    
set_task((fRestartCvar 0.2), "Event_RoundEnd")
}

get_connectedplayers()
{
    new 
cpl
    
for(new 1<= get_maxplayers(); ++i) if(is_user_connected(i)) {
        
cpl += 1
    
}
    return 
cpl
}

public 
Event_StatusValue(id)
{
    new 
target read_data(2)
    if(
target != id && target != 0)
    {
        new 
sName[32], szMenuBody[512]
        
get_user_name(targetsName31)
        
        new 
len format(szMenuBody511"Name: %s^"", sName)
        len += format(szMenuBody[len], 511-len, "
Level: %d^""PlayerLevel[target])
        
len += format(szMenuBody[len], 511-len"Items: %d^"", g_PlayerNumItems[target])
        for(new i = 1; i <= g_numberofitems; ++i) if(g_iPlayerItem[target][i]) {
            len += format(szMenuBody[len], 511-len, "
%s^""g_itemname[i])
        }
        
set_hudmessage(2552552550.6, -1.000.06.00.00.01)
        
show_hudmessage(idszMenuBody)
    }
}

public 
Event_DeathMsg() 

    new 
attacker read_data(1)
    new 
victim read_data(2)
    
    if(!
is_user_connected(attacker) || !is_user_connected(victim)) {
        return 
PLUGIN_CONTINUE
    
}
    
    
#if(Item_Death)
        
Drop_Items(victim)
    
#endif
    
if(get_user_team(attacker) == get_user_team(victim)) {
        return 
PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

public 
Event_Damage(id)
{
    if(!
is_user_connected(id)) {
        return 
PLUGIN_CONTINUE
    
}
    
#if(Item_Death)
        
Drop_Items(id)
    
#endif
    
return PLUGIN_CONTINUE
}

public 
display_myitems(id)
{
    new 
szMenuBody[512]
    new 
len format(szMenuBody511"Items: %d^"", g_PlayerNumItems[id])
    for(new i = 1; i <= g_numberofitems; ++i) if(g_iPlayerItem[id][i]) {
        len += format(szMenuBody[len], 511-len, "
%s^""g_itemname[i])
    }
    
set_hudmessage(2552552550.6, -1.000.010.00.00.04)
    
show_hudmessage(idszMenuBody)
    
    return 
PLUGIN_HANDLED
}

public 
open_Shop(id)
{
    
display_Shop(idg_menuPosition[id] = 0)
    return 
PLUGIN_HANDLED
}

public 
cmd_DropItems(id)
{
    if(!
is_user_alive(id)) {
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_PlayerNumItems[id] < 1
    {
        
client_print(idprint_chat"You dont have any items")
        return 
PLUGIN_HANDLED
    
}
    
Drop_Items(id)
    
client_cmd(id"spk %s"DropItemSound)
    return 
PLUGIN_HANDLED
}

public 
Open_MapItemConfig(idlevelcid)
{
    if(!
cmd_access(idlevelcid1)) {
        return 
PLUGIN_HANDLED
    
}
    
    if(!
g_DirExist
    {
        
console_print(id"itemconfig directory does not exist")
        return 
PLUGIN_HANDLED
    
}
    
display_MapItemConfig(id)
    return 
PLUGIN_HANDLED
}

display_MapItemConfig(id)
{
    new 
MenuBody[512]
    new 
len format(MenuBody511"Map Item Menu^"")
    len += format(MenuBody[len], 511-len, "
^"1. Create Spawn Points")
    
len += format(MenuBody[len], 511-len"^"2  Remove All Spawn Points")
    len += format(MenuBody[len], 511-len, "
^"^"0. Cancel")
    
    new keys = (1<<0|1<<1|1<<9)
    show_menu(id, keys, MenuBody, -1, "
MI Config Menu") 
}

public Action_MapItemConfig(id, key)
{
    switch(key) 
    {
        case 0: 
        {
            if(g_MapItemNum >= MAX_MAPITEMS)
            {
                client_print(id, print_chat, "
Max map items reached")
                return PLUGIN_HANDLED
            }
            
            new Origin[3]
            get_user_origin(id, Origin, 0)
            
            new MapName[33]
            get_mapname(MapName, 32)
            Save_Origin(MapName, Origin)
            
            Load_Origins(MapName)
            display_MapItemConfig(id)
            client_print(id, print_chat, "
item spawn point created")
        }           
        case 1: 
        {
            RemoveMapItems()
            client_print(id, print_chat, "
All spawn points removed")
        }
    }
    return PLUGIN_HANDLED
}

display_Shop(id, pos)
{
    if(pos < 0) {
        return
    }
    
    new start = pos * 8
    if(start >= g_numberofitems) {
        start = pos = g_menuPosition[id]
    }
    
    new menuBody[512]
    new len = format(menuBody, 511, "
Item Shop^"^"")
    
    new end = start + 8
    new keys = MENU_KEY_0
    
    if(end > g_numberofitems) {
        end = g_numberofitems
    }
    
    new b = 0
    for(new a = start; a < end; ++a) 
    {
        new i = a + 1
        keys |= (1<<b)
        new money
        #if(Item_Money)     
            money = cs_get_user_money(id)
        #endif
        if(g_iPlayerItem[id][i] ||(money < g_itemcost[i]) || g_PlayerNumItems[id] >= Max_PlayerItems) {
            len += format(menuBody[len], 511-len,"
\r%d. %(%d)\w^"", ++bg_itemname[i], g_itemcost[i])
            } else {
            
len += format(menuBody[len], 511-len,"%d. %s (%d)^"", ++b, g_itemname[i], g_itemcost[i])
        }
    }
    
    if(end != g_numberofitems)
    {
        format(menuBody[len], 511-len, "
^"9. %L...^"0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
        keys |= MENU_KEY_9
    }
    else
    {
        format(menuBody[len], 511-len, "
^"0. %L"idpos "BACK" "EXIT")
    }
    
show_menu(idkeysmenuBody, -1"Item Shop")
}

public 
Action_Shop(idkey)
{
    switch(
key
    {
        case 
8display_Shop(id, ++g_menuPosition[id])
            case 
9display_Shop(id, --g_menuPosition[id])
                default:
            {
            if(!
is_user_alive(id)) {
                return 
PLUGIN_HANDLED
            
}
            
            ++
key
            
new money
            
new plugin_id g_itemindex[g_menuPosition[id] * key]
            new 
item_id g_menuPosition[id] * key
            
new func get_func_id("Enable_Item"plugin_id)
            
#if(Item_Money)
                
money cs_get_user_money(id)
            
#endif
            
new cost g_itemcost[item_id]
            if(
g_PlayerNumItems[id] >= Max_PlayerItems
            {
                
client_print(idprint_chat"Only %d items"Max_PlayerItems)
                
client_cmd(id"spk %s"DeniedSound)
                
display_Shop(idg_menuPosition[id])
                return 
PLUGIN_HANDLED
            
}
            
            if(
g_iPlayerItem[id][item_id])
            {
                
client_print(idprint_chat"You already have %s"g_itemname[item_id])
                
client_cmd(id"spk %s"DeniedSound)
                
display_Shop(idg_menuPosition[id])
                return 
PLUGIN_HANDLED
            
}
            
            if(
money >= cost)
            {
                
callfunc_begin_i(funcplugin_id)
                
callfunc_push_int(id)
                
callfunc_end()
                
                
g_PlayerNumItems[id] += 1
                g_iPlayerItem
[id][item_id] = true
                
#if(Item_Money)
                    
cs_set_user_money(idmoney cost1)
                
#endif
                
client_cmd(id"spk %s"BoughtItemSound)
                
client_print(idprint_chat"Item Bought: %s"g_itemname[item_id])
                
client_print(idprint_chat"Item Description: %s"g_itemdesc[item_id])
                
                if(
g_PlayerNumItems[id] < Max_PlayerItems) {
                    
display_Shop(idg_menuPosition[id])
                }
            }
            else
            {
                
#if(Item_Money)
                    
client_print(idprint_chat"You need $%d to buy %s"g_itemcost[item_id], g_itemname[item_id])
                
#else
                    
client_print(idprint_chat"You need %d xp to buy %s"g_itemcost[item_id], g_itemname[item_id])
                
#endif
                
display_Shop(idg_menuPosition[id])
                
client_cmd(id"spk %s"DeniedSound)
            }
        }
    }
    return 
PLUGIN_HANDLED
}

public 
register_umitem(item_indexitem_name[], item_desc[], item_cost)
{
    if(
g_numberofitems == MAX_ITEMS) {
        return -
2
    
}
    
    
g_numberofitems++
    
g_itemindex[g_numberofitems] = item_index
    format
(g_itemname[g_numberofitems], MAX_ITEM_NAME_SIZEitem_name)
    
format(g_itemdesc[g_numberofitems], MAX_ITEM_DESC_SIZEitem_desc)
    
g_itemcost[g_numberofitems] = item_cost
    
    
return g_numberofitems
}

public 
Pickup_Items(ptrptd)
{
    if(
is_user_alive(ptd) && is_valid_ent(ptr)) 
    { 
        new 
item_id entity_get_int(ptrEV_INT_iuser4)
        new 
plugin_id g_itemindex[item_id]
        new 
func get_func_id("Enable_Item"plugin_id)
        if(!
g_iPlayerItem[ptd][item_id])
        {
            if(
g_PlayerNumItems[ptd] < Max_PlayerItems)
            {
                
callfunc_begin_i(funcplugin_id)
                
callfunc_push_int(ptd)
                
callfunc_end()
                
                
g_PlayerNumItems[ptd] += 1
                g_iPlayerItem
[ptd][item_id] = true
                client_cmd
(ptd"spk %s"PickUpItemSound)
                
client_print(ptdprint_chat"Item Picked: %s"g_itemname[item_id])
                
                
remove_entity(ptr)
            }
        }
    }
}

Drop_Items(id)
{
    for(new 
item_id 1item_id <= MAX_ITEMS item_id++) 
    {
        if(
g_iPlayerItem[id][item_id])
        {
            new 
Float:fVelocity[3], Float:fOrigin[3], Float:fGlowColors[3] = {100.0100.0100.0}
            
entity_get_vector(idEV_VEC_originfOrigin)
            
fOrigin[2] += 75
            
            VelocityByAim
(id130fVelocity)
            
            new 
item_ent create_entity("info_target")
            if(
is_valid_ent(item_ent))
            {
                
entity_set_string(item_entEV_SZ_classname"UmItem")
                
                
entity_set_int(item_entEV_INT_solidSOLID_TRIGGER)
                
entity_set_int(item_entEV_ENT_owner0)
                
entity_set_int(item_entEV_INT_movetype6)
                
entity_set_int(item_entEV_INT_iuser4item_id)
                
entity_set_int(item_entEV_INT_renderfxkRenderFxGlowShell)
                
                
entity_set_vector(item_entEV_VEC_originfOrigin)
                
entity_set_vector(item_entEV_VEC_velocityfVelocity)
                
entity_set_vector(item_entEV_VEC_rendercolorfGlowColors)
                
                
entity_set_model(item_entItemModel)
                
entity_set_size(item_entFloat:{-2.5, -2.5, -1.5}, Float:{2.52.51.5})
                
                new 
plugin_id g_itemindex[item_id]
                new 
func get_func_id("Disable_Item"plugin_id)
                
                
callfunc_begin_i(funcplugin_id)
                
callfunc_push_int(id)
                
callfunc_end()
                
                
g_iPlayerItem[id][item_id] = false
                g_PlayerNumItems
[id] = 0
            
}
        }
    }
    return 
PLUGIN_CONTINUE


Save_Origin(CurMap[], Origin[3])
{
    new 
MapFile[64], Text[64]
    
format(MapFile63"%s/%s.cfg"g_ItemOriginDirCurMap)
    if(!
file_exists(MapFile)) 
    {
        new 
Comments[64]
        
format(Comments63"; Map item origins for %s"CurMap)
        
write_file(MapFileComments, -1)
    }
    
    
format(Text64"%i %i %i"Origin[0], Origin[1], Origin[2])
    
write_file(MapFileText, -1)
}

Load_Origins(CurMap[])
{
    new 
MapFile[64]
    
format(MapFile63"%s/%s.cfg"g_ItemOriginDirCurMap)
    if(!
file_exists(MapFile)) {
        return 
PLUGIN_CONTINUE
    
}
    
    
g_MapItemNum 0
    
for(new 1<= MAX_MAPITEMS; ++i
    {
        
g_MapItemOrgins[i][0] = 0
        g_MapItemOrgins
[i][1] = 0
        g_MapItemOrgins
[i][2] = 0
    
}
    
    new 
Text[64], Line 0Len 0
    
while(read_file(MapFileLine++, Text63Len))
        {
        if((
equal(Text[0],";")) || !Len) {
            continue
        }
        
        if(
g_MapItemNum >= MAX_MAPITEMS
        {
            
log_amx("Max map items reached, please increase MAX_MAPITEMS")
            break
        }
        
        new 
iOrigin[3][16]
        
parse(TextiOrigin[0], 15iOrigin[1], 15iOrigin[2], 15)
        
        
g_MapItemNum++
        
g_MapItemOrgins[g_MapItemNum][0] = str_to_num(iOrigin[0])
        
g_MapItemOrgins[g_MapItemNum][1] = str_to_num(iOrigin[1])
        
g_MapItemOrgins[g_MapItemNum][2] = str_to_num(iOrigin[2])
    }
    return 
PLUGIN_CONTINUE
}

public 
Spawn_Items()
{
    for(new 
1<= MAX_MAPITEMS; ++i)
    {
        if((
g_MapItemOrgins[i][0] == 0
        && (
g_MapItemOrgins[i][1] == 0
        && 
g_MapItemOrgins[i][2] == 0) { 
            continue
        }
        
Create_Items(g_MapItemOrgins[i])
    }
}

RemoveMapItems()
{
    new 
MapFile[64], CurMap[32]
    
get_mapname(CurMap31)
    
format(MapFile63"%s/%s.cfg"g_ItemOriginDirCurMap)
    if(
file_exists(MapFile)) {
        
delete_file(MapFile)
    }
    
    
g_MapItemNum 0
    
for(new 1<= MAX_MAPITEMS; ++i
    {
        
g_MapItemOrgins[i][0] = 0
        g_MapItemOrgins
[i][1] = 0
        g_MapItemOrgins
[i][2] = 0
    
}
}

Create_Items(Origin[3])
{
    new 
Float:flOrigin[3]
    
IVecFVec(OriginflOrigin)
    
    new 
Float:fGlowColors[3] = {0.0100.00.0}
    new 
item_ent create_entity("info_target")
    new 
item_id random_num(1g_numberofitems)
    if(
is_valid_ent(item_ent))
    {
        
entity_set_string(item_entEV_SZ_classname"UmItem")
        
        
entity_set_int(item_entEV_INT_solidSOLID_TRIGGER)
        
entity_set_int(item_entEV_ENT_owner0)
        
entity_set_int(item_entEV_INT_movetype6)
        
entity_set_int(item_entEV_INT_iuser4item_id)
        
entity_set_int(item_entEV_INT_renderfxkRenderFxGlowShell)
        
        
entity_set_vector(item_entEV_VEC_originflOrigin)
        
entity_set_vector(item_entEV_VEC_rendercolorfGlowColors)
        
        
drop_to_floor(item_ent)
        
entity_set_model(item_entItemModel)
        
entity_set_size(item_entFloat:{-2.5, -2.5, -1.5}, Float:{2.52.51.5})
        
    }
    return 
PLUGIN_CONTINUE


public 
plugin_precache() 
{
    
precache_model(ItemModel)
    
precache_sound(PickUpItemSound)
    
precache_sound(BoughtItemSound)



kp_uparrow 12-28-2007 13:55

Re: can anyone help me?
 
tryin to modify upgrades to shop3 again lol

aznbeau1121g 12-28-2007 17:04

Re: can anyone help me?
 
na, i'm learning how script using shopmenu3 as an example... taking out the health things and... seeing whats wrong with script is the basics if learning how to script...

aznbeau1121g 12-28-2007 17:05

Re: can anyone help me?
 
Quote:

Originally Posted by M249-M4A1 (Post 567729)
Compiles but I cannot guarantee it will work because of the errors already in the plugin.

PHP Code:

// Max items players can carry
#define Max_PlayerItems     3

// Death Lose?
#define Item_Death      1 // Player lose item on death

// More defines
#define Item_Money 1
#define DeniedSound 1

// Item plugins configs
#define MAX_ITEMS       100
#define MAX_MAPITEMS        100
#define MAX_ITEM_NAME_SIZE  64
#define MAX_ITEM_DESC_SIZE  128

// ETC
new BoughtItemSound[]   = { "items/ammopickup1.wav" }
new 
PickUpItemSound[]   = { "items/ammopickup2.wav" }
new 
DropItemSound[] = { "events/enemy_died.wav" }
new 
ItemModel[]     = { "models/w_gaussammo.mdl" }

// Includes
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <vault>
#include <fun>

// New
new g_MapItemNum
new bool:ftimeover
new bool:g_DirExist
new g_ConfigsDir[64]
new 
g_ItemOriginDir[64]
new 
g_MapItemOrgins[MAX_MAPITEMS+1][3]

new 
g_numberofitems
new g_menuPosition[33]
new 
g_itemindex[MAX_ITEMS+1]
new 
g_itemcost[MAX_ITEMS+1]
new 
g_itemname[MAX_ITEMS+1][MAX_ITEM_NAME_SIZE+1]
new 
g_itemdesc[MAX_ITEMS+1][MAX_ITEM_DESC_SIZE+1]
new 
bool:g_iPlayerItem[33][MAX_ITEMS+1]
new 
g_PlayerNumItems[33]
new 
PlayerLevel[33]

// Plugin Description
new PLUGIN_NAME[]   = "NoobShop"
new PLUGIN_VERSION[]    = "1.0"
new PLUGIN_AUTHOR[]     = "TheNoobBox"

public plugin_init() 
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
    if(
get_cvar_num("um_enable"))
    {
        
register_clcmd("um_mapitems""Open_MapItemConfig"ADMIN_IMMUNITY"- Open's Map item configs")
        
register_clcmd("say /shop""open_Shop")
        
register_concmd("shop",     "open_Shop")
        
register_clcmd("say /dropitems","cmd_DropItems")
        
register_concmd("dropitems",    "cmd_DropItems")
        
        
register_touch("UmItem""player""Pickup_Items")
        
        
register_directory()
        
        
register_event("DeathMsg""Event_DeathMsg""a")
        
register_event("ResetHUD""Event_ResetHUD""be")
        
register_event("CurWeapon""Event_CurWeapon""be""1=1")
        
register_event("Damage""Event_Damage""bd""2>0")
        
register_event("StatusValue""Event_StatusValue""bd""1=2")
        
        
register_event("TextMsg""Event_GameRestart""a""2=#Game_will_restart_in""2&#Game_C"
        
register_event("SendAudio""Event_RoundEnd""a""2=%!MRAD_terwin""2=%!MRAD_ctwin""2=%!MRAD_rounddraw")   
        
        
register_logevent("LogEvent_Objectives"3"1=triggered")
        
register_logevent("LogEvent_RoundStart"2"0=World triggered""1=Round_Start")
        
        
register_menucmd(register_menuid("MI Config Menu"), 1023"Action_MapItemConfig")
        
register_menucmd(register_menuid("Noob's Shop"), 1023"Action_Shop")
    }
}

public 
check_cvar()
{
    if(!
get_cvar_num("um_enable"))
    {
        
remove_items()
        
remove_task(12)
        
remove_task(34)
        
        for(new 
1<= get_maxplayers(); ++i) if(is_user_connected(i)) 
        {
            
message_begin(MSG_ONEget_user_msgid("StatusText"), {000}, i
            
write_byte(0
            
write_string("")
            
message_end()
        }
        
        for(new 
0get_pluginsnum(); ++i)
        {
            new 
temp[2], name[64]
            
get_plugin(iname63temp1temp1temp1temp1)
            if(
equali(name"Item_"5)) {
                
server_cmd("amxx pause %s"name)
            }
        }
        
        
server_cmd("amxx pause %s"PLUGIN_NAME)
        
server_print("If enabled again, restart server for upgrades mod to work properly")
    }


register_directory()
{
    
get_configsdir(g_ConfigsDir63)
    
format(g_ItemOriginDir63"%s/itemorigin"g_ConfigsDir)
    
    if(!
dir_exists(g_ItemOriginDir)) 
    {
        
log_amx("itemorigin directory does not exist")
        
g_DirExist false
    

    else 
    {
        
g_DirExist true
        
        
new CurMap[32]
        
get_mapname(CurMap31)
        
Load_Origins(CurMap)
    }
    
}

public 
client_authorized(id)
{
    
g_PlayerNumItems[id] = 0
    
for(new 1<= MAX_ITEMS; ++i) {
        
g_iPlayerItem[id][MAX_ITEMS] = false
    
}
}

public 
LogEvent_RoundStart() 
{
    
ftimeover true
    set_task
(0.6"Spawn_Items")
}

public 
Event_RoundEnd()
{
    
ftimeover false
    
if(get_cvar_num("um_itemsremoved")) {
        
set_task(2.5"remove_items")
    }
}

public 
remove_items()
{
    new 
items find_ent_by_class(-1"UmItem")
    while(
items
        {
        
remove_entity(items)
        
items find_ent_by_class(items"UmItem")
    }
}

public 
Event_GameRestart()
{
    new 
Float:fRestartCvar get_cvar_float("sv_restart")
    
set_task((fRestartCvar 0.2), "Event_RoundEnd")
}

get_connectedplayers()
{
    new 
cpl
    
for(new 1<= get_maxplayers(); ++i) if(is_user_connected(i)) {
        
cpl += 1
    
}
    return 
cpl
}

public 
Event_StatusValue(id)
{
    new 
target read_data(2)
    if(
target != id && target != 0)
    {
        new 
sName[32], szMenuBody[512]
        
get_user_name(targetsName31)
        
        new 
len format(szMenuBody511"Name: %s^"", sName)
        len += format(szMenuBody[len], 511-len, "
Level: %d^""PlayerLevel[target])
        
len += format(szMenuBody[len], 511-len"Items: %d^"", g_PlayerNumItems[target])
        for(new i = 1; i <= g_numberofitems; ++i) if(g_iPlayerItem[target][i]) {
            len += format(szMenuBody[len], 511-len, "
%s^""g_itemname[i])
        }
        
set_hudmessage(2552552550.6, -1.000.06.00.00.01)
        
show_hudmessage(idszMenuBody)
    }
}

public 
Event_DeathMsg() 

    new 
attacker read_data(1)
    new 
victim read_data(2)
    
    if(!
is_user_connected(attacker) || !is_user_connected(victim)) {
        return 
PLUGIN_CONTINUE
    
}
    
    
#if(Item_Death)
        
Drop_Items(victim)
    
#endif
    
if(get_user_team(attacker) == get_user_team(victim)) {
        return 
PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

public 
Event_Damage(id)
{
    if(!
is_user_connected(id)) {
        return 
PLUGIN_CONTINUE
    
}
    
#if(Item_Death)
        
Drop_Items(id)
    
#endif
    
return PLUGIN_CONTINUE
}

public 
display_myitems(id)
{
    new 
szMenuBody[512]
    new 
len format(szMenuBody511"Items: %d^"", g_PlayerNumItems[id])
    for(new i = 1; i <= g_numberofitems; ++i) if(g_iPlayerItem[id][i]) {
        len += format(szMenuBody[len], 511-len, "
%s^""g_itemname[i])
    }
    
set_hudmessage(2552552550.6, -1.000.010.00.00.04)
    
show_hudmessage(idszMenuBody)
    
    return 
PLUGIN_HANDLED
}

public 
open_Shop(id)
{
    
display_Shop(idg_menuPosition[id] = 0)
    return 
PLUGIN_HANDLED
}

public 
cmd_DropItems(id)
{
    if(!
is_user_alive(id)) {
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_PlayerNumItems[id] < 1
    {
        
client_print(idprint_chat"You dont have any items")
        return 
PLUGIN_HANDLED
    
}
    
Drop_Items(id)
    
client_cmd(id"spk %s"DropItemSound)
    return 
PLUGIN_HANDLED
}

public 
Open_MapItemConfig(idlevelcid)
{
    if(!
cmd_access(idlevelcid1)) {
        return 
PLUGIN_HANDLED
    
}
    
    if(!
g_DirExist
    {
        
console_print(id"itemconfig directory does not exist")
        return 
PLUGIN_HANDLED
    
}
    
display_MapItemConfig(id)
    return 
PLUGIN_HANDLED
}

display_MapItemConfig(id)
{
    new 
MenuBody[512]
    new 
len format(MenuBody511"Map Item Menu^"")
    len += format(MenuBody[len], 511-len, "
^"1. Create Spawn Points")
    
len += format(MenuBody[len], 511-len"^"2  Remove All Spawn Points")
    len += format(MenuBody[len], 511-len, "
^"^"0. Cancel")
    
    new keys = (1<<0|1<<1|1<<9)
    show_menu(id, keys, MenuBody, -1, "
MI Config Menu") 
}

public Action_MapItemConfig(id, key)
{
    switch(key) 
    {
        case 0: 
        {
            if(g_MapItemNum >= MAX_MAPITEMS)
            {
                client_print(id, print_chat, "
Max map items reached")
                return PLUGIN_HANDLED
            }
            
            new Origin[3]
            get_user_origin(id, Origin, 0)
            
            new MapName[33]
            get_mapname(MapName, 32)
            Save_Origin(MapName, Origin)
            
            Load_Origins(MapName)
            display_MapItemConfig(id)
            client_print(id, print_chat, "
item spawn point created")
        }           
        case 1: 
        {
            RemoveMapItems()
            client_print(id, print_chat, "
All spawn points removed")
        }
    }
    return PLUGIN_HANDLED
}

display_Shop(id, pos)
{
    if(pos < 0) {
        return
    }
    
    new start = pos * 8
    if(start >= g_numberofitems) {
        start = pos = g_menuPosition[id]
    }
    
    new menuBody[512]
    new len = format(menuBody, 511, "
Item Shop^"^"")
    
    new end = start + 8
    new keys = MENU_KEY_0
    
    if(end > g_numberofitems) {
        end = g_numberofitems
    }
    
    new b = 0
    for(new a = start; a < end; ++a) 
    {
        new i = a + 1
        keys |= (1<<b)
        new money
        #if(Item_Money)     
            money = cs_get_user_money(id)
        #endif
        if(g_iPlayerItem[id][i] ||(money < g_itemcost[i]) || g_PlayerNumItems[id] >= Max_PlayerItems) {
            len += format(menuBody[len], 511-len,"
\r%d. %(%d)\w^"", ++bg_itemname[i], g_itemcost[i])
            } else {
            
len += format(menuBody[len], 511-len,"%d. %s (%d)^"", ++b, g_itemname[i], g_itemcost[i])
        }
    }
    
    if(end != g_numberofitems)
    {
        format(menuBody[len], 511-len, "
^"9. %L...^"0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
        keys |= MENU_KEY_9
    }
    else
    {
        format(menuBody[len], 511-len, "
^"0. %L"idpos "BACK" "EXIT")
    }
    
show_menu(idkeysmenuBody, -1"Item Shop")
}

public 
Action_Shop(idkey)
{
    switch(
key
    {
        case 
8display_Shop(id, ++g_menuPosition[id])
            case 
9display_Shop(id, --g_menuPosition[id])
                default:
            {
            if(!
is_user_alive(id)) {
                return 
PLUGIN_HANDLED
            
}
            
            ++
key
            
new money
            
new plugin_id g_itemindex[g_menuPosition[id] * key]
            new 
item_id g_menuPosition[id] * key
            
new func get_func_id("Enable_Item"plugin_id)
            
#if(Item_Money)
                
money cs_get_user_money(id)
            
#endif
            
new cost g_itemcost[item_id]
            if(
g_PlayerNumItems[id] >= Max_PlayerItems
            {
                
client_print(idprint_chat"Only %d items"Max_PlayerItems)
                
client_cmd(id"spk %s"DeniedSound)
                
display_Shop(idg_menuPosition[id])
                return 
PLUGIN_HANDLED
            
}
            
            if(
g_iPlayerItem[id][item_id])
            {
                
client_print(idprint_chat"You already have %s"g_itemname[item_id])
                
client_cmd(id"spk %s"DeniedSound)
                
display_Shop(idg_menuPosition[id])
                return 
PLUGIN_HANDLED
            
}
            
            if(
money >= cost)
            {
                
callfunc_begin_i(funcplugin_id)
                
callfunc_push_int(id)
                
callfunc_end()
                
                
g_PlayerNumItems[id] += 1
                g_iPlayerItem
[id][item_id] = true
                
#if(Item_Money)
                    
cs_set_user_money(idmoney cost1)
                
#endif
                
client_cmd(id"spk %s"BoughtItemSound)
                
client_print(idprint_chat"Item Bought: %s"g_itemname[item_id])
                
client_print(idprint_chat"Item Description: %s"g_itemdesc[item_id])
                
                if(
g_PlayerNumItems[id] < Max_PlayerItems) {
                    
display_Shop(idg_menuPosition[id])
                }
            }
            else
            {
                
#if(Item_Money)
                    
client_print(idprint_chat"You need $%d to buy %s"g_itemcost[item_id], g_itemname[item_id])
                
#else
                    
client_print(idprint_chat"You need %d xp to buy %s"g_itemcost[item_id], g_itemname[item_id])
                
#endif
                
display_Shop(idg_menuPosition[id])
                
client_cmd(id"spk %s"DeniedSound)
            }
        }
    }
    return 
PLUGIN_HANDLED
}

public 
register_umitem(item_indexitem_name[], item_desc[], item_cost)
{
    if(
g_numberofitems == MAX_ITEMS) {
        return -
2
    
}
    
    
g_numberofitems++
    
g_itemindex[g_numberofitems] = item_index
    format
(g_itemname[g_numberofitems], MAX_ITEM_NAME_SIZEitem_name)
    
format(g_itemdesc[g_numberofitems], MAX_ITEM_DESC_SIZEitem_desc)
    
g_itemcost[g_numberofitems] = item_cost
    
    
return g_numberofitems
}

public 
Pickup_Items(ptrptd)
{
    if(
is_user_alive(ptd) && is_valid_ent(ptr)) 
    { 
        new 
item_id entity_get_int(ptrEV_INT_iuser4)
        new 
plugin_id g_itemindex[item_id]
        new 
func get_func_id("Enable_Item"plugin_id)
        if(!
g_iPlayerItem[ptd][item_id])
        {
            if(
g_PlayerNumItems[ptd] < Max_PlayerItems)
            {
                
callfunc_begin_i(funcplugin_id)
                
callfunc_push_int(ptd)
                
callfunc_end()
                
                
g_PlayerNumItems[ptd] += 1
                g_iPlayerItem
[ptd][item_id] = true
                client_cmd
(ptd"spk %s"PickUpItemSound)
                
client_print(ptdprint_chat"Item Picked: %s"g_itemname[item_id])
                
                
remove_entity(ptr)
            }
        }
    }
}

Drop_Items(id)
{
    for(new 
item_id 1item_id <= MAX_ITEMS item_id++) 
    {
        if(
g_iPlayerItem[id][item_id])
        {
            new 
Float:fVelocity[3], Float:fOrigin[3], Float:fGlowColors[3] = {100.0100.0100.0}
            
entity_get_vector(idEV_VEC_originfOrigin)
            
fOrigin[2] += 75
            
            VelocityByAim
(id130fVelocity)
            
            new 
item_ent create_entity("info_target")
            if(
is_valid_ent(item_ent))
            {
                
entity_set_string(item_entEV_SZ_classname"UmItem")
                
                
entity_set_int(item_entEV_INT_solidSOLID_TRIGGER)
                
entity_set_int(item_entEV_ENT_owner0)
                
entity_set_int(item_entEV_INT_movetype6)
                
entity_set_int(item_entEV_INT_iuser4item_id)
                
entity_set_int(item_entEV_INT_renderfxkRenderFxGlowShell)
                
                
entity_set_vector(item_entEV_VEC_originfOrigin)
                
entity_set_vector(item_entEV_VEC_velocityfVelocity)
                
entity_set_vector(item_entEV_VEC_rendercolorfGlowColors)
                
                
entity_set_model(item_entItemModel)
                
entity_set_size(item_entFloat:{-2.5, -2.5, -1.5}, Float:{2.52.51.5})
                
                new 
plugin_id g_itemindex[item_id]
                new 
func get_func_id("Disable_Item"plugin_id)
                
                
callfunc_begin_i(funcplugin_id)
                
callfunc_push_int(id)
                
callfunc_end()
                
                
g_iPlayerItem[id][item_id] = false
                g_PlayerNumItems
[id] = 0
            
}
        }
    }
    return 
PLUGIN_CONTINUE


Save_Origin(CurMap[], Origin[3])
{
    new 
MapFile[64], Text[64]
    
format(MapFile63"%s/%s.cfg"g_ItemOriginDirCurMap)
    if(!
file_exists(MapFile)) 
    {
        new 
Comments[64]
        
format(Comments63"; Map item origins for %s"CurMap)
        
write_file(MapFileComments, -1)
    }
    
    
format(Text64"%i %i %i"Origin[0], Origin[1], Origin[2])
    
write_file(MapFileText, -1)
}

Load_Origins(CurMap[])
{
    new 
MapFile[64]
    
format(MapFile63"%s/%s.cfg"g_ItemOriginDirCurMap)
    if(!
file_exists(MapFile)) {
        return 
PLUGIN_CONTINUE
    
}
    
    
g_MapItemNum 0
    
for(new 1<= MAX_MAPITEMS; ++i
    {
        
g_MapItemOrgins[i][0] = 0
        g_MapItemOrgins
[i][1] = 0
        g_MapItemOrgins
[i][2] = 0
    
}
    
    new 
Text[64], Line 0Len 0
    
while(read_file(MapFileLine++, Text63Len))
        {
        if((
equal(Text[0],";")) || !Len) {
            continue
        }
        
        if(
g_MapItemNum >= MAX_MAPITEMS
        {
            
log_amx("Max map items reached, please increase MAX_MAPITEMS")
            break
        }
        
        new 
iOrigin[3][16]
        
parse(TextiOrigin[0], 15iOrigin[1], 15iOrigin[2], 15)
        
        
g_MapItemNum++
        
g_MapItemOrgins[g_MapItemNum][0] = str_to_num(iOrigin[0])
        
g_MapItemOrgins[g_MapItemNum][1] = str_to_num(iOrigin[1])
        
g_MapItemOrgins[g_MapItemNum][2] = str_to_num(iOrigin[2])
    }
    return 
PLUGIN_CONTINUE
}

public 
Spawn_Items()
{
    for(new 
1<= MAX_MAPITEMS; ++i)
    {
        if((
g_MapItemOrgins[i][0] == 0
        && (
g_MapItemOrgins[i][1] == 0
        && 
g_MapItemOrgins[i][2] == 0) { 
            continue
        }
        
Create_Items(g_MapItemOrgins[i])
    }
}

RemoveMapItems()
{
    new 
MapFile[64], CurMap[32]
    
get_mapname(CurMap31)
    
format(MapFile63"%s/%s.cfg"g_ItemOriginDirCurMap)
    if(
file_exists(MapFile)) {
        
delete_file(MapFile)
    }
    
    
g_MapItemNum 0
    
for(new 1<= MAX_MAPITEMS; ++i
    {
        
g_MapItemOrgins[i][0] = 0
        g_MapItemOrgins
[i][1] = 0
        g_MapItemOrgins
[i][2] = 0
    
}
}

Create_Items(Origin[3])
{
    new 
Float:flOrigin[3]
    
IVecFVec(OriginflOrigin)
    
    new 
Float:fGlowColors[3] = {0.0100.00.0}
    new 
item_ent create_entity("info_target")
    new 
item_id random_num(1g_numberofitems)
    if(
is_valid_ent(item_ent))
    {
        
entity_set_string(item_entEV_SZ_classname"UmItem")
        
        
entity_set_int(item_entEV_INT_solidSOLID_TRIGGER)
        
entity_set_int(item_entEV_ENT_owner0)
        
entity_set_int(item_entEV_INT_movetype6)
        
entity_set_int(item_entEV_INT_iuser4item_id)
        
entity_set_int(item_entEV_INT_renderfxkRenderFxGlowShell)
        
        
entity_set_vector(item_entEV_VEC_originflOrigin)
        
entity_set_vector(item_entEV_VEC_rendercolorfGlowColors)
        
        
drop_to_floor(item_ent)
        
entity_set_model(item_entItemModel)
        
entity_set_size(item_entFloat:{-2.5, -2.5, -1.5}, Float:{2.52.51.5})
        
    }
    return 
PLUGIN_CONTINUE


public 
plugin_precache() 
{
    
precache_model(ItemModel)
    
precache_sound(PickUpItemSound)
    
precache_sound(BoughtItemSound)



can u tell me what errors?

aznbeau1121g 12-28-2007 19:56

Re: can anyone help me?
 
ow i tried the one that u edited m249 it doesn't work don't know y?

Drak 12-28-2007 23:24

Re: can anyone help me?
 
Well for one, the CVar "um_enable" is in the shop plugin.
That means you have to register the CVars in the other plugin, unless you running both plugins at the same time. (Even then, the original shop plugin needs to be listed first in "plugins.ini" for the cvar to work)

M249-M4A1 12-28-2007 23:55

Re: can anyone help me?
 
There were a lot of missing things because the plugin depended on other things (and while you were in the process of removing things, you removed important variables like PlayerLevel[33] and some defines)


All times are GMT -4. The time now is 11:09.

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