Raised This Month: $ Target: $400
 0% 

if item is in vault --> item in menu = \d


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 01-05-2019 , 11:01   if item is in vault --> item in menu = \d
Reply With Quote #1

Hello guys, I am using this plugin https://amxx.pl/index.php?app=core&m...ttach_id=30680
which is called missions https://amxx.pl/topic/72044-misje-qu...rsja-4-update/

And I would like to make this:
Once you are done with one quest, that quest in menu would be other color (for example \d)

Menu function is Menu_Questow(id) but I can not figure out the way how to do it. I tried if(LoadQuest(id, item)) but there must be some kind of for cycle and I have no idea which. Could you help me a little bit? Thank you.
TheBladerX is offline
thEsp
BANNED
Join Date: Aug 2017
Old 01-05-2019 , 12:56   Re: if item is in vault --> item in menu = \d
Reply With Quote #2

Can you please be more clear in posts you make?
You should include your code, we can't help you with a single line of code.
OR AT LEAST describe what's your point of plugin you want to make...
thEsp is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 01-05-2019 , 13:11   Re: if item is in vault --> item in menu = \d
Reply With Quote #3

Yeah, this is the code I would like to edit.

Code:
public Menu_Questow(id)
{
	if( ! ePlayerQuestType[id] )
	{
		new menu = menu_create("\yWybierz Rozdzial:", "menu_first_handle")
		new formats[128]
		
		
		for(new i; i < sizeof(QuestyPrzedzial); i++)
		{
			if( cod_get_user_level(id) >= QuestyPrzedzial[i][0]){
				
				formatex(formats,127,"Rozdzial \r%s \y(od %i do %i Lv.)",QuestRozdzial[i], QuestyPrzedzial[i][0], QuestyPrzedzial[i][1]);
				menu_additem(menu,formats)
				
			}else{
				formatex(formats,127,"\dRozdzial %s (od %i do %i Lv.)",QuestRozdzial[i], QuestyPrzedzial[i][0], QuestyPrzedzial[i][1]);
				menu_additem(menu,formats, _, _, MenuCallback)
			}
		}
		
		menu_display(id,menu,0)
	}else{
		QuestMessage(id, "Wykonaj najpierw poprzedni quest");
	}
}

