Quote:
Originally Posted by Moody92
Hello there, I am in the intro tutorial but I didn't understand this
First thing is
PHP Code:
return PLUGIN_HANDLED
why did he used PLUGIN_HANDLED exactly. and what if I put it without return PLUGIN_HANDLED, or retrun PLUGIN_CONTINUE or even return % what will happen ?
|
Quote:
|
Originally Posted by wiki.alliedmods.net
PLUGIN_CONTINUE generally means "continue with normal operation", and PLUGIN_HANDLED means "block further operation". The differences are subtle but important. For example, when binding a command, you should never return PLUGIN_CONTINUE. But if you return PLUGIN_HANDLED while binding to the "say" command, it will block the player's text from ever appearing.
|
So clearly, he used return PLUGIN_HANDLED to block any further functions from working (Stop the command from working to make it simpler)
Quote:
Originally Posted by Moody92
2nd thing
PHP Code:
read_argv(1, Arg1, 23) read_argv(2, Arg2, 3)
I realize the number 1,2 the arguments number but which I didn't understand is 23,3 I think they're the ID of the operation but how to get the id or it should be specific numbers depends on the operation ?
|
Actully, your wrong.
The last argument in the function(s) (23, 3) are the len.
Len is max characters that can be stored in Arg1, Arg2.
Just to make sure you understood,
PHP Code:
new szString1[35] // Here, max characters that can be stored 34, but len can be 1,2,3,4,5,6,7.......34
// So,
charsmax(szString) // == 34
Quote:
Originally Posted by Moody92
also this one
PHP Code:
new players[32], num
What is 32 ? I saw in many threads that It's player index id, but what is player index id ?
|
Player index is the player's unique id, defined by amxx or half life engine (I don't really know).
Player index ranges from 1 to 32 (Thats why we created an array with 32 rows), but when you use this
PHP Code:
get_players(players, num)
All players indexes will be stored in players like this: (BTW, count is the number of the players)
PHP Code:
// You need to read arrays to understand this
// If count == 5 (Note that == is used for checking, = is used for assigning)
players[0] = 1
players[1] = 2
players[2] = 3
players[3] = 4
players[4] = 5
// If count == 10 (Players connected are 10)
players[0] = 1
players[1] = 2
players[2] = 3
players[3] = 4
players[4] = 5
players[5] = 6
players[6] = 7
players[7] = 8
players[8] = 9
players[9] = 10
// Etc
Also, as I know, ids (Players indexes) are assigned depending on who connects first, so if the server had 0 players, and you connected, players count will change to 1, also your index will be 1
Let's say that there were 3 players connected, and players[32] was like this
PHP Code:
players[0] = 1 // Player 1
players[1] = 2 // Player 2
players[2] = 3 // Player 3
And then suddenly, player with index 2 has disconnected, so who will get index 2?
players are shifted automatically to fill the empty index
so players[32] will be like this:
PHP Code:
players[0] = 1 // Player 1
players[1] = 2 // Player 3
That's all.
I too at the first didn't understand much about indexes, but then I started reading and testing till I understood it.
I think you should do that too.
Hopefully, you understood everything.
Regards.
EDIT: LOOOOL!
After I wrote all this post, I looked in the forum just to waste sometime, then I found this:
http://forums.alliedmods.net/showthread.php?t=181629
My idea about indexes was just a thought, I only understood it from get_players as I got confused in it, but it turned out that my thought is true! LOL!
PS: Only read the top of that post, you will get confused about other things.
__________________