Raised This Month: $ Target: $400
 0% 

Simple question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 09-14-2017 , 06:22   Simple question
Reply With Quote #1

Its been a while since i coded amxx, i forgot some things.

My question:
Server has 32 slots, MAX_PLAYERS=32+1
g_Password has a max limit of 12 characters

PHP Code:
new g_Password[MAX_PLAYERS][12
or
PHP Code:
new g_Password[12][MAX_PLAYERS
Wich one is correct?

Also, if the character limit is 12, should i use [11]?
Syturi0 is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-14-2017 , 06:42   Re: Simple question
Reply With Quote #2

In your case first is correct, because each player id correspondent for one string.
If you want to copy something in the string you have to
Code:
copy(g_Password[id], charsmax(g_Password[]), "Pass here");
otherwise you can't achive this.

You have to remember one rule: brackets for string in multidimensional array is always last.
In another language, where string is a type, you will have an array of strings (like array of ints), but behind the scenes every string is char-array.

Last edited by KiLLeR.; 09-14-2017 at 06:46.
KiLLeR. is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-14-2017 , 12:04   Re: Simple question
Reply With Quote #3

g_Password[12] will make 11 chars and one null at the end.
If the character limit is 12 you should use [13].
Black Rose is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 09-14-2017 , 13:49   Re: Simple question
Reply With Quote #4

MAX_PLAYERS is 32. https://github.com/alliedmodders/amx...xconst.inc#L40
So, you should use MAX_PLAYERS + 1.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 09-14-2017 , 16:45   Re: Simple question
Reply With Quote #5

Thank you everyone.
Syturi0 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 02:03.


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