Raised This Month: $ Target: $400
 0% 

Stack implementation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Marcin RN
New Member
Join Date: Dec 2012
Old 12-17-2014 , 08:22   Stack implementation
Reply With Quote #1

Hi!
Is there any stack implementation available in amxmodx?
I only found this:
https://www.amxmodx.org/api/cellstack/__raw

But this seems to be not available in latest amxmodx.
Any thoughts?

Best regards,
Marcin
Marcin RN is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-17-2014 , 08:59   Re: Stack implementation
Reply With Quote #2

It's available in 1.8.3 dev build.

http://www.amxmodx.org/snapshots.php
__________________
Arkshine is offline
Marcin RN
New Member
Join Date: Dec 2012
Old 12-17-2014 , 09:07   Re: Stack implementation
Reply With Quote #3

Okay, I just found that it's in dev version

However, I have an issue with it.

I need an array that holds stack handles for each of player
Code:
new Stack:g_LastHP[33]

for ( new i = 1; i <= g_MaxPL; i++ )
	g_LastHP[i] = CreateStack()
However, if I try to use any cellstack function on any handle it would print Invalid handle error.

Code:
PushStackCell(g_LastHP[id], pev(target, pev_health))

L 12/17/2014 - 15:02:13: Invalid array handle provided (0)
L 12/17/2014 - 15:02:13: [AMXX] Displaying debug trace (plugin "test.amxx", version "2.8.2")
L 12/17/2014 - 15:02:13: [AMXX] Run time error 10: native error (native "PushStackCell")
For a single stack handle (not an array) it works fine:

Code:
	g_testStack = CreateStack()
		
	PushStackCell(g_testStack, 5)
	PushStackCell(g_testStack, 25)
	new z;
	PopStackCell(g_testStack, z)
	server_print("%d", z)   //prints 25
Any help appreciated!
Marcin RN is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-17-2014 , 09:52   Re: Stack implementation
Reply With Quote #4

Did you try to debug at least? Like printing each cell of g_LastHP ?

Error states you pass an invalid handle, meaning g_LastHP[i] returns 0. Are you sure that "i" is not 0, because at 0 you don't create handle.
__________________
Arkshine is offline
Marcin RN
New Member
Join Date: Dec 2012
Old 12-17-2014 , 10:04   Re: Stack implementation
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
Did you try to debug at least? Like printing each cell of g_LastHP ?

Error states you pass an invalid handle, meaning g_LastHP[i] returns 0. Are you sure that "i" is not 0, because at 0 you don't create handle.
Oops that's embarassing

Turns out that g_MaxPL was 0 from the start. Everything is fine now.

Sorry for bothering you and thanks for the help!
Marcin RN is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-17-2014 , 11:39   Re: Stack implementation
Reply With Quote #6

Quote:
Originally Posted by Arkshine View Post
Did you try to debug at least? Like printing each cell of g_LastHP ?

Error states you pass an invalid handle, meaning g_LastHP[i] returns 0. Are you sure that "i" is not 0, because at 0 you don't create handle.
How a stack is different from an array ? Or better to ask what is a stack. I really have no ideea
__________________

Last edited by HamletEagle; 12-17-2014 at 11:40.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-17-2014 , 12:39   Re: Stack implementation
Reply With Quote #7

Stack is just another dynamic array like.

Difference is how you store and retrieve elements, that's it in a stack way.

http://www.wikiwand.com/en/Stack_(abstract_data_type)

You can check also the test plugin in scripting/testsuite/.
__________________
Arkshine 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 15:26.


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