-PTM-Andrey

[Plugin] Meniu

7 postări în acest topic

Am acest code:
 

 

/* Plugin generated by AMXX-Studio */
    
#include <amxmodx>
#include <cstrike>
#include <fun>


#define PLUGIN "Menu"
#define VERSION "1.0"
#define AUTHOR "Andrei"


new boss = "models/player/SJB-GRT.mdl";

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("say /special", "menu")
    register_clcmd("say_team /special", "menu")
}

public info (id)
{
    new menu = menu_create("Items available" , "menu_handler")
    menu_additem(menu, "M4A1 --> [ 4500 $ ]", "1")
    menu_additem(menu, "Model SJB(X) --> [ 16000 $ ]", "2")
    menu_additem(menu, "+50 HP --> [ 2000 $ ]", "3")
    menu_additem(menu, "+100 Armor --> [ 1500 $ ]", "4")
    
    menu_setprop(menu, MPROP_EXITNAME, "BEST SERVER")
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    
    menu_display(id, menu, 0)
    
}

public plugin_precache()
{
    precache_model(boss)
    
}

public meniu_handler(id,menu,item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new access, callback
    new money = cs_get_user_money(id)
    menu_item_getinfo(menu, item, access, data,5,iName,63,callback)
    
    new key=str_to_num(data)
    switch(key)
    {
        case 1:
        {
            if(cs_get_user_money(id) >=4500)
            {
                cs_set_user_money(id, money - 4500)
                give_item(id, "weapon_m4a1")
                cs_set_user_bpammo(id, CSW_M4A1, 90)
                client_print(id, print_chat, "You buy M4A1. Good luck, have fun !")
            }

        }
        case 2:
        {
            if(cs_get_user_money(id) ==16000)
            {
                cs_set_user_money(id, money - 16000 )
                cs_set_user_model(id, "boss")
                client_print(id, print_chat, "Your have model SJB(X)")
            }
        }
        case 3:
        {
            if(cs_get_user_money(id) >=2000)
            {
                cs_set_user_money(id, money - 2000)
                set_user_health(id, get_user_health(id) + 50 )
                client_print(id, print_chat, "You take +50 HP")
            }
        }
        case 4:
        {
            if(cs_get_user_money(id)>=1500)
            {
                cs_set_user_money(id, money-1500)
                set_user_armor(id, get_user_armor(id)+100)
                client_print(id, print_chat, "You take +100 Armor")
            }
        }
    }
    return PLUGIN_HANDLED
}

 

 

Dar cand vreau sa-l compilez imi apar erorile acestea:

menu_simple.sma(40) : error 035: argument type mismatch (argument 1)
menu_simple.sma(99) : warning 203: symbol is never used: "boss"

1 Error.

 

Ma puteti ajuta sa rezolv problema?

Editat de -PTM-Andrey

Partajează acest post


Link spre post
Distribuie pe alte site-uri

Incearca asta:

Spoiler

/* Plugin generated by AMXX-Studio */
    
#include <amxmodx>
#include <cstrike>
#include <fun>


#define PLUGIN "Menu"
#define VERSION "1.0"
#define AUTHOR "Andrei"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("say /special", "menu")
    register_clcmd("say_team /special", "menu")
}

public info (id)
{
    new menu = menu_create("Items available" , "menu_handler")
    menu_additem(menu, "M4A1 --> [ 4500 $ ]", "1")
    menu_additem(menu, "Model SJB(X) --> [ 16000 $ ]", "2")
    menu_additem(menu, "+50 HP --> [ 2000 $ ]", "3")
    menu_additem(menu, "+100 Armor --> [ 1500 $ ]", "4")
    
    menu_setprop(menu, MPROP_EXITNAME, "BEST SERVER")
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    
    menu_display(id, menu, 0)
    
}

public plugin_precache()
{
    precache_model("models/player/SJB-GRT/SJB-GRT.mdl")
    
}

