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

I tried to do stock for the menu that getting online player but i got bug in rehlds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 07-25-2021 , 03:15   I tried to do stock for the menu that getting online player but i got bug in rehlds
Reply With Quote #1

I tried to optimize the code by doing stock for the menu that getting the online players but i got bug in rehlds server, when i choose one of players it choice other one!!.

This is the code:
Code:
public DonateMenu(id)
{	
	PlayerMenu(id, DONATE_ACCESS, "\yChoose a player: \r[Donate]", "Donate_Handler", "ch")
}

public Donate_Handler(id, iMenu, iItem) 
{
	if(iItem != MENU_EXIT) 
	{
		new iAccess, iCallback, iData[6], szName[MAX_PLAYERS * 2];
		menu_item_getinfo(iMenu, iItem, iAccess, iData, charsmax(iData), szName, charsmax(szName), iCallback);
		
		g_iPlayerData[ id ][ Donate ] = str_to_num(iData);
		
		if (!g_iPlayerData[ id ][ Donate ])
		{
			CC_SendMessage(id,"This player does not exist.");
			menu_display(id, iMenu)
			return PLUGIN_HANDLED;
		}
		
		client_cmd(id, "messagemode EnterAmount");
		
		set_hudmessage(255, 255, 85, 0.01, 0.18, 2, 0.5, 6.0, 0.05, 0.05, -1);
		show_hudmessage(id, "Type how much you want to give.");
	}
	menu_destroy(iMenu);
	return PLUGIN_HANDLED
}

public ResetMenu(id)
{	
	PlayerMenu(id, RESET_ACCESS, "\yChoose a player: \r[Reset Bank]", "Reset_Handler", "ch")
}

public Reset_Handler(id, iMenu, iItem) 
{
	if(iItem != MENU_EXIT) 
	{
		new iAccess, iCallback, iData[6];
		menu_item_getinfo(iMenu, iItem, iAccess, iData, charsmax(iData), _, _, iCallback);
		
		new iPlayer = str_to_num(iData);
		
		ResetBank(id, iPlayer) 
	}
	menu_destroy(iMenu);
	return PLUGIN_HANDLED
}

public OnDonate(id)
{
	static szValue[32], iValue, iPlayer, iCash
	iPlayer = get_user_userid( g_iPlayerData[ id ][ Donate ] );
	read_argv(1, szValue, charsmax(szValue));
	iValue = str_to_num(szValue)
	iCash = get_user_cash(id)

	if( iCash < iValue || iValue <= 0)
	{
		CC_SendMessage(id,"You do not have enough money or invalid value.");
		return PLUGIN_CONTINUE
	}
	
	set_user_cash( iPlayer, get_user_cash(iPlayer) + iValue)
	set_user_cash( id, iCash - iValue)
	
	CC_SendMessage(0,"Player^4 %s^1 donated^4 $%i^1 for^4 %s.", g_iPlayerData[ id ][ Name ], iValue, g_iPlayerData[ iPlayer ][ Name ]);
	
	client_cmd(iPlayer, "spk ^"items/9mmclip1.wav^"")
    
	return PLUGIN_HANDLED;
} 

public ResetBank(id, iPlayer) 
{
	if (!iPlayer)
	{
		CC_SendMessage(id,"This player does not exist.");
		return PLUGIN_HANDLED;
	}
	
	g_iPlayerData[ iPlayer ][ Cash ] = 0
	
	CC_SendMessage(id,"^1[ADMIN]^4 %s:^1 reset bank of^4 %s.", g_iPlayerData[ id ][ Name ], g_iPlayerData[ iPlayer ][ Name ]);
				
	SaveData(iPlayer);
	return PLUGIN_HANDLED;
}

PlayerMenu(id, iAccess, const szTitle[ ], const szHandler[ ], const szGetPlayersFlag[ ])
{		
	static iPlayers[MAX_PLAYERS], iNum, szUserID[32], szData[MAX_MENU_LENGTH], iMenu 
	
	if(!access(id, iAccess))
	{
		CC_SendMessage(id, "You don't have access to this command.");
		return PLUGIN_HANDLED
	}
				
	formatex(szData, charsmax(szData), szTitle)
	
	iMenu = menu_create(szData, szHandler); get_players(iPlayers, iNum, szGetPlayersFlag);
	
	for(new iPlayer, i; i < iNum; i++)
	{
		iPlayer = iPlayers[i]
		
		formatex(szData, charsmax(szData), "%s", g_iPlayerData[ iPlayer ][ Name ]);
		num_to_str(get_user_userid(iPlayer), szUserID, charsmax(szUserID));
		menu_additem(iMenu, szData, szUserID)
	}
	
	menu_setprop(iMenu, MPROP_BACKNAME, "Previous page")
	menu_setprop(iMenu, MPROP_NEXTNAME, "Next page")
	menu_setprop(iMenu, MPROP_EXITNAME, "\rClose")

	menu_display(id, iMenu)
	return PLUGIN_HANDLED
}
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-25-2021 , 06:38   Re: I tried to do stock for the menu that getting online player but i got bug in rehl
Reply With Quote #2

PHP Code:
g_iPlayerDataid ][ Donate ] = find_player("k"str_to_num(iData)) 
PHP Code:
iPlayer g_iPlayerDataid ][ Donate ]; 
PHP Code:
new iPlayer find_player("k"str_to_num(iData)); 
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 07-25-2021 at 06:46.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 07-25-2021 , 16:15   Re: I tried to do stock for the menu that getting online player but i got bug in rehl
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
PHP Code:
g_iPlayerDataid ][ Donate ] = find_player("k"str_to_num(iData)) 
PHP Code:
iPlayer g_iPlayerDataid ][ Donate ]; 
PHP Code:
new iPlayer find_player("k"str_to_num(iData)); 
Thanks, but the issue isn't thier i tested my code on hlds server and it worked, but when i tested it on rehlds i found this bug! and also i found the same issue in reset menu so i think the issue from the stock of the menu !
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 07-25-2021 at 16:28.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-25-2021 , 18:18   Re: I tried to do stock for the menu that getting online player but i got bug in rehl
Reply With Quote #4

Quote:
Originally Posted by Supremache View Post
Thanks, but the issue isn't thier i tested my code on hlds server and it worked, but when i tested it on rehlds i found this bug! and also i found the same issue in reset menu so i think the issue from the stock of the menu !
Have you even understood what i just posted ?

Its not a bug its mis-understanding what is the userid is...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 07-25-2021 at 18:20.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 07-25-2021 , 18:46   Re: I tried to do stock for the menu that getting online player but i got bug in rehl
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
Have you even understood what i just posted ?

Its not a bug its mis-understanding what is the userid is...
Well, I will test it.
Thanks
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache 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 05:51.


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