Raised This Month: $32 Target: $400
 8% 

Multi Vote


Post New Thread Reply   
 
Thread Tools Display Modes
edga85
BANNED
Join Date: Jan 2009
Old 05-07-2009 , 12:33   Re: Multi Vote
Reply With Quote #31

Can someone fix that when i start vote i can see and vote for THAT VOTE
edga85 is offline
Send a message via Skype™ to edga85
pizzahut
Senior Member
Join Date: Oct 2004
Old 09-24-2021 , 08:36   Re: Multi Vote
Reply With Quote #32

There's a bug with two occurrences in the source code.
While player IDs start with 1, array indexes start with 0.
So in lines 65 to 67 and 104 to 106 this is wrong:
Code:
	get_players(Players, iNum, "ch")
	
	for(new a = 1; a < iNum; a++)
It should be changed to:
Code:
	get_players(Players, iNum, "ch")
	
	for(new a; a < iNum; a++)
Then a minor issue, the menu exit should be at 0, not 9. To achieve this, these two lines can be commented out or deleted:
Code:
	menu_addblank(menu, 0)
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
E.g.
Code:
	// menu_addblank(menu, 0)
	// menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
And another tiny thing, the plugin's name is "Multi Vote", so I would replace this:
Code:
#define Plugin "Custom Vote"
with this:
Code:
#define Plugin "Multi Vote" // was: "Custom Vote"
And naturally the version should be changed then, too.

EDIT: Access level should be changed to "ADMIN_VOTE".

Last edited by pizzahut; 09-25-2021 at 15:52.
pizzahut is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 09-27-2021 , 11:46   Re: Multi Vote
Reply With Quote #33

Quote:
Originally Posted by pizzahut View Post
There's a bug with two occurrences in the source code.
While player IDs start with 1, array indexes start with 0.
So in lines 65 to 67 and 104 to 106 this is wrong:
Code:
	get_players(Players, iNum, "ch")
	
	for(new a = 1; a < iNum; a++)
It should be changed to:
Code:
	get_players(Players, iNum, "ch")
	
	for(new a; a < iNum; a++)
When 0 passes it is the world though. For instance when my client temp program is running and 0 is applied from get_players it gets server's temperature. It's quite demonstrative seeing that occur. When 0 is used it is broadcast in messages all 1-32, that's the 32 potential clients. Perhaps confused with entity index against client's index. While one of the players is 1-32 they are a different number deeper down.

Quoting Valve now.
Quote:
An entity index is a unique integer given to every entity by the engine. It allows the same entity to be referred to across library boundaries, but will be different on the client and server unless an edict is used.
  • Tip: Worldspawn is always entity 0, while indices 1 to <maxplayers> are reserved for players.
Perhaps they cannot see menu because 0 wasn't being used to broadcast and sent it to everybody. That being said, I did not look at the script on this thread yet.
__________________
DJEarthQuake is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 09-28-2021 , 06:40   Re: Multi Vote
Reply With Quote #34

As already mentioned, it's not a player index, but an array index. I've omitted the next line because it's different for the two locations with the bug. But the use of "get_players" should be a clue.

Original code:
Code:
	new Players[32], iNum
	get_players(Players, iNum, "ch")
	for(new a = 1; a < iNum; a++)
		menu_display(Players[a], menu, 0)
Code:
	new Players[32], iNum
	get_players(Players, iNum, "ch")
	for(new a = 1; a < iNum; a++)
		menu_cancel(Players[a])
Examples are in the wiki:
https://wiki.alliedmods.net/Intro_to...Admin_Commands
https://wiki.alliedmods.net/Advanced...g_Log_Messages
https://wiki.alliedmods.net/Optimizi...e-index_Arrays

Last edited by pizzahut; 09-28-2021 at 06:45.
pizzahut is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 09-28-2021 , 12:32   Re: Multi Vote
Reply With Quote #35

When a human's IP occasionally shows as localhost they may not see the menu.

PHP Code:
/*new Players[32], iNum
    get_players(Players, iNum, "ch")
    
    for(new a = 1; a < iNum; a++)
        menu_display(Players[a], menu, 0)*/
        
menu_display(0menu0
__________________
DJEarthQuake is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 09-29-2021 , 05:22   Re: Multi Vote
Reply With Quote #36

For other people reading this: https://github.com/alliedmodders/amxmodx/issues/848

Quote:
Originally Posted by DJEarthQuake View Post
When a human's IP occasionally shows as localhost they may not see the menu.
This might happen, however 0 isn't a valid player index for this command.

Code:
L 09/29/2021 - 10:55:13: Invalid player id 0.
L 09/29/2021 - 10:55:13: [AMXX] Displaying debug trace (plugin "multi_vote_test.amxx", version "1.4-test")
L 09/29/2021 - 10:55:13: [AMXX] Run time error 10: native error (native "menu_display")
It could also be that omitting bots is safe, because AFAIR something like "is_user_bot(id)" usually works correctly, i.e. it returns false for human players even if AMXX assigned "127.0.0.1" as IP because the bot flag was originally and incorrectly set for a human player.

I can only speculate that the bot flag doesn't stay wrong, but the assigned "127.0.0.1" IP remains.

Last edited by pizzahut; 09-29-2021 at 05:40.
pizzahut is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 09-29-2021 , 05:51   Re: Multi Vote
Reply With Quote #37

My bad, show_menu, instead I mean. Menu_display is single client. Now that I popped open the code. Does stock Amxx 182 with amx_vote accomplish this feat?
__________________

Last edited by DJEarthQuake; 09-29-2021 at 06:16.
DJEarthQuake 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 18:25.


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