public meniu_handler(id,menu,item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new access, callback
    new money = cs_get_user_money(id)
    menu_item_getinfo(menu, item, access, data,5,iName,63,callback)
    
    new key=str_to_num(data)
    switch(key)
    {
        case 1:
        {
            if(cs_get_user_money(id) >=4500)
            {
                cs_set_user_money(id, money - 4500)
                give_item(id, "weapon_m4a1")
                cs_set_user_bpammo(id, CSW_M4A1, 90)
                client_print(id, print_chat, "You buy M4A1. Good luck, have fun !")
            }

        }
        case 2:
        {
            if(cs_get_user_money(id) ==16000)
            {
                cs_set_user_money(id, money - 16000 )
                cs_set_user_model(id, "SJB-GRT")
                client_print(id, print_chat, "Your have model SJB(X)")
            }
        }
        case 3:
        {
            if(cs_get_user_money(id) >=2000)
            {
                cs_set_user_money(id, money - 2000)
                set_user_health(id, get_user_health(id) + 50 )
                client_print(id, print_chat, "You take +50 HP")
            }
        }
        case 4:
        {
            if(cs_get_user_money(id)>=1500)
            {
                cs_set_user_money(id, money-1500)
                set_user_armor(id, get_user_armor(id)+100)
                client_print(id, print_chat, "You take +100 Armor")
            }
        }
    }
    return PLUGIN_HANDLED
}

 

Directorul in care se afla modelul .mdl : models/player/SJB-GRT/SJB-GRT.mdl

Partajează acest post


Link spre post
Distribuie pe alte site-uri

Am o problema.. cand scriu in chat /special nu mi se deschide meniul

Partajează acest post


Link spre post
Distribuie pe alte site-uri

Aveai mai multe greseli de scriere, poftim:

Spoiler

/* Plugin generated by AMXX-Studio */
    
#include <amxmodx>
#include <cstrike>
#include <fun>

#define PLUGIN "Menu"
#define VERSION "1.0"
#define AUTHOR "Andrei"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("say /special", "info")
    register_clcmd("say_team /special", "info")
}

public info (id)
{
    new menu = menu_create("Items available" , "menu_handler")
    menu_additem(menu, "M4A1 --> [ 4500 $ ]", "1")
    menu_additem(menu, "Model SJB(X) --> [ 16000 $ ]", "2")
    menu_additem(menu, "+50 HP --> [ 2000 $ ]", "3")
    menu_additem(menu, "+100 Armor --> [ 1500 $ ]", "4")
    
    menu_setprop(menu, MPROP_EXITNAME, "BEST SERVER")
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    
    menu_display(id, menu, 0)    
}

public plugin_precache()
{
    precache_model("models/player/SJB-GRT/SJB-GRT.mdl")   
}

public menu_handler(id,menu,item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new access, callback
    new money = cs_get_user_money(id)
    menu_item_getinfo(menu, item, access, data,5,iName,63,callback)
    
    new key=str_to_num(data)
    switch(key)
    {
        case 1:
        {
            if(cs_get_user_money(id) >=4500)
            {
                cs_set_user_money(id, money - 4500)
                give_item(id, "weapon_m4a1")
                cs_set_user_bpammo(id, CSW_M4A1, 90)
                client_print(id, print_chat, "You buy M4A1. Good luck, have fun !")
            }

        }
        case 2:
        {
            if(cs_get_user_money(id) ==16000)
            {
                cs_set_user_money(id, money - 16000 )
                cs_set_user_model(id, "SJB-GRT")
                client_print(id, print_chat, "Your have model SJB(X)")
            }
        }
        case 3:
        {
            if(cs_get_user_money(id) >=2000)
            {
                cs_set_user_money(id, money - 2000)
                set_user_health(id, get_user_health(id) + 50 )
                client_print(id, print_chat, "You take +50 HP")
            }
        }
        case 4:
        {
            if(cs_get_user_money(id)>=1500)
            {
                cs_set_user_money(id, money-1500)
                set_user_armor(id, get_user_armor(id)+100)
                client_print(id, print_chat, "You take +100 Armor")
            }
        }
    }
    return PLUGIN_HANDLED
}

 

 

Partajează acest post


Link spre post
Distribuie pe alte site-uri

Postat (editat)

Ai putea sa rezolvi si asta?

Sa faci cumva ca daca ai cumparat odata arma sa nu poti cumpara o alta arma... adica sa nu ai 2, 3 arme in dotare ci doar una

Daca as avea set grenade la fel sa fie si acolo(  sa primesti doar un set de grenade.. nu sa cumperi pana nu mai sunt bani )

La hp sa fie restrictie de maxim 150 hp.

Pretul itemelor sa apara in dreapta ca in imaginea asta:

nN1AZXw.png.003bd616b3c2254649d9b00c3f084e97.png

Editat de -PTM-Andrey

Partajează acest post


Link spre post
Distribuie pe alte site-uri
Spoiler

/* Plugin generated by AMXX-Studio */
    