public menu_first_handle(id, menu, item)
{

	client_cmd(id, "spk QTM_CodMod/select");
	
	if(item == MENU_EXIT){
		menu_destroy(menu);
		return PLUGIN_CONTINUE;
	}

	
	new menu2 = menu_create("Wybierz Quest:","menu_handle")
	new formats[128]
	for(new i = 0;i<MaxQuest;i++)
	{	
		if(ArrayGetCell(gPrzedzial, i) == item)
		{
						
			switch(ArrayGetCell(gTyp, i))
			{
				case KILL: formatex(formats, 127, "Zabij %i osob Nagroda: %i expa", ArrayGetCell(gIleRazy, i), ArrayGetCell(gNagroda, i))
				case HEADSHOT: formatex(formats, 127, "Jebnij %i HeadShotow Nagroda: %i expa",  ArrayGetCell(gIleRazy, i), ArrayGetCell(gNagroda, i))
				case SUBSTRATES: formatex(formats, 127, "Podloz %i bomb Nagroda: %i expa",  ArrayGetCell(gIleRazy, i), ArrayGetCell(gNagroda, i))
				case RESUCE_HOSTAGES: formatex(formats, 127, "Uratuj %i razy hosty Nagroda: %i expa",  ArrayGetCell(gIleRazy, i), ArrayGetCell(gNagroda, i))
				case DISARM: formatex(formats, 127, "Rozbroj %i bomb Nagroda: %i expa",  ArrayGetCell(gIleRazy, i),  ArrayGetCell(gNagroda, i))
				case DMG: formatex(formats, 127, "Zadaj %i obrazen Nagroda: %i expa",  ArrayGetCell(gIleRazy, i),  ArrayGetCell(gNagroda, i))
			}
			menu_additem(menu2, formats);
		}
	}
	iPlayerPrzedzial[id] = item;
	menu_setprop(menu2, MPROP_PERPAGE, 6);
	menu_display(id,menu2,0)
	menu_destroy(menu);
	
	return PLUGIN_HANDLED
}
public menu_handle(id, menu, item)
{
	if(item == MENU_EXIT){
		menu_destroy(menu);
		return PLUGIN_CONTINUE;
	}
		
	new ile = 0;
	for(new i = 0;i<MaxQuest;i++){
		if(ArrayGetCell(gPrzedzial, i) != iPlayerPrzedzial[id])
		continue;
		
		if(ile == item)
		{
			item = i;
			break;
		}
		
		ile++;
	}

	if(LoadQuest(id, item)){
		QuestMessage(id, "Juz wykonywales tego Questa!. Wybierz Innego.");
		Menu_Questow(id);
		return PLUGIN_HANDLED;
	}
	
	ResetQuest(id)
	
	iPlayerQuestID[id] = item;
	ePlayerQuestType[id] = ArrayGetCell(gTyp, item)
	
	QuestMessage(id, "Rozpoczales Quest. Powodzenia!");
	
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
And what do I need?

There is function
Code:
menu_first_handle(id, menu, item)
Under it there are these cases
Code:
case KILL: formatex(formats, 127, "Zabij %i osob Nagroda: %i expa", ArrayGetCell(gIleRazy, i), ArrayGetCell(gNagroda, i))
				case HEADSHOT: formatex(formats, 127, "Jebnij %i HeadShotow Nagroda: %i expa",  ArrayGetCell(gIleRazy, i), ArrayGetCell(gNagroda, i))
				case SUBSTRATES: formatex(formats, 127, "Podloz %i bomb Nagroda: %i expa",  ArrayGetCell(gIleRazy, i), ArrayGetCell(gNagroda, i))
				case RESUCE_HOSTAGES: formatex(formats, 127, "Uratuj %i razy hosty Nagroda: %i expa",  ArrayGetCell(gIleRazy, i), ArrayGetCell(gNagroda, i))
				case DISARM: formatex(formats, 127, "Rozbroj %i bomb Nagroda: %i expa",  ArrayGetCell(gIleRazy, i),  ArrayGetCell(gNagroda, i))
				case DMG: formatex(formats, 127, "Zadaj %i obrazen Nagroda: %i expa",  ArrayGetCell(gIleRazy, i),  ArrayGetCell(gNagroda, i))
Right now I have this situation. Once you completed one "case", it is still shown in menu, but when you click it, it calls this

Code:
if(LoadQuest(id, item)){
		QuestMessage(id, "Juz wykonywales tego Questa!. Wybierz Innego.");
		Menu_Questow(id);
		return PLUGIN_HANDLED;
	}
which is under
Code:
public menu_handle(id, menu, item)
My question is, how can I make a case in menu look like \d color, once you completed it? I believe it has something to do with

Code:
public menu_handle(id, menu, item)
{
	if(item == MENU_EXIT){
		menu_destroy(menu);
		return PLUGIN_CONTINUE;
	}
		
	new ile = 0;
	for(new i = 0;i<MaxQuest;i++){
		if(ArrayGetCell(gPrzedzial, i) != iPlayerPrzedzial[id])
		continue;
		
		if(ile == item)
		{
			item = i;
			break;
		}
		
		ile++;
	}

	if(LoadQuest(id, item)){
		QuestMessage(id, "Juz wykonywales tego Questa!. Wybierz Innego.");
		Menu_Questow(id);
		return PLUGIN_HANDLED;
	}
	
	ResetQuest(id)
	
	iPlayerQuestID[id] = item;
	ePlayerQuestType[id] = ArrayGetCell(gTyp, item)
	
	QuestMessage(id, "Rozpoczales Quest. Powodzenia!");
	
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
but i could not figure out what is it. I tried to put
Code:
if(LoadQuest(id, item)){
before each case, but it did not work that way.

Last edited by TheBladerX; 01-05-2019 at 13:12.
TheBladerX is offline
thEsp
BANNED
Join Date: Aug 2017
Old 01-05-2019 , 14:39   Re: if item is in vault --> item in menu = \d
Reply With Quote #4

I think the problem is in the first menu, you have to set menu properties (Exit, next & back - Optional). And in the second (I believe) menu you show menu and right after that you destroy it.
But I don't fully understand what do you exactly mean, but I think you want to check if an x specific item exists in menu (right?)

Then the best way to do that is when you add items to menu (for i loop) you should check if item[i] has title/text/id you want, if yes, make custom (global - in the begging of the code) boolean and set it to true. And if menu has x item (true boolean) continue your code.

Last edited by thEsp; 01-05-2019 at 14:40. Reason: .
thEsp is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 01-05-2019 , 14:59   Re: if item is in vault --> item in menu = \d
Reply With Quote #5

exactly, check the item in menu (it should be saving to nvault whether it's set to 0 or 1). tried to do it with global in the beginning, but still did not figure out how [i] is works in menu handler function. could you show me what exactly you mean? I am not sure about all that.

Last edited by TheBladerX; 01-05-2019 at 15:00.
TheBladerX is offline
thEsp
BANNED
Join Date: Aug 2017
Old 01-06-2019 , 16:13   Re: if item is in vault --> item in menu = \d
Reply With Quote #6

Sorry for late reply, I created this EXAMPLE code but I haven't tested it. (Should be working in my opinion)


PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "--"
#define VERSION "1.0"
#define AUTHOR "thEsp"

new SpecificItem[32] = "3"

new bool:MenuHas_Item=false

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /test","Test")
    
register_clcmd("say /test_check","TestCheck")
}

public 
Test(id)
{
    new 
menu menu_create("\rMenu for test","menu_handler_event")
    
    new 
i
    
new str[32]
    new 
i_ItemNumber=0
    
new str_ItemNumber[32]
    
    for(
i=0i<6i++)
    {
        if(
i==SpecificItem[id])
        {
            
MenuHas_Item=true
        
}
        
        
num_to_str(i,str,10)
        
num_to_str(i_ItemNumber,str_ItemNumber,10)
        
        
menu_additem(menu,str,str_ItemNumber)
        
        
i_ItemNumber++
    }
    
    
menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
    
    
menu_display(id,menu,0)
}

public 
menu_handler_event(id,item,menu)
{
    switch(
item)
    {
        case 
MENU_EXIT:
        {
            
menu_destroy(menu)
        }
    }
}

public 
TestCheck(id)
{
    if(
MenuHas_Item==true)
    {
        
client_print(id,print_chat,"Item [ %s ] exists",SpecificItem)
    }

EDIT: I checked this, and works alright. The reason I added just 6 items in menu is because menus can display 7 items (Including exit I think) and make simplier code.

Last edited by thEsp; 01-06-2019 at 16:19. Reason: testing
thEsp is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 01-07-2019 , 06:51   Re: if item is in vault --> item in menu = \d
Reply With Quote #7

Yes, got it. Thank you!
TheBladerX 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 07:36.


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