#include <amxmodx>
#include <cstrike>
#include <fun>

#define PLUGIN "Menu"
#define VERSION "1.0"
#define AUTHOR "Andrei"

new bool:use[33];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("say /special", "info")
    register_clcmd("say_team /special", "info")
    register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
}

public Event_NewRound()
{
	arrayset(use, false, 33);
}

public info (id)
{
    new menu = menu_create("Items available" , "menu_handler")
    menu_additem(menu, "M4A1                \y4500 $", "1")
    menu_additem(menu, "Model SJB(X)       \y16000 $", "2")
    menu_additem(menu, "+50 HP              \y2000 $", "3")
    menu_additem(menu, "+100 Armor          \y1500 $", "4")
    
    menu_setprop(menu, MPROP_EXITNAME, "BEST SERVER")
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    
    menu_display(id, menu, 0)    
}

public plugin_precache()
{
    precache_model("models/player/SJB-GRT/SJB-GRT.mdl")   
}

public menu_handler(id,menu,item)
{
    if(use[id])
    {
        client_print(id, print_chat, "Meniul poate fi folosit doar o data pe runda !");
        return PLUGIN_HANDLED;
    }
	
    if(item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new access, callback
    new money = cs_get_user_money(id)
    menu_item_getinfo(menu, item, access, data,5,iName,63,callback)
    
    new key=str_to_num(data)
    switch(key)
    {
        case 1:
        {
            if(cs_get_user_money(id) >=4500)
            {
                cs_set_user_money(id, money - 4500)
                give_item(id, "weapon_m4a1")
                cs_set_user_bpammo(id, CSW_M4A1, 90)
                client_print(id, print_chat, "You buy M4A1. Good luck, have fun !")
            }
            use[id] = true

        }
        case 2:
        {
            if(cs_get_user_money(id) ==16000)
            {
                cs_set_user_money(id, money - 16000 )
                cs_set_user_model(id, "SJB-GRT")
                client_print(id, print_chat, "Your have model SJB(X)")
            }
        }
        case 3:
        {
            if(cs_get_user_money(id) >=2000)
            {
                cs_set_user_money(id, money - 2000)
                set_user_health(id, get_user_health(id) + 50 )
                client_print(id, print_chat, "You take +50 HP")
				
                if(get_user_health(id) >= 150)
                {
                    set_user_health(id, 150);
                    return PLUGIN_HANDLED;
                }
            }
        }
        case 4:
        {
            if(cs_get_user_money(id)>=1500)
            {
                cs_set_user_money(id, money-1500)
                set_user_armor(id, get_user_armor(id)+100)
                client_print(id, print_chat, "You take +100 Armor")
            }
        }
    }
    return PLUGIN_HANDLED
}

 

 

Tutorial restrictie folosire item:

Spoiler

#include <amxmodx>
// and more..

new bool:use[33]

public plugin_init(){
    register_plugin(PLUGIN, AUTHOR, VERSION);
    
    register_clcmd("say /command", "menu")
    register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0");
}

public Event_NewRound()
{
    arrayset(use, false, 33);
}

public menu(id){
    // write your items for menu
}


public menu_handler(id){
    if(use[id])
    {
        client_print(id, print_chat,"Meniul poate fi folosit doar o data pe runda !");
        return PLUGIN_HANDLED;
    }

    
    // type your code here...
    // something just like this...

    switch(key)
    {
        case 1:
        {
            if(cs_get_user_money(id) >=4500)
            {
                cs_set_user_money(id, money - 4500)
                give_item(id, "weapon_m4a1")
                cs_set_user_bpammo(id, CSW_M4A1, 90)
                client_print(id, print_chat, "You buy M4A1. Good luck, have fun !")
            }
            use[id] = true;
        }
        
        case 2:
        {
            // anything .. 
        }
    }
}    

Folosesti use[id] = true; in orice item pe care doresti sa-l folosesti doar o singura data. Il poti folosi dupa toate case-urile deci niciunul nu va putea fi folosit decat o data.

Daca punem spre ex ++use[id] = true; putem foli itemul de 3 ori, cu fiecare + adaugat, de atatea ori poate fi folosit itemul.

 

Sper ca ai inteles si te-am ajutat. :-)

Partajează acest post


Link spre post
Distribuie pe alte site-uri

Multumesc mult!

Partajează acest post


Link spre post
Distribuie pe alte site-uri

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!


Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.


Autentifică-te acum