Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
text
Languages:
Russian
Size:
10K - 100K
Tags:
code
License:
RichieBurundi
commited on
Commit
•
82d6031
1
Parent(s):
c2b71e2
Upload 28 files
Browse files- Correct use of certain Events.txt +153 -0
- Damaged Soul's Message Logging plugin.txt +543 -0
- Fake Forwards.txt +203 -0
- Finding Entities.txt +82 -0
- Half-Life 1 Events, Registering, Using, Reaing.txt +90 -0
- Half-Life 1 List of Events.txt +1947 -0
- Messages (Temp Entities, Game Events, etc.).txt +115 -0
- NEW DBI API (MySQL SQL).txt +66 -0
- New AMXX Menu System.txt +909 -0
- Plugin API.txt +200 -0
- Regular Expressions. regex_tester.txt +99 -0
- Regular Expressions.txt +388 -0
- Scripting Cvars.txt +96 -0
- The advantages cellArray.sma.txt +55 -0
- The advantages cellArrayResults.txt.txt +36 -0
- The advantages cellTrie.sma.txt +45 -0
- The advantages cellTrieResults.txt.txt +31 -0
- The advantages of a trie over an array for strings storage.txt +43 -0
- Touch Stuff.txt +106 -0
- Usage EngFunc_EntitiesInPVS.txt +27 -0
- Using Button Constants.txt +67 -0
- Using Files to write datavalues(old and new file commands).txt +351 -0
- Using Files to write datavalues, filehandle.sma.txt +90 -0
- set_speak() in Fakemeta.txt +175 -0
- set_tasks when they are and when they aren't necessary.txt +153 -0
Correct use of certain Events.txt
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Intro
|
2 |
+
|
3 |
+
I posting this because i saw so numerous mistakes/questions at this area of srcipting. This is the one of the common problems amongst the coders and even not only beginners! New Round / Player Spawn / Round Start / Round End is a different things so read the below explanations and do not mess them.
|
4 |
+
|
5 |
+
Usual call order of the events is listed below:
|
6 |
+
New Round
|
7 |
+
Player Spawn
|
8 |
+
Round Start
|
9 |
+
Round End
|
10 |
+
|
11 |
+
1. New Round
|
12 |
+
|
13 |
+
The "New Round" is happen at the "Freeze Time" start. The "Freeze Time" is a time in Counter-Strike when all players are "freezed" which means that they can't walk and do a primary attacks.
|
14 |
+
|
15 |
+
In the past years the most common way that was used to determine this event was the use of the "RoundTime" event with a "Time" message argument check, but there was a certain issues which makes this metod inefficient:
|
16 |
+
this event is specified, i.e. is sent to every player, so if there are no players no a server then it's not possible to detect the "New Round" with this method;
|
17 |
+
this event is also can be the same for the "Round Start" because the value of the "mp_freezetime" server CVar can be equal to the value of the "Time" argument of the "RoundTime" message, so it is not accurate enough.
|
18 |
+
Of course i haven't like that method so i had to think of something more efficient. So some months ago after a little research i've discovered the new method which does not have the issues that is listed above:
|
19 |
+
PHP Code:
|
20 |
+
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
|
21 |
+
Notice the two conditions.
|
22 |
+
|
23 |
+
Note that this event is not called for very first round, i.e. on map start. If you need to catch that moment as well then in the most cases it's enough to use the plugin_init() or plugin_cfg() forward functions.
|
24 |
+
|
25 |
+
Also i was amazed at how many mistakes was made even by the "expirienced" coders in try to detect the "New Round"! The most common mistake was:
|
26 |
+
PHP Code:
|
27 |
+
register_event("ResetHUD", "newRound", "b")
|
28 |
+
which is completely incorrect. The "ResetHUD" is a specified event which is called under many circumstances for every player. So sometimes you can get more than even one hundred such "newRound" function calls per a single round!
|
29 |
+
|
30 |
+
|
31 |
+
2. Player Spawn
|
32 |
+
|
33 |
+
I think no need to explain what the "Player Spawn" is. But many of the coders still do not know how to detect this event correctly.
|
34 |
+
|
35 |
+
If you are using AMX Mod X v1.8 or higher, or if you have the "Ham Sandwich" module installed the most simple and efficient way of the "Player Spawn" detection is a hook of the "Spawn" function itself:
|
36 |
+
PHP Code:
|
37 |
+
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
|
38 |
+
The last parameter means that the registered function will be called right after player spawn (post variant of the hook) and not right before player spawn (pre variant of the hook). At least for Counter-Strike it's also necessary to skip registered function call for a dead players. This call is happen when a player enters a server. The most common example is shown below:
|
39 |
+
PHP Code:
|
40 |
+
#include <amxmodx>
|
41 |
+
#include <hamsandwich>
|
42 |
+
|
43 |
+
public plugin_init() {
|
44 |
+
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
|
45 |
+
}
|
46 |
+
|
47 |
+
public fwHamPlayerSpawnPost(iPlayer) {
|
48 |
+
if (is_user_alive(iPlayer)) {
|
49 |
+
// player spawned
|
50 |
+
}
|
51 |
+
}
|
52 |
+
If the above method isn't suitable for you for some reasons, it's possible to use the different more "famous" method of the "ResetHUD" event hook that doesn't require an additional module but is more complex.
|
53 |
+
|
54 |
+
You should note that the use of that method may even lead to a server crash. It could happen because the plugin actions is performed on a player in the middle of his spawn process. The example of such "dangerous" action is a call of the strip_user_weapons() fun module's function.
|
55 |
+
|
56 |
+
Many of plugin writers does know that the "ResetHUD" event is called on a player spawn but not all of them does know that this event is also called when a player is enter a server (at least in Counter-Strike), on "fullupdate" client command execution, demo recording and round restart attempt (on Counter-Strike's "sv_restartround" / "sv_restart" CVar change for alive players). So to use the "ResetHUD" to detect the "Player Spawn" we will need to filter out all that actions.
|
57 |
+
|
58 |
+
The moment when a player is joined a server can be filtered out by registering the "ResetHUD" event with a "e" flag which means that the registered function will be called on alive players. Note that sometimes that "e" flag will also allow a calls of the registered function on a dead players as well (this is a bug of the AMX Mod X core that has been fixed in version 1.80). So it's recommended to do the "alive" check inside of the registered function itself.
|
59 |
+
|
60 |
+
The execution of the "fullupdate" client command and the start of a demo recording can be filtered out by blocking the command:
|
61 |
+
PHP Code:
|
62 |
+
// ...
|
63 |
+
register_clcmd("fullupdate", "clcmd_fullupdate")
|
64 |
+
// ...
|
65 |
+
|
66 |
+
public clcmd_fullupdate() {
|
67 |
+
// stops the command but allows to "catch" it by any other running plugin
|
68 |
+
return PLUGIN_HANDLED_MAIN
|
69 |
+
}
|
70 |
+
Though that method is simple it's recommended to not block the "fullupdate" command since it is used (automatically) on a client side on demo recording to properly update the HUD display and pass a proper data to a demo file on a beginning of a record process. Instead of "fullupdate" command block it's enough to just skip a call of the registered (to the "ResetHUD" event) function at the time when that command is issued on a client side.
|
71 |
+
|
72 |
+
As for round restart attempt, probably some of you does think that it's not necessary to filter this event out because it's always called right before "New Round". This is incorrect - not always, it's possible to set "sv_restartround" / "sv_restart" CVar value for example to 60 so new round will be delayed for one full minute! Therefore to filter this out as well on round restart attempt for every alive player we will have to skip the call of the registered to the "ResetHUD" event function.
|
73 |
+
|
74 |
+
The result code that is able to detect the "Player Spawn" is shown below:
|
75 |
+
PHP Code:
|
76 |
+
#include <amxmodx>
|
77 |
+
#include <fakemeta>
|
78 |
+
|
79 |
+
#define MAX_CLIENTS 32
|
80 |
+
|
81 |
+
new bool:g_bPlayerNonSpawnEvent[MAX_CLIENTS + 1]
|
82 |
+
|
83 |
+
new g_iFwFmClientCommandPost
|
84 |
+
|
85 |
+
public plugin_init() {
|
86 |
+
register_event("ResetHUD", "fwEvResetHUD", "b")
|
87 |
+
register_event("TextMsg", "fwEvGameWillRestartIn", "a", "2=#Game_will_restart_in")
|
88 |
+
register_clcmd("fullupdate", "fwCmdClFullupdate")
|
89 |
+
}
|
90 |
+
|
91 |
+
public fwEvResetHUD(iPlayerId) {
|
92 |
+
if (!is_user_alive(iPlayerId))
|
93 |
+
return
|
94 |
+
|
95 |
+
if (g_bPlayerNonSpawnEvent[iPlayerId]) {
|
96 |
+
g_bPlayerNonSpawnEvent[iPlayerId] = false
|
97 |
+
return
|
98 |
+
}
|
99 |
+
|
100 |
+
fwPlayerSpawn(iPlayerId)
|
101 |
+
}
|
102 |
+
|
103 |
+
public fwEvGameWillRestartIn() {
|
104 |
+
static iPlayers[32], iPlayersNum, i
|
105 |
+
get_players(iPlayers, iPlayersNum, "a")
|
106 |
+
for (i = 0; i < iPlayersNum; ++i)
|
107 |
+
g_bPlayerNonSpawnEvent[iPlayers[i]] = true
|
108 |
+
}
|
109 |
+
|
110 |
+
public fwCmdClFullupdate(iPlayerId) {
|
111 |
+
g_bPlayerNonSpawnEvent[iPlayerId] = true
|
112 |
+
static const szFwFmClientCommandPost[] = "fwFmClientCommandPost"
|
113 |
+
g_iFwFmClientCommandPost = register_forward(FM_ClientCommand, szFwFmClientCommandPost, 1)
|
114 |
+
return PLUGIN_CONTINUE
|
115 |
+
}
|
116 |
+
|
117 |
+
public fwFmClientCommandPost(iPlayerId) {
|
118 |
+
unregister_forward(FM_ClientCommand, g_iFwFmClientCommandPost, 1)
|
119 |
+
g_bPlayerNonSpawnEvent[iPlayerId] = false
|
120 |
+
return FMRES_HANDLED
|
121 |
+
}
|
122 |
+
|
123 |
+
public fwPlayerSpawn(iPlayerId) {
|
124 |
+
// player spawned
|
125 |
+
}
|
126 |
+
|
127 |
+
3. Round Start
|
128 |
+
|
129 |
+
The "Round Start" is happen at the "Freeze Time" end.
|
130 |
+
|
131 |
+
Many of the coders does think that the "Round Start" and "New Round" is the same event and doing a things that is related to the "New Round" in "Round Start" but this is incorrect. Some of the coders especially in the past have used the "RoundTime" event to detect the "Round Start", but again this is inefficient method (the details can be found in the "New Round" section of the article).
|
132 |
+
|
133 |
+
The correct method that can be used to detect the "Round Start" is shown below:
|
134 |
+
PHP Code:
|
135 |
+
register_logevent("logevent_round_start", 2, "1=Round_Start")
|
136 |
+
|
137 |
+
4. Round End
|
138 |
+
|
139 |
+
The "Round End" is happen right at the moment when one of the teams is completed objectives: all players in the opposite team is killed, all hostages is rescued, time of the round is up, etc.
|
140 |
+
|
141 |
+
Some of the coders does think that the "Round End" and "New Round" is the same event and doing a things that is related to the "New Round" in the "Round End" but this is incorrect.
|
142 |
+
|
143 |
+
The correct method that can be used to detect the "Round End" is shown below:
|
144 |
+
PHP Code:
|
145 |
+
register_logevent("logevent_round_end", 2, "1=Round_End")
|
146 |
+
|
147 |
+
Still confused?
|
148 |
+
|
149 |
+
Still confused and don't really sure which from the above events should be used in your plugin? Review the below examples that may help you to understand the things better.
|
150 |
+
The "New Round" event can be used to move a spawn point entities or to play a music for a players if a freeze time is too long.
|
151 |
+
The "Player Spawn" can be used to alter a player's properties like start health, weapons, etc.
|
152 |
+
The "Round Start" can be used to create your own "buytime" for a plugins that provide a purchasable items or when you want to create a surprise item.
|
153 |
+
The "Round End" can be used to protect a players with a godmode until the "New Round" or to create a quick minigame until the "New Round".
|
Damaged Soul's Message Logging plugin.txt
ADDED
@@ -0,0 +1,543 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Message Logging 1.17
|
2 |
+
by Damaged Soul
|
3 |
+
|
4 |
+
AMX Mod X Version: 1.75 and above
|
5 |
+
Supported Mods: All
|
6 |
+
|
7 |
+
Description
|
8 |
+
This plugin allows for the logging of any or all messages sent by the HL engine or mod (such as DeathMsg, CurWeapon, etc) It also allows these messages to be filtered by entity.
|
9 |
+
|
10 |
+
Information that is logged includes:
|
11 |
+
Message name
|
12 |
+
Number of message arguments
|
13 |
+
Message ID
|
14 |
+
Message destination (i.e. Broadcast, One, All, etc)
|
15 |
+
Message origin
|
16 |
+
Entity that received the message
|
17 |
+
Entity classname
|
18 |
+
Entity netname
|
19 |
+
Every argument value and type
|
20 |
+
Required Modules
|
21 |
+
Fakemeta
|
22 |
+
|
23 |
+
Usage
|
24 |
+
Console Commands
|
25 |
+
amx_msglog <command> [argument]
|
26 |
+
Displays help for logging engine/mod messages when no command is given
|
27 |
+
Commands:
|
28 |
+
start [msg name or id]
|
29 |
+
Starts logging given message or all if no argument
|
30 |
+
stop [msg name or id]
|
31 |
+
Stops logging given message or all if no argument
|
32 |
+
list [page]
|
33 |
+
Displays list of messages and their logging status
|
34 |
+
Cvars
|
35 |
+
amx_ml_filter [Default Value: 1]
|
36 |
+
Allows for filtering messages by entity index
|
37 |
+
Set this to the index of the entity for which you want to log messages
|
38 |
+
If this is set to 0, message logging will be done for all entities
|
39 |
+
amx_ml_logmode [Default Value: 1]
|
40 |
+
Determines where to log message information
|
41 |
+
Set this to 0 to log information to the standard AMX Mod X log file
|
42 |
+
Set this to 1 to log information to a separate file (messages.log) in the log directory
|
43 |
+
Examples
|
44 |
+
To log the DeathMsg message:
|
45 |
+
amx_msglog start DeathMsg OR amx_msglog start 83
|
46 |
+
To stop logging the DeathMsg message:
|
47 |
+
amx_msglog stop DeathMsg OR amx_msglog stop 83
|
48 |
+
To log all messages except the DeathMsg message:
|
49 |
+
amx_msglog start
|
50 |
+
amx_msglog stop DeathMsg OR amx_msglog stop 83
|
51 |
+
To log messages only sent to third player of the server:
|
52 |
+
amx_ml_filter 3
|
53 |
+
To log messages sent to all entities:
|
54 |
+
amx_ml_filter 0
|
55 |
+
|
56 |
+
|
57 |
+
/* Message Logging 1.17 by Damaged Soul
|
58 |
+
|
59 |
+
AMX Mod X Version: 1.75 and above
|
60 |
+
Supported Mods: All
|
61 |
+
|
62 |
+
This file is provided as is (no warranties).
|
63 |
+
|
64 |
+
***************
|
65 |
+
* Description *
|
66 |
+
***************
|
67 |
+
This plugin allows for the logging of any or all messages sent by the HL engine or mod (such as
|
68 |
+
DeathMsg, CurWeapon, etc) It also allows these messages to be filtered by entity.
|
69 |
+
|
70 |
+
Information that is logged includes:
|
71 |
+
- Message name
|
72 |
+
- Number of message arguments
|
73 |
+
- Message ID
|
74 |
+
- Message destination (i.e. Broadcast, One, All, etc)
|
75 |
+
- Message origin
|
76 |
+
- Entity that received the message
|
77 |
+
- Entity classname
|
78 |
+
- Entity netname
|
79 |
+
- Every argument value and type
|
80 |
+
|
81 |
+
********************
|
82 |
+
* Required Modules *
|
83 |
+
********************
|
84 |
+
Fakemeta
|
85 |
+
|
86 |
+
*********
|
87 |
+
* Usage *
|
88 |
+
*********
|
89 |
+
Console Commands:
|
90 |
+
amx_msglog <command> [argument]
|
91 |
+
- Displays help for logging engine/mod messages when no command is given
|
92 |
+
- Commands:
|
93 |
+
start [msg name or id]
|
94 |
+
- Starts logging given message or all if no argument
|
95 |
+
stop [msg name or id]
|
96 |
+
- Stops logging given message or all if no argument
|
97 |
+
list [page]
|
98 |
+
- Displays list of messages and their logging status
|
99 |
+
|
100 |
+
Cvars:
|
101 |
+
amx_ml_filter [Default Value: 1]
|
102 |
+
- Allows for filtering messages by entity index
|
103 |
+
- Set this to the index of the entity for which you want to log messages
|
104 |
+
- If this is set to 0, message logging will be done for all entities
|
105 |
+
|
106 |
+
amx_ml_logmode [Default Value: 1]
|
107 |
+
- Determines where to log message information
|
108 |
+
- Set this to 0 to log information to the standard AMX Mod X log file
|
109 |
+
- Set this to 1 to log information to a separate file (messages.log) in the log directory
|
110 |
+
|
111 |
+
Examples:
|
112 |
+
To log the DeathMsg message:
|
113 |
+
amx_msglog start DeathMsg OR amx_msglog start 83
|
114 |
+
|
115 |
+
To stop logging the DeathMsg message:
|
116 |
+
amx_msglog stop DeathMsg OR amx_msglog stop 83
|
117 |
+
|
118 |
+
To log all messages except the DeathMsg message:
|
119 |
+
amx_msglog start
|
120 |
+
amx_msglog stop DeathMsg OR amx_msglog stop 83
|
121 |
+
|
122 |
+
To log messages only sent to third player of the server:
|
123 |
+
amx_ml_filter 3
|
124 |
+
|
125 |
+
To log messages sent to all entities:
|
126 |
+
amx_ml_filter 0
|
127 |
+
|
128 |
+
*******************
|
129 |
+
* Version History *
|
130 |
+
*******************
|
131 |
+
1.17 [Feb. 11, 2007]
|
132 |
+
- Fixed: Long arguments were being reported as bytes (Thanks XxAvalanchexX)
|
133 |
+
|
134 |
+
1.16 [Oct. 4, 2006]
|
135 |
+
- Fixed: String arguments of messages that contained format paramaters (such as %s) caused
|
136 |
+
runtime error 25 (thanks sawce :avast:)
|
137 |
+
- Tabs and new-lines in string arguments of messages are now converted to ^t and ^n
|
138 |
+
|
139 |
+
1.15 [July 4, 2006]
|
140 |
+
- Now uses the Fakemeta module instead of Engine
|
141 |
+
- Now uses vformat instead of the deprecated format_args when logging information
|
142 |
+
- Very minor optimizations
|
143 |
+
|
144 |
+
1.11 [May 11, 2006]
|
145 |
+
- Fixed: String arguments of messages were being logged as numbers
|
146 |
+
|
147 |
+
1.10 [Apr. 23, 2006]
|
148 |
+
- Minor optimizations including the use of pcvar natives to improve performance a bit
|
149 |
+
- Much of the logged text has been rewritten in an attempt to make it more like the Half-Life
|
150 |
+
log standard
|
151 |
+
- Now when using the start or stop commands on a specified message, both the message name and
|
152 |
+
ID are printed instead of just whatever was given as the argument
|
153 |
+
- Added: amx_ml_logmode cvar for controlling where to log message information
|
154 |
+
- Fixed: When no arguments were given to amx_msglog, usage information was not printed
|
155 |
+
|
156 |
+
1.03 [Oct. 26, 2004]
|
157 |
+
- Public release
|
158 |
+
- Fixed: Entity filter wasn't actually checking for valid entities correctly (thanks JGHG)
|
159 |
+
|
160 |
+
1.02 [Oct. 25, 2004]
|
161 |
+
- Fixed: If logging had been started for a message, stopped, then started again, same message
|
162 |
+
was logged twice.
|
163 |
+
- Fixed: If message name or ID was invalid, started/stopped logging all messages instead
|
164 |
+
|
165 |
+
1.01 [Oct. 23, 2004]
|
166 |
+
- Fixed: List command was not reporting correct logging status
|
167 |
+
- Fixed: Filter was incorrectly filtering messages if amx_ml_filter was 0
|
168 |
+
|
169 |
+
1.00 [Oct. 19, 2004]
|
170 |
+
- Initial version
|
171 |
+
*/
|
172 |
+
|
173 |
+
#include <amxmodx>
|
174 |
+
#include <amxmisc>
|
175 |
+
#include <fakemeta>
|
176 |
+
|
177 |
+
// Plugin information constants
|
178 |
+
new const PLUGIN[] = "Message Logging"
|
179 |
+
new const AUTHOR[] = "Damaged Soul"
|
180 |
+
new const VERSION[] = "1.16"
|
181 |
+
|
182 |
+
#define MAX_ENGINE_MESSAGES 63 // Max messages reserved by engine (DO NOT MODIFY)
|
183 |
+
#define MAX_POSSIBLE_MESSAGES 255 // Max possible messages for mod, is 255 really the limit?
|
184 |
+
|
185 |
+
#define MSGLOG_STOPPED 0 // Logging status: Stopped
|
186 |
+
#define MSGLOG_STARTED 1 // Logging status: Started
|
187 |
+
|
188 |
+
// Cvar pointers
|
189 |
+
new g_cvarFilter, g_cvarLogMode
|
190 |
+
|
191 |
+
// Filename of separate log file for message info
|
192 |
+
new const LOGFILE_NAME[] = "messages.log"
|
193 |
+
|
194 |
+
// Is message currently being hooked for logging?
|
195 |
+
new bool:g_msgLogging[MAX_POSSIBLE_MESSAGES + 1] = {false}
|
196 |
+
// Is message registered to message_forward?
|
197 |
+
new bool:g_msgRegistered[MAX_POSSIBLE_MESSAGES + 1] = {false}
|
198 |
+
// Stores the names of messages, indexed by message ID
|
199 |
+
new g_msgCache[MAX_POSSIBLE_MESSAGES + 1][32]
|
200 |
+
|
201 |
+
// Max messages allowed by mod
|
202 |
+
new g_maxMessages = MAX_ENGINE_MESSAGES
|
203 |
+
|
204 |
+
new const NULL_STR[] = "<NULL>"
|
205 |
+
|
206 |
+
/* Initialize plugin; Register commands and cvars */
|
207 |
+
public plugin_init()
|
208 |
+
{
|
209 |
+
register_plugin(PLUGIN, VERSION, AUTHOR)
|
210 |
+
|
211 |
+
g_cvarFilter = register_cvar("amx_ml_filter", "1")
|
212 |
+
g_cvarLogMode = register_cvar("amx_ml_logmode", "1")
|
213 |
+
|
214 |
+
register_concmd("amx_msglog", "cmd_msglog", ADMIN_ADMIN,
|
215 |
+
"<command> [argument] - displays help for logging engine/mod messages")
|
216 |
+
|
217 |
+
g_maxMessages = generate_msg_table()
|
218 |
+
}
|
219 |
+
|
220 |
+
/* Handles command amx_msglog */
|
221 |
+
public cmd_msglog(id, level, cid) {
|
222 |
+
if (!cmd_access(id, level, cid, 1))
|
223 |
+
return PLUGIN_HANDLED
|
224 |
+
|
225 |
+
new argCmd[6]
|
226 |
+
read_argv(1, argCmd, 5)
|
227 |
+
remove_quotes(argCmd)
|
228 |
+
|
229 |
+
if (equali(argCmd, "start") || equali(argCmd, "stop")) // start or stop commands
|
230 |
+
{
|
231 |
+
new argMsg[32]
|
232 |
+
read_argv(2, argMsg, 31)
|
233 |
+
remove_quotes(argMsg)
|
234 |
+
|
235 |
+
new msgid = str_to_msgid(argMsg)
|
236 |
+
|
237 |
+
if (is_msg_valid(msgid))
|
238 |
+
{
|
239 |
+
new status = get_msglog_status(msgid)
|
240 |
+
|
241 |
+
if (argCmd[2] == 'a') // start <message>
|
242 |
+
{
|
243 |
+
if (status == MSGLOG_STOPPED)
|
244 |
+
{
|
245 |
+
set_msglog_status(msgid, MSGLOG_STARTED)
|
246 |
+
log_msgf("Logging started for message (%s ^"%d^")", g_msgCache[msgid], msgid)
|
247 |
+
}
|
248 |
+
else
|
249 |
+
console_print(id, "Logging has already been started for message (%s ^"%d^")", g_msgCache[msgid], msgid)
|
250 |
+
}
|
251 |
+
else // stop <message>
|
252 |
+
{
|
253 |
+
if (status == MSGLOG_STARTED)
|
254 |
+
{
|
255 |
+
set_msglog_status(msgid, MSGLOG_STOPPED)
|
256 |
+
log_msgf("Logging stopped for message (%s ^"%d^")", g_msgCache[msgid], msgid)
|
257 |
+
}
|
258 |
+
else
|
259 |
+
console_print(id, "Logging has already been stopped for message (%s ^"%d^")", g_msgCache[msgid], msgid)
|
260 |
+
}
|
261 |
+
}
|
262 |
+
else
|
263 |
+
{
|
264 |
+
// If msg name or ID isn't blank, then at this point we have an invalid msg
|
265 |
+
if (argMsg[0])
|
266 |
+
{
|
267 |
+
console_print(id, "%s is not a valid message name or ID", argMsg)
|
268 |
+
return PLUGIN_HANDLED
|
269 |
+
}
|
270 |
+
|
271 |
+
if (argCmd[2] == 'a') // start
|
272 |
+
{
|
273 |
+
set_msglog_status(0, MSGLOG_STARTED)
|
274 |
+
log_msgf("Logging started for all messages")
|
275 |
+
}
|
276 |
+
else // stop
|
277 |
+
{
|
278 |
+
set_msglog_status(0, MSGLOG_STOPPED)
|
279 |
+
log_msgf("Logging stopped for all messages")
|
280 |
+
}
|
281 |
+
}
|
282 |
+
}
|
283 |
+
else if (equali(argCmd, "list")) // list command
|
284 |
+
{
|
285 |
+
new argStart[4]
|
286 |
+
new start = read_argv(2, argStart, 3) ? str_to_num(argStart) : 1
|
287 |
+
|
288 |
+
if (start < 1)
|
289 |
+
start = 1
|
290 |
+
else if (start > g_maxMessages)
|
291 |
+
start = g_maxMessages
|
292 |
+
|
293 |
+
new end = start + 9
|
294 |
+
if (end > g_maxMessages)
|
295 |
+
end = g_maxMessages
|
296 |
+
|
297 |
+
new logstatus[8], msgname[32]
|
298 |
+
|
299 |
+
console_print(id, "^n------------ Message Logging Statuses -------------")
|
300 |
+
console_print(id, " %-31s %s", "Message Name", "Status")
|
301 |
+
|
302 |
+
for (new i = start; i <= end; i++)
|
303 |
+
{
|
304 |
+
copy(msgname, 31, g_msgCache[i])
|
305 |
+
|
306 |
+
if (!msgname[0])
|
307 |
+
copy(msgname, 31, "<Unknown>")
|
308 |
+
|
309 |
+
copy(logstatus, 7, g_msgLogging[i] ? "LOGGING" : "IDLE")
|
310 |
+
|
311 |
+
console_print(id, "%3d: %-31s %s", i, msgname, logstatus)
|
312 |
+
}
|
313 |
+
|
314 |
+
console_print(id, "Entries %d - %d of %d", start, end, g_maxMessages)
|
315 |
+
|
316 |
+
if (end < g_maxMessages)
|
317 |
+
console_print(id, "-------- Use 'amx_msglog list %d' for more --------", end + 1)
|
318 |
+
else
|
319 |
+
console_print(id,"-------- Use 'amx_msglog list 1' for beginning --------")
|
320 |
+
|
321 |
+
}
|
322 |
+
else
|
323 |
+
{
|
324 |
+
// Display usage information
|
325 |
+
console_print(id, "Usage: amx_msglog <command> [argument]")
|
326 |
+
console_print(id, "Valid commands are: ")
|
327 |
+
|
328 |
+
console_print(id, " start [msg name or id] - Starts logging given message or all if no argument")
|
329 |
+
console_print(id, " stop [msg name or id] - Stops logging given message or all if no argument")
|
330 |
+
console_print(id, " list [page] - Displays list of messages and their logging status")
|
331 |
+
}
|
332 |
+
|
333 |
+
return PLUGIN_HANDLED
|
334 |
+
}
|
335 |
+
|
336 |
+
/* Forward for hooked messages */
|
337 |
+
public message_forward(msgid, msgDest, msgEnt) {
|
338 |
+
if (!g_msgLogging[msgid]) return PLUGIN_CONTINUE
|
339 |
+
|
340 |
+
new entFilter = get_pcvar_num(g_cvarFilter)
|
341 |
+
|
342 |
+
/* If value of amx_ml_filter isn't a valid entity index (0 is accepted in order to log ALL)
|
343 |
+
Then stop all logging */
|
344 |
+
if (entFilter != 0 && !pev_valid(entFilter)) {
|
345 |
+
set_msglog_status(0, MSGLOG_STOPPED)
|
346 |
+
|
347 |
+
log_msgf("Logging stopped for all messages because entity index ^"%d^" is not valid", entFilter)
|
348 |
+
return PLUGIN_CONTINUE
|
349 |
+
}
|
350 |
+
|
351 |
+
// If not filtering by entity and the receiver entity doesn't match the filter, don't log message
|
352 |
+
if (entFilter != 0 && msgEnt != 0 && msgEnt != entFilter)
|
353 |
+
return PLUGIN_CONTINUE
|
354 |
+
|
355 |
+
new msgname[32], id[4], argcount, dest[15], Float:msgOrigin[3], entStr[7], entClassname[32], entNetname[32]
|
356 |
+
|
357 |
+
// Get message name
|
358 |
+
copy(msgname, 31, g_msgCache[msgid])
|
359 |
+
|
360 |
+
// If message has no name, then set the name to message ID
|
361 |
+
if (!msgname[0])
|
362 |
+
{
|
363 |
+
num_to_str(msgid, id, 3)
|
364 |
+
copy(msgname, 31, id)
|
365 |
+
}
|
366 |
+
|
367 |
+
// Get number of message arguments
|
368 |
+
argcount = get_msg_args()
|
369 |
+
|
370 |
+
// Determine the destination of the message
|
371 |
+
switch (msgDest) {
|
372 |
+
case MSG_BROADCAST:
|
373 |
+
copy(dest, 9, "Broadcast")
|
374 |
+
case MSG_ONE:
|
375 |
+
copy(dest, 3, "One")
|
376 |
+
case MSG_ALL:
|
377 |
+
copy(dest, 3, "All")
|
378 |
+
case MSG_INIT:
|
379 |
+
copy(dest, 4, "Init")
|
380 |
+
case MSG_PVS:
|
381 |
+
copy(dest, 3, "PVS")
|
382 |
+
case MSG_PAS:
|
383 |
+
copy(dest, 3, "PAS")
|
384 |
+
case MSG_PVS_R:
|
385 |
+
copy(dest, 12, "PVS Reliable")
|
386 |
+
case MSG_PAS_R:
|
387 |
+
copy(dest, 12, "PAS Reliable")
|
388 |
+
case MSG_ONE_UNRELIABLE:
|
389 |
+
copy(dest, 14, "One Unreliable")
|
390 |
+
case MSG_SPEC:
|
391 |
+
copy(dest, 4, "Spec")
|
392 |
+
default:
|
393 |
+
copy(dest, 7, "Unknown")
|
394 |
+
}
|
395 |
+
|
396 |
+
// Get the origin of the message (only truly valid for PVS through PAS_R)
|
397 |
+
get_msg_origin(msgOrigin)
|
398 |
+
|
399 |
+
// Get the receiving entity's classname and netname
|
400 |
+
if (msgEnt != 0) {
|
401 |
+
num_to_str(msgEnt, entStr, 6)
|
402 |
+
pev(msgEnt, pev_classname, entClassname, 31)
|
403 |
+
pev(msgEnt, pev_netname, entNetname, 31)
|
404 |
+
|
405 |
+
if (!entNetname[0])
|
406 |
+
copy(entNetname, 31, NULL_STR)
|
407 |
+
} else {
|
408 |
+
copy(entStr, 6, NULL_STR)
|
409 |
+
copy(entClassname, 6, NULL_STR)
|
410 |
+
copy(entNetname, 6, NULL_STR)
|
411 |
+
}
|
412 |
+
|
413 |
+
// Log message information (MessageBegin)
|
414 |
+
log_msgf("MessageBegin (%s ^"%d^") (Destination ^"%s<%d>^") (Args ^"%d^") (Entity ^"%s^") (Classname ^"%s^") (Netname ^"%s^") (Origin ^"%f %f %f^")",
|
415 |
+
msgname, msgid, dest, msgDest, argcount, entStr, entClassname, entNetname, msgOrigin[0], msgOrigin[1], msgOrigin[2])
|
416 |
+
|
417 |
+
static str[256]
|
418 |
+
|
419 |
+
// Log all argument data
|
420 |
+
if (argcount > 0)
|
421 |
+
{
|
422 |
+
for (new i = 1; i <= argcount; i++) {
|
423 |
+
switch (get_msg_argtype(i)) {
|
424 |
+
case ARG_BYTE:
|
425 |
+
log_msgf("Arg %d (Byte ^"%d^")", i, get_msg_arg_int(i))
|
426 |
+
case ARG_CHAR:
|
427 |
+
log_msgf("Arg %d (Char ^"%d^")", i, get_msg_arg_int(i))
|
428 |
+
case ARG_SHORT:
|
429 |
+
log_msgf("Arg %d (Short ^"%d^")", i, get_msg_arg_int(i))
|
430 |
+
case ARG_LONG:
|
431 |
+
log_msgf("Arg %d (Long ^"%d^")", i, get_msg_arg_int(i))
|
432 |
+
case ARG_ANGLE:
|
433 |
+
log_msgf("Arg %d (Angle ^"%f^")", i, get_msg_arg_float(i))
|
434 |
+
case ARG_COORD:
|
435 |
+
log_msgf("Arg %d (Coord ^"%f^")", i, get_msg_arg_float(i))
|
436 |
+
case ARG_STRING:
|
437 |
+
{
|
438 |
+
get_msg_arg_string(i, str, 255)
|
439 |
+
|
440 |
+
replace_all(str, 254, "^t", "^^t")
|
441 |
+
replace_all(str, 254, "^n", "^^n")
|
442 |
+
replace_all(str, 254, "%", "%%")
|
443 |
+
|
444 |
+
log_msgf("Arg %d (String ^"%s^")", i, str)
|
445 |
+
}
|
446 |
+
case ARG_ENTITY:
|
447 |
+
log_msgf("Arg %d (Entity ^"%d^")", i, get_msg_arg_int(i))
|
448 |
+
default:
|
449 |
+
log_msgf("Arg %d (Unknown ^"%d^")", i, get_msg_arg_int(i))
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
else
|
454 |
+
{
|
455 |
+
log_msgf("Message contains no arguments")
|
456 |
+
}
|
457 |
+
|
458 |
+
// Log that the message ended (MessageEnd)
|
459 |
+
log_msgf("MessageEnd (%s ^"%d^")", msgname, msgid)
|
460 |
+
|
461 |
+
return PLUGIN_CONTINUE
|
462 |
+
}
|
463 |
+
|
464 |
+
/***************** Other Functions *****************/
|
465 |
+
|
466 |
+
/* Fills g_msgCache with message names for faster look up
|
467 |
+
Return value: Number of messages that are valid */
|
468 |
+
generate_msg_table() {
|
469 |
+
for (new i = MAX_ENGINE_MESSAGES + 1; i <= MAX_POSSIBLE_MESSAGES; i++)
|
470 |
+
{
|
471 |
+
// Store the message name in the cache for faster lookup
|
472 |
+
if (!get_user_msgname(i, g_msgCache[i], 31))
|
473 |
+
return i - 1
|
474 |
+
}
|
475 |
+
|
476 |
+
return MAX_POSSIBLE_MESSAGES
|
477 |
+
}
|
478 |
+
|
479 |
+
/* Returns true if msgid is a valid message */
|
480 |
+
bool:is_msg_valid(msgid)
|
481 |
+
{
|
482 |
+
return (msgid > 0 && msgid <= g_maxMessages)
|
483 |
+
}
|
484 |
+
|
485 |
+
/* Returns message ID from string */
|
486 |
+
str_to_msgid(const str[]) {
|
487 |
+
new n = str_to_num(str)
|
488 |
+
|
489 |
+
if (n <= 0 )
|
490 |
+
return get_user_msgid(str)
|
491 |
+
|
492 |
+
return n
|
493 |
+
}
|
494 |
+
|
495 |
+
/* Gets logging status of message */
|
496 |
+
get_msglog_status(msgid)
|
497 |
+
{
|
498 |
+
return g_msgLogging[msgid] ? MSGLOG_STARTED : MSGLOG_STOPPED
|
499 |
+
}
|
500 |
+
|
501 |
+
/* Sets logging status of message
|
502 |
+
If msgid = 0, status will be applied to all messages */
|
503 |
+
set_msglog_status(msgid, status)
|
504 |
+
{
|
505 |
+
if (msgid > 0) // Individual message
|
506 |
+
{
|
507 |
+
g_msgLogging[msgid] = (status == MSGLOG_STARTED)
|
508 |
+
if (!g_msgRegistered[msgid])
|
509 |
+
{
|
510 |
+
register_message(msgid, "message_forward")
|
511 |
+
g_msgRegistered[msgid] = true
|
512 |
+
}
|
513 |
+
|
514 |
+
}
|
515 |
+
else // ALL messages
|
516 |
+
{
|
517 |
+
for (new i = 1; i <= g_maxMessages; i++)
|
518 |
+
{
|
519 |
+
g_msgLogging[i] = (status == MSGLOG_STARTED)
|
520 |
+
if (status == MSGLOG_STARTED)
|
521 |
+
{
|
522 |
+
if (!g_msgRegistered[i])
|
523 |
+
{
|
524 |
+
register_message(i, "message_forward")
|
525 |
+
g_msgRegistered[i] = true
|
526 |
+
}
|
527 |
+
}
|
528 |
+
}
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
/* Writes messages to log file depending on value of amx_ml_logmode */
|
533 |
+
log_msgf(const fmt[], {Float,Sql,Result,_}:...)
|
534 |
+
{
|
535 |
+
static buffer[512]
|
536 |
+
vformat(buffer, 511, fmt, 2)
|
537 |
+
|
538 |
+
if (get_pcvar_num(g_cvarLogMode))
|
539 |
+
log_to_file(LOGFILE_NAME, buffer)
|
540 |
+
else
|
541 |
+
log_amx(buffer)
|
542 |
+
}
|
543 |
+
|
Fake Forwards.txt
ADDED
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Your plugin has many forwards?
|
2 |
+
with this example you can create forward like register_forward of fakemeta module.
|
3 |
+
I know that other way is CreateMultiForward but this can be a another option.
|
4 |
+
|
5 |
+
PHP Code:
|
6 |
+
#include <amxmodx>
|
7 |
+
|
8 |
+
enum
|
9 |
+
{
|
10 |
+
Fake_Connect = 0,
|
11 |
+
Fake_Disconnect,
|
12 |
+
Fake_ChangeName,
|
13 |
+
Fake_PutInServer
|
14 |
+
}
|
15 |
+
|
16 |
+
new Array:g_fakeforwards_type
|
17 |
+
new Array:g_fakeforwards_num
|
18 |
+
|
19 |
+
public plugin_precache()
|
20 |
+
{
|
21 |
+
register_plugin("Fake Forwards", "1.0", "ReymonARG")
|
22 |
+
|
23 |
+
g_fakeforwards_num = ArrayCreate(1, 1)
|
24 |
+
g_fakeforwards_type = ArrayCreate(1, 1)
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
// We need to register the call for the forwards
|
29 |
+
public plugin_natives()
|
30 |
+
{
|
31 |
+
// Librery
|
32 |
+
register_library("fake_forwards")
|
33 |
+
|
34 |
+
// Natives
|
35 |
+
register_native("register_fakeforward", "_register_event")
|
36 |
+
register_native("unregister_fakeforward", "_unregister_event")
|
37 |
+
}
|
38 |
+
|
39 |
+
public _register_event(plugin, params)
|
40 |
+
{
|
41 |
+
// Are correct the params? return
|
42 |
+
if( params != 2 )
|
43 |
+
return -1
|
44 |
+
|
45 |
+
static type, g_callout[33], forwards_num
|
46 |
+
type = get_param(1)
|
47 |
+
get_string(2, g_callout, 32)
|
48 |
+
|
49 |
+
// Here We create the Forward.
|
50 |
+
switch( type )
|
51 |
+
{
|
52 |
+
// So some forwards have diferent out, so we need this to create diferent styles.
|
53 |
+
case Fake_Connect: forwards_num = CreateOneForward(plugin, g_callout, FP_CELL)
|
54 |
+
case Fake_Disconnect : forwards_num = CreateOneForward(plugin, g_callout, FP_CELL)
|
55 |
+
case Fake_ChangeName : forwards_num = CreateOneForward(plugin, g_callout, FP_CELL, FP_STRING)
|
56 |
+
case Fake_PutInServer : forwards_num = CreateOneForward(plugin, g_callout, FP_CELL)
|
57 |
+
default: return -1
|
58 |
+
}
|
59 |
+
|
60 |
+
// Can create the forward? Return.
|
61 |
+
if( forwards_num == -1 )
|
62 |
+
return -1
|
63 |
+
|
64 |
+
// Save the type of the forward and the num.
|
65 |
+
ArrayPushCell(g_fakeforwards_type, type)
|
66 |
+
ArrayPushCell(g_fakeforwards_num, forwards_num)
|
67 |
+
|
68 |
+
return forwards_num
|
69 |
+
}
|
70 |
+
|
71 |
+
// Well i think that this dont is good, But i will try to better this part.
|
72 |
+
public _unregister_event(plugin, params)
|
73 |
+
{
|
74 |
+
// Its param = 1 ? return.
|
75 |
+
if( params != 1 )
|
76 |
+
return -1
|
77 |
+
|
78 |
+
static i, fwd_id
|
79 |
+
fwd_id = get_param(1)
|
80 |
+
|
81 |
+
// Found the forward and delete.
|
82 |
+
for( i = 0; i < ArraySize( g_fakeforwards_num ); i++)
|
83 |
+
{
|
84 |
+
if( ArrayGetCell(g_fakeforwards_num, i) == fwd_id )
|
85 |
+
{
|
86 |
+
// Delete forward
|
87 |
+
DestroyForward(fwd_id)
|
88 |
+
|
89 |
+
// And items.
|
90 |
+
ArrayDeleteItem(g_fakeforwards_type, i)
|
91 |
+
ArrayDeleteItem(g_fakeforwards_num, i)
|
92 |
+
|
93 |
+
return 1
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
return 0
|
98 |
+
}
|
99 |
+
|
100 |
+
public client_connect(id)
|
101 |
+
{
|
102 |
+
static i, null_id
|
103 |
+
|
104 |
+
// Well this is the mechanism to exec the forwards.
|
105 |
+
for( i = 0; i < ArraySize( g_fakeforwards_num ); i++)
|
106 |
+
{
|
107 |
+
// If item type is Fake_Connect ?
|
108 |
+
if( ArrayGetCell(g_fakeforwards_type, i) == Fake_Connect )
|
109 |
+
{
|
110 |
+
// Exec the forward.
|
111 |
+
ExecuteForward(ArrayGetCell(g_fakeforwards_num, i), null_id, id)
|
112 |
+
}
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
public client_disconnect(id)
|
117 |
+
{
|
118 |
+
static i, null_id
|
119 |
+
for( i = 0; i < ArraySize( g_fakeforwards_num ); i++)
|
120 |
+
{
|
121 |
+
if( ArrayGetCell(g_fakeforwards_type, i) == Fake_Disconnect )
|
122 |
+
{
|
123 |
+
ExecuteForward(ArrayGetCell(g_fakeforwards_num, i), null_id, id)
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
public client_infochanged(id)
|
129 |
+
{
|
130 |
+
static oldname[32], newname[32], i, null_id
|
131 |
+
get_user_name(id, oldname, 31)
|
132 |
+
get_user_info(id, "name", newname, 31)
|
133 |
+
|
134 |
+
if( !equal(oldname, newname) )
|
135 |
+
{
|
136 |
+
for( i = 0; i < ArraySize( g_fakeforwards_num ); i++)
|
137 |
+
{
|
138 |
+
if( ArrayGetCell(g_fakeforwards_type, i) == Fake_ChangeName )
|
139 |
+
{
|
140 |
+
ExecuteForward(ArrayGetCell(g_fakeforwards_num, i), null_id, id, newname)
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
public client_putinserver(id)
|
147 |
+
{
|
148 |
+
static i, null_id
|
149 |
+
for( i = 0; i < ArraySize( g_fakeforwards_num ); i++)
|
150 |
+
{
|
151 |
+
if( ArrayGetCell(g_fakeforwards_type, i) == Fake_PutInServer )
|
152 |
+
{
|
153 |
+
ExecuteForward(ArrayGetCell(g_fakeforwards_num, i), null_id, id)
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
And Example for recibe the forwards.
|
158 |
+
|
159 |
+
PHP Code:
|
160 |
+
#include <amxmodx>
|
161 |
+
|
162 |
+
#pragma library fake_forwards
|
163 |
+
|
164 |
+
enum Fake_Forwards
|
165 |
+
{
|
166 |
+
Fake_Connect = 0,
|
167 |
+
Fake_Disconnect,
|
168 |
+
Fake_ChangeName,
|
169 |
+
Fake_PutInServer
|
170 |
+
}
|
171 |
+
|
172 |
+
native register_fakeforward(Fake_Forwards:type, const out[])
|
173 |
+
native unregister_fakeforward(fwd_id)
|
174 |
+
|
175 |
+
public plugin_init()
|
176 |
+
{
|
177 |
+
register_plugin("Forward Recive", "1.0", "ReymonARG")
|
178 |
+
|
179 |
+
register_fakeforward(Fake_Connect, "fw_client_connect")
|
180 |
+
register_fakeforward(Fake_Disconnect, "fw_client_disconnect")
|
181 |
+
register_fakeforward(Fake_ChangeName, "fw_client_changename")
|
182 |
+
register_fakeforward(Fake_PutInServer, "fw_client_putinserver")
|
183 |
+
}
|
184 |
+
|
185 |
+
public fw_client_connect(id)
|
186 |
+
{
|
187 |
+
server_print("Client %d Connecting", id)
|
188 |
+
}
|
189 |
+
|
190 |
+
public fw_client_disconnect(id)
|
191 |
+
{
|
192 |
+
server_print("Client %d Disconnect", id)
|
193 |
+
}
|
194 |
+
|
195 |
+
public fw_client_changename(id, const newname[])
|
196 |
+
{
|
197 |
+
server_print("Client %d Change name to %s", id, newname)
|
198 |
+
}
|
199 |
+
|
200 |
+
public fw_client_putinserver(id)
|
201 |
+
{
|
202 |
+
server_print("Client %d Connect", id)
|
203 |
+
}
|
Finding Entities.txt
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Introduction
|
2 |
+
It is sometimes necessary to find an entity in the world for some reason. For example, you may need to find a button in the world, and then remove it (this example will be covered later). This article will explain how to do so.
|
3 |
+
|
4 |
+
Functions
|
5 |
+
There are a number of functions built into AMX Mod X / AMXX Modules that allow you to find entities. For a complete list, please consult this page: http://www.amxmodx.org/funcwiki.php?search=find_ent&go=search
|
6 |
+
|
7 |
+
(As of last edit, these are the functions included):
|
8 |
+
|
9 |
+
find_ent_by_class
|
10 |
+
find_ent_by_model
|
11 |
+
find_ent_by_owner
|
12 |
+
find_ent_by_target
|
13 |
+
find_ent_by_tname
|
14 |
+
find_ent_in_sphere
|
15 |
+
find_sphere_class
|
16 |
+
find_ent_by_class
|
17 |
+
<Function is included in Engine>
|
18 |
+
|
19 |
+
This function allows you to find an entity based on it's classname. All entities have classnames. For example, a player's classname is "player", while a button is either "func_button" or "func_rot_button".
|
20 |
+
|
21 |
+
To find an entity using this, one would simply use the following:
|
22 |
+
|
23 |
+
find_ent_by_class(-1,"classname_to_find");
|
24 |
+
Note : Index is -1 because that's the invalid entity index. We start from the invalid one so we can get all the entities, if you start from a different index, all entities with a lower index will be ignored.
|
25 |
+
|
26 |
+
find_ent_by_model
|
27 |
+
<Function is included in Engine>
|
28 |
+
|
29 |
+
This function can be used to find an entity based on its model. Some entities do not have models, meaning they cannot be found using this method. Also, it is, most of the time, better to use another type of ent finding, as this can be highly inaccurate and be broken by something as simple as a model changing plugin. This function also takes into account the class name, and is generally used more for isolating a certain model from a set of classnames (ex you have 3 grenades, with different models, and want to find 1 of them)
|
30 |
+
|
31 |
+
To find an entity using this, one would use the following:
|
32 |
+
|
33 |
+
find_ent_by_model(-1,"classname_to_find","model_to_find")
|
34 |
+
find_ent_by_owner
|
35 |
+
<Function is included in Engine>
|
36 |
+
|
37 |
+
This function can be used to find an entity based on an owner. For example, if there is a player in the world, and you want to find if he has thrown a grenade out, you would use this and check for "grenade" entities that's owner is the player. Note: planted C4 (in CS) also have "grenade" classname.
|
38 |
+
|
39 |
+
To find an entity using this, one would use the following:
|
40 |
+
|
41 |
+
find_ent_by_owner(-1,"classname_to_find",owner_id,0);
|
42 |
+
Notice the last parameter. This is a mode to find in.
|
43 |
+
|
44 |
+
find_ent_by_target
|
45 |
+
<Function is included in Engine>
|
46 |
+
|
47 |
+
This function allows one to find an entity based on its target. This function also checks for classname.
|
48 |
+
|
49 |
+
To find an entity using this, one would use the following:
|
50 |
+
|
51 |
+
find_ent_by_target(-1,"classname_to_find");
|
52 |
+
find_ent_by_tname
|
53 |
+
<Function is included in Engine> This essentially functions the same as find_ent_by_target.
|
54 |
+
|
55 |
+
find_ent_in_sphere
|
56 |
+
<Function is included in Engine>
|
57 |
+
|
58 |
+
This function can be used to find an entity within a certain distance of another entity. This can be quite handy to, for example, see if a player is around another player, and then deal damage or slap that player. This is effectively a shortcut to using find_ent_by_class and get_distance(_f) together.
|
59 |
+
|
60 |
+
To find an entity using this, one would use the following:
|
61 |
+
|
62 |
+
find_ent_in_sphere(-1,location_of_ent_vector,radius_float);
|
63 |
+
find_sphere_class
|
64 |
+
This function is probably the most complex of all the find_ent functions. This allows you to find an entity inside a certain radius of another entity, with a certian classname. This is effectively a shortcut to using find_ent_by_class & get_distance & entity_get_string(ent,EV_SZ_classname... or find_ent_in_sphere & entity_get_string(ent,EV_SZ_classname...
|
65 |
+
|
66 |
+
To find an entity using this, one would use the following:
|
67 |
+
|
68 |
+
new entlist[513];
|
69 |
+
find_sphere_class(0,"classname_to_find",radius_float,entlist,512,origin_vector);
|
70 |
+
Also, note that origin_vector and the first parameter (_aroundent) should not both be specified. If _aroundent is specified as 0, origin_vector is used. If origin_vector is not specified, or is 0, then _aroundent is used.
|
71 |
+
|
72 |
+
Looping
|
73 |
+
If, for example, one wants to loop one of these, it is quite simple to do so.
|
74 |
+
|
75 |
+
Example:
|
76 |
+
|
77 |
+
while((ent = find_ent_by_class(ent,"classname_to_find")) != 0)
|
78 |
+
{
|
79 |
+
// do whatever
|
80 |
+
}
|
81 |
+
This will find every entity with classname "classname_to_find" and then execute the "// do whatever" code every time it finds one.
|
82 |
+
|
Half-Life 1 Events, Registering, Using, Reaing.txt
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Introduction
|
2 |
+
|
3 |
+
This tutorial will cover the correct ways to register, use, and read events. It is written to address beginners new to PAWN language. So lets begin:
|
4 |
+
|
5 |
+
Part 1: Registering Events
|
6 |
+
|
7 |
+
Registering events is quite easy. Just use register_event in the plugin_init() function to make that event usable in your code.
|
8 |
+
|
9 |
+
|
10 |
+
e.x.:
|
11 |
+
|
12 |
+
Code:
|
13 |
+
#include <amxmodx>
|
14 |
+
#include <amxmisc>
|
15 |
+
|
16 |
+
public plugin_init() {
|
17 |
+
register_plugin("Events", "1.0", "Rolnaaba")
|
18 |
+
register_event("DeathMsg", "Death", "a", "3!0")
|
19 |
+
}
|
20 |
+
when using register_event the first parameter is the event to be registered (which in this case is the “DeathMsg” event, which is called whenever anyone dies) the second is the function to be called when this even happens (which in this case is “Death”), the third parameter are the flags (which in this case is flag “a” (global event), for more information on flags check your amxmodx.inc), the fourth parameter are the restrictions. In this case the restrictions are as follows: the 3 argument (which is whether the killshot was a headshot or not), Cannot (“!”) equal “0”. (this means the kill shot must be a headshot for the function to be called upon)
|
21 |
+
Here is the code from amxmodx.inc concerning register_event:
|
22 |
+
Code:
|
23 |
+
/* Registers event on which a given function will be called
|
24 |
+
* Flags:
|
25 |
+
* "a" - global event.
|
26 |
+
* "b" - specified.
|
27 |
+
* "c" - send only once when repeated to other players.
|
28 |
+
* "d" - call if is send to dead player.
|
29 |
+
* "e" - to alive.
|
30 |
+
* Examples for conditions:
|
31 |
+
* "2=c4" - 2nd parameter of message must be sting "c4".
|
32 |
+
* "3>10" - 3rd parameter must be greater then 10.
|
33 |
+
* "3!4" - 3rd must be different from 4.
|
34 |
+
* "2&Buy" - 2nd parameter of message must contain "Buy" substring.
|
35 |
+
* "2!Buy" - 2nd parameter of message can't contain "Buy" substring. */
|
36 |
+
native register_event(const event[],const function[],const flags[],cond[]="", ... );
|
37 |
+
Part 2: Using Events
|
38 |
+
|
39 |
+
Using an event is even easier than calling it. All you do is register the event you wish to use then on the function you set, then execute what you wish to do.
|
40 |
+
Lets say you want to create a chat message (sent to everybody on the server) that says “someone has died by a headshot”
|
41 |
+
|
42 |
+
e.x.:
|
43 |
+
|
44 |
+
Code:
|
45 |
+
#include <amxmodx>
|
46 |
+
#include <amxmisc>
|
47 |
+
|
48 |
+
public plugin_init() {
|
49 |
+
register_plugin("Events", "1.0", "Rolnaaba")
|
50 |
+
register_event("DeathMsg", "Death", "a", "3!0")
|
51 |
+
}
|
52 |
+
|
53 |
+
public Death() {
|
54 |
+
client_print(0, print_chat, “Someone has died by a headshot”)
|
55 |
+
}
|
56 |
+
|
57 |
+
Part 3: reading the data that event collect
|
58 |
+
|
59 |
+
Most events have special data that is collected when that event occurs in game. Lets use the “DeathMsg” event as an example. This event is called whenever someone dies. The data it collects is as follows: (1) The Killer’s ID, (2) The Victim’s ID, (3) Was Kill A Headshot or Not, (4) Weapon Name that issued the Kill. (check out “HL1 Events and their data” in the Helpful Links Section at the beginning of this tutorial for more information on all events and their data). This means we can use the read_data function to get this data.
|
60 |
+
e.x.:
|
61 |
+
|
62 |
+
Code:
|
63 |
+
#include <amxmodx>
|
64 |
+
#include <amxmisc>
|
65 |
+
|
66 |
+
public plugin_init() {
|
67 |
+
register_plugin("Events", "1.0", "Rolnaaba")
|
68 |
+
register_event("DeathMsg", "Death", "a", “3!0”)
|
69 |
+
}
|
70 |
+
|
71 |
+
public Death() {
|
72 |
+
new victim = read_data(2)
|
73 |
+
client_print(victim, print_chat, “You died by a headshot”)
|
74 |
+
}
|
75 |
+
This would get the ID of the person killed (new victim = read_data(2)) and print “You died by a headshot” in their chat, when the “DeathMsg” event is called. You use read_data(2) since Victim ID is the second pack of data collected during this event. If we had written:
|
76 |
+
|
77 |
+
Code:
|
78 |
+
#include <amxmodx>
|
79 |
+
#include <amxmisc>
|
80 |
+
|
81 |
+
public plugin_init() {
|
82 |
+
register_plugin("Events", "1.0", "Rolnaaba")
|
83 |
+
register_event("DeathMsg", "Death", "a", “3!0”)
|
84 |
+
}
|
85 |
+
|
86 |
+
public Death() {
|
87 |
+
new victim = read_data(1)
|
88 |
+
client_print(victim, print_chat, “You died by a headshot”)
|
89 |
+
}
|
90 |
+
This would have printed “You died by a headshot” in the chat of the killer’s screen since we used read_data(1) to read the first pack of data, which in this event is the killers ID, and not read_data(2) (the victims ID).
|
Half-Life 1 List of Events.txt
ADDED
@@ -0,0 +1,1947 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Introduction
|
2 |
+
In AMX Mod X you are able to hook in-game messages/events with register_message / register_event. Here are the list of messages/events and their arguments which can be read with get_msg_arg_* / read_data.
|
3 |
+
|
4 |
+
|
5 |
+
See the Advanced Scripting article for more on events and messages.
|
6 |
+
See messages.inc and message_const.inc from amxmodx/scriptong/include folder or Messaging functions and Message constants for full messages control including blocking, argument alteration and much more.
|
7 |
+
Type meta game in the server console to list messages for the current mod.
|
8 |
+
Damaged Soul's Message Logging plugin for AMX Mod X can be used to log messages and their parameters on a live server.
|
9 |
+
|
10 |
+
|
11 |
+
ADStop
|
12 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
13 |
+
|
14 |
+
Note: No Information is available for this message.
|
15 |
+
Note: This message has no arguments.
|
16 |
+
|
17 |
+
Name: ADStop
|
18 |
+
Structure:
|
19 |
+
|
20 |
+
|
21 |
+
AlienInfo
|
22 |
+
Supported Mods: Natural Selection
|
23 |
+
|
24 |
+
Note: No Information is available for this message.
|
25 |
+
|
26 |
+
AllowSpec
|
27 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Half-Life: Opposing Force • Team Fortress Classic
|
28 |
+
|
29 |
+
This message changes whether or not "SPECTATE" appears on the change team menu. It is sent whenever the allow_spectators CVar is changed, with its new value sent as the byte.
|
30 |
+
|
31 |
+
Note: This changes how the change team menu appears, but spectating functionality is based on the actual CVar value.
|
32 |
+
|
33 |
+
Name: AllowSpec
|
34 |
+
Structure:
|
35 |
+
byte Allowed
|
36 |
+
|
37 |
+
|
38 |
+
AmmoPickup
|
39 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
40 |
+
|
41 |
+
This message temporarily draws HUD numerical ammo amount and corresponding ammo HUD icon in the middle of the right side of the screen.
|
42 |
+
|
43 |
+
Note: Draw time depends on the hud_drawhistory_time client CVar value.
|
44 |
+
Note: See CS Weapons Information for more information.
|
45 |
+
|
46 |
+
Name: AmmoPickup
|
47 |
+
Structure:
|
48 |
+
byte AmmoID
|
49 |
+
byte Ammount
|
50 |
+
|
51 |
+
|
52 |
+
AmmoShort
|
53 |
+
Supported Mods: Day of Defeat
|
54 |
+
|
55 |
+
Note: No Information is available for this message.
|
56 |
+
|
57 |
+
AmmoX
|
58 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
59 |
+
|
60 |
+
This message updates the green bar indicator in the HUD weapons list. It also updates HUD backpack ammo number in the lower right corner of the screen if the given ammo type is compatible with the current weapon.
|
61 |
+
|
62 |
+
Note: See CS Weapons Information for more information.
|
63 |
+
|
64 |
+
Name: AmmoX
|
65 |
+
Structure:
|
66 |
+
byte AmmoID
|
67 |
+
byte Ammount
|
68 |
+
|
69 |
+
|
70 |
+
ArmorType
|
71 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
72 |
+
|
73 |
+
This message draws/removes the helmet HUD icon. If flag is set to 1, the helmet HUD icon will be drawn (located right on the armor icon).
|
74 |
+
|
75 |
+
Name: ArmorType
|
76 |
+
Structure:
|
77 |
+
byte Flag
|
78 |
+
|
79 |
+
|
80 |
+
BalanceVar
|
81 |
+
Supported Mods: Natural Selection
|
82 |
+
|
83 |
+
Note: No Information is available for this message.
|
84 |
+
|
85 |
+
BarTime
|
86 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
87 |
+
|
88 |
+
This message draws a HUD progress bar which is filled from 0% to 100% for the time Duration seconds. Once the bar is fully filled it will be removed from the screen automatically.
|
89 |
+
|
90 |
+
Note: Set Duration to 0 to hide the bar.
|
91 |
+
|
92 |
+
Name: BarTime
|
93 |
+
Structure:
|
94 |
+
short Duration
|
95 |
+
|
96 |
+
|
97 |
+
BarTime2
|
98 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
99 |
+
|
100 |
+
The message is the same as BarTime, but StartPercent specifies how much of the bar is (already) filled.
|
101 |
+
|
102 |
+
Note: Display time can be calculated with this formula: (1 - (StartPercent / 100)) / Duration
|
103 |
+
|
104 |
+
Name: BarTime2
|
105 |
+
Structure:
|
106 |
+
short Duration
|
107 |
+
short StartPercent
|
108 |
+
|
109 |
+
|
110 |
+
Battery
|
111 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
112 |
+
|
113 |
+
This message updates the icon and numerical armor value on the HUD.
|
114 |
+
|
115 |
+
Name: Battery
|
116 |
+
Structure:
|
117 |
+
short Armor
|
118 |
+
|
119 |
+
|
120 |
+
Bench
|
121 |
+
Supported Mods: Team Fortress Classic
|
122 |
+
|
123 |
+
Note: No Information is available for this message.
|
124 |
+
|
125 |
+
BlinkAcct
|
126 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
127 |
+
|
128 |
+
This message makes a player's money display flash rapidly, a total of BlinkAmt times.
|
129 |
+
|
130 |
+
Name: BlinkAcct
|
131 |
+
Structure:
|
132 |
+
byte BlinkAmt
|
133 |
+
|
134 |
+
|
135 |
+
BlipList
|
136 |
+
Supported Mods: Natural Selection
|
137 |
+
|
138 |
+
Note: No Information is available for this message.
|
139 |
+
|
140 |
+
BloodPuff
|
141 |
+
Supported Mods: Day of Defeat
|
142 |
+
|
143 |
+
This message creates a puff of blood at the specified coordinates.
|
144 |
+
|
145 |
+
|
146 |
+
|
147 |
+
Name: BloodPuff
|
148 |
+
Structure:
|
149 |
+
coord CoordX
|
150 |
+
coord CoordY
|
151 |
+
coord CoordZ
|
152 |
+
|
153 |
+
|
154 |
+
BombDrop
|
155 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
156 |
+
|
157 |
+
This message is sent when the bomb is dropped or planted by a player.
|
158 |
+
|
159 |
+
The first three arguments are the origin of the dropped bomb. The last argument is set to 0 if the bomb was dropped due to voluntary dropping or death/disconnect. It is set to 1 if the bomb was planted, which will trigger the round timer to hide. It also will show the dropped bomb on the Terrorist team's radar in the location specified by the first three arguments.
|
160 |
+
|
161 |
+
Name: BombDrop
|
162 |
+
Structure:
|
163 |
+
coord CoordX
|
164 |
+
coord CoordY
|
165 |
+
coord CoordZ
|
166 |
+
byte Flag
|
167 |
+
|
168 |
+
|
169 |
+
BombPickup
|
170 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
171 |
+
|
172 |
+
This message just tells the clients that the bomb has been picked up. It will cause the dropped bomb to disappear from the Terrorist team's radar.
|
173 |
+
|
174 |
+
Note: This message has no arguments.
|
175 |
+
|
176 |
+
Name: BombPickup
|
177 |
+
Structure:
|
178 |
+
|
179 |
+
|
180 |
+
BotProgress
|
181 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
182 |
+
|
183 |
+
This message is sent when CZ's bots are learning a new map. It displays a progress bar in the middle of the screen, with some header text. The bar doesn't move, and you can't do anything while the bar is displayed. This is a different style of progress bar than from the BarTime event. This really doesn't display well in CS.
|
184 |
+
|
185 |
+
Note: Flag can be 0 (update bar), 1 (create new bar), or 2 (remove bar). When using flag 0, send all arguments. When using flag 1, send only Flag and Header. When using flag 2, send only Flag.
|
186 |
+
|
187 |
+
Name: BotProgress
|
188 |
+
Structure:
|
189 |
+
byte Flag
|
190 |
+
byte Progress
|
191 |
+
string Header
|
192 |
+
|
193 |
+
|
194 |
+
BotVoice
|
195 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
196 |
+
|
197 |
+
This message displays (or hides) the voice icon above a user's head and the talking icon on the right side of the screen. This is called by CZ for bots; it's not called for regular players, although you can specify a regular player (non-bot) for the PlayerIndex. Status is 1 for talking, or 0 for not talking.
|
198 |
+
|
199 |
+
Name: BotVoice
|
200 |
+
Structure:
|
201 |
+
byte Status
|
202 |
+
byte PlayerIndex
|
203 |
+
|
204 |
+
|
205 |
+
Brass
|
206 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
207 |
+
|
208 |
+
This message creates a brass shell. Used, for example, by the AWP, after firing.
|
209 |
+
|
210 |
+
Name: Brass
|
211 |
+
Structure:
|
212 |
+
byte MessageID
|
213 |
+
coord StartX
|
214 |
+
coord StartY
|
215 |
+
coord StartZ
|
216 |
+
coord VelocityX?
|
217 |
+
coord VelocityY?
|
218 |
+
coord VelocityZ?
|
219 |
+
coord UnknownX
|
220 |
+
coord UnknownY
|
221 |
+
coord UnknownZ
|
222 |
+
angle Rotation
|
223 |
+
short ModelIndex
|
224 |
+
byte BounceSoundType
|
225 |
+
byte Life
|
226 |
+
byte PlayerID
|
227 |
+
|
228 |
+
|
229 |
+
BuildSt
|
230 |
+
Supported Mods: Team Fortress Classic
|
231 |
+
|
232 |
+
Note: No Information is available for this message.
|
233 |
+
|
234 |
+
BuyClose
|
235 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
236 |
+
|
237 |
+
This message forces the buy menu to close. This is not called when the player manually closes the buy menu; it's only called when the game forces them to do so (e.g. walking outside of the buy zone, getting killed, etcetera).
|
238 |
+
|
239 |
+
Note: This message has no arguments.
|
240 |
+
|
241 |
+
Name: BuyClose
|
242 |
+
Structure:
|
243 |
+
|
244 |
+
|
245 |
+
Camera
|
246 |
+
Supported Mods: Sven Co-op
|
247 |
+
|
248 |
+
Note: No Information is available for this message.
|
249 |
+
|
250 |
+
CameraMouse
|
251 |
+
Supported Mods: Sven Co-op
|
252 |
+
|
253 |
+
Note: No Information is available for this message.
|
254 |
+
|
255 |
+
CameraView
|
256 |
+
Supported Mods: Day of Defeat
|
257 |
+
|
258 |
+
Note: No Information is available for this message.
|
259 |
+
|
260 |
+
CancelProg
|
261 |
+
Supported Mods: Day of Defeat
|
262 |
+
|
263 |
+
Note: No Information is available for this message.
|
264 |
+
|
265 |
+
CapMsg
|
266 |
+
Supported Mods: Day of Defeat
|
267 |
+
|
268 |
+
This displays a message like "Player captured the Allied plaza for the Axis". An example PointName is POINT_CAEN_AXISPLAZA.
|
269 |
+
|
270 |
+
Name: CapMsg
|
271 |
+
Structure:
|
272 |
+
byte PlayerID
|
273 |
+
string PointName
|
274 |
+
byte TeamID
|
275 |
+
|
276 |
+
|
277 |
+
CbElec
|
278 |
+
Supported Mods: Sven Co-op
|
279 |
+
|
280 |
+
Note: No Information is available for this message.
|
281 |
+
|
282 |
+
ClanTimer
|
283 |
+
Supported Mods: Day of Defeat
|
284 |
+
|
285 |
+
Note: No Information is available for this message.
|
286 |
+
|
287 |
+
ClCorpse
|
288 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat
|
289 |
+
|
290 |
+
This message spawns a player's corpse. ModelName is the player's model name, for example: "leet". Delay is a delay before animation playback, which can be a negative value.
|
291 |
+
|
292 |
+
Note: Coord and Delay is multiplied by 128.
|
293 |
+
Note: In CS, argument #10 is always equal to 0.
|
294 |
+
|
295 |
+
See CS Team Constants for team indices constants list.
|
296 |
+
Name: ClCorpse
|
297 |
+
Structure:
|
298 |
+
string ModelName
|
299 |
+
long CoordX
|
300 |
+
long CoordY
|
301 |
+
long CoordZ
|
302 |
+
coord Angle0
|
303 |
+
coord Angle1
|
304 |
+
coord Angle2
|
305 |
+
long Delay
|
306 |
+
byte Sequence
|
307 |
+
byte ClassID?
|
308 |
+
byte TeamID
|
309 |
+
byte PlayerID
|
310 |
+
|
311 |
+
|
312 |
+
ClientAreas
|
313 |
+
Supported Mods: Day of Defeat
|
314 |
+
|
315 |
+
Note: No Information is available for this message.
|
316 |
+
|
317 |
+
ClScript
|
318 |
+
Supported Mods: Natural Selection
|
319 |
+
|
320 |
+
Note: No Information is available for this message.
|
321 |
+
|
322 |
+
Concuss
|
323 |
+
Supported Mods: Team Fortress Classic • Half-Life Deathmatch • Counter-Strike • Counter-Strike: Condition Zero
|
324 |
+
|
325 |
+
This message creates screen shake effect similar to the TFC concussion grenade effect.
|
326 |
+
|
327 |
+
Note: In all mods except TFC, this message requires to be registered by using EngFunc_RegUserMsg.
|
328 |
+
|
329 |
+
Name: Concuss
|
330 |
+
Structure:
|
331 |
+
byte amount
|
332 |
+
|
333 |
+
|
334 |
+
Countdown
|
335 |
+
Supported Mods: Natural Selection
|
336 |
+
|
337 |
+
Note: No Information is available for this message.
|
338 |
+
|
339 |
+
CreateBlood
|
340 |
+
Supported Mods: Sven Co-op
|
341 |
+
|
342 |
+
Note: No Information is available for this message.
|
343 |
+
|
344 |
+
Crosshair
|
345 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
346 |
+
|
347 |
+
This message draws/removes a crosshair. If Flag is set to 1 the crosshair will be drawn.
|
348 |
+
|
349 |
+
Note: This crosshair looks not like the regular one, but like the one that is drawn in spectator mode.
|
350 |
+
|
351 |
+
Name: Crosshair
|
352 |
+
Structure:
|
353 |
+
byte Flag
|
354 |
+
|
355 |
+
|
356 |
+
CTFScore
|
357 |
+
Supported Mods: Half-Life: Opposing Force
|
358 |
+
|
359 |
+
Note: No Information is available for this message.
|
360 |
+
|
361 |
+
CurMarker
|
362 |
+
Supported Mods: Day of Defeat
|
363 |
+
|
364 |
+
Note: No Information is available for this message.
|
365 |
+
|
366 |
+
CurWeapon
|
367 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
368 |
+
|
369 |
+
This message updates the numerical magazine ammo count and the corresponding ammo type icon on the HUD.
|
370 |
+
|
371 |
+
Note: See CS Weapons Information for more information on Counter-Strike weapons.
|
372 |
+
|
373 |
+
Name: CurWeapon
|
374 |
+
Structure:
|
375 |
+
byte IsActive
|
376 |
+
byte WeaponID
|
377 |
+
byte ClipAmmo
|
378 |
+
|
379 |
+
|
380 |
+
CustomIcon
|
381 |
+
Supported Mods: Half-Life: Opposing Force
|
382 |
+
|
383 |
+
Note: No Information is available for this message.
|
384 |
+
|
385 |
+
CZCareer
|
386 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
387 |
+
|
388 |
+
This message supplies certain updates to the player regarding Condition Zero single-player missions.
|
389 |
+
|
390 |
+
Note: See the CZCareer page for more information.
|
391 |
+
Note: Using an invalid type has no repercussions whatsoever. Therefore, you can use this to make your own custom communications (you can send any number of arguments of any type after the first string).
|
392 |
+
Note: The Type argument is case-sensitive.
|
393 |
+
Note: This event does nothing in CS and CZ multiplayer.
|
394 |
+
|
395 |
+
Name: CZCareer
|
396 |
+
Structure:
|
397 |
+
string Type
|
398 |
+
* Parameters
|
399 |
+
|
400 |
+
|
401 |
+
CZCareerHUD
|
402 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
403 |
+
|
404 |
+
This message displays certain HUD elements regarding Condition Zero single-player missions.
|
405 |
+
|
406 |
+
Note: See the CZCareerHUD page for more information.
|
407 |
+
Note: Using an invalid type has no repercussions whatsoever. Therefore, you can use this to make your own custom communications (you can send any number of arguments of any type after the first string).
|
408 |
+
Note: The Type argument is case-sensitive.
|
409 |
+
Note: This event has some limited functionality in CS and CZ multi-player (albeit better in CZ).
|
410 |
+
|
411 |
+
Name: CZCareerHUD
|
412 |
+
Structure:
|
413 |
+
string Type
|
414 |
+
* Parameters
|
415 |
+
|
416 |
+
|
417 |
+
Damage
|
418 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
419 |
+
|
420 |
+
This message is sent when a player takes damage, to display the red locational indicators. The last three arguments are the origin of the damage inflicter or victim origin if inflicter isn't found. DamageType is a bitwise value which usually consists of a single bit.
|
421 |
+
|
422 |
+
Note: To capture this message, you should use "b" as the third parameter in the register_event() function.
|
423 |
+
|
424 |
+
Name: Damage
|
425 |
+
Structure:
|
426 |
+
byte DamageSave
|
427 |
+
byte DamageTake
|
428 |
+
long DamageType
|
429 |
+
coord CoordX
|
430 |
+
coord CoordY
|
431 |
+
coord CoordZ
|
432 |
+
|
433 |
+
|
434 |
+
DeathMsg
|
435 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
436 |
+
|
437 |
+
This event is fired to all players (MSG_ALL or MSG_BROADCAST) to notify them of a death. This generates the HUD message the client sees in the upper right corner of their screen.
|
438 |
+
It also prints the console text message "KillerName killed VictimName with TruncatedWeaponName" or "*** KillerName killed VictimName with a headshot from TruncatedWeaponName ***"
|
439 |
+
|
440 |
+
Note: This message has different parameters depending upon the mod.
|
441 |
+
Note: KillerID may not always be a Player ID. It would be 0 if a player died from fall/acid/radiation/fire/etc damage/lack of oxygen or from touch to a "trigger_hurt" entity, in which cases TruncatedWeaponName will be "worldspawn" and "trigger_hurt" respectively.
|
442 |
+
Note: For vehicle kills, TruncatedWeaponName could be "vehicle", "tank", etc.
|
443 |
+
Note: In some mods, TruncatedWeaponName is "teammate" for a team kill, which shows a green skull in the HUD message.
|
444 |
+
|
445 |
+
Name: DeathMsg
|
446 |
+
Structure:
|
447 |
+
byte KillerID
|
448 |
+
byte VictimID
|
449 |
+
string TruncatedWeaponName
|
450 |
+
|
451 |
+
|
452 |
+
Counter-Strike
|
453 |
+
Note: TruncatedWeaponName doesn't contain a "weapon_" prefix. See CS Weapons Information for more information.
|
454 |
+
Note: For a grenade kill, TruncatedWeaponName isn't "hegrenade", but rather "grenade", which is the actual classname of a thrown grenade.
|
455 |
+
|
456 |
+
Name: DeathMsg
|
457 |
+
Structure:
|
458 |
+
byte KillerID
|
459 |
+
byte VictimID
|
460 |
+
byte IsHeadshot
|
461 |
+
string TruncatedWeaponName
|
462 |
+
|
463 |
+
|
464 |
+
Day of Defeat
|
465 |
+
Name: DeathMsg
|
466 |
+
Structure:
|
467 |
+
byte KillerID
|
468 |
+
byte VictimID
|
469 |
+
byte WeaponID
|
470 |
+
|
471 |
+
|
472 |
+
DebugCSP
|
473 |
+
Supported Mods: Natural Selection
|
474 |
+
|
475 |
+
Note: No Information is available for this message.
|
476 |
+
|
477 |
+
DelEntHier
|
478 |
+
Supported Mods: Natural Selection
|
479 |
+
|
480 |
+
Note: No Information is available for this message.
|
481 |
+
|
482 |
+
DelParts
|
483 |
+
Supported Mods: Natural Selection
|
484 |
+
|
485 |
+
Note: No Information is available for this message.
|
486 |
+
|
487 |
+
Detpack
|
488 |
+
Supported Mods: Team Fortress Classic
|
489 |
+
|
490 |
+
Note: No Information is available for this message.
|
491 |
+
|
492 |
+
EditPS
|
493 |
+
Supported Mods: Natural Selection
|
494 |
+
|
495 |
+
Note: No Information is available for this message.
|
496 |
+
|
497 |
+
EndRnd
|
498 |
+
Supported Mods: Ricochet
|
499 |
+
|
500 |
+
Note: No Information is available for this message.
|
501 |
+
|
502 |
+
EntHier
|
503 |
+
Supported Mods: Natural Selection
|
504 |
+
|
505 |
+
Note: No Information is available for this message.
|
506 |
+
|
507 |
+
Feign
|
508 |
+
Supported Mods: Team Fortress Classic
|
509 |
+
|
510 |
+
Note: No Information is available for this message.
|
511 |
+
|
512 |
+
FlagIcon
|
513 |
+
Supported Mods: Half-Life: Opposing Force
|
514 |
+
|
515 |
+
Note: No Information is available for this message.
|
516 |
+
|
517 |
+
FlagTimer
|
518 |
+
Supported Mods: Half-Life: Opposing Force
|
519 |
+
|
520 |
+
Note: No Information is available for this message.
|
521 |
+
|
522 |
+
FlashBat
|
523 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
524 |
+
|
525 |
+
This message updates the flashlight battery charge on the HUD.
|
526 |
+
|
527 |
+
Name: FlashBat
|
528 |
+
Structure:
|
529 |
+
byte ChargePercentage
|
530 |
+
|
531 |
+
|
532 |
+
Flashlight
|
533 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
534 |
+
|
535 |
+
This message updates the flashlight state and battery charge on the HUD. If Flag is set to 1 the flashlight HUD icon will be shown as active.
|
536 |
+
|
537 |
+
Name: Flashlight
|
538 |
+
Structure:
|
539 |
+
byte Flag
|
540 |
+
byte ChargePercent
|
541 |
+
|
542 |
+
|
543 |
+
Fog
|
544 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Natural Selection • Sven Co-op
|
545 |
+
|
546 |
+
Note: mp_Fog 1 for fog in Counter-Strike
|
547 |
+
|
548 |
+
Name: Fog
|
549 |
+
Structure:
|
550 |
+
byte FogValue
|
551 |
+
byte FogValue
|
552 |
+
byte Unknown
|
553 |
+
|
554 |
+
|
555 |
+
ForceCam
|
556 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
557 |
+
|
558 |
+
This message is sent whenever mp_forcecam or mp_forcechasecam are changed, with their new values passed. There is presumably a third CVar that this tracks, but which one is currently unknown. Note that this message doesn't actually change any of the spectating rules for the client.
|
559 |
+
|
560 |
+
Note: Even if mp_forcechasecam is set to 2, it is sent by this message as 1.
|
561 |
+
|
562 |
+
Name: ForceCam
|
563 |
+
Structure:
|
564 |
+
byte ForcecamValue
|
565 |
+
byte ForcechasecamValue
|
566 |
+
byte Unknown
|
567 |
+
|
568 |
+
|
569 |
+
Frags
|
570 |
+
Supported Mods: Day of Defeat
|
571 |
+
|
572 |
+
This message sets a player's kills, as seen on the scoreboard. This message is only sent for the killer.
|
573 |
+
|
574 |
+
Name: Frags
|
575 |
+
Structure:
|
576 |
+
byte PlayerID
|
577 |
+
short Kills
|
578 |
+
|
579 |
+
|
580 |
+
Frozen
|
581 |
+
Supported Mods: Ricochet
|
582 |
+
|
583 |
+
Note: No Information is available for this message.
|
584 |
+
|
585 |
+
GameMode
|
586 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
587 |
+
|
588 |
+
This message informs the client of the current game mode.
|
589 |
+
|
590 |
+
Name: GameMode
|
591 |
+
Structure:
|
592 |
+
byte Game mode
|
593 |
+
|
594 |
+
|
595 |
+
GameRules
|
596 |
+
Supported Mods: Day of Defeat
|
597 |
+
|
598 |
+
Note: No Information is available for this message.
|
599 |
+
|
600 |
+
GameStatus
|
601 |
+
Supported Mods: Natural Selection
|
602 |
+
|
603 |
+
Note: No Information is available for this message.
|
604 |
+
|
605 |
+
GameTitle
|
606 |
+
Supported Mods: Deathmatch Classic • Half-Life: Opposing Force • Half-Life Deathmatch
|
607 |
+
|
608 |
+
Display game title (gametitle) - 0 is No and 1 is Yes. If write_byte 1, then Half-Life will be displayed.
|
609 |
+
Note: This only works for Half-life
|
610 |
+
|
611 |
+
|
612 |
+
Name: GameTitle
|
613 |
+
Structure:
|
614 |
+
byte 0 or 1
|
615 |
+
|
616 |
+
|
617 |
+
GargSplash
|
618 |
+
Supported Mods: Sven Co-op
|
619 |
+
|
620 |
+
Note: No Information is available for this message.
|
621 |
+
|
622 |
+
Geiger
|
623 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
624 |
+
|
625 |
+
This message signals the client to notify the player of the radiation level through special sound signals. Distance is the distance to the hazard area.
|
626 |
+
|
627 |
+
Name: Geiger
|
628 |
+
Structure:
|
629 |
+
byte Distance
|
630 |
+
|
631 |
+
|
632 |
+
Gib
|
633 |
+
Supported Mods: Sven Co-op
|
634 |
+
|
635 |
+
Note: No Information is available for this message.
|
636 |
+
|
637 |
+
HandSignal
|
638 |
+
Supported Mods: Day of Defeat
|
639 |
+
|
640 |
+
Note: No Information is available for this message.
|
641 |
+
|
642 |
+
Health
|
643 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
644 |
+
|
645 |
+
This message updates the numerical health value on the HUD.
|
646 |
+
|
647 |
+
Name: Health
|
648 |
+
Structure:
|
649 |
+
byte Health
|
650 |
+
|
651 |
+
|
652 |
+
HideWeapon
|
653 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
654 |
+
|
655 |
+
This message hides the specified HUD elements.
|
656 |
+
Flags:
|
657 |
+
|
658 |
+
1 (1<<0) - crosshair, ammo, weapons list
|
659 |
+
2 (1<<1) - flashlight, +
|
660 |
+
4 (1<<2) - ALL
|
661 |
+
8 (1<<3) - radar, health, armor, +
|
662 |
+
16 (1<<4) - timer, +
|
663 |
+
32 (1<<5) - money, +
|
664 |
+
64 (1<<6) - crosshair
|
665 |
+
128 (1<<7) - +
|
666 |
+
Symbol + mean that an additional crosshair will be drawn. That crosshair looks exactly like the one from Crosshair message.
|
667 |
+
|
668 |
+
Name: HideWeapon
|
669 |
+
Structure:
|
670 |
+
byte Flags
|
671 |
+
|
672 |
+
|
673 |
+
HLTV
|
674 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat
|
675 |
+
|
676 |
+
This message is sent for HLTV and is unique for each round-start.
|
677 |
+
On new round is fired 2 messages:
|
678 |
+
|
679 |
+
// reset all players health for HLTV
|
680 |
+
MESSAGE_BEGIN( MSG_SPEC, gmsgHLTV );
|
681 |
+
WRITE_BYTE( 0 ); // 0 = all players
|
682 |
+
WRITE_BYTE( 100 | 128 );
|
683 |
+
MESSAGE_END();
|
684 |
+
|
685 |
+
// reset all players FOV for HLTV
|
686 |
+
MESSAGE_BEGIN( MSG_SPEC, gmsgHLTV );
|
687 |
+
WRITE_BYTE( 0 ); // all players
|
688 |
+
WRITE_BYTE( 0 );
|
689 |
+
MESSAGE_END();
|
690 |
+
Name: HLTV
|
691 |
+
Structure:
|
692 |
+
byte ClientID
|
693 |
+
byte Flags
|
694 |
+
|
695 |
+
|
696 |
+
HostageK
|
697 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
698 |
+
|
699 |
+
This message temporarily draws a blinking red dot on the CT players' radar when a hostage is killed.
|
700 |
+
|
701 |
+
Name: HostageK
|
702 |
+
Structure:
|
703 |
+
byte HostageID
|
704 |
+
|
705 |
+
|
706 |
+
HostagePos
|
707 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
708 |
+
|
709 |
+
This message draws/updates the blue mark on the CT players' radar which indicates the corresponding hostage's position.
|
710 |
+
|
711 |
+
Note: It is called with Flag set to 1 on player HUD full update.
|
712 |
+
|
713 |
+
Name: HostagePos
|
714 |
+
Structure:
|
715 |
+
byte Flag
|
716 |
+
byte HostageID
|
717 |
+
coord CoordX
|
718 |
+
coord CoordY
|
719 |
+
coord CoordZ
|
720 |
+
|
721 |
+
|
722 |
+
HudColor
|
723 |
+
Supported Mods: Half-Life: Opposing Force
|
724 |
+
|
725 |
+
This message sets HudColor. Set HUD color in RGB.
|
726 |
+
Note: This only works for OP4. Affects weapon pick-ups, health, armor, and ammo.
|
727 |
+
|
728 |
+
|
729 |
+
Name: HudColor
|
730 |
+
Structure:
|
731 |
+
byte 0-255 RED
|
732 |
+
byte 0-255 GRN
|
733 |
+
byte 0-255 BLU
|
734 |
+
|
735 |
+
|
736 |
+
HudText
|
737 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
738 |
+
|
739 |
+
This message prints HUD text.
|
740 |
+
|
741 |
+
Note: Prints message with specified style in titles.txt with small signs (like in HL)
|
742 |
+
|
743 |
+
Name: HudText
|
744 |
+
Structure:
|
745 |
+
string TextCode
|
746 |
+
byte InitHUDstyle
|
747 |
+
|
748 |
+
|
749 |
+
HudText2
|
750 |
+
Supported Mods: Natural Selection
|
751 |
+
|
752 |
+
Note: No Information is available for this message.
|
753 |
+
|
754 |
+
HudTextArgs
|
755 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
756 |
+
|
757 |
+
This message prints HUD text.
|
758 |
+
|
759 |
+
Note: An example of TextCode could be "#Hint_you_have_the_bomb".
|
760 |
+
Note: Prints message with specified style in titles.txt with Big signs (CS Default)
|
761 |
+
Note: If you have problems specifying the last two arguments, use 1 and 0 respectively.
|
762 |
+
|
763 |
+
Name: HudTextArgs
|
764 |
+
Structure:
|
765 |
+
string TextCode
|
766 |
+
byte InitHUDstyle
|
767 |
+
byte NumberOfSubMessages
|
768 |
+
string SubMsg
|
769 |
+
string SubMsg
|
770 |
+
string ...
|
771 |
+
|
772 |
+
|
773 |
+
HudTextPro
|
774 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
775 |
+
|
776 |
+
This message prints HUD text.
|
777 |
+
|
778 |
+
Note: Prints message with specified style in titles.txt with Big signs (CS Default)
|
779 |
+
|
780 |
+
Name: HudText
|
781 |
+
Structure:
|
782 |
+
string TextCode
|
783 |
+
byte InitHUDstyle
|
784 |
+
|
785 |
+
|
786 |
+
InitHUD
|
787 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
788 |
+
|
789 |
+
This message initializes the HUD.
|
790 |
+
|
791 |
+
Note: This message has no arguments.
|
792 |
+
|
793 |
+
Name: InitHUD
|
794 |
+
Structure:
|
795 |
+
|
796 |
+
|
797 |
+
InitObj
|
798 |
+
Supported Mods: Day of Defeat
|
799 |
+
|
800 |
+
This message updates the flags (axis/allies/objective flags, not programming flags) displayed to the client when a point is captured.
|
801 |
+
|
802 |
+
Name: InitObj
|
803 |
+
Structure:
|
804 |
+
byte TotalObjectives
|
805 |
+
Objective ...
|
806 |
+
...
|
807 |
+
|
808 |
+
|
809 |
+
TotalObjectives represents the number of Objective sub-messages that are present. Each Objective sub-message is in the following format:
|
810 |
+
|
811 |
+
Name: Objective
|
812 |
+
Structure:
|
813 |
+
short EntityID?
|
814 |
+
byte ObjectiveID?
|
815 |
+
byte TeamID
|
816 |
+
byte Unknown
|
817 |
+
byte Unknown
|
818 |
+
byte Unknown
|
819 |
+
byte Unknown
|
820 |
+
coord CoordX?
|
821 |
+
coord CoordY?
|
822 |
+
|
823 |
+
|
824 |
+
If a map has 5 objectives, this message will have 46 arguments (1 + 5 * 9).
|
825 |
+
|
826 |
+
IssueOrder
|
827 |
+
Supported Mods: Natural Selection
|
828 |
+
|
829 |
+
Note: No Information is available for this message.
|
830 |
+
|
831 |
+
ItemPickup
|
832 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
833 |
+
|
834 |
+
This message temporarily draws a corresponding item HUD icon in the middle of the right side of the screen.
|
835 |
+
|
836 |
+
Note: Draw time is dependent on the hud_drawhistory_time client CVar value.
|
837 |
+
|
838 |
+
Name: ItemPickup
|
839 |
+
Structure:
|
840 |
+
string ItemName
|
841 |
+
|
842 |
+
|
843 |
+
Items
|
844 |
+
Supported Mods: Team Fortress Classic
|
845 |
+
|
846 |
+
Note: No Information is available for this message.
|
847 |
+
|
848 |
+
ItemStatus
|
849 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
850 |
+
|
851 |
+
This message notifies the client about carried items.
|
852 |
+
Example of some item bits:
|
853 |
+
|
854 |
+
1 (1<<0) - nightvision goggles
|
855 |
+
2 (1<<1) - defusal kit
|
856 |
+
Name: ItemStatus
|
857 |
+
Structure:
|
858 |
+
byte ItemsBitSum
|
859 |
+
|
860 |
+
|
861 |
+
ListPS
|
862 |
+
Supported Mods: Natural Selection
|
863 |
+
|
864 |
+
Note: No Information is available for this message.
|
865 |
+
|
866 |
+
Location
|
867 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
868 |
+
|
869 |
+
This message is sent when a player changes zones on a map.
|
870 |
+
|
871 |
+
Name: Location
|
872 |
+
Structure:
|
873 |
+
byte PlayerId
|
874 |
+
string LocationName
|
875 |
+
|
876 |
+
|
877 |
+
MapList
|
878 |
+
Supported Mods: Sven Co-op
|
879 |
+
|
880 |
+
Note: No Information is available for this message.
|
881 |
+
|
882 |
+
MapMarker
|
883 |
+
Supported Mods: Day of Defeat
|
884 |
+
|
885 |
+
Note: No Information is available for this message.
|
886 |
+
|
887 |
+
MiniMap
|
888 |
+
Supported Mods: Natural Selection
|
889 |
+
|
890 |
+
Note: No Information is available for this message.
|
891 |
+
|
892 |
+
Money
|
893 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
894 |
+
|
895 |
+
This message updates the amount of money on the HUD. If the Flag is 1, the amount of money added will also be displayed.
|
896 |
+
|
897 |
+
Name: Money
|
898 |
+
Structure:
|
899 |
+
long Amount
|
900 |
+
byte Flag
|
901 |
+
|
902 |
+
|
903 |
+
Monitor
|
904 |
+
Supported Mods: Sven Co-op
|
905 |
+
|
906 |
+
Note: No Information is available for this message.
|
907 |
+
|
908 |
+
MOTD
|
909 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
910 |
+
|
911 |
+
This message displays the MOTD window.
|
912 |
+
|
913 |
+
Note: Max. Text length is 60. A larger MOTD is sent in multiple messages. Flag will be set to 1 for the final segment.
|
914 |
+
|
915 |
+
Name: MOTD
|
916 |
+
Structure:
|
917 |
+
byte Flag
|
918 |
+
string Text
|
919 |
+
|
920 |
+
|
921 |
+
NextMap
|
922 |
+
Supported Mods: Sven Co-op
|
923 |
+
|
924 |
+
Note: No Information is available for this message.
|
925 |
+
|
926 |
+
NexusBytes
|
927 |
+
Supported Mods: Natural Selection
|
928 |
+
|
929 |
+
Note: No Information is available for this message.
|
930 |
+
|
931 |
+
NVGToggle
|
932 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
933 |
+
|
934 |
+
This message toggles night vision mode. For Flag: 1 is on, 0 is off.
|
935 |
+
|
936 |
+
Name: NVGToggle
|
937 |
+
Structure:
|
938 |
+
byte Flag
|
939 |
+
|
940 |
+
|
941 |
+
Object
|
942 |
+
Supported Mods: Day of Defeat
|
943 |
+
|
944 |
+
This message is sent when a player picks up certain objects. The specified sprite will be displayed on the left side of the HUD. An example Sprite is sprites/mapsprites/ae_satchel2.spr.
|
945 |
+
|
946 |
+
Name: Object
|
947 |
+
Structure:
|
948 |
+
string Sprite
|
949 |
+
|
950 |
+
|
951 |
+
ObjScore
|
952 |
+
Supported Mods: Day of Defeat
|
953 |
+
|
954 |
+
This message sets a player's score, as seen on the scoreboard.
|
955 |
+
|
956 |
+
Name: ObjScore
|
957 |
+
Structure:
|
958 |
+
byte PlayerID
|
959 |
+
short Score
|
960 |
+
|
961 |
+
|
962 |
+
OldWeapon
|
963 |
+
Supported Mods: Half-Life: Opposing Force
|
964 |
+
|
965 |
+
Note: No Information is available for this message.
|
966 |
+
|
967 |
+
Particles
|
968 |
+
Supported Mods: Natural Selection
|
969 |
+
|
970 |
+
Note: No Information is available for this message.
|
971 |
+
|
972 |
+
PClass
|
973 |
+
Supported Mods: Day of Defeat
|
974 |
+
|
975 |
+
Note: No Information is available for this message.
|
976 |
+
|
977 |
+
Name: PClass
|
978 |
+
Structure:
|
979 |
+
byte PlayerID?
|
980 |
+
byte Unknown
|
981 |
+
|
982 |
+
|
983 |
+
PlayerIcon
|
984 |
+
Supported Mods: Half-Life: Opposing Force
|
985 |
+
|
986 |
+
Note: No Information is available for this message.
|
987 |
+
|
988 |
+
PlayersIn
|
989 |
+
Supported Mods: Day of Defeat
|
990 |
+
|
991 |
+
Note: No Information is available for this message.
|
992 |
+
|
993 |
+
PlayHUDNot
|
994 |
+
Supported Mods: Natural Selection
|
995 |
+
|
996 |
+
Note: No Information is available for this message.
|
997 |
+
|
998 |
+
Playlist
|
999 |
+
Supported Mods: Sven Co-op
|
1000 |
+
|
1001 |
+
Note: No Information is available for this message.
|
1002 |
+
|
1003 |
+
PlyrBrowse
|
1004 |
+
Supported Mods: Half-Life: Opposing Force
|
1005 |
+
|
1006 |
+
Note: No Information is available for this message.
|
1007 |
+
|
1008 |
+
Portal
|
1009 |
+
Supported Mods: Sven Co-op
|
1010 |
+
|
1011 |
+
Note: No Information is available for this message.
|
1012 |
+
|
1013 |
+
Powerup
|
1014 |
+
Supported Mods: Ricochet
|
1015 |
+
|
1016 |
+
Note: No Information is available for this message.
|
1017 |
+
|
1018 |
+
ProfileInfo
|
1019 |
+
Supported Mods: Natural Selection
|
1020 |
+
|
1021 |
+
Note: No Information is available for this message.
|
1022 |
+
|
1023 |
+
Progress
|
1024 |
+
Supported Mods: Natural Selection
|
1025 |
+
|
1026 |
+
Note: No Information is available for this message.
|
1027 |
+
|
1028 |
+
ProgUpdate
|
1029 |
+
Supported Mods: Day of Defeat
|
1030 |
+
|
1031 |
+
Note: No Information is available for this message.
|
1032 |
+
|
1033 |
+
PShoot
|
1034 |
+
Supported Mods: Day of Defeat
|
1035 |
+
|
1036 |
+
Note: No Information is available for this message.
|
1037 |
+
|
1038 |
+
PStatus
|
1039 |
+
Supported Mods: Day of Defeat
|
1040 |
+
|
1041 |
+
This message is sent along with Object when a player picks up an object. It may have other uses. When I picked up a satchel charge, the Unknown value was 5.
|
1042 |
+
|
1043 |
+
Name: PStatus
|
1044 |
+
Structure:
|
1045 |
+
byte PlayerID?
|
1046 |
+
byte Unknown
|
1047 |
+
|
1048 |
+
|
1049 |
+
PTeam
|
1050 |
+
Supported Mods: Day of Defeat
|
1051 |
+
|
1052 |
+
Note: No Information is available for this message.
|
1053 |
+
|
1054 |
+
QItems
|
1055 |
+
Supported Mods: Deathmatch Classic
|
1056 |
+
|
1057 |
+
Note: No Information is available for this message.
|
1058 |
+
|
1059 |
+
Radar
|
1060 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1061 |
+
|
1062 |
+
This message draws/updates the dot on the HUD radar which indicates the given player position.
|
1063 |
+
|
1064 |
+
Note: This works for teammates only.
|
1065 |
+
|
1066 |
+
Name: Radar
|
1067 |
+
Structure:
|
1068 |
+
byte PlayerID
|
1069 |
+
coord CoordX
|
1070 |
+
coord CoordY
|
1071 |
+
coord CoordZ
|
1072 |
+
|
1073 |
+
|
1074 |
+
RampSprite
|
1075 |
+
Supported Mods: Sven Co-op
|
1076 |
+
|
1077 |
+
Note: No Information is available for this message.
|
1078 |
+
|
1079 |
+
RandomPC
|
1080 |
+
Supported Mods: Team Fortress Classic
|
1081 |
+
|
1082 |
+
Note: No Information is available for this message.
|
1083 |
+
|
1084 |
+
ReceiveW
|
1085 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1086 |
+
|
1087 |
+
This message tells the client which visual weather effect to be executed client side, if client's cl_weather CVar is above 0.
|
1088 |
+
|
1089 |
+
Note: Main part of CBasePlayer::SendWeatherInfo() function that is sent in CBasePlayer :: UpdateClientData() when player offset m_fInitHUD is 1
|
1090 |
+
(right after putinserver or after fullupdate command)
|
1091 |
+
Mode: 1 is for rain effect, 2 is for snow effect
|
1092 |
+
Though mode 0 is never sent by the game itself, it removes the weather effect.
|
1093 |
+
Alternatively send mode 1 and mode 2 with judicious delays (time for effect to disappear) to make both rain and snow effect
|
1094 |
+
|
1095 |
+
Name: ReceiveW
|
1096 |
+
Structure:
|
1097 |
+
byte Mode
|
1098 |
+
|
1099 |
+
|
1100 |
+
ReloadDone
|
1101 |
+
Supported Mods: Day of Defeat
|
1102 |
+
|
1103 |
+
Note: No Information is available for this message.
|
1104 |
+
|
1105 |
+
ReloadSound
|
1106 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1107 |
+
|
1108 |
+
This message plays generic reload sounds.
|
1109 |
+
|
1110 |
+
Note: Setting IsNotShotgun to 1 will play weapons/generic_reload.wav
|
1111 |
+
Note: Setting IsNotShotgun to 0 will play weapons/generic_shot_reload.wav
|
1112 |
+
|
1113 |
+
Name: ReloadSound
|
1114 |
+
Structure:
|
1115 |
+
byte Volume * 255
|
1116 |
+
byte IsNotShotgun
|
1117 |
+
|
1118 |
+
|
1119 |
+
ReqState
|
1120 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1121 |
+
|
1122 |
+
Note: No Information is available for this message.
|
1123 |
+
Note: This message has no arguments.
|
1124 |
+
|
1125 |
+
Name: ReqState
|
1126 |
+
Structure:
|
1127 |
+
|
1128 |
+
|
1129 |
+
ResetFade
|
1130 |
+
Supported Mods: Team Fortress Classic
|
1131 |
+
|
1132 |
+
Note: No Information is available for this message.
|
1133 |
+
|
1134 |
+
ResetHUD
|
1135 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1136 |
+
|
1137 |
+
This message resets the HUD.
|
1138 |
+
|
1139 |
+
Note: This message has no arguments.
|
1140 |
+
|
1141 |
+
Name: ResetHUD
|
1142 |
+
Structure:
|
1143 |
+
|
1144 |
+
|
1145 |
+
ResetSens
|
1146 |
+
Supported Mods: Day of Defeat
|
1147 |
+
|
1148 |
+
This message resets the client's sensitivity?
|
1149 |
+
|
1150 |
+
Note: This message has no arguments.
|
1151 |
+
|
1152 |
+
Name: ResetSens
|
1153 |
+
Structure:
|
1154 |
+
|
1155 |
+
|
1156 |
+
Reward
|
1157 |
+
Supported Mods: Ricochet
|
1158 |
+
|
1159 |
+
Note: No Information is available for this message.
|
1160 |
+
|
1161 |
+
RoundState
|
1162 |
+
Supported Mods: Day of Defeat
|
1163 |
+
|
1164 |
+
Note: No Information is available for this message.
|
1165 |
+
|
1166 |
+
RoundTime
|
1167 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1168 |
+
|
1169 |
+
This message updates the round timer on the HUD. Time is in seconds.
|
1170 |
+
|
1171 |
+
Name: RoundTime
|
1172 |
+
Structure:
|
1173 |
+
short Time
|
1174 |
+
|
1175 |
+
|
1176 |
+
SayText
|
1177 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1178 |
+
|
1179 |
+
This message prints say HUD text. The second argument can be a predefined string or a custom one. In the latter case, the last two arguments aren't required.
|
1180 |
+
Examples of predefined Counter-Strike string values include #Cstrike_Chat_AllDead and #Cstrike_Name_Change.
|
1181 |
+
|
1182 |
+
Note: For #Cstrike_Name_Change String2 is an old name and String3 is a new name.
|
1183 |
+
|
1184 |
+
Name: SayText
|
1185 |
+
Structure:
|
1186 |
+
byte SenderID
|
1187 |
+
string String1
|
1188 |
+
string String2
|
1189 |
+
string String3
|
1190 |
+
|
1191 |
+
|
1192 |
+
Scenario
|
1193 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1194 |
+
|
1195 |
+
If Active is 0, this display will be hidden. If Active is 1, this displays Sprite (valid names listed in sprites/hud.txt) to the right of the round timer with an alpha value of Alpha (100-255). If FlashRate is nonzero, then the sprite will flash from the given alpha to an alpha of 100, at a rate of FlashRate (measured in ???). This is used by CZ to display how many hostages remain unrescued, and also to display the ticking bomb when it is planted.
|
1196 |
+
|
1197 |
+
|
1198 |
+
Scenario message in CS, using the following parameters: 1, d_mp5navy, 150
|
1199 |
+
Note: If Active is 0, don't send any other arguments afterwards. Also, you don't need to send either short if FlashRate is just going to be 0.
|
1200 |
+
Note: This works in both CS and CZ!
|
1201 |
+
Note: In CZ (and possibly CS), if someone respawns after the bomb has been planted, their Scenario event will not work at all until the next round.
|
1202 |
+
|
1203 |
+
Name: Scenario
|
1204 |
+
Structure:
|
1205 |
+
byte Active
|
1206 |
+
string Sprite
|
1207 |
+
byte Alpha
|
1208 |
+
short FlashRate
|
1209 |
+
short FlashDelay
|
1210 |
+
|
1211 |
+
|
1212 |
+
Scope
|
1213 |
+
Supported Mods: Day of Defeat
|
1214 |
+
|
1215 |
+
Note: No Information is available for this message.
|
1216 |
+
|
1217 |
+
Name: Scope
|
1218 |
+
Structure:
|
1219 |
+
byte Unknown
|
1220 |
+
|
1221 |
+
|
1222 |
+
ScoreAttrib
|
1223 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1224 |
+
|
1225 |
+
This message updates the scoreboard attribute for the specified player. For the 2nd argument, 0 is nothing, (1<<0) i.e. 1 is dead, (1<<1) i.e. 2 is bomb, (1<<2) i.e. 4 is VIP, (1<<3) i.e. 8 is defuse kit.
|
1226 |
+
|
1227 |
+
Note: Flags is a bitwise value so if VIP player is dying with the bomb the Flags will be 7 i.e. bit sum of all flags.
|
1228 |
+
|
1229 |
+
Name: ScoreAttrib
|
1230 |
+
Structure:
|
1231 |
+
byte PlayerID
|
1232 |
+
byte Flags
|
1233 |
+
|
1234 |
+
|
1235 |
+
ScoreInfo
|
1236 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1237 |
+
|
1238 |
+
This message updates the scoreboard with the given player's Score and Deaths. In Counter-Strike, the score is based on the number of frags and the bomb detonating or being defused. In Team Fortress Classic, the score is based on the number of kills, suicides, and captures. Day of Defeat uses ScoreShort and ObjScore instead of this message to update score and deaths.
|
1239 |
+
|
1240 |
+
Note: In CS the 4th argument (ClassID) is always equal to 0.
|
1241 |
+
|
1242 |
+
See CS Team Constants for team indices constants list.
|
1243 |
+
Name: ScoreInfo
|
1244 |
+
Structure:
|
1245 |
+
byte PlayerID
|
1246 |
+
short Score
|
1247 |
+
short Deaths
|
1248 |
+
short ClassID
|
1249 |
+
short TeamID
|
1250 |
+
|
1251 |
+
|
1252 |
+
ScoreInfoLong
|
1253 |
+
Supported Mods: Day of Defeat
|
1254 |
+
|
1255 |
+
Note: Although Metamod lists this message, it doesn't appear to be used or even a valid message name.
|
1256 |
+
|
1257 |
+
ScoreShort
|
1258 |
+
Supported Mods: Day of Defeat
|
1259 |
+
|
1260 |
+
This message updates a player's Score, Kills, and Deaths as seen on the scoreboard. This message is only sent for the victim.
|
1261 |
+
|
1262 |
+
Note: The fifth argument appears to be the same as the refresh parameter used in dod_set_pl_deaths and was always 1 in my testing.
|
1263 |
+
|
1264 |
+
Name: ScoreShort
|
1265 |
+
Structure:
|
1266 |
+
byte PlayerID
|
1267 |
+
short Score
|
1268 |
+
short Kills
|
1269 |
+
short Deaths
|
1270 |
+
short Refresh?
|
1271 |
+
|
1272 |
+
|
1273 |
+
ScreenFade
|
1274 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1275 |
+
|
1276 |
+
This message fades the screen.
|
1277 |
+
|
1278 |
+
Note: Duration and HoldTime is in special units. 1 second is equal to (1<<12) i.e. 4096 units.
|
1279 |
+
|
1280 |
+
Flags (from HLSDK):
|
1281 |
+
|
1282 |
+
FFADE_IN 0x0000 // Just here so we don't pass 0 into the function
|
1283 |
+
FFADE_OUT 0x0001 // Fade out (not in)
|
1284 |
+
FFADE_MODULATE 0x0002 // Modulate (don't blend)
|
1285 |
+
FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received
|
1286 |
+
Name: ScreenFade
|
1287 |
+
Structure:
|
1288 |
+
short Duration
|
1289 |
+
short HoldTime
|
1290 |
+
short Flags
|
1291 |
+
byte ColorR
|
1292 |
+
byte ColorG
|
1293 |
+
byte ColorB
|
1294 |
+
byte Alpha
|
1295 |
+
|
1296 |
+
|
1297 |
+
ScreenShake
|
1298 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1299 |
+
|
1300 |
+
This message shakes the screen.
|
1301 |
+
|
1302 |
+
Note: All arguments is in special units. 1 second is equal to (1<<12) i.e. 4096 units.
|
1303 |
+
|
1304 |
+
Name: ScreenShake
|
1305 |
+
Structure:
|
1306 |
+
short Amplitude
|
1307 |
+
short Duration
|
1308 |
+
short Frequency
|
1309 |
+
|
1310 |
+
|
1311 |
+
SecAmmoIcon
|
1312 |
+
Supported Mods: Team Fortress Classic • Half-Life Deathmatch • Counter-Strike • Counter-Strike: Condition Zero
|
1313 |
+
|
1314 |
+
This message creates an icon at the bottom right corner of the screen. TFC uses it to display carried grenade icon. It is not registered in other mods, but it is still useable though.
|
1315 |
+
|
1316 |
+
Note: icon is any sprite name from hud.txt.
|
1317 |
+
Note: this message will have effect only when sent in conjuction with SecAmmoVal message.
|
1318 |
+
|
1319 |
+
Name: SecAmmoIcon
|
1320 |
+
Structure:
|
1321 |
+
string icon
|
1322 |
+
|
1323 |
+
|
1324 |
+
SecAmmoVal
|
1325 |
+
Supported Mods: Team Fortress Classic • Half-Life Deathmatch • Counter-Strike • Counter-Strike: Condition Zero
|
1326 |
+
|
1327 |
+
It is used to show carried grenade amount in TFC; it is disabled on all other mods, but it is still useable though.
|
1328 |
+
|
1329 |
+
Note: Slots range from 1 to 4.
|
1330 |
+
Note: Sending 0 as amount for all slots will remove the effect of this message.
|
1331 |
+
|
1332 |
+
|
1333 |
+
|
1334 |
+
Name: SecAmmoVal
|
1335 |
+
Structure:
|
1336 |
+
byte slot
|
1337 |
+
byte amount
|
1338 |
+
|
1339 |
+
|
1340 |
+
SelAmmo
|
1341 |
+
Supported Mods: Deathmatch Classic • Half-Life: Opposing Force • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1342 |
+
|
1343 |
+
Note: No Information is available for this message.
|
1344 |
+
|
1345 |
+
SendAudio
|
1346 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1347 |
+
|
1348 |
+
This message plays the specified audio. An example of AudioCode could be "%!MRAD_rounddraw".
|
1349 |
+
|
1350 |
+
Name: SendAudio
|
1351 |
+
Structure:
|
1352 |
+
byte SenderID
|
1353 |
+
string AudioCode
|
1354 |
+
short Pitch
|
1355 |
+
|
1356 |
+
|
1357 |
+
ServerName
|
1358 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1359 |
+
|
1360 |
+
This message sends the server name to a client.
|
1361 |
+
|
1362 |
+
Name: ServerName
|
1363 |
+
Structure:
|
1364 |
+
string ServerName
|
1365 |
+
|
1366 |
+
|
1367 |
+
ServerVar
|
1368 |
+
Supported Mods: Natural Selection
|
1369 |
+
|
1370 |
+
Note: No Information is available for this message.
|
1371 |
+
|
1372 |
+
SetFOV
|
1373 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1374 |
+
|
1375 |
+
This message sets the specified field of view.
|
1376 |
+
|
1377 |
+
Name: SetFOV
|
1378 |
+
Structure:
|
1379 |
+
byte Degrees
|
1380 |
+
|
1381 |
+
|
1382 |
+
SetGmma
|
1383 |
+
Supported Mods: Natural Selection
|
1384 |
+
|
1385 |
+
Note: No Information is available for this message.
|
1386 |
+
|
1387 |
+
SetMenuTeam
|
1388 |
+
Supported Mods: Half-Life: Opposing Force
|
1389 |
+
|
1390 |
+
Note: No Information is available for this message.
|
1391 |
+
|
1392 |
+
SetObj
|
1393 |
+
Supported Mods: Day of Defeat
|
1394 |
+
|
1395 |
+
Note: No Information is available for this message.
|
1396 |
+
|
1397 |
+
Name: SetObj
|
1398 |
+
Structure:
|
1399 |
+
byte Unknown1
|
1400 |
+
byte Unknown2
|
1401 |
+
byte Unknown3
|
1402 |
+
|
1403 |
+
|
1404 |
+
SetOrder
|
1405 |
+
Supported Mods: Natural Selection
|
1406 |
+
|
1407 |
+
Note: No Information is available for this message.
|
1408 |
+
|
1409 |
+
SetRequest
|
1410 |
+
Supported Mods: Natural Selection
|
1411 |
+
|
1412 |
+
Note: No Information is available for this message.
|
1413 |
+
|
1414 |
+
SetSelect
|
1415 |
+
Supported Mods: Natural Selection
|
1416 |
+
|
1417 |
+
Note: No Information is available for this message.
|
1418 |
+
|
1419 |
+
SetTech
|
1420 |
+
Supported Mods: Natural Selection
|
1421 |
+
|
1422 |
+
Note: No Information is available for this message.
|
1423 |
+
|
1424 |
+
SetTopDown
|
1425 |
+
Supported Mods: Natural Selection
|
1426 |
+
|
1427 |
+
Note: No Information is available for this message.
|
1428 |
+
|
1429 |
+
SetUpgrades
|
1430 |
+
Supported Mods: Natural Selection
|
1431 |
+
|
1432 |
+
Note: No Information is available for this message.
|
1433 |
+
|
1434 |
+
SetupMap
|
1435 |
+
Supported Mods: Natural Selection
|
1436 |
+
|
1437 |
+
Note: No Information is available for this message.
|
1438 |
+
|
1439 |
+
ShadowIdx
|
1440 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1441 |
+
|
1442 |
+
Note: Creates/Hides shadow beneath player.
|
1443 |
+
Note: Passing 0 as the argument will hide the shadow.
|
1444 |
+
|
1445 |
+
Name: ShadowIdx
|
1446 |
+
Structure:
|
1447 |
+
long spriteIndex
|
1448 |
+
|
1449 |
+
|
1450 |
+
ShieldRic
|
1451 |
+
Supported Mods: Sven Co-op
|
1452 |
+
|
1453 |
+
Note: No Information is available for this message.
|
1454 |
+
|
1455 |
+
ShkFlash
|
1456 |
+
Supported Mods: Sven Co-op
|
1457 |
+
|
1458 |
+
Note: No Information is available for this message.
|
1459 |
+
|
1460 |
+
ShowMenu
|
1461 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1462 |
+
|
1463 |
+
This message displays a "menu" to a player (text on the left side of the screen). It acts like AMXX's show_menu (in fact, this is how AMXX shows a menu).
|
1464 |
+
|
1465 |
+
Note: Multipart should be 1 if your menu takes up multiple messages (i.e.: string is too big to fit into one). On the final message, Multipart should be 0.
|
1466 |
+
|
1467 |
+
Name: ShowMenu
|
1468 |
+
Structure:
|
1469 |
+
short KeysBitSum
|
1470 |
+
char Time
|
1471 |
+
byte Multipart
|
1472 |
+
string Text
|
1473 |
+
|
1474 |
+
|
1475 |
+
ShowTimer
|
1476 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1477 |
+
|
1478 |
+
This message forces the round timer to display.
|
1479 |
+
|
1480 |
+
Note: This message has no arguments.
|
1481 |
+
|
1482 |
+
Name: ShowTimer
|
1483 |
+
Structure:
|
1484 |
+
|
1485 |
+
|
1486 |
+
Sky3D
|
1487 |
+
Supported Mods: Sven Co-op
|
1488 |
+
|
1489 |
+
Note: No Information is available for this message.
|
1490 |
+
|
1491 |
+
SoundList
|
1492 |
+
Supported Mods: Sven Co-op
|
1493 |
+
|
1494 |
+
Note: No Information is available for this message.
|
1495 |
+
|
1496 |
+
SoundNames
|
1497 |
+
Supported Mods: Natural Selection
|
1498 |
+
|
1499 |
+
Note: No Information is available for this message.
|
1500 |
+
|
1501 |
+
Speaksent
|
1502 |
+
Supported Mods: Sven Co-op
|
1503 |
+
|
1504 |
+
Note: No Information is available for this message.
|
1505 |
+
|
1506 |
+
SpecFade
|
1507 |
+
Supported Mods: Team Fortress Classic
|
1508 |
+
|
1509 |
+
Note: No Information is available for this message.
|
1510 |
+
|
1511 |
+
SpecHealth
|
1512 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Team Fortress Classic
|
1513 |
+
|
1514 |
+
This message updates a spectator's screen with health of the currently spectated player, on health change (on TakeDamage, doesn't seems to be sent anywhere else).
|
1515 |
+
|
1516 |
+
Note: Previous information has been checked on cs1.6/cz only
|
1517 |
+
|
1518 |
+
Name: SpecHealth
|
1519 |
+
Structure:
|
1520 |
+
byte Health
|
1521 |
+
|
1522 |
+
|
1523 |
+
SpecHealth2
|
1524 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1525 |
+
|
1526 |
+
This message updates a spectator's screen with the name and health of the given player when player is freshly spectated.
|
1527 |
+
|
1528 |
+
Name: SpecHealth2
|
1529 |
+
Structure:
|
1530 |
+
byte Health
|
1531 |
+
byte PlayerID
|
1532 |
+
|
1533 |
+
|
1534 |
+
Spectator
|
1535 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Half-Life: Opposing Force • Ricochet • Sven Co-op • Team Fortress Classic
|
1536 |
+
|
1537 |
+
This message is sent when a player becomes an observer/spectator.
|
1538 |
+
|
1539 |
+
Note: On join to Spectators this usually is fired twice in a row.
|
1540 |
+
|
1541 |
+
Name: Spectator
|
1542 |
+
Structure:
|
1543 |
+
byte ClientID
|
1544 |
+
byte IsSpectator
|
1545 |
+
|
1546 |
+
|
1547 |
+
SporeTrail
|
1548 |
+
Supported Mods: Sven Co-op
|
1549 |
+
|
1550 |
+
Note: No Information is available for this message.
|
1551 |
+
|
1552 |
+
SRDetonate
|
1553 |
+
Supported Mods: Sven Co-op
|
1554 |
+
|
1555 |
+
Note: No Information is available for this message.
|
1556 |
+
|
1557 |
+
SRPrimed
|
1558 |
+
Supported Mods: Sven Co-op
|
1559 |
+
|
1560 |
+
Note: No Information is available for this message.
|
1561 |
+
|
1562 |
+
SRPrimedOff
|
1563 |
+
Supported Mods: Sven Co-op
|
1564 |
+
|
1565 |
+
Note: No Information is available for this message.
|
1566 |
+
|
1567 |
+
StartProg
|
1568 |
+
Supported Mods: Day of Defeat
|
1569 |
+
|
1570 |
+
Note: No Information is available for this message.
|
1571 |
+
|
1572 |
+
StartProgF
|
1573 |
+
Supported Mods: Day of Defeat
|
1574 |
+
|
1575 |
+
Note: No Information is available for this message.
|
1576 |
+
|
1577 |
+
StartRnd
|
1578 |
+
Supported Mods: Ricochet
|
1579 |
+
|
1580 |
+
Note: No Information is available for this message.
|
1581 |
+
|
1582 |
+
StartSound
|
1583 |
+
Supported Mods: Sven Co-op
|
1584 |
+
|
1585 |
+
Note: No Information is available for this message.
|
1586 |
+
|
1587 |
+
StatsInfo
|
1588 |
+
Supported Mods: Half-Life: Opposing Force
|
1589 |
+
|
1590 |
+
Note: No Information is available for this message.
|
1591 |
+
|
1592 |
+
StatsPlayer
|
1593 |
+
Supported Mods: Half-Life: Opposing Force
|
1594 |
+
|
1595 |
+
Note: No Information is available for this message.
|
1596 |
+
|
1597 |
+
StatusIcon
|
1598 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Half-Life: Opposing Force • Team Fortress Classic
|
1599 |
+
|
1600 |
+
This message draws/removes the specified status HUD icon. For Status, 0 is Hide Icon, 1 is Show Icon, 2 is Flash Icon. Color arguments are optional and are required only if Status isn't equal to 0.
|
1601 |
+
|
1602 |
+
Name: StatusIcon
|
1603 |
+
Structure:
|
1604 |
+
byte Status
|
1605 |
+
string SpriteName
|
1606 |
+
byte ColorR
|
1607 |
+
byte ColorG
|
1608 |
+
byte ColorB
|
1609 |
+
|
1610 |
+
|
1611 |
+
StatusText
|
1612 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Natural Selection • Team Fortress Classic • Half-Life Deathmatch
|
1613 |
+
|
1614 |
+
This message specifies the status text format.
|
1615 |
+
|
1616 |
+
Name: StatusText
|
1617 |
+
Structure:
|
1618 |
+
byte Unknown
|
1619 |
+
string Text
|
1620 |
+
|
1621 |
+
|
1622 |
+
StatusValue
|
1623 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Natural Selection • Team Fortress Classic • Half-Life Deathmatch
|
1624 |
+
|
1625 |
+
This message sends/updates the status values. For Flag, 1 is TeamRelation, 2 is PlayerID, and 3 is Health. For TeamRelation, 1 is Teammate player, 2 is Non-Teammate player, 3 is Hostage. If TeamRelation is Hostage, PlayerID will be 0 or will be not sent at all.
|
1626 |
+
Usually this is fired as a triple message, for example:
|
1627 |
+
|
1628 |
+
{1, 2} - non-teammate player
|
1629 |
+
{2, 17} - player index is 17
|
1630 |
+
{3, 59} - player health is 59
|
1631 |
+
Name: StatusValue
|
1632 |
+
Structure:
|
1633 |
+
byte Flag
|
1634 |
+
short Value
|
1635 |
+
|
1636 |
+
|
1637 |
+
TaskTime
|
1638 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1639 |
+
|
1640 |
+
This message displays a secondary timer above the round timer. It is used for Condition Zero singleplayer missions.
|
1641 |
+
If Time is -1, the timer dissappears. If Time is any other negative value, it is displayed as green instead of yellow, and considered positive.
|
1642 |
+
If Active is true, timer counts down. Otherwise, it is paused.
|
1643 |
+
If Fade is above zero, the timer will slowly fade out after that many seconds have passed (even if the timer is inactive).
|
1644 |
+
|
1645 |
+
Note: This event can only be used on missions that have an objective requiring a secondary timer!
|
1646 |
+
|
1647 |
+
Name: TaskTime
|
1648 |
+
Structure:
|
1649 |
+
short Time
|
1650 |
+
byte Active
|
1651 |
+
byte Fade
|
1652 |
+
|
1653 |
+
|
1654 |
+
TE_CUSTOM
|
1655 |
+
Supported Mods: Sven Co-op
|
1656 |
+
|
1657 |
+
Note: No Information is available for this message.
|
1658 |
+
|
1659 |
+
TeamFull
|
1660 |
+
Supported Mods: Half-Life: Opposing Force
|
1661 |
+
|
1662 |
+
Note: No Information is available for this message.
|
1663 |
+
|
1664 |
+
TeamInfo
|
1665 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1666 |
+
|
1667 |
+
This message sets the team information for the given player.
|
1668 |
+
|
1669 |
+
Note: In CS TeamName is either "UNASSIGNED", "TERRORIST", "CT" or "SPECTATOR".
|
1670 |
+
|
1671 |
+
Name: TeamInfo
|
1672 |
+
Structure:
|
1673 |
+
byte PlayerID
|
1674 |
+
string TeamName
|
1675 |
+
|
1676 |
+
|
1677 |
+
TeamNames
|
1678 |
+
Supported Mods: Half-Life: Opposing Force • Natural Selection • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1679 |
+
|
1680 |
+
Note: No Information is available for this message.
|
1681 |
+
|
1682 |
+
TeamScore
|
1683 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1684 |
+
|
1685 |
+
This message updates the team score on the scoreboard.
|
1686 |
+
|
1687 |
+
Note: This message has different parameters depending upon the mod.
|
1688 |
+
Note: In CS TeamName is either "TERRORIST" or "CT".
|
1689 |
+
|
1690 |
+
Name: TeamScore
|
1691 |
+
Structure:
|
1692 |
+
string TeamName
|
1693 |
+
short Score
|
1694 |
+
|
1695 |
+
|
1696 |
+
Day of Defeat
|
1697 |
+
Name: TeamScore
|
1698 |
+
Structure:
|
1699 |
+
byte TeamID
|
1700 |
+
short Score
|
1701 |
+
|
1702 |
+
|
1703 |
+
TechSlots
|
1704 |
+
Supported Mods: Natural Selection
|
1705 |
+
|
1706 |
+
Note: No Information is available for this message.
|
1707 |
+
|
1708 |
+
TextMsg
|
1709 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1710 |
+
|
1711 |
+
This message prints a custom or predefined text message.
|
1712 |
+
There does not necessarily have to be a total of 6 arguments; there could be as little as 2. For example, you can send a message with the following:
|
1713 |
+
|
1714 |
+
Arg1: 1
|
1715 |
+
Arg2: #Game_join_ct
|
1716 |
+
Arg3: Pimp Daddy
|
1717 |
+
Name: TextMsg
|
1718 |
+
Structure:
|
1719 |
+
byte DestinationType
|
1720 |
+
string Message
|
1721 |
+
string Submsg
|
1722 |
+
string Submsg
|
1723 |
+
string Submsg
|
1724 |
+
string Submsg
|
1725 |
+
|
1726 |
+
|
1727 |
+
TimeEnd
|
1728 |
+
Supported Mods: Sven Co-op
|
1729 |
+
|
1730 |
+
Note: No Information is available for this message.
|
1731 |
+
|
1732 |
+
TimeLeft
|
1733 |
+
Supported Mods: Day of Defeat
|
1734 |
+
|
1735 |
+
Note: No Information is available for this message.
|
1736 |
+
|
1737 |
+
TimerStatus
|
1738 |
+
Supported Mods: Day of Defeat
|
1739 |
+
|
1740 |
+
Note: No Information is available for this message.
|
1741 |
+
|
1742 |
+
ToxicCloud
|
1743 |
+
Supported Mods: Sven Co-op
|
1744 |
+
|
1745 |
+
Note: No Information is available for this message.
|
1746 |
+
|
1747 |
+
TracerDecal
|
1748 |
+
Supported Mods: Sven Co-op
|
1749 |
+
|
1750 |
+
Note: No Information is available for this message.
|
1751 |
+
|
1752 |
+
Train
|
1753 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1754 |
+
|
1755 |
+
This message displays the speed bar used for controlling a train.
|
1756 |
+
|
1757 |
+
Note: Speed is as follows: 0 (disable display), 1 (neutral), 2 (slow speed), 3 (medium speed), 4 (maximum speed), 5 (reverse)
|
1758 |
+
|
1759 |
+
Name: Train
|
1760 |
+
Structure:
|
1761 |
+
byte Speed
|
1762 |
+
|
1763 |
+
|
1764 |
+
TurretLaser
|
1765 |
+
Supported Mods: Sven Co-op
|
1766 |
+
|
1767 |
+
Note: No Information is available for this message.
|
1768 |
+
|
1769 |
+
TutorClose
|
1770 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1771 |
+
|
1772 |
+
This message closes all CZ-style tutor popups.
|
1773 |
+
|
1774 |
+
Note: This message has no arguments.
|
1775 |
+
|
1776 |
+
Name: TutorClose
|
1777 |
+
Structure:
|
1778 |
+
|
1779 |
+
|
1780 |
+
TutorLine
|
1781 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1782 |
+
|
1783 |
+
Note: No Information is available for this message.
|
1784 |
+
|
1785 |
+
Name: TutorLine
|
1786 |
+
Structure:
|
1787 |
+
short Unknown1
|
1788 |
+
short Unknown2
|
1789 |
+
|
1790 |
+
|
1791 |
+
TutorState
|
1792 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1793 |
+
|
1794 |
+
Note: No Information is available for this message.
|
1795 |
+
|
1796 |
+
Name: TutorState
|
1797 |
+
Structure:
|
1798 |
+
string Unknown
|
1799 |
+
|
1800 |
+
|
1801 |
+
TutorText
|
1802 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero
|
1803 |
+
|
1804 |
+
This message is used to display a CZ-style tutor popup.
|
1805 |
+
|
1806 |
+
Note: If NumberOfSubMsgs is higher than 0, there should be such amount of write_string after this byte.
|
1807 |
+
Note: TutorMessageEventId is indexed as listed in czero/tutordata.txt and starts from 0
|
1808 |
+
Note: IsDead is the message receiver alive status
|
1809 |
+
|
1810 |
+
DEFAULT 1 // 1<<0 | GREEN | INFO
|
1811 |
+
FRIENDDEATH 2 // 1<<1 | RED | SKULL
|
1812 |
+
ENEMYDEATH 4 // 1<<2 | BLUE | SKULL
|
1813 |
+
SCENARIO 8 // 1<<3 | YELLOW | INFO
|
1814 |
+
BUY 16 // 1<<4 | GREEN | INFO
|
1815 |
+
CAREER 32 // 1<<5 | GREEN | INFO
|
1816 |
+
HINT 64 // 1<<6 | GREEN | INFO
|
1817 |
+
INGAMEHINT 128 // 1<<7 | GREEN | INFO
|
1818 |
+
ENDGAME 256 // 1<<8 | YELLOW | INFO
|
1819 |
+
Name: TutorText
|
1820 |
+
Structure:
|
1821 |
+
string String
|
1822 |
+
byte NumberOfSubMsgs
|
1823 |
+
string SubMessage
|
1824 |
+
string ...
|
1825 |
+
short TutorMessageEventId
|
1826 |
+
short IsDead
|
1827 |
+
short Type
|
1828 |
+
|
1829 |
+
|
1830 |
+
UseSound
|
1831 |
+
Supported Mods: Day of Defeat
|
1832 |
+
|
1833 |
+
Note: No Information is available for this message.
|
1834 |
+
|
1835 |
+
ValClass
|
1836 |
+
Supported Mods: Team Fortress Classic
|
1837 |
+
|
1838 |
+
Note: No Information is available for this message.
|
1839 |
+
|
1840 |
+
VGUIMenu
|
1841 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Half-Life: Opposing Force • Sven Co-op • Team Fortress Classic
|
1842 |
+
|
1843 |
+
This message displays a predefined VGUI menu.
|
1844 |
+
|
1845 |
+
Name: VGUIMenu
|
1846 |
+
Structure:
|
1847 |
+
byte MenuID
|
1848 |
+
short KeysBitSum
|
1849 |
+
char Time?
|
1850 |
+
byte Multipart?
|
1851 |
+
string Name?
|
1852 |
+
|
1853 |
+
|
1854 |
+
ViewMode
|
1855 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Team Fortress Classic
|
1856 |
+
|
1857 |
+
Note: No Information is available for this message (HLSDK says this switches to first-person view, but it doesn't seem to function as so).
|
1858 |
+
Note: This message has no arguments.
|
1859 |
+
|
1860 |
+
Name: ViewMode
|
1861 |
+
Structure:
|
1862 |
+
|
1863 |
+
|
1864 |
+
VoiceMask
|
1865 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1866 |
+
|
1867 |
+
This message tells a client whom they can hear over the microphone.
|
1868 |
+
|
1869 |
+
Name: VoiceMask
|
1870 |
+
Structure:
|
1871 |
+
long AudiblePlayersIndexBitSum
|
1872 |
+
long ServerBannedPlayersIndexBitSum
|
1873 |
+
|
1874 |
+
|
1875 |
+
VoteMenu
|
1876 |
+
Supported Mods: Sven Co-op
|
1877 |
+
|
1878 |
+
Note: No Information is available for this message.
|
1879 |
+
|
1880 |
+
WaveStatus
|
1881 |
+
Supported Mods: Day of Defeat
|
1882 |
+
|
1883 |
+
Note: No Information is available for this message.
|
1884 |
+
|
1885 |
+
WaveTime
|
1886 |
+
Supported Mods: Day of Defeat
|
1887 |
+
|
1888 |
+
Note: No Information is available for this message.
|
1889 |
+
|
1890 |
+
WeaponList
|
1891 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1892 |
+
|
1893 |
+
This message configures the HUD weapons list.
|
1894 |
+
|
1895 |
+
Note: This is fired on map initialization.
|
1896 |
+
Note: SlotID starts from 0.
|
1897 |
+
|
1898 |
+
Flags (from HLSDK):
|
1899 |
+
|
1900 |
+
ITEM_FLAG_SELECTONEMPTY 1
|
1901 |
+
ITEM_FLAG_NOAUTORELOAD 2
|
1902 |
+
ITEM_FLAG_NOAUTOSWITCHEMPTY 4
|
1903 |
+
ITEM_FLAG_LIMITINWORLD 8
|
1904 |
+
ITEM_FLAG_EXHAUSTIBLE 16 // A player can totally exhaust their ammo supply and lose this weapon.
|
1905 |
+
Note: See CS Weapons Information for more information.
|
1906 |
+
|
1907 |
+
Name: WeaponList
|
1908 |
+
Structure:
|
1909 |
+
string WeaponName
|
1910 |
+
byte PrimaryAmmoID
|
1911 |
+
byte PrimaryAmmoMaxAmount
|
1912 |
+
byte SecondaryAmmoID
|
1913 |
+
byte SecondaryAmmoMaxAmount
|
1914 |
+
byte SlotID
|
1915 |
+
byte NumberInSlot
|
1916 |
+
byte WeaponID
|
1917 |
+
byte Flags
|
1918 |
+
|
1919 |
+
|
1920 |
+
WeapPickup
|
1921 |
+
Supported Mods: Counter-Strike • Counter-Strike: Condition Zero • Day of Defeat • Deathmatch Classic • Half-Life: Opposing Force • Natural Selection • Ricochet • Sven Co-op • Team Fortress Classic • Half-Life Deathmatch
|
1922 |
+
|
1923 |
+
This message temporarily draws the corresponding weapon HUD icon in the middle of the right side of the screen.
|
1924 |
+
|
1925 |
+
Note: Draw time depends on the hud_drawhistory_time client CVar value.
|
1926 |
+
Note: This is fired right before weapon is picked up (notice "before").
|
1927 |
+
Note: See CS Weapons Information for more information.
|
1928 |
+
|
1929 |
+
Name: WeapPickup
|
1930 |
+
Structure:
|
1931 |
+
byte WeaponID
|
1932 |
+
|
1933 |
+
|
1934 |
+
Weather
|
1935 |
+
Supported Mods: Day of Defeat
|
1936 |
+
|
1937 |
+
Note: No Information is available for this message.
|
1938 |
+
|
1939 |
+
WeatherFX
|
1940 |
+
Supported Mods: Sven Co-op
|
1941 |
+
|
1942 |
+
Note: No Information is available for this message.
|
1943 |
+
|
1944 |
+
YouDied
|
1945 |
+
Supported Mods: Day of Defeat
|
1946 |
+
|
1947 |
+
This message is sent to a player when they die.
|
Messages (Temp Entities, Game Events, etc.).txt
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
Old 01-13-2007 , 17:59 [TUT] Messages (Temp Entities, Game Events, etc.)
|
3 |
+
Reply With Quote #1
|
4 |
+
Before we begin, please be advised that this tutorial is intended for intermediate level scripters. It will not cover any basic concepts and assumes that you know the syntax of Pawn.
|
5 |
+
|
6 |
+
A message is essentially the server's way of telling a client about something that should be interpreted and acted upon accordingly by the client dll. In easier terms, it works like this:
|
7 |
+
|
8 |
+
Server sends small bit of information. Player's computer reads it, figures out what to do with it, then displays that to the player. In human terms, this could be compared to someone (the server) giving you a recipe (the message) and you (client / player's computer) preparing the meal. The components are not included in the recipe (message), and it is the chef (player's computer) that brings them together.
|
9 |
+
|
10 |
+
Messages can serve many purposes. They can do things from make a player implode to make a user think they have more ammo. Thus, the scope of this article is naturally going to be very large and will not cover everything.
|
11 |
+
|
12 |
+
The most basic part of a message is the structure. Messages are started with a "message_begin" function call, followed by "write_x" function call(s) (where x is "byte","short","coord","angle","char","string ","long" and one more that I can't remember), and concluded with a "message_end" function call. Thus, the structure is usually some variant of this:
|
13 |
+
|
14 |
+
Code:
|
15 |
+
#define FFADE_IN 0x0000 // Just here so we don't pass 0 into the function
|
16 |
+
#define FFADE_OUT 0x0001 // Fade out (not in)
|
17 |
+
#define FFADE_MODULATE 0x0002 // Modulate (don't blend)
|
18 |
+
#define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received
|
19 |
+
|
20 |
+
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("ScreenFade"),{0,0,0},id)
|
21 |
+
write_short(1<<12) // fade time (1 second = 4096 = 1<<12)
|
22 |
+
write_short(2<<12) // hold time (how long it lasts after fading) (1 second = 4096 = 1<<12)
|
23 |
+
write_short(FFADE_IN) // fade type (in/out)
|
24 |
+
write_byte(255) // r
|
25 |
+
write_byte(255) // g
|
26 |
+
write_byte(255) // b
|
27 |
+
write_byte(150) // alpha / intensity
|
28 |
+
message_end()
|
29 |
+
There are a few important things in this that I haven't even touched upon yet. The first one is the params of message_begin.
|
30 |
+
|
31 |
+
As found in message_const (in the include directory), the options for the first param are the following:
|
32 |
+
|
33 |
+
Code:
|
34 |
+
/* Destination types for message_begin() */
|
35 |
+
#define MSG_BROADCAST 0 // Unreliable to all
|
36 |
+
#define MSG_ONE 1 // Reliable to one (msg_entity)
|
37 |
+
#define MSG_ALL 2 // Reliable to all
|
38 |
+
#define MSG_INIT 3 // Write to the init string
|
39 |
+
#define MSG_PVS 4 // Ents in PVS of org
|
40 |
+
#define MSG_PAS 5 // Ents in PAS of org
|
41 |
+
#define MSG_PVS_R 6 // Reliable to PVS
|
42 |
+
#define MSG_PAS_R 7 // Reliable to PAS
|
43 |
+
#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram (could be dropped)
|
44 |
+
#define MSG_SPEC 9 // Sends to all spectator proxies
|
45 |
+
The most commonly used of these is MSG_BROADCAST, MSG_ONE, MSG_ALL, MSG_ONE_UNRELIABLE, and MSG_SPEC, of which the rest I've never seen in use personally.
|
46 |
+
|
47 |
+
This parameter's function is to tell the engine which clients to send the message to. MSG_BROADCAST and MSG_ALL both send to ALL clients, whereas MSG_ONE and MSG_ONE_UNRELIABLE send to one client (but id, the final parameter of message_begin, must be specified in order to use this). Generally, it is better to use MSG_BROADCAST or MSG_ONE_UNRELIABLE. The reason for this is that these both send to the unreliable stream (as opposed to the reliable stream), which avoids the chance of a crash in the event that the message gets dropped. If a message is sent on the reliable channel but fails to make it to the client, the server generally crashes, or at the very best the client gets dropped.
|
48 |
+
|
49 |
+
The next parameter is the type of message. There are many options for this. The two generally most used types of messages are events (like the ScreenFade one called, generally with the usage of get_user_msgid), or SVC_TEMPENTITY. Event related messages are used to artificially tell the client that an event has happened, such as the round ending, the player's health changing, weapons changing, etc. SVC_TEMPENTITY (or just temp ents for short) is used to create a temporary entity, usually to make a nice visual effect or so a group of entities don't have to be manually removed.
|
50 |
+
|
51 |
+
Note that the get_user_msgid native can be cached in another forward (such as plugin_init) and then called using a variable, like this:
|
52 |
+
|
53 |
+
Code:
|
54 |
+
new g_MsgScreenFade
|
55 |
+
|
56 |
+
public plugin_init()
|
57 |
+
{
|
58 |
+
//...
|
59 |
+
g_MsgScreenFade = get_user_msgid("ScreenFade")
|
60 |
+
//...
|
61 |
+
}
|
62 |
+
|
63 |
+
// ...
|
64 |
+
{
|
65 |
+
// ...
|
66 |
+
message_begin(MSG_ONE_UNRELIABLE,g_MsgScreenFade,...
|
67 |
+
The next parameter is the origin. Note that this is NOT where the message will appear if it has any visual effects, but is used for scripting so anything catching/reading it knows where the message originated from on the map. This parameter is generally unimportant.
|
68 |
+
|
69 |
+
The next parameter, as already talked about, is the id of the player to send this message to. This is only needed when not using MSG_BROADCAST, MSG_ALL or MSG_SPEC, since these messages all target either everyone or a predefined set of people.
|
70 |
+
|
71 |
+
Onto the next part - the writing of data. The next function call will always be a write_byte if you're using SVC_TEMPENTITY. This function will tell the engine which type of temp ent you want to make. The list is too long to post, but it can be found in message_const.inc (all of the TE_ defines).
|
72 |
+
|
73 |
+
As you can see, it's quite lengthy. For the sake of this tutorial, your and my own sanity, I'm going to pick the first one to use as an example, TE_BEAMPOINTS.
|
74 |
+
|
75 |
+
Here's how I'd do it:
|
76 |
+
|
77 |
+
Code:
|
78 |
+
new g_Beam
|
79 |
+
|
80 |
+
public plugin_precache()
|
81 |
+
g_Beam = precache_model("sprites/lightning1.spr")
|
82 |
+
|
83 |
+
//...
|
84 |
+
|
85 |
+
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
|
86 |
+
write_byte(TE_BEAMPOINTS)
|
87 |
+
// this is where the beginning of the beam is
|
88 |
+
write_coord(0) // x
|
89 |
+
write_coord(0) // y
|
90 |
+
write_coord(0) // z
|
91 |
+
// this is where the end of the beam is
|
92 |
+
write_coord(4096) // x
|
93 |
+
write_coord(4096) // y
|
94 |
+
write_coord(4096) // z
|
95 |
+
// this is the sprite index, as we got in plugin_precache)
|
96 |
+
write_short(g_Beam)
|
97 |
+
// this is the starting frame, it's generally best to leave this at 1
|
98 |
+
write_byte(1)
|
99 |
+
// frame rate in 0.1s
|
100 |
+
write_byte(10)
|
101 |
+
// how long it lasts in 0.1 seconds (10 for 1 second)
|
102 |
+
write_byte(100)
|
103 |
+
// line width in 0.1s
|
104 |
+
write_byte(10)
|
105 |
+
// amplitude (how much it goes off the line)
|
106 |
+
write_byte(10)
|
107 |
+
// r, g, b
|
108 |
+
write_byte(255)
|
109 |
+
write_byte(255)
|
110 |
+
write_byte(255)
|
111 |
+
// brightness
|
112 |
+
write_byte(255)
|
113 |
+
// scroll speed
|
114 |
+
write_byte(100)
|
115 |
+
message_end()
|
NEW DBI API (MySQL SQL).txt
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
This is very important for scripters! For AMXx 0.20, I have significantly changed the SQL interface. All plugins will be rendered broken, so you will need to upgrade.
|
2 |
+
|
3 |
+
If you need any help with this, just ask. I can help you convert your plugin or answer technical questions. Remember though, this is for 0.20 and you should be prepared to swap in the new code close to the release date (we will announce this).
|
4 |
+
|
5 |
+
This new DBI is important because it gets rid of the shoddy interface from AMX 0.9.x. Plugin writers now get resource handles for both result sets and connections, as well as a better guarantee that the driver will not crash.
|
6 |
+
|
7 |
+
To best explain this, here is a sample program:
|
8 |
+
|
9 |
+
Code:
|
10 |
+
//Create a connection
|
11 |
+
new Sql:mysql = dbi_connect("localhost", "dvander", "pass", "dbase")
|
12 |
+
|
13 |
+
//If the connection is less than 1, it is bad
|
14 |
+
if (mysql < SQL_OK) {
|
15 |
+
new err[255]
|
16 |
+
new errNum = dbi_error(mysql, err, 254)
|
17 |
+
server_print("error1: %s|%d", err, errNum)
|
18 |
+
return 1
|
19 |
+
}
|
20 |
+
|
21 |
+
server_print("Connection handle: %d", mysql)
|
22 |
+
//Run a query
|
23 |
+
new Result:ret = dbi_query(mysql, "INSERT INTO config (keyname, val) VALUES ('amx', 'yes')")
|
24 |
+
|
25 |
+
//If the query is less than 0, it failed
|
26 |
+
if (ret < RESULT_NONE) {
|
27 |
+
new err[255]
|
28 |
+
new errNum = dbi_error(mysql, err, 254)
|
29 |
+
server_print("error2: %s|%d", err, errNum)
|
30 |
+
return 1
|
31 |
+
}
|
32 |
+
|
33 |
+
//Do a select query
|
34 |
+
new Result:res = dbi_query(mysql, "SELECT * FROM config")
|
35 |
+
|
36 |
+
//If the query is greater than 0, you got a handle to the result set
|
37 |
+
if (res <= RESULT_NONE) {
|
38 |
+
new err[255]
|
39 |
+
new errNum = dbi_error(mysql, err, 254)
|
40 |
+
server_print("error3: %s|%d", err, errNum)
|
41 |
+
return 1
|
42 |
+
}
|
43 |
+
|
44 |
+
server_print("Result handle: %d", res)
|
45 |
+
|
46 |
+
//Loop through the result set
|
47 |
+
while (res && dbi_nextrow(res)>0) {
|
48 |
+
new qry[32]
|
49 |
+
//Get the column/field called "keyname" from the result set
|
50 |
+
dbi_result(res, "keyname", qry, 32)
|
51 |
+
server_print("result: %s", qry)
|
52 |
+
}
|
53 |
+
|
54 |
+
//Free the result set
|
55 |
+
dbi_free_result(res)
|
56 |
+
|
57 |
+
//Close the connection
|
58 |
+
ret = dbi_close(mysql)
|
59 |
+
if (ret <= RESULT_NONE) {
|
60 |
+
new err[255]
|
61 |
+
new errNum = dbi_error(mysql, err, 254)
|
62 |
+
server_print("error4: %s|%d", err, errNum)
|
63 |
+
return 1
|
64 |
+
}
|
65 |
+
|
66 |
+
These differences are subtle and important. It means you can create nested or recursive SQL queries and not have the previous ones erased. It also gives you much better errorchecking/debugging control. You can also reference fields by name instead of number.
|
New AMXX Menu System.txt
ADDED
@@ -0,0 +1,909 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Basic Menu - for interacting within a plugin or having a player select between objects ( such as a weapon menu )
|
2 |
+
Player Menu - for interacting with a selected player ( such as a kick menu )
|
3 |
+
Basic Vote Menu - for getting a preference from players ( such as a mapvote menu )
|
4 |
+
Sub-Menu - for having a menu within a menu ( such as a multilayered admin menu )
|
5 |
+
Advanced Vote Menu - for getting a more advanced preference ( such as a Galileo's map menu )
|
6 |
+
Multiple Menus with 1 Handler - for having multiple menus and only using a single menu_handler
|
7 |
+
Menu Items with Callbacks - for enabling/disabling menu items ( such as a Shop menu that disables items if you don't have enough money )
|
8 |
+
newmenus.inc - some helpful things from newmenus.inc
|
9 |
+
End Notes - some tips with the new menus
|
10 |
+
|
11 |
+
|
12 |
+
Basic Menu [top]
|
13 |
+
Code:
|
14 |
+
#include <amxmodx>
|
15 |
+
|
16 |
+
public plugin_init()
|
17 |
+
{
|
18 |
+
//..stuff for your plugin
|
19 |
+
|
20 |
+
register_clcmd( "my_awesome_menu","AwesomeMenu" );
|
21 |
+
//note that we do not need to register the menu anymore, but just a way to get to it
|
22 |
+
}
|
23 |
+
//lets make the function that will make the menu
|
24 |
+
public AwesomeMenu( id )
|
25 |
+
{
|
26 |
+
//first we need to make a variable that will hold the menu
|
27 |
+
new menu = menu_create( "\rLook at this awesome Menu!:", "menu_handler" );
|
28 |
+
//Note - menu_create
|
29 |
+
//The first parameter is what the menu will be titled ( what is at the very top )
|
30 |
+
//The second parameter is the function that will deal/handle with the menu ( which key was pressed, and what to do )
|
31 |
+
|
32 |
+
//Now lets add some things to select from the menu
|
33 |
+
menu_additem( menu, "\wI'm Selection #1", "", 0 );
|
34 |
+
menu_additem( menu, "\wI'm Selection #2", "", 0 );
|
35 |
+
menu_additem( menu, "\wI'm Secret Selection #3", "", ADMIN_ADMIN );
|
36 |
+
//Note - menu_additem
|
37 |
+
//The first parameter is which menu we will be adding this item/selection to
|
38 |
+
//The second parameter is what text will appear on the menu ( Note that it is preceeded with a number of which item it is )
|
39 |
+
//The third parameter is data that we want to send with this item
|
40 |
+
//The fourth parameter is which admin flag we want to be able to access this item ( Refer to the admin flags from the amxconst.inc )
|
41 |
+
//The fifth parameter is the callback for enabling/disabling items, by default we will omit this and use no callback ( default value of -1 ) Refer to the Menu Items with Callbacks section for more information.
|
42 |
+
|
43 |
+
//Set a property on the menu
|
44 |
+
menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
|
45 |
+
//Note - menu_setprop
|
46 |
+
//The first parameter is the menu to modify
|
47 |
+
//The second parameter is what to modify ( found in amxconst.inc )
|
48 |
+
//The third parameter is what to modify it to ( in this case, we are adding a option to the menu that will exit the menu. setting it to MEXIT_NEVER will disable this option )
|
49 |
+
//Additional note - MEXIT_ALL is the default property for MPROP_EXIT, so this is redundant
|
50 |
+
|
51 |
+
//Lets display the menu
|
52 |
+
menu_display( id, menu, 0 );
|
53 |
+
//Note - menu_display
|
54 |
+
//The first parameter is which index to show it to ( you cannot show this to everyone at once )
|
55 |
+
//The second parameter is which menu to show them ( in this case, the one we just made )
|
56 |
+
//The third parameter is which page to start them on
|
57 |
+
}
|
58 |
+
//okay, we showed them the menu, now lets handle it ( looking back at menu_create, we are going to use that function )
|
59 |
+
public menu_handler( id, menu, item )
|
60 |
+
{
|
61 |
+
//Because of the simplicity of this menu, we can switch for which item was pressed
|
62 |
+
//Note - this is zero-based, so the first item is 0
|
63 |
+
switch( item )
|
64 |
+
{
|
65 |
+
case 0:
|
66 |
+
{
|
67 |
+
client_print( id, print_chat, "Hooray! You selected the Awesome 1st Selection" );
|
68 |
+
|
69 |
+
//Note that if we dont want to continue through the function, we can't just end with a return. We want to kill the menu first
|
70 |
+
menu_destroy( menu );
|
71 |
+
return PLUGIN_HANDLED;
|
72 |
+
}
|
73 |
+
case 1:
|
74 |
+
{
|
75 |
+
client_print( id, print_chat, "OH NO! You selected the Awesome 2nd Selection! BEWARE!" );
|
76 |
+
}
|
77 |
+
case 2:
|
78 |
+
{
|
79 |
+
client_print( id, print_chat, "You have selected the Awesome Admin Selection! Hail Teh Bail!" );
|
80 |
+
}
|
81 |
+
case MENU_EXIT:
|
82 |
+
{
|
83 |
+
client_print( id, print_chat, "You exited the menu... what a bummer!" );
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
//lets finish up this function by destroying the menu with menu_destroy, and a return
|
88 |
+
menu_destroy( menu );
|
89 |
+
return PLUGIN_HANDLED;
|
90 |
+
}
|
91 |
+
|
92 |
+
Player Menu [top]
|
93 |
+
*Note - You should have an understanding of the Basic Menu first.
|
94 |
+
Code:
|
95 |
+
#include <amxmodx>
|
96 |
+
#include <fun>
|
97 |
+
|
98 |
+
public plugin_init()
|
99 |
+
{
|
100 |
+
//Register a way to get to your menu...
|
101 |
+
register_clcmd( "my_player_menu","AwesomeMenu" );
|
102 |
+
}
|
103 |
+
|
104 |
+
public AwesomeMenu( id )
|
105 |
+
{
|
106 |
+
//Create a variable to hold the menu
|
107 |
+
new menu = menu_create( "\rLook at this Player Menu!:", "menu_handler" );
|
108 |
+
|
109 |
+
//We will need to create some variables so we can loop through all the players
|
110 |
+
new players[32], pnum, tempid;
|
111 |
+
|
112 |
+
//Some variables to hold information about the players
|
113 |
+
new szName[32], szUserId[32];
|
114 |
+
|
115 |
+
//Fill players with available players
|
116 |
+
get_players( players, pnum, "a" ); // flag "a" because we are going to add health to players, but this is just for this specific case
|
117 |
+
|
118 |
+
//Start looping through all players
|
119 |
+
for ( new i; i<pnum; i++ )
|
120 |
+
{
|
121 |
+
//Save a tempid so we do not re-index
|
122 |
+
tempid = players[i];
|
123 |
+
|
124 |
+
//Get the players name and userid as strings
|
125 |
+
get_user_name( tempid, szName, charsmax( szName ) );
|
126 |
+
//We will use the data parameter to send the userid, so we can identify which player was selected in the handler
|
127 |
+
formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ) );
|
128 |
+
|
129 |
+
//Add the item for this player
|
130 |
+
menu_additem( menu, szName, szUserId, 0 );
|
131 |
+
}
|
132 |
+
|
133 |
+
//We now have all players in the menu, lets display the menu
|
134 |
+
menu_display( id, menu, 0 );
|
135 |
+
}
|
136 |
+
|
137 |
+
public menu_handler( id, menu, item )
|
138 |
+
{
|
139 |
+
//Do a check to see if they exited because menu_item_getinfo ( see below ) will give an error if the item is MENU_EXIT
|
140 |
+
if ( item == MENU_EXIT )
|
141 |
+
{
|
142 |
+
menu_destroy( menu );
|
143 |
+
return PLUGIN_HANDLED;
|
144 |
+
}
|
145 |
+
|
146 |
+
//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
|
147 |
+
new szData[6], szName[64];
|
148 |
+
new _access, item_callback;
|
149 |
+
//heres the function that will give us that information ( since it doesnt magicaly appear )
|
150 |
+
menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
|
151 |
+
|
152 |
+
//Get the userid of the player that was selected
|
153 |
+
new userid = str_to_num( szData );
|
154 |
+
|
155 |
+
//Try to retrieve player index from its userid
|
156 |
+
new player = find_player( "k", userid ); // flag "k" : find player from userid
|
157 |
+
|
158 |
+
//If player == 0, this means that the player's userid cannot be found
|
159 |
+
//If the player is still alive ( we had retrieved alive players when formating the menu but some players may have died before id could select an item from the menu )
|
160 |
+
if ( player && is_user_alive( player ) )
|
161 |
+
{
|
162 |
+
//Set their health to 100
|
163 |
+
set_user_health( player, 100 );
|
164 |
+
}
|
165 |
+
|
166 |
+
menu_destroy( menu );
|
167 |
+
return PLUGIN_HANDLED;
|
168 |
+
}
|
169 |
+
|
170 |
+
Here is a generic player menu from ConnorMcLeod that you can use to easily add to your plugin
|
171 |
+
Code:
|
172 |
+
#include <amxmodx>
|
173 |
+
#include <amxmisc>
|
174 |
+
|
175 |
+
#define VERSION "0.0.1"
|
176 |
+
#define PLUGIN "Players Menu Generic"
|
177 |
+
|
178 |
+
public plugin_init()
|
179 |
+
{
|
180 |
+
register_plugin( PLUGIN, VERSION, "ConnorMcLeod" );
|
181 |
+
register_clcmd( "say /players", "ClCmd_Menu", ADMIN_RCON );
|
182 |
+
}
|
183 |
+
|
184 |
+
public ClCmd_Menu( id, lvl, cid )
|
185 |
+
{
|
186 |
+
if ( cmd_access( id, lvl, cid, 0 ) )
|
187 |
+
{
|
188 |
+
new iMenu = MakePlayerMenu( id, "Players Menu Misc", "PlayersMenuHandler" );
|
189 |
+
menu_setprop( iMenu, MPROP_NUMBER_COLOR, "\y" );
|
190 |
+
menu_display( id, iMenu );
|
191 |
+
}
|
192 |
+
return PLUGIN_HANDLED;
|
193 |
+
}
|
194 |
+
|
195 |
+
enum ( <<= 1 )
|
196 |
+
{
|
197 |
+
PLMENU_OBEY_IMMUNITY = 1,
|
198 |
+
PLMENU_ALLOW_SELF,
|
199 |
+
PLMENU_ONLY_ALIVE,
|
200 |
+
PLMENU_NO_BOTS
|
201 |
+
}
|
202 |
+
|
203 |
+
MakePlayerMenu( id, const szMenuTitle[], const szMenuHandler[], iFlags = PLMENU_OBEY_IMMUNITY )
|
204 |
+
{
|
205 |
+
new iMenu = menu_create( szMenuTitle, szMenuHandler );
|
206 |
+
new bool:bIsSuperAdmin;
|
207 |
+
if ( iFlags & PLMENU_OBEY_IMMUNITY )
|
208 |
+
{
|
209 |
+
bIsSuperAdmin = !!( get_user_flags( id ) & ADMIN_RCON );
|
210 |
+
}
|
211 |
+
|
212 |
+
new iPlayers[32], iNum, iPlayer, szPlayerName[32], szUserId[32];
|
213 |
+
new szFlags[4] = "h";
|
214 |
+
if ( iFlags & PLMENU_ONLY_ALIVE )
|
215 |
+
{
|
216 |
+
szFlags[++iNum] = 'a';
|
217 |
+
}
|
218 |
+
if ( flags & PLMENU_NO_BOTS )
|
219 |
+
{
|
220 |
+
szFlags[++iNum] = 'c';
|
221 |
+
}
|
222 |
+
|
223 |
+
get_players( iPlayers, iNum, szFlags );
|
224 |
+
|
225 |
+
for ( --iNum; iNum >= 0; iNum-- )
|
226 |
+
{
|
227 |
+
iPlayer = iPlayers[iNum];
|
228 |
+
get_user_name( iPlayer, szPlayerName, charsmax( szPlayerName ) );
|
229 |
+
|
230 |
+
if ( iFlags & PLMENU_OBEY_IMMUNITY && !bIsSuperAdmin
|
231 |
+
&& ( ( get_user_flags( iPlayer ) & ADMIN_IMMUNITY ) &&
|
232 |
+
( ( iFlags & PLMENU_ALLOW_SELF ) ? ( id != iPlayer ) : true ) ) )
|
233 |
+
{
|
234 |
+
menu_addtext( iMenu, szPlayerName );
|
235 |
+
}
|
236 |
+
else
|
237 |
+
{
|
238 |
+
formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( iPlayer ) );
|
239 |
+
menu_additem( iMenu, szPlayerName, szUserId, 0 );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
return iMenu;
|
244 |
+
}
|
245 |
+
|
246 |
+
public PlayersMenuHandler_Sample( id, iMenu, iItem )
|
247 |
+
{
|
248 |
+
if ( iItem == MENU_EXIT )
|
249 |
+
{
|
250 |
+
menu_destroy( iMenu );
|
251 |
+
return PLUGIN_HANDLED;
|
252 |
+
}
|
253 |
+
|
254 |
+
new szUserId[32], szPlayerName[32], iPlayer, iAccess, iCallback;
|
255 |
+
menu_item_getinfo( iMenu, iItem, iCallback, szUserId, charsmax( szUserId ), szPlayerName, charsmax( szPlayerName ), iCallback );
|
256 |
+
|
257 |
+
if ( ( iPlayer = find_player( "k", str_to_num( szUserId ) ) ) )
|
258 |
+
{
|
259 |
+
new szName[32];
|
260 |
+
get_user_name( iPlayer, szName, charsmax( szName ) );
|
261 |
+
client_print( id, print_chat, "You have chosen #%s %s %s", szUserId, szPlayerName, szName );
|
262 |
+
}
|
263 |
+
else
|
264 |
+
{
|
265 |
+
client_print( id, print_chat, "Player %s<%s> seems to be disconnected", szPlayerName, szAuthid );
|
266 |
+
}
|
267 |
+
menu_destroy( iMenu );
|
268 |
+
return PLUGIN_HANDLED;
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
Basic Vote Menu [top]
|
273 |
+
*Note - You should have an understanding of the Basic Menu first.
|
274 |
+
Code:
|
275 |
+
#include <amxmodx>
|
276 |
+
|
277 |
+
//This will hold the VoteMenu
|
278 |
+
new gVoteMenu;
|
279 |
+
//This will hold the votes for each option
|
280 |
+
new gVotes[2];
|
281 |
+
//This determines if a vote is already happening
|
282 |
+
new gVoting;
|
283 |
+
|
284 |
+
public plugin_init()
|
285 |
+
{
|
286 |
+
//Register a way to get to your vote...
|
287 |
+
register_clcmd( "start_vote","StartVote" );
|
288 |
+
}
|
289 |
+
public StartVote( id )
|
290 |
+
{
|
291 |
+
//If there is already a vote, don't start another
|
292 |
+
if ( gVoting )
|
293 |
+
{
|
294 |
+
client_print( id, print_chat, "There is already a vote going." );
|
295 |
+
//We return PLUGIN_HANDLED so the person does not get Unknown Command in console
|
296 |
+
return PLUGIN_HANDLED;
|
297 |
+
}
|
298 |
+
|
299 |
+
//Reset vote counts from any previous votes
|
300 |
+
gVotes[0] = gVotes[1] = 0;
|
301 |
+
//Note that if you have more than 2 options, it would be better to use the line below:
|
302 |
+
//arrayset( gVotes, 0, sizeof gVotes );
|
303 |
+
|
304 |
+
//Store the menu in the global
|
305 |
+
gVoteMenu = menu_create( "\rLook at this Vote Menu!:", "menu_handler" );
|
306 |
+
|
307 |
+
//Add some vote options
|
308 |
+
menu_additem( gVoteMenu, "Vote Option 1", "", 0 );
|
309 |
+
menu_additem( gVoteMenu, "Vote Option 2", "", 0 );
|
310 |
+
|
311 |
+
//We will need to create some variables so we can loop through all the players
|
312 |
+
new players[32], pnum, tempid;
|
313 |
+
|
314 |
+
//Fill players with available players
|
315 |
+
get_players( players, pnum );
|
316 |
+
|
317 |
+
//Start looping through all players to show the vote to
|
318 |
+
for ( new i; i < pnum; i++ )
|
319 |
+
{
|
320 |
+
//Save a tempid so we do not re-index
|
321 |
+
tempid = players[i];
|
322 |
+
|
323 |
+
//Show the vote to this player
|
324 |
+
menu_display( tempid, gVoteMenu, 0 );
|
325 |
+
|
326 |
+
//Increase how many players are voting
|
327 |
+
gVoting++;
|
328 |
+
}
|
329 |
+
|
330 |
+
//End the vote in 10 seconds
|
331 |
+
set_task(10.0, "EndVote" );
|
332 |
+
|
333 |
+
return PLUGIN_HANDLED;
|
334 |
+
}
|
335 |
+
public menu_handler( id, menu, item )
|
336 |
+
{
|
337 |
+
//If the menu was exited or if there is not a vote
|
338 |
+
if ( item == MENU_EXIT || !gVoting )
|
339 |
+
{
|
340 |
+
//Note were not destroying the menu
|
341 |
+
return PLUGIN_HANDLED;
|
342 |
+
}
|
343 |
+
|
344 |
+
//Increase the votes for what they selected
|
345 |
+
gVotes[ item ]++;
|
346 |
+
|
347 |
+
//Note were not destroying the menu
|
348 |
+
return PLUGIN_HANDLED;
|
349 |
+
}
|
350 |
+
public EndVote()
|
351 |
+
{
|
352 |
+
//If the first option recieved the most votes
|
353 |
+
if ( gVotes[0] > gVotes[1] )
|
354 |
+
client_print(0, print_chat, "First option recieved most votes (%d )", gVotes[0] );
|
355 |
+
|
356 |
+
//Else if the second option recieved the most votes
|
357 |
+
else if ( gVotes[0] < gVotes[1] )
|
358 |
+
client_print(0, print_chat, "Second option recieved most votes (%d )", gVotes[1] );
|
359 |
+
|
360 |
+
//Otherwise the vote tied
|
361 |
+
else
|
362 |
+
client_print(0, print_chat, "The vote tied at %d votes each.", gVotes[0] );
|
363 |
+
|
364 |
+
//Don't forget to destroy the menu now that we are completely done with it
|
365 |
+
menu_destroy( gVoteMenu );
|
366 |
+
|
367 |
+
//Reset that no players are voting
|
368 |
+
gVoting = 0;
|
369 |
+
}
|
370 |
+
|
371 |
+
Sub-Menu [top]
|
372 |
+
*Note - You should have an understanding of the Basic Menu first.
|
373 |
+
Code:
|
374 |
+
#include <amxmodx>
|
375 |
+
|
376 |
+
public plugin_init()
|
377 |
+
{
|
378 |
+
register_clcmd( "my_awesome_menu","AwesomeMenu" );
|
379 |
+
}
|
380 |
+
public AwesomeMenu( id )
|
381 |
+
{
|
382 |
+
new menu = menu_create( "\rLook at this awesome Menu!:", "menu_handler" )
|
383 |
+
|
384 |
+
menu_additem( menu, "\wI'm Selection #1", "", 0 );
|
385 |
+
menu_additem( menu, "\wGo to SubMenu", "", 0 );
|
386 |
+
|
387 |
+
menu_display( id, menu, 0 );
|
388 |
+
}
|
389 |
+
public menu_handler( id, menu, item )
|
390 |
+
{
|
391 |
+
switch( item )
|
392 |
+
{
|
393 |
+
case 0:
|
394 |
+
{
|
395 |
+
client_print( id, print_chat, "Hooray! You selected the Awesome 1st Selection" );
|
396 |
+
}
|
397 |
+
case 1:
|
398 |
+
{
|
399 |
+
//Send them to the submenu
|
400 |
+
SubMenu( id );
|
401 |
+
}
|
402 |
+
case MENU_EXIT:
|
403 |
+
{
|
404 |
+
//Do nothing?
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
menu_destroy( menu );
|
409 |
+
return PLUGIN_HANDLED;
|
410 |
+
}
|
411 |
+
SubMenu( id )
|
412 |
+
{
|
413 |
+
//Note that we will be using a different menu handler
|
414 |
+
new menu = menu_create( "\rLook at this awesome Sub-Menu!:", "submenu_handler" )
|
415 |
+
|
416 |
+
menu_additem( menu, "\wI'm Sub-Selection #1", "", 0 );
|
417 |
+
menu_additem( menu, "\wI'm Sub-Selection #2", "", 0 );
|
418 |
+
|
419 |
+
menu_display( id, menu, 0 );
|
420 |
+
}
|
421 |
+
public submenu_handler( id, menu, item )
|
422 |
+
{
|
423 |
+
switch( item )
|
424 |
+
{
|
425 |
+
case 0:
|
426 |
+
{
|
427 |
+
client_print( id, print_chat, "Hooray! You selected the Awesome 1st Sub-Selection" );
|
428 |
+
}
|
429 |
+
case 1:
|
430 |
+
{
|
431 |
+
client_print( id, print_chat, "OH NO! You selected the Awesome 2nd Sub-Selection! BEWARE!" );
|
432 |
+
}
|
433 |
+
case MENU_EXIT:
|
434 |
+
{
|
435 |
+
//If they are still connected
|
436 |
+
if ( is_user_connected( id ) )
|
437 |
+
//Lets send them back to the top menu
|
438 |
+
AwesomeMenu( id );
|
439 |
+
}
|
440 |
+
}
|
441 |
+
|
442 |
+
menu_destroy( menu );
|
443 |
+
return PLUGIN_HANDLED;
|
444 |
+
}
|
445 |
+
|
446 |
+
Advanced Vote Menu [top]
|
447 |
+
*Note - You should have an understanding of the Basic Menu and the Basic Vote Menu first.
|
448 |
+
Code:
|
449 |
+
#include <amxmisc>
|
450 |
+
#include <fun>
|
451 |
+
|
452 |
+
//How many different votes there will be in the menu
|
453 |
+
#define MAX_VOTEIDS 7
|
454 |
+
|
455 |
+
//How much "weight" a normal player's vote is worth
|
456 |
+
#define WEIGHT_PLAYER 1
|
457 |
+
//How much "weight" an admin's vote is worth
|
458 |
+
#define WEIGHT_ADMIN 2
|
459 |
+
|
460 |
+
new gVoteMenu;
|
461 |
+
new gVotes[MAX_VOTEIDS];
|
462 |
+
new gVoting;
|
463 |
+
|
464 |
+
//This will store the voteids
|
465 |
+
new gVoteID[MAX_VOTEIDS];
|
466 |
+
|
467 |
+
public plugin_init()
|
468 |
+
{
|
469 |
+
register_clcmd( "start_vote","StartVote" );
|
470 |
+
}
|
471 |
+
public StartVote( id )
|
472 |
+
{
|
473 |
+
if ( gVoting )
|
474 |
+
{
|
475 |
+
client_print( id, print_chat, "There is already a vote going." );
|
476 |
+
return PLUGIN_HANDLED;
|
477 |
+
}
|
478 |
+
|
479 |
+
//Reset vote counts from any previous votes
|
480 |
+
arrayset( gVotes, 0, sizeof gVotes );
|
481 |
+
|
482 |
+
gVoteMenu = menu_create( "\rWho should get 255 Health?", "menu_handler" );
|
483 |
+
|
484 |
+
//Here you can do whatever you want to add your voteids.
|
485 |
+
//We are going to use players for the example
|
486 |
+
new players[32], pnum, tempid;
|
487 |
+
get_players( players, pnum, "a" );
|
488 |
+
|
489 |
+
//Variable for if the player was added to the vote
|
490 |
+
new bool:player_added[33], voteid_count;
|
491 |
+
|
492 |
+
new szName[32], szVoteId[10];
|
493 |
+
|
494 |
+
//Loop through until we get enough voteids or run out of players
|
495 |
+
while( voteid_count < MAX_VOTEIDS && voteid_count < pnum )
|
496 |
+
{
|
497 |
+
//Get a random player
|
498 |
+
tempid = players[ random( pnum ) ];
|
499 |
+
|
500 |
+
//If they haven't been added yet
|
501 |
+
if ( !player_added[tempid] )
|
502 |
+
{
|
503 |
+
get_user_name( tempid, szName, charsmax( szName ) );
|
504 |
+
|
505 |
+
//We are setting the data to the voteid number
|
506 |
+
num_to_str( voteid_count, szVoteId, charsmax( szVoteId ) );
|
507 |
+
|
508 |
+
menu_additem( gVoteMenu, szName, szVoteId, 0 );
|
509 |
+
|
510 |
+
//Make sure we do not add them again
|
511 |
+
player_added[tempid] = true;
|
512 |
+
|
513 |
+
//Save the voteid as the user id for the player
|
514 |
+
gVoteID[voteid_count] = get_user_userid( tempid );
|
515 |
+
|
516 |
+
//Go to the next voteid
|
517 |
+
voteid_count++;
|
518 |
+
}
|
519 |
+
}
|
520 |
+
|
521 |
+
//Now we have all the voteids
|
522 |
+
|
523 |
+
for ( new i; i < pnum; i++ )
|
524 |
+
{
|
525 |
+
//Save a tempid so we do not re-index
|
526 |
+
tempid = players[i];
|
527 |
+
|
528 |
+
//Show the vote to this player
|
529 |
+
menu_display( tempid, gVoteMenu, 0 );
|
530 |
+
|
531 |
+
//Increase how many players are voting by their weight
|
532 |
+
if ( is_user_admin( tempid ) )
|
533 |
+
gVoting += WEIGHT_ADMIN;
|
534 |
+
else
|
535 |
+
gVoting += WEIGHT_PLAYER;
|
536 |
+
}
|
537 |
+
|
538 |
+
set_task(10.0, "EndVote" );
|
539 |
+
|
540 |
+
return PLUGIN_HANDLED;
|
541 |
+
}
|
542 |
+
public menu_handler( id, menu, item )
|
543 |
+
{
|
544 |
+
//If the menu was exited or if there is not a vote
|
545 |
+
if ( item == MENU_EXIT || !gVoting )
|
546 |
+
{
|
547 |
+
return PLUGIN_HANDLED;
|
548 |
+
}
|
549 |
+
|
550 |
+
new szData[6], szName[64];
|
551 |
+
new item_access, item_callback;
|
552 |
+
menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
|
553 |
+
|
554 |
+
//Get the voteid number that was selected
|
555 |
+
new voteid_num = str_to_num( szData );
|
556 |
+
|
557 |
+
//Increase the votes for what they selected by weight
|
558 |
+
if ( is_user_admin( id ) )
|
559 |
+
gVotes[voteid_num] += WEIGHT_ADMIN;
|
560 |
+
else
|
561 |
+
gVotes[voteid_num] += WEIGHT_PLAYER;
|
562 |
+
|
563 |
+
return PLUGIN_HANDLED;
|
564 |
+
}
|
565 |
+
public EndVote()
|
566 |
+
{
|
567 |
+
//This will hold how many different votes were selected
|
568 |
+
new votes_select;
|
569 |
+
|
570 |
+
//This will hold the top 3 votes
|
571 |
+
new votes[3];
|
572 |
+
|
573 |
+
//This will hold the top 3 selected voteids
|
574 |
+
new voteid[3];
|
575 |
+
|
576 |
+
new i, j;
|
577 |
+
|
578 |
+
//Loop through all the voteids
|
579 |
+
for ( i=0; i<MAX_VOTEIDS; i++ )
|
580 |
+
{
|
581 |
+
//If the voteid recieved any votes
|
582 |
+
if ( gVotes[i] )
|
583 |
+
{
|
584 |
+
//If we are still trying to get the top 3
|
585 |
+
if ( votes_select < 3 )
|
586 |
+
{
|
587 |
+
//Save the data for the current voteid selected
|
588 |
+
votes[votes_select] = gVotes[i];
|
589 |
+
voteid[votes_select] = i;
|
590 |
+
|
591 |
+
//Go to the next voteid that might have been selected
|
592 |
+
votes_select++;
|
593 |
+
}
|
594 |
+
else
|
595 |
+
{
|
596 |
+
//Loop through all the top votes, replace any that are lower than the selected voteid
|
597 |
+
for ( j=0; j<3; j++ )
|
598 |
+
{
|
599 |
+
//If this one recieved less votes
|
600 |
+
if ( votes[j] < gVotes[i] )
|
601 |
+
{
|
602 |
+
//Change the data to the voteid with more votes
|
603 |
+
votes[j] = gVotes[i];
|
604 |
+
voteid[j] = i;
|
605 |
+
|
606 |
+
//Don't need to bother looking for more
|
607 |
+
break;
|
608 |
+
}
|
609 |
+
}
|
610 |
+
}
|
611 |
+
}
|
612 |
+
}
|
613 |
+
|
614 |
+
//If noone voted
|
615 |
+
if ( !votes_select )
|
616 |
+
{
|
617 |
+
client_print(0, print_chat, "CRICKEY! No one voted!" );
|
618 |
+
}
|
619 |
+
//Else if one voteid recieved all the votes
|
620 |
+
else if ( votes_select == 1 )
|
621 |
+
{
|
622 |
+
//Get the player id from the voteid
|
623 |
+
new player = find_player( "k", voteid[0]);
|
624 |
+
VoteGiveHealth( player );
|
625 |
+
}
|
626 |
+
//Else if two different voteids recieved all the votes
|
627 |
+
else if ( votes_select == 2 )
|
628 |
+
{
|
629 |
+
//If they recieved even votes
|
630 |
+
if ( votes[0] == votes[1] )
|
631 |
+
{
|
632 |
+
//Give it to a random one
|
633 |
+
client_print(0, print_chat, "Vote has tied. Choosing random from tied votes." );
|
634 |
+
new player = find_player( "k", voteid[ random(2 ) ] );
|
635 |
+
VoteGiveHealth( player );
|
636 |
+
}
|
637 |
+
|
638 |
+
//Else if the first recieved the most
|
639 |
+
else if ( votes[0] > votes[1] )
|
640 |
+
{
|
641 |
+
//Give it to the first
|
642 |
+
new player = find_player( "k", voteid[ 0 ] );
|
643 |
+
VoteGiveHealth( player );
|
644 |
+
}
|
645 |
+
|
646 |
+
//Else the second recieved the most
|
647 |
+
else
|
648 |
+
{
|
649 |
+
//Give it to the second
|
650 |
+
new player = find_player( "k", voteid[ 1 ] );
|
651 |
+
VoteGiveHealth( player );
|
652 |
+
}
|
653 |
+
}
|
654 |
+
//Else there were at least 3 different votes
|
655 |
+
else
|
656 |
+
{
|
657 |
+
//Here you might want to do run-off voting, but well just select a random one
|
658 |
+
new player = find_player( "k", voteid[ random( MAX_VOTEIDS ) ] );
|
659 |
+
client_print(0, print_chat, "Could not determine a winner. Selecting random." );
|
660 |
+
VoteGiveHealth( player );
|
661 |
+
}
|
662 |
+
|
663 |
+
menu_destroy( gVoteMenu );
|
664 |
+
gVoting = 0;
|
665 |
+
}
|
666 |
+
VoteGiveHealth( id )
|
667 |
+
{
|
668 |
+
if ( is_user_alive( id ) )
|
669 |
+
{
|
670 |
+
set_user_health( id, 255 );
|
671 |
+
new szName[32];
|
672 |
+
get_user_name( id, szName, charsmax( szName ) );
|
673 |
+
client_print(0, print_chat, "Look that Kangaroo %s has 255 Health!", szName );
|
674 |
+
}
|
675 |
+
}
|
676 |
+
|
677 |
+
Multiple Menus with 1 Handler [top]
|
678 |
+
*Note - You should have a good understanding of the Sub Menu first.
|
679 |
+
Code:
|
680 |
+
#include <amxmodx>
|
681 |
+
|
682 |
+
public plugin_init()
|
683 |
+
{
|
684 |
+
register_clcmd( "my_awesome_menu","AwesomeMenu" );
|
685 |
+
}
|
686 |
+
public AwesomeMenu( id )
|
687 |
+
{
|
688 |
+
new menu = menu_create( "\rLook at this awesome Menu!:", "menu_handler" )
|
689 |
+
|
690 |
+
//Note that our data is 'm' to know it is from the main menu
|
691 |
+
menu_additem( menu, "\wI'm Selection #1", "m", 0 );
|
692 |
+
menu_additem( menu, "\wGo to SubMenu", "m", 0 );
|
693 |
+
|
694 |
+
menu_display( id, menu, 0 );
|
695 |
+
}
|
696 |
+
SubMenu( id )
|
697 |
+
{
|
698 |
+
new menu = menu_create( "\rLook at this awesome Sub-Menu!:", "menu_handler" )
|
699 |
+
|
700 |
+
//Note that our data is 's' to know it is from the sub menu
|
701 |
+
menu_additem( menu, "\wI'm Sub-Selection #1", "s", 0 );
|
702 |
+
menu_additem( menu, "\wI'm Sub-Selection #2", "s", 0 );
|
703 |
+
|
704 |
+
menu_display( id, menu, 0 );
|
705 |
+
}
|
706 |
+
public menu_handler( id, menu, item )
|
707 |
+
{
|
708 |
+
if ( item == MENU_EXIT )
|
709 |
+
{
|
710 |
+
menu_destroy( menu );
|
711 |
+
return PLUGIN_HANDLED;
|
712 |
+
}
|
713 |
+
|
714 |
+
new szData[6], szName[64];
|
715 |
+
new item_access, item_callback;
|
716 |
+
menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
|
717 |
+
|
718 |
+
//Switch based on the first character of the data ( the 'm' or the 's')
|
719 |
+
switch( szData[0] )
|
720 |
+
{
|
721 |
+
//All our main menu data will be handled in this case
|
722 |
+
case 'm':
|
723 |
+
{
|
724 |
+
switch( item )
|
725 |
+
{
|
726 |
+
case 0:
|
727 |
+
{
|
728 |
+
client_print( id, print_chat, "Hooray! You selected the Awesome 1st Selection" );
|
729 |
+
}
|
730 |
+
case 1:
|
731 |
+
{
|
732 |
+
SubMenu( id );
|
733 |
+
}
|
734 |
+
}
|
735 |
+
}
|
736 |
+
//All our sub menu data will be handled in this case
|
737 |
+
case 's':
|
738 |
+
{
|
739 |
+
switch( item )
|
740 |
+
{
|
741 |
+
case 0:
|
742 |
+
{
|
743 |
+
client_print( id, print_chat, "Hooray! You selected the Awesome 1st Sub-Selection" );
|
744 |
+
}
|
745 |
+
case 1:
|
746 |
+
{
|
747 |
+
client_print( id, print_chat, "OH NO! You selected the Awesome 2nd Sub-Selection! BEWARE!" );
|
748 |
+
}
|
749 |
+
}
|
750 |
+
|
751 |
+
//Note that this is still only for our sub menu
|
752 |
+
AwesomeMenu( id );
|
753 |
+
}
|
754 |
+
}
|
755 |
+
|
756 |
+
menu_destroy( menu );
|
757 |
+
return PLUGIN_HANDLED;
|
758 |
+
}
|
759 |
+
|
760 |
+
Menu Items with Callbacks [top]
|
761 |
+
*Note - You should have a good understanding of the Player Menu first.
|
762 |
+
*Additional Note - This example uses a respawn function specific for Counter-Strike
|
763 |
+
Code:
|
764 |
+
#include <amxmodx>
|
765 |
+
#include <hamsandwich>
|
766 |
+
|
767 |
+
//Create a global variable to hold our callback
|
768 |
+
new g_MenuCallback;
|
769 |
+
|
770 |
+
public plugin_init()
|
771 |
+
{
|
772 |
+
register_clcmd( "my_player_menu","RespawnMenu" );
|
773 |
+
|
774 |
+
//Create our callback and save it to our variable
|
775 |
+
g_MenuCallback = menu_makecallback( "menuitem_callback" );
|
776 |
+
//The first parameter is the public function to be called when a menu item is being shown.
|
777 |
+
}
|
778 |
+
public RespawnMenu( id )
|
779 |
+
{
|
780 |
+
new menu = menu_create( "\rRevive Player Menu!:", "menu_handler" );
|
781 |
+
|
782 |
+
new players[32], pnum, tempid;
|
783 |
+
new szName[32], szUserId[10];
|
784 |
+
get_players( players, pnum );
|
785 |
+
|
786 |
+
for ( new i; i < pnum; i++ )
|
787 |
+
{
|
788 |
+
tempid = players[i];
|
789 |
+
get_user_name( tempid, szName, charsmax( szName ) );
|
790 |
+
formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ) );
|
791 |
+
|
792 |
+
//Add the item for this player with the callback
|
793 |
+
menu_additem( menu, szName, szUserId, 0, g_MenuCallback );
|
794 |
+
//Note that the last parameter that we usually omit is now filled with the callback variable
|
795 |
+
|
796 |
+
}
|
797 |
+
|
798 |
+
menu_display( id, menu, 0 );
|
799 |
+
}
|
800 |
+
//This is our callback function. Return ITEM_ENABLED, ITEM_DISABLED, or ITEM_IGNORE.
|
801 |
+
public menuitem_callback( id, menu, item )
|
802 |
+
{
|
803 |
+
//Create some variables to hold information about the menu item
|
804 |
+
new szData[6], szName[64];
|
805 |
+
new item_access, item_callback;
|
806 |
+
|
807 |
+
//Get information about the menu item
|
808 |
+
menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
|
809 |
+
//Note - item_callback should be equal to g_MenuCallback
|
810 |
+
|
811 |
+
//Get which player the item is for
|
812 |
+
new userid = str_to_num( szData );
|
813 |
+
new player = find_player( "k", userid ); // flag "k" : find player from userid
|
814 |
+
|
815 |
+
//If the user is alive, we want to disable reviving them
|
816 |
+
if ( is_user_alive( tempid ) )
|
817 |
+
{
|
818 |
+
return ITEM_DISABLED;
|
819 |
+
}
|
820 |
+
|
821 |
+
//Otherwise we can just ignore the return value
|
822 |
+
return ITEM_IGNORE;
|
823 |
+
//Note that returning ITEM_ENABLED will override the admin flag check from menu_additem
|
824 |
+
}
|
825 |
+
public menu_handler( id, menu, item )
|
826 |
+
{
|
827 |
+
if ( item == MENU_EXIT )
|
828 |
+
{
|
829 |
+
menu_destroy( menu );
|
830 |
+
return PLUGIN_HANDLED;
|
831 |
+
}
|
832 |
+
|
833 |
+
new szData[6], szName[64];
|
834 |
+
new item_access, item_callback;
|
835 |
+
menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
|
836 |
+
|
837 |
+
//Get the id of the player that was selected
|
838 |
+
new userid = str_to_num( szData );
|
839 |
+
new player = find_player( "k", userid ); // flag "k" : find player from userid
|
840 |
+
|
841 |
+
//If the player is not alive
|
842 |
+
//Note - you should check this again in the handler function because the player could have been revived after the menu was shown
|
843 |
+
if ( !is_user_alive( player ) )
|
844 |
+
{
|
845 |
+
//Respawn them
|
846 |
+
ExecuteHamB( Ham_CS_RoundRespawn, player );
|
847 |
+
}
|
848 |
+
|
849 |
+
menu_destroy( menu );
|
850 |
+
return PLUGIN_HANDLED;
|
851 |
+
}
|
852 |
+
|
853 |
+
|
854 |
+
|
855 |
+
newmenus.inc [top]
|
856 |
+
Code:
|
857 |
+
//The following defines are to be used with the native menu_setprop
|
858 |
+
#define MPROP_PERPAGE 1 /* Number of items per page ( param1 = number, 0=no paginating, 7=default ) */
|
859 |
+
#define MPROP_BACKNAME 2 /* Name of the back button ( param1 = string ) */
|
860 |
+
#define MPROP_NEXTNAME 3 /* Name of the next button ( param1 = string ) */
|
861 |
+
#define MPROP_EXITNAME 4 /* Name of the exit button ( param1 = string ) */
|
862 |
+
#define MPROP_TITLE 5 /* Menu title text ( param1 = string ) */
|
863 |
+
#define MPROP_EXIT 6 /* Exit functionality ( param1 = number, see MEXIT constants ) */
|
864 |
+
#define MPROP_NOCOLORS 8 /* Sets whether colors are not auto ( param1 = number, 0=default ) */
|
865 |
+
#define MPROP_NUMBER_COLOR 10 /* Color indicator to use for numbers ( param1 = string, "\r"=default ) */
|
866 |
+
|
867 |
+
//These two defines are to be used when changing a menu's MPROP_EXIT value
|
868 |
+
#define MEXIT_ALL 1 /* Menu will have an exit option ( default )*/
|
869 |
+
#define MEXIT_NEVER -1 /* Menu will not have an exit option */
|
870 |
+
|
871 |
+
//For more details about the following natives, check your actual newmenus.inc
|
872 |
+
native menu_create( const title[], const handler[], ml=0 );
|
873 |
+
native menu_makecallback( const function[]);
|
874 |
+
native menu_additem( menu, const name[], const info[]="", paccess=0, callback=-1 );
|
875 |
+
native menu_pages( menu );
|
876 |
+
native menu_items( menu );
|
877 |
+
native menu_display( id, menu, page=0 );
|
878 |
+
native menu_find_id( menu, page, key );
|
879 |
+
native menu_item_getinfo( menu, item, &access, info[], infolen, name[]="", namelen=0, &callback );
|
880 |
+
native menu_item_setname( menu, item, const name[]);
|
881 |
+
native menu_item_setcmd( menu, item, const info[]);
|
882 |
+
native menu_item_setcall( menu, item, callback=-1 );
|
883 |
+
native menu_destroy( menu );
|
884 |
+
native player_menu_info( id, &menu, &newmenu, &menupage=0 );
|
885 |
+
native menu_addblank( menu, slot=1 );
|
886 |
+
native menu_addtext( menu, const text[], slot=1 );
|
887 |
+
native menu_setprop( menu, prop, ...);
|
888 |
+
native menu_cancel( player );
|
889 |
+
|
890 |
+
|
891 |
+
End Notes: [top]
|
892 |
+
Most of the menu_* natives will throw errors if they are passed an invalid menu. A menu is invalid if it is -1.
|
893 |
+
You can expand on these in many ways, like only have one menu_handler to handle more than 1 menu
|
894 |
+
If you are using a constant menu ( doesn't change at all ) you do not need to create and destroy it each time. It is better to save it as a global.
|
895 |
+
These examples are not completely optimized, but they are for beginners and so they are simplified.
|
896 |
+
List of Colors for menus: ( there are no other colors available )
|
897 |
+
White - \w
|
898 |
+
Yellow - \y
|
899 |
+
Red - \r
|
900 |
+
Grey/Disabled - \d
|
901 |
+
To align text to the right - \R
|
902 |
+
A menu will not show if it does not have any items.
|
903 |
+
Text and blanks can only be added after an item.
|
904 |
+
To hide a menu ( new or old style ) one can do:
|
905 |
+
Code:
|
906 |
+
show_menu( id, 0, "^n", 1 );
|
907 |
+
One can remove the Next, Back, and Exit buttons to show up to 10 items by using:
|
908 |
+
Code:
|
909 |
+
menu_setprop( menu, MPROP_PERPAGE, 0 );
|
Plugin API.txt
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
There is API functionality in AMXX plugins, implemented through a set of natives. The following natives, built into the core, allow API capabilities:
|
2 |
+
CreateMultiForward
|
3 |
+
CreateOneForward
|
4 |
+
ExecuteForward
|
5 |
+
PrepareArray
|
6 |
+
DestroyForward
|
7 |
+
|
8 |
+
But what are they used for? Well, let's take a look at an example and then pull it apart to figure out how it works. Please keep in mind that an API is designed for multiple plugins, so every example will be 2 individual scripts instead of 1 (although it's possible to put them both in one)
|
9 |
+
|
10 |
+
Code:
|
11 |
+
#include <amxmodx>
|
12 |
+
|
13 |
+
new Float:g_flDelay
|
14 |
+
|
15 |
+
public plugin_init()
|
16 |
+
{
|
17 |
+
register_plugin("API Test - Core","1.0","Hawk552")
|
18 |
+
|
19 |
+
g_flDelay = random_float(0.1,0.5)
|
20 |
+
set_task(g_flDelay,"fnDoForward")
|
21 |
+
}
|
22 |
+
|
23 |
+
public fnDoForward()
|
24 |
+
{
|
25 |
+
new iForward = CreateMultiForward("plugin_init_delay",ET_IGNORE,FP_FLOAT),iReturn
|
26 |
+
if(iForward < 0)
|
27 |
+
return log_amx("Forward could not be created.")
|
28 |
+
|
29 |
+
if(!ExecuteForward(iForward,iReturn,g_flDelay))
|
30 |
+
return log_amx("Could not execute forward.")
|
31 |
+
|
32 |
+
return DestroyForward(iForward)
|
33 |
+
}
|
34 |
+
|
35 |
+
Code:
|
36 |
+
#include <amxmodx>
|
37 |
+
|
38 |
+
public plugin_init()
|
39 |
+
register_plugin("API Test - Attachment","1.0","Hawk552")
|
40 |
+
|
41 |
+
public plugin_init_delay(Float:flDelay)
|
42 |
+
log_amx("Forward executed %f seconds after plugin_init.",flDelay)
|
43 |
+
|
44 |
+
Now, let's pick these two apart.
|
45 |
+
|
46 |
+
In the first script, the important part starts at fnDoForward. What we see is:
|
47 |
+
|
48 |
+
Code:
|
49 |
+
new iForward = CreateMultiForward("plugin_init_delay",ET_IGNORE,FP_FLOAT)
|
50 |
+
|
51 |
+
CreateMultiForward and CreateOneForward (which will be addressed later) return handles that can be used for ExecuteForward and DestroyForward.
|
52 |
+
NOTE: Difference between CreateMultiForward and CreateOneForward: multi accepts a return value and you must specify upon which condition it'll stop. Multi also sends to all plugins that have a public function after the name of const name[], as shown below. CreateOneForward requires a plugin id, and automatically ignores the return value (although you can still pass it byref)
|
53 |
+
|
54 |
+
But as for the parameters:
|
55 |
+
|
56 |
+
const name[] - this is the name of the public function you want to call from whatever plugin(s) specified
|
57 |
+
stop_type - this is what the plugin should obey in terms of stopping. For example, if you register a client command "kill" and then return PLUGIN_HANDLED, it'll stop right there. This parameter allows you to specify whether or not it will stop there, and whether or not the return value from plugins called matters. The possibilities are here:
|
58 |
+
|
59 |
+
Code:
|
60 |
+
#define ET_IGNORE 0 //ignore return val
|
61 |
+
#define ET_STOP 1 //stop on PLUGIN_HANDLED
|
62 |
+
#define ET_STOP2 2 //same, except return biggest
|
63 |
+
#define ET_CONTINUE 3 //no stop, return biggest
|
64 |
+
|
65 |
+
In this case, we use ET_IGNORE because plugin_init never stops calling, despite what plugins return (which is why it's useless to return PLUGIN_CONTINUE/_HANDLED in plugin_init), and we want to duplicate that functionality.
|
66 |
+
|
67 |
+
... - This is where the parameters of the header of the function called should be specified. In the above example, FP_FLOAT was specified. This is to let the AMXX core know that we want to send a floating point int to the functions called.
|
68 |
+
|
69 |
+
Here are the possibilities for the previous section (I will explain how to pass an array/string later):
|
70 |
+
|
71 |
+
Code:
|
72 |
+
#define FP_CELL 0
|
73 |
+
#define FP_FLOAT 1
|
74 |
+
#define FP_STRING 2
|
75 |
+
#define FP_ARRAY 4
|
76 |
+
|
77 |
+
Next we check if iForward > 0, or if it's not we stop there and inform the server console. As said in the funcwiki, "Results will be > 0 for success.".
|
78 |
+
|
79 |
+
Next, we execute the forward using ExecuteForward. Picking this function apart:
|
80 |
+
|
81 |
+
forward_handle - this is the forward to call. It's the handle returned from CreateMultiForward / CreateOneForward.
|
82 |
+
|
83 |
+
&ret - this is the return value, passed by reference. It is effectively the value that the function being called returns (ex. return PLUGIN_HANDLED -> &ret == 1) It usually is effected by the stop_type in CreateMultiForward.
|
84 |
+
|
85 |
+
... - this is the param(s) where you can input the data that will be passed onto the function header for the function being called. In the example above, g_flDelay is passed and in the second plugin, the plugin_init_delay function recieves it in the header as Float:flDelay. NOTE: You can theoretically have infinite parameters, but they must match with the types passed into CreateOneForward / CreateMultiForward.
|
86 |
+
|
87 |
+
If ExecuteForward returns 0 (false) then we stop there and inform the server of this error. Otherwise, we continue onward to DestroyForward.
|
88 |
+
|
89 |
+
The next part we find is DestroyForward. The functionality for this is quite obvious, and can be used on any forward but should be used by the time plugin_end is called (or the FM forward for server shutting down) otherwise memory leaks can occur.
|
90 |
+
|
91 |
+
Now, what was the point of that? Not really much, that was pretty damn useless. Here's something a little more useful:
|
92 |
+
|
93 |
+
Code:
|
94 |
+
#include <amxmodx>
|
95 |
+
#include <fakemeta>
|
96 |
+
|
97 |
+
new g_iForward
|
98 |
+
new g_iReturn
|
99 |
+
|
100 |
+
public plugin_init()
|
101 |
+
{
|
102 |
+
register_plugin("API Test 2 - Core","1.0","Hawk552")
|
103 |
+
|
104 |
+
g_iForward = CreateMultiForward("client_PreThink",ET_IGNORE,FP_CELL)
|
105 |
+
if(g_iForward < 0)
|
106 |
+
log_amx("Error creating forward")
|
107 |
+
|
108 |
+
register_forward(FM_PlayerPreThink,"fnForwardPlayerPreThink")
|
109 |
+
register_forward(FM_Sys_Error,"fnForwardSysError")
|
110 |
+
}
|
111 |
+
|
112 |
+
public fnForwardPlayerPreThink(id)
|
113 |
+
if(!ExecuteForward(g_iForward,g_iReturn,id))
|
114 |
+
log_amx("Could not execute forward")
|
115 |
+
|
116 |
+
public fnForwardSysError()
|
117 |
+
plugin_end()
|
118 |
+
|
119 |
+
public plugin_end()
|
120 |
+
DestroyForward(g_iForward)
|
121 |
+
|
122 |
+
Code:
|
123 |
+
#include <amxmodx>
|
124 |
+
|
125 |
+
public plugin_init()
|
126 |
+
register_plugin("API Test - Attachment 2","1.0","Hawk552")
|
127 |
+
|
128 |
+
public client_PreThink(id)
|
129 |
+
log_amx("PreThink called on %d",id)
|
130 |
+
|
131 |
+
We just allowed a plugin to use client_PreThink using fakemeta without having to even create the fakemeta forward in the other plugin. On top of this, if we added another plugin to the API, it would call client_PreThink for that one too. Be careful though, it'll call it twice if you have engine included.
|
132 |
+
|
133 |
+
But one thing remains unanswered: how do you pass an array/string?
|
134 |
+
|
135 |
+
A special native has been implemented for this, PrepareArray. Here's an example of how to use it:
|
136 |
+
|
137 |
+
Code:
|
138 |
+
#include <amxmodx>
|
139 |
+
#include <fakemeta>
|
140 |
+
|
141 |
+
new g_iForward
|
142 |
+
new g_iReturn
|
143 |
+
|
144 |
+
public plugin_init()
|
145 |
+
{
|
146 |
+
register_plugin("API Test 2 - Core","1.0","Hawk552")
|
147 |
+
|
148 |
+
g_iForward = CreateMultiForward("client_PreThink",ET_IGNORE,FP_ARRAY)
|
149 |
+
if(g_iForward < 0)
|
150 |
+
log_amx("Error creating forward")
|
151 |
+
|
152 |
+
register_forward(FM_PlayerPreThink,"fnForwardPlayerPreThink")
|
153 |
+
register_forward(FM_Sys_Error,"fnForwardSysError")
|
154 |
+
}
|
155 |
+
|
156 |
+
public fnForwardPlayerPreThink(id)
|
157 |
+
{
|
158 |
+
new iRand = random(5),iArray[2]
|
159 |
+
iArray[0] = id
|
160 |
+
iArray[1] = iRand
|
161 |
+
|
162 |
+
new iArrayPass = PrepareArray(iArray,2,0)
|
163 |
+
|
164 |
+
if(!ExecuteForward(g_iForward,g_iReturn,iArrayPass))
|
165 |
+
log_amx("Could not execute forward")
|
166 |
+
}
|
167 |
+
|
168 |
+
public fnForwardSysError()
|
169 |
+
plugin_end()
|
170 |
+
|
171 |
+
public plugin_end()
|
172 |
+
DestroyForward(g_iForward)
|
173 |
+
|
174 |
+
Code:
|
175 |
+
#include <amxmodx>
|
176 |
+
|
177 |
+
public plugin_init()
|
178 |
+
register_plugin("API Test - Attachment 2","1.0","Hawk552")
|
179 |
+
|
180 |
+
public client_PreThink(iArray[2])
|
181 |
+
log_amx("PreThink called on %d, random value is %d",iArray[0],iArray[1])
|
182 |
+
|
183 |
+
Regardless of the fact we could use 2 cells instead of an array, this allows client_PreThink to have a random value from 0-5 packed into the parameters (which is quite useless, again this is just an example).
|
184 |
+
|
185 |
+
Now, to pick this apart:
|
186 |
+
|
187 |
+
We created an array and then packed it with data. You should know how to already do this.
|
188 |
+
|
189 |
+
We then use:
|
190 |
+
|
191 |
+
Code:
|
192 |
+
new iArrayPass = PrepareArray(iArray,2,0)
|
193 |
+
|
194 |
+
The usage of PrepareArray is as follows:
|
195 |
+
|
196 |
+
array[] - this is the array to be prepared
|
197 |
+
size - this is the amount of cells in the array (the same amount as when declaring it, not the highest cell)
|
198 |
+
copyback=0 - this is whether or not changing the array will result in the calling function's array being changed as well. This defaults to 0.
|
199 |
+
|
200 |
+
PrepareArray returns a handle as well that can be passed into ExecuteForward under the param of FP_ARRAY or FP_STRING. The difference between these two is that FP_STRING stops reading at the null terminator (and does not need to be prepared using PrepareArray), but FP_ARRAY must be prepared and only stops reading at the "size" cell.
|
Regular Expressions. regex_tester.txt
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include < amxmodx >
|
2 |
+
#include < amxmisc >
|
3 |
+
#include < regex >
|
4 |
+
|
5 |
+
new Regex:g_pPattern = REGEX_PATTERN_FAIL;
|
6 |
+
|
7 |
+
new Regex:g_pPatternFlags;
|
8 |
+
|
9 |
+
public plugin_init( )
|
10 |
+
{
|
11 |
+
register_plugin( "Regex Tester", "0.0.1", "Exolent" );
|
12 |
+
|
13 |
+
register_concmd( "regex_pattern", "CmdPattern", _, "<pattern>" );
|
14 |
+
register_concmd( "regex_test", "CmdTest", _, "<test data>" );
|
15 |
+
|
16 |
+
new iReturn, szError[ 128 ];
|
17 |
+
g_pPatternFlags = regex_compile( "^^\/(.*)\/([imsx]*)$", iReturn, szError, charsmax( szError ) );
|
18 |
+
|
19 |
+
if( g_pPatternFlags == REGEX_PATTERN_FAIL )
|
20 |
+
{
|
21 |
+
log_amx( "Error creating pattern for patterns: %s", szError );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
public CmdPattern( iPlayer, iLevel, iCID )
|
26 |
+
{
|
27 |
+
if( !cmd_access( iPlayer, iLevel, iCID, 2 ) )
|
28 |
+
{
|
29 |
+
return PLUGIN_HANDLED;
|
30 |
+
}
|
31 |
+
|
32 |
+
new szPattern[ 128 ];
|
33 |
+
read_args( szPattern, charsmax( szPattern ) );
|
34 |
+
trim( szPattern );
|
35 |
+
remove_quotes( szPattern );
|
36 |
+
|
37 |
+
new szFlags[ 5 ];
|
38 |
+
|
39 |
+
new iReturn;
|
40 |
+
|
41 |
+
if( regex_match_c( szPattern, g_pPatternFlags, iReturn ) > 0 )
|
42 |
+
{
|
43 |
+
regex_substr( g_pPatternFlags, 1, szPattern, charsmax( szPattern ) );
|
44 |
+
regex_substr( g_pPatternFlags, 2, szFlags, charsmax( szFlags ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
new szError[ 128 ];
|
48 |
+
g_pPattern = regex_compile( szPattern, iReturn, szError, charsmax( szError ), szFlags );
|
49 |
+
|
50 |
+
if( g_pPattern == REGEX_PATTERN_FAIL )
|
51 |
+
{
|
52 |
+
console_print( iPlayer, "Error with pattern: %s", szError );
|
53 |
+
}
|
54 |
+
else
|
55 |
+
{
|
56 |
+
console_print( iPlayer, "Pattern set to: %s", szPattern );
|
57 |
+
console_print( iPlayer, "Flags set to: %s", szFlags );
|
58 |
+
}
|
59 |
+
|
60 |
+
return PLUGIN_HANDLED;
|
61 |
+
}
|
62 |
+
|
63 |
+
public CmdTest( iPlayer, iLevel, iCID )
|
64 |
+
{
|
65 |
+
if( !cmd_access( iPlayer, iLevel, iCID, 2 ) )
|
66 |
+
{
|
67 |
+
return PLUGIN_HANDLED;
|
68 |
+
}
|
69 |
+
|
70 |
+
if( g_pPattern == REGEX_PATTERN_FAIL )
|
71 |
+
{
|
72 |
+
console_print( iPlayer, "No pattern set. Use regex_pattern first." );
|
73 |
+
return PLUGIN_HANDLED;
|
74 |
+
}
|
75 |
+
|
76 |
+
new szData[ 256 ];
|
77 |
+
read_args( szData, charsmax( szData ) );
|
78 |
+
trim( szData );
|
79 |
+
remove_quotes( szData );
|
80 |
+
|
81 |
+
new iReturn;
|
82 |
+
if( regex_match_c( szData, g_pPattern, iReturn ) != -2 )
|
83 |
+
{
|
84 |
+
console_print( iPlayer, "%d matches", iReturn );
|
85 |
+
|
86 |
+
for( new i = 0; i < iReturn; i++ )
|
87 |
+
{
|
88 |
+
regex_substr( g_pPattern, i, szData, charsmax( szData ) );
|
89 |
+
|
90 |
+
console_print( iPlayer, "%d. ^"%s^"", ( i + 1 ), szData );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
else
|
94 |
+
{
|
95 |
+
console_print( iPlayer, "Regex match error code %d", iReturn );
|
96 |
+
}
|
97 |
+
|
98 |
+
return PLUGIN_HANDLED;
|
99 |
+
}
|
Regular Expressions.txt
ADDED
@@ -0,0 +1,388 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Regular Expressions
|
2 |
+
|
3 |
+
Introduction
|
4 |
+
For information on what regular expressions are (or how to create them), consult the wiki.
|
5 |
+
|
6 |
+
RegEx Patterns
|
7 |
+
Here is a quick reference for patterns:
|
8 |
+
Code:
|
9 |
+
+-------------+--------------------------------------------------------------+
|
10 |
+
| Expression | Description |
|
11 |
+
+-------------+--------------------------------------------------------------+
|
12 |
+
| . | Any character except newline. |
|
13 |
+
+-------------+--------------------------------------------------------------+
|
14 |
+
| \. | A period (and so on for \*, \(, \\, etc.) |
|
15 |
+
+-------------+--------------------------------------------------------------+
|
16 |
+
| ^ | The start of the string. |
|
17 |
+
+-------------+--------------------------------------------------------------+
|
18 |
+
| $ | The end of the string. |
|
19 |
+
+-------------+--------------------------------------------------------------+
|
20 |
+
| \d,\w,\s | A digit, word character [A-Za-z0-9_], or whitespace. |
|
21 |
+
+-------------+--------------------------------------------------------------+
|
22 |
+
| \D,\W,\S | Anything except a digit, word character, or whitespace. |
|
23 |
+
+-------------+--------------------------------------------------------------+
|
24 |
+
| [abc] | Character a, b, or c. |
|
25 |
+
+-------------+--------------------------------------------------------------+
|
26 |
+
| [a-z] | a through z. |
|
27 |
+
+-------------+--------------------------------------------------------------+
|
28 |
+
| [^abc] | Any character except a, b, or c. |
|
29 |
+
+-------------+--------------------------------------------------------------+
|
30 |
+
| aa|bb | Either aa or bb. |
|
31 |
+
+-------------+--------------------------------------------------------------+
|
32 |
+
| ? | Zero or one of the preceding element. |
|
33 |
+
+-------------+--------------------------------------------------------------+
|
34 |
+
| * | Zero or more of the preceding element. |
|
35 |
+
+-------------+--------------------------------------------------------------+
|
36 |
+
| + | One or more of the preceding element. |
|
37 |
+
+-------------+--------------------------------------------------------------+
|
38 |
+
| {n} | Exactly n of the preceding element. |
|
39 |
+
+-------------+--------------------------------------------------------------+
|
40 |
+
| {n,} | n or more of the preceding element. |
|
41 |
+
+-------------+--------------------------------------------------------------+
|
42 |
+
| {m,n} | Between m and n of the preceding element. |
|
43 |
+
+-------------+--------------------------------------------------------------+
|
44 |
+
| ??,*?,+?, | Same as above, but as few as possible. |
|
45 |
+
| {n}?, etc. | |
|
46 |
+
+-------------+--------------------------------------------------------------+
|
47 |
+
| (expr) | Capture expr for use with \1, etc. |
|
48 |
+
+-------------+--------------------------------------------------------------+
|
49 |
+
| (?:expr) | Non-capturing group. |
|
50 |
+
+-------------+--------------------------------------------------------------+
|
51 |
+
| (?=expr) | Followed by expr. |
|
52 |
+
+-------------+--------------------------------------------------------------+
|
53 |
+
| (?!expr) | Not followed by expr. |
|
54 |
+
+-------------+--------------------------------------------------------------+
|
55 |
+
|
56 |
+
Example:
|
57 |
+
Let's try to catch a swear work, like "ass".
|
58 |
+
We could simply make our pattern "ass" and it would match it.
|
59 |
+
But, it would also match "glass" or "brass", so how do we fix that?
|
60 |
+
|
61 |
+
We add a non-character requirement in front of ass.
|
62 |
+
So we would do this: "\Wass", which means allow anything except for a letter before "ass".
|
63 |
+
Now, "glass" or "brass" won't get picked, but now just "ass" won't because it requires something besides a letter in front.
|
64 |
+
|
65 |
+
To fix this, we make the non-character requirement also allow nothing in front, like so: "\W*ass"
|
66 |
+
|
67 |
+
We're still not done yet. What about the word "assassin"?
|
68 |
+
That will still get picked up because it matches the first "ass" in "assassin".
|
69 |
+
So now we have to allow nothing, or anything except a character, after it: "\W*ass\W*"
|
70 |
+
|
71 |
+
Looks good, right? Now, we need to add checking for people who would type variations, like asssss or aaasssss.
|
72 |
+
So, let's just say any number of A's and at least 2 S's: "\W*a+s{2,}\W*"
|
73 |
+
|
74 |
+
One last thing is checking for non-alphabetic characters to look like those letters, like a$$.
|
75 |
+
Well, let's see what looks alike:
|
76 |
+
a = @, 4, /\, /-\
|
77 |
+
s = 5, z, $
|
78 |
+
|
79 |
+
Now, let's transform them into character classes:
|
80 |
+
a = (?:[a@4]|\/\\|\/-\\)
|
81 |
+
s = [s5z\$]
|
82 |
+
|
83 |
+
We had to put A's in a non-capturing group since /\ and /-\ are more than 1 character and won't work for character classes.
|
84 |
+
I used a non-capturing group so every A isn't put into the matches when checked.
|
85 |
+
Also, the slashes in A's and the dollar sign in S's needed to be escaped.
|
86 |
+
|
87 |
+
Add those to the pattern now:
|
88 |
+
"\W*(?:[a@4]|\/\\|\/-\\)+[s5z\$]{2,}\W*"
|
89 |
+
|
90 |
+
Finally, let's add the ignore case-sensitivity flag to allow capital letters checking:
|
91 |
+
/\W*(?:[a@4]|\/\\|\/-\\)+[s5z\$]{2,}\W*/i
|
92 |
+
|
93 |
+
That's how you create RegEx patterns, and they normally do look crazy when you're done with them so be sure to comment what they are for in case you need to go back to them later.
|
94 |
+
|
95 |
+
RegEx Flags
|
96 |
+
Flags were introduced to AMXX in version 1.8.
|
97 |
+
|
98 |
+
These are the flags you can use with your patterns:
|
99 |
+
i - Ignore case
|
100 |
+
- Ignores case sensitivity with your pattern, so /a/i would be "a" and "A"
|
101 |
+
m - Multilines
|
102 |
+
- Affects ^ and $ so that they match the start/end of a line rather than the start/end of the string
|
103 |
+
s - Single line
|
104 |
+
- Affects . so it matches any character, even new line characters
|
105 |
+
x - Pattern extension
|
106 |
+
- Ignore whitespace and # comments
|
107 |
+
|
108 |
+
RegEx in AMXX
|
109 |
+
In most languages, you will see this format for the expression: /pattern/flags
|
110 |
+
In AMXX, the pattern and flags are separated, and those slashes are taken away.
|
111 |
+
|
112 |
+
So if you had this pattern: /[ch]+at/i
|
113 |
+
It would be split into:
|
114 |
+
- pattern: [ch]+at
|
115 |
+
- flags: i
|
116 |
+
|
117 |
+
Do not escape for new line characters (or other escapable characters) with Pawns escape character, like ^n.
|
118 |
+
Instead, use the RegEx escape with \n.
|
119 |
+
|
120 |
+
Using RegEx
|
121 |
+
First, you'll need to include regex.inc:
|
122 |
+
Code:
|
123 |
+
#include <regex>
|
124 |
+
|
125 |
+
These are the error codes from matching:
|
126 |
+
Code:
|
127 |
+
enum Regex
|
128 |
+
{
|
129 |
+
REGEX_MATCH_FAIL = -2,
|
130 |
+
REGEX_PATTERN_FAIL,
|
131 |
+
REGEX_NO_MATCH,
|
132 |
+
REGEX_OK
|
133 |
+
};
|
134 |
+
|
135 |
+
Checking if a string matches a pattern is simple.
|
136 |
+
Spoiler
|
137 |
+
Code:
|
138 |
+
/**
|
139 |
+
* Matches a string against a regular expression pattern.
|
140 |
+
*
|
141 |
+
* @note If you intend on using the same regular expression pattern
|
142 |
+
* multiple times, consider using regex_compile and regex_match_c
|
143 |
+
* instead of making this function reparse the expression each time.
|
144 |
+
*
|
145 |
+
* @param string The string to check.
|
146 |
+
* @param pattern The regular expression pattern.
|
147 |
+
* @param ret Error code, or result state of the match.
|
148 |
+
* @param error Error message, if applicable.
|
149 |
+
* @param maxLen Maximum length of the error buffer.
|
150 |
+
* @param flags General flags for the regular expression.
|
151 |
+
* i = Ignore case
|
152 |
+
* m = Multilines (affects ^ and $ so that they match
|
153 |
+
* the start/end of a line rather than matching the
|
154 |
+
* start/end of the string).
|
155 |
+
* s = Single line (affects . so that it matches any character,
|
156 |
+
* even new line characters).
|
157 |
+
* x = Pattern extension (ignore whitespace and # comments).
|
158 |
+
*
|
159 |
+
* @return -2 = Matching error (error code is stored in ret)
|
160 |
+
* -1 = Error in pattern (error message and offset # in error and ret)
|
161 |
+
* 0 = No match.
|
162 |
+
* >1 = Handle for getting more information (via regex_substr)
|
163 |
+
*
|
164 |
+
* @note Flags only exist in amxmodx 1.8 and later.
|
165 |
+
* @note You should free the returned handle (with regex_free())
|
166 |
+
* when you are done extracting all of the substrings.
|
167 |
+
*/
|
168 |
+
native Regex:regex_match(const string[], const pattern[], &ret, error[], maxLen, const flags[] = "");
|
169 |
+
|
170 |
+
|
171 |
+
Example:
|
172 |
+
Spoiler
|
173 |
+
Code:
|
174 |
+
new const string[] = "123.456"
|
175 |
+
|
176 |
+
new ret, error[128]
|
177 |
+
new Regex:regex_handle = regex_match(string, "\d+\.\d+", ret, error, charsmax(error))
|
178 |
+
|
179 |
+
switch(regex_handle)
|
180 |
+
{
|
181 |
+
case REGEX_MATCH_FAIL:
|
182 |
+
{
|
183 |
+
// There was an error matching against the pattern
|
184 |
+
// Check the {error} variable for message, and {ret} for error code
|
185 |
+
}
|
186 |
+
case REGEX_PATTERN_FAIL:
|
187 |
+
{
|
188 |
+
// There is an error in your pattern
|
189 |
+
// Check the {error} variable for message, and {ret} for error code
|
190 |
+
}
|
191 |
+
case REGEX_NO_MATCH:
|
192 |
+
{
|
193 |
+
// Matched string 0 times
|
194 |
+
}
|
195 |
+
default:
|
196 |
+
{
|
197 |
+
// Matched string {ret} times
|
198 |
+
|
199 |
+
// Free the Regex handle
|
200 |
+
regex_free(regex_handle);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
+
You can get the individual matches (if you supplied groupings).
|
206 |
+
Spoiler
|
207 |
+
Code:
|
208 |
+
/**
|
209 |
+
* Returns a matched substring from a regex handle.
|
210 |
+
* Substring ids start at 0 and end at ret-1, where ret is from the corresponding
|
211 |
+
* regex_match or regex_match_c function call.
|
212 |
+
*
|
213 |
+
* @param id The regex handle to extract data from.
|
214 |
+
* @param str_id The index of the expression to get - starts at 0, and ends at ret - 1.
|
215 |
+
* @param buffer The buffer to set to the matching substring.
|
216 |
+
* @param maxLen The maximum string length of the buffer.
|
217 |
+
*
|
218 |
+
*/
|
219 |
+
native regex_substr(Regex:id, str_id, buffer[], maxLen);
|
220 |
+
|
221 |
+
|
222 |
+
Example, grabbing the numbers from a SteamID:
|
223 |
+
Spoiler
|
224 |
+
Code:
|
225 |
+
new const steamID[] = "STEAM_0:1:23456"
|
226 |
+
|
227 |
+
new ret, error[128]
|
228 |
+
new Regex:regex_handle = regex_match(steamID, "^^STEAM_0:[01]:(\d+)$", ret, error, charsmax(error))
|
229 |
+
|
230 |
+
if(regex_handle > REGEX_NO_MATCH)
|
231 |
+
{
|
232 |
+
// 0 string ID is always the whole string that matched
|
233 |
+
// After 0 are the groupings
|
234 |
+
|
235 |
+
new numbers[32]
|
236 |
+
regex_substr(regex_handle, 1, numbers, charsmax(numbers))
|
237 |
+
|
238 |
+
// numbers = "23456"
|
239 |
+
|
240 |
+
regex_free(regex_handle)
|
241 |
+
}
|
242 |
+
|
243 |
+
Compiling Patterns
|
244 |
+
When you have a pattern that will be used more than one time, it is more efficient to compile it.
|
245 |
+
|
246 |
+
Spoiler
|
247 |
+
Code:
|
248 |
+
/**
|
249 |
+
* Precompile a regular expression. Use this if you intend on using the
|
250 |
+
* same expression multiple times. Pass the regex handle returned here to
|
251 |
+
* regex_match_c to check for matches.
|
252 |
+
*
|
253 |
+
* @param pattern The regular expression pattern.
|
254 |
+
* @param errcode Error code encountered, if applicable.
|
255 |
+
* @param error Error message encountered, if applicable.
|
256 |
+
* @param maxLen Maximum string length of the error buffer.
|
257 |
+
* @param flags General flags for the regular expression.
|
258 |
+
* i = Ignore case
|
259 |
+
* m = Multilines (affects ^ and $ so that they match
|
260 |
+
* the start/end of a line rather than matching the
|
261 |
+
* start/end of the string).
|
262 |
+
* s = Single line (affects . so that it matches any character,
|
263 |
+
* even new line characters).
|
264 |
+
* x = Pattern extension (ignore whitespace and # comments).
|
265 |
+
*
|
266 |
+
* @return -1 on error in the pattern, > valid regex handle (> 0) on success.
|
267 |
+
*
|
268 |
+
* @note This handle is automatically freed on map change. However,
|
269 |
+
* if you are completely done with it before then, you should
|
270 |
+
* call regex_free on this handle.
|
271 |
+
*/
|
272 |
+
native Regex:regex_compile(const pattern[], &ret, error[], maxLen, const flags[]="");
|
273 |
+
|
274 |
+
|
275 |
+
Example:
|
276 |
+
Spoiler
|
277 |
+
Code:
|
278 |
+
new ret, error[128]
|
279 |
+
new Regex:regex_handle = regex_compile("^^STEAM_0:[01]:(\d+)$", ret, error, charsmax(error))
|
280 |
+
|
281 |
+
if(regex_handle != REGEX_PATTERN_FAIL)
|
282 |
+
{
|
283 |
+
// Match against strings
|
284 |
+
}
|
285 |
+
|
286 |
+
|
287 |
+
When matching against strings, you have to use another match function:
|
288 |
+
Spoiler
|
289 |
+
Code:
|
290 |
+
/**
|
291 |
+
* Matches a string against a pre-compiled regular expression pattern.
|
292 |
+
*
|
293 |
+
*
|
294 |
+
* @param pattern The regular expression pattern.
|
295 |
+
* @param string The string to check.
|
296 |
+
* @param ret Error code, if applicable, or number of results on success.
|
297 |
+
*
|
298 |
+
* @return -2 = Matching error (error code is stored in ret)
|
299 |
+
* 0 = No match.
|
300 |
+
* >1 = Number of results.
|
301 |
+
*
|
302 |
+
* @note You should free the returned handle (with regex_free())
|
303 |
+
* when you are done with this pattern.
|
304 |
+
*
|
305 |
+
* @note Use the regex handle passed to this function to extract
|
306 |
+
* matches with regex_substr().
|
307 |
+
*/
|
308 |
+
native regex_match_c(const string[], Regex:pattern, &ret);
|
309 |
+
|
310 |
+
|
311 |
+
Example:
|
312 |
+
Spoiler
|
313 |
+
Code:
|
314 |
+
new ret, error[128]
|
315 |
+
new Regex:regex_handle = regex_compile("^^STEAM_0:[01]:(\d+)$", ret, error, charsmax(error))
|
316 |
+
|
317 |
+
if(regex_handle != REGEX_PATTERN_FAIL)
|
318 |
+
{
|
319 |
+
new players[32], pnum
|
320 |
+
get_players(players, pnum, "ch")
|
321 |
+
|
322 |
+
new steamID[35], number[32]
|
323 |
+
|
324 |
+
for(new i = 0; i < pnum; i++)
|
325 |
+
{
|
326 |
+
get_user_authid(players[i], steamID, charsmax(steamID))
|
327 |
+
|
328 |
+
if(regex_match_c(steamID, regex_handle, ret) > 0)
|
329 |
+
{
|
330 |
+
regex_substr(regex_handle, 1, numbers, charsmax(numbers))
|
331 |
+
|
332 |
+
// numbers = trailing numbers in SteamID of this player
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
regex_free(regex_handle)
|
337 |
+
}
|
338 |
+
|
339 |
+
|
340 |
+
Another example for compiling:
|
341 |
+
Spoiler
|
342 |
+
Code:
|
343 |
+
#include <amxmodx>
|
344 |
+
#include <regex>
|
345 |
+
|
346 |
+
new Regex:gPatternSteamID = REGEX_PATTERN_FAIL // Default to invalid handle
|
347 |
+
|
348 |
+
public plugin_init()
|
349 |
+
{
|
350 |
+
new ret, error[128]
|
351 |
+
gPatternSteamID = regex_compile("^^STEAM_0:[01]:\d+$", ret, error, charsmax(error))
|
352 |
+
|
353 |
+
if(gPatternSteamID == REGEX_PATTERN_FAIL)
|
354 |
+
{
|
355 |
+
log_amx("Error creating SteamID pattern (%d): %s", ret, error)
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
stock bool:IsValidSteamID(const string[])
|
360 |
+
{
|
361 |
+
new ret
|
362 |
+
return (gPatternSteamID != REGEX_PATTERN_FAIL && regex_match_c(string, gPatternSteamID, ret) > 0)
|
363 |
+
}
|
364 |
+
|
365 |
+
RegEx Tester
|
366 |
+
RegEx Tester is a plugin I wrote to be able to check strings against a pattern via the server console.
|
367 |
+
|
368 |
+
Command:
|
369 |
+
- regex_pattern <pattern>
|
370 |
+
- regex_test <test data>
|
371 |
+
|
372 |
+
The pattern can be in /pattern/flags format or just the pattern itself.
|
373 |
+
|
374 |
+
Example:
|
375 |
+
Code:
|
376 |
+
] regex_pattern "^STEAM_0:[01]:\d+$"
|
377 |
+
Pattern set to: ^STEAM_0:[01]:\d+$
|
378 |
+
Flags set to:
|
379 |
+
] regex_test "STEAM_0:1:23456"
|
380 |
+
1 matches
|
381 |
+
1. "STEAM_0:1:23456"
|
382 |
+
] regex_pattern "/^STEAM_0:[01]:\d+$/i"
|
383 |
+
Pattern set to: ^STEAM_0:[01]:\d+$
|
384 |
+
Flags set to: i
|
385 |
+
] regex_test "steam_0:1:23456"
|
386 |
+
1 matches
|
387 |
+
1. "steam_0:1:23456"
|
388 |
+
You can use this if you are unsure whether or not your pattern will work.
|
Scripting Cvars.txt
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Scripting Cvars (AMX Mod X)
|
2 |
+
CVARs, or Console VARiables, are an easy and efficient way to store configurable variables on the server. Half-Life 1 supports both server-side cvars and client-side cvars. Internally, cvars are stored as both a float and a string. CVARs can be used for easy access outside the plugin. Valid example would be : Storing Weapon Knock back in a CVAR then editing it via configurable files.
|
3 |
+
|
4 |
+
Contents
|
5 |
+
1 Server-Side
|
6 |
+
1.1 Getting Values
|
7 |
+
1.2 Setting Value
|
8 |
+
1.3 Flags
|
9 |
+
2 Client Side CVARs
|
10 |
+
2.1 Getting
|
11 |
+
2.2 Setting
|
12 |
+
2.3 Locking
|
13 |
+
Server-Side
|
14 |
+
To create a cvar, use register_cvar.
|
15 |
+
|
16 |
+
register_cvar(const name[],const string[],flags = 0,Float:fvalue = 0.0);
|
17 |
+
Note: The last parameter is for backwards compatibility only, and serves no purpose in AMXx. It is recommended you register CVARs during plugin_init, so that other plugins may alter them at plugin_cfg.
|
18 |
+
|
19 |
+
Parameters:
|
20 |
+
name[] : The name of the CVAR you want to register
|
21 |
+
string[] : The default value of the CVAR
|
22 |
+
flags : See Cvars (AMX Mod X).
|
23 |
+
Getting Values
|
24 |
+
/* Gets a cvar float. */
|
25 |
+
Float:get_cvar_float(const cvarname[]);
|
26 |
+
|
27 |
+
/* Gets a cvar integer value. */
|
28 |
+
get_cvar_num(const cvarname[]);
|
29 |
+
|
30 |
+
/* Reads a cvar value. */
|
31 |
+
get_cvar_string(const cvarname[],output[],iLen);
|
32 |
+
Setting Value
|
33 |
+
/* Sets a cvar to given value. */
|
34 |
+
set_cvar_string(const cvar[],const value[]);
|
35 |
+
|
36 |
+
/* Sets a cvar to given float. */
|
37 |
+
set_cvar_float(const cvar[],Float:value);
|
38 |
+
|
39 |
+
/* Sets a cvar with integer value. */
|
40 |
+
set_cvar_num(const cvarname[],value);
|
41 |
+
Flags
|
42 |
+
These flags can be used for the third parameter in the register_cvar native:
|
43 |
+
|
44 |
+
#define FCVAR_ARCHIVE 1 /* set to cause it to be saved to vars.rc */
|
45 |
+
#define FCVAR_USERINFO 2 /* changes the client's info string */
|
46 |
+
#define FCVAR_SERVER 4 /* notifies players when changed */
|
47 |
+
#define FCVAR_EXTDLL 8 /* defined by external DLL */
|
48 |
+
#define FCVAR_CLIENTDLL 16 /* defined by the client dll */
|
49 |
+
#define FCVAR_PROTECTED 32 /* It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value */
|
50 |
+
#define FCVAR_SPONLY 64 /* This cvar cannot be changed by clients connected to a multiplayer server. */
|
51 |
+
#define FCVAR_PRINTABLEONLY 128 /* This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). */
|
52 |
+
#define FCVAR_UNLOGGED 256 /* If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log */
|
53 |
+
You can alter these flags dynamically, using the cvar flag natives:
|
54 |
+
|
55 |
+
/* Returns a cvar flags. */
|
56 |
+
get_cvar_flags(const cvar[]);
|
57 |
+
|
58 |
+
/* Sets a cvar flags (not allowed for amx_version,
|
59 |
+
* fun_version and sv_cheats cvars). */
|
60 |
+
set_cvar_flags(const cvar[],flags);
|
61 |
+
|
62 |
+
/* Removes a cvar flags (not allowed for amx_version,
|
63 |
+
* fun_version and sv_cheats cvars). */
|
64 |
+
remove_cvar_flags(const cvar[],flags = -1);
|
65 |
+
Client Side CVARs
|
66 |
+
Client side cvars cannot be created in Half-Life 1. The cvar must exist in advance. Furthermore, since it must be retrieved or set over the network, knowing the value at a given point in time is impossible. You can, however, query a client for a cvar and get an asynchronous response, and use client_cmd to set a new value if necessary.
|
67 |
+
|
68 |
+
Getting
|
69 |
+
Recently, VALVE added a client CVAR checking interface, which has been added to AMX Mod X:
|
70 |
+
|
71 |
+
// Dispatches a client cvar query
|
72 |
+
// id: Player id
|
73 |
+
// cvar: cvar name
|
74 |
+
// resultFunc: public handler function
|
75 |
+
// paramLen + params: optional array parameter
|
76 |
+
// resultFunc looks like:
|
77 |
+
// public callbackCvarValue(id, const cvar[], const value[])
|
78 |
+
// or if you use the optional parameter:
|
79 |
+
// public callbackCvarValue(id, const cvar[], const value[], const param[])
|
80 |
+
query_client_cvar(id, const cvar[], const resultFunc[], paramlen=0, const params[] = "");
|
81 |
+
This native may appear daunting, but it is actually quite simple; the first parameter is the player, the second the cvar, the third the function called which will contain the client CVAR, and the last two are for allowing the passage of strings.
|
82 |
+
|
83 |
+
If you wish to get an array or strting back, simply put the length you want it, and fill params will a value. Then, in your return function, you will receive an array.
|
84 |
+
|
85 |
+
Setting
|
86 |
+
Setting a client side CVAR is easy; execute a new value onto the client:
|
87 |
+
|
88 |
+
client_cmd(player_id,"cvar value")
|
89 |
+
|
90 |
+
Locking
|
91 |
+
Since the client can change cvar values back as soon as they're set, it might be necessary to lock them. Since alias's are executed before cvars, you can create an alias of the same name of the cvar, thus locking the cvar:
|
92 |
+
|
93 |
+
//CVAR: cvar_ex.
|
94 |
+
client_cmd(player_id,"cvar_ex 1")
|
95 |
+
client_cmd(player_id,";alias cvar_ex")
|
96 |
+
Now the cvar cannot be changed by the player or the server; it is locked.
|
The advantages cellArray.sma.txt
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#include <amxmodx>
|
3 |
+
#include <amxmisc>
|
4 |
+
#include <cellarray>
|
5 |
+
|
6 |
+
#define PLUGIN "New Plugin"
|
7 |
+
#define AUTHOR "Unknown"
|
8 |
+
#define VERSION "1.0"
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
public plugin_init()
|
13 |
+
{
|
14 |
+
register_plugin(PLUGIN, VERSION, AUTHOR)
|
15 |
+
}
|
16 |
+
|
17 |
+
public findSteamID(steamID[34],Array:steamIDs)
|
18 |
+
{
|
19 |
+
new size = ArraySize(steamIDs);
|
20 |
+
new steamIDSearch[34];
|
21 |
+
|
22 |
+
for(new i=0;i<size;i++)
|
23 |
+
{
|
24 |
+
ArrayGetString(steamIDs,i,steamIDSearch,33)
|
25 |
+
|
26 |
+
if(!strcmp(steamID,steamIDSearch))
|
27 |
+
return true;
|
28 |
+
}
|
29 |
+
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
|
33 |
+
public plugin_cfg()
|
34 |
+
{
|
35 |
+
new file = fopen("list","r")
|
36 |
+
|
37 |
+
new steamID[34]
|
38 |
+
|
39 |
+
new Array:steamIDs = ArrayCreate(34);
|
40 |
+
|
41 |
+
while(fgets(file,steamID,33))
|
42 |
+
{
|
43 |
+
steamID[strlen(steamID)-2] = 0;
|
44 |
+
ArrayPushString(steamIDs,steamID);
|
45 |
+
}
|
46 |
+
|
47 |
+
new steamIDFind[34] = "STEAM_0:1:1234567";
|
48 |
+
|
49 |
+
for(new i=0;i<10000;i++)
|
50 |
+
{
|
51 |
+
findSteamID(steamIDFind,steamIDs);
|
52 |
+
}
|
53 |
+
|
54 |
+
server_cmd("quit");
|
55 |
+
}
|
The advantages cellArrayResults.txt.txt
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
date: Mon Mar 23 12:32:18 2009 map: de_dust2
|
2 |
+
type | name | calls | time / min / max
|
3 |
+
-------------------------------------------------------------------
|
4 |
+
n | register_plugin | 1 | 0.000010 / 0.000010 / 0.000010
|
5 |
+
n | ArraySize | 10000 | 0.021665 / 0.000001 / 0.000070
|
6 |
+
n | ArrayGetString | 690000 | 1.522466 / 0.000001 / 0.000169
|
7 |
+
n | strcmp | 690000 | 1.526563 / 0.000001 / 0.000304
|
8 |
+
n | fopen | 1 | 0.000037 / 0.000037 / 0.000037
|
9 |
+
n | ArrayCreate | 1 | 0.000003 / 0.000003 / 0.000003
|
10 |
+
n | fgets | 70 | 0.000193 / 0.000002 / 0.000020
|
11 |
+
n | strlen | 69 | 0.000165 / 0.000002 / 0.000004
|
12 |
+
n | ArrayPushString | 69 | 0.000173 / 0.000002 / 0.000007
|
13 |
+
n | server_cmd | 1 | 0.000015 / 0.000015 / 0.000015
|
14 |
+
p | plugin_cfg | 1 | 0.023199 / 0.023199 / 0.023199
|
15 |
+
p | plugin_init | 1 | 0.000005 / 0.000005 / 0.000005
|
16 |
+
f | findSteamID | 10000 | 3.195967 / 0.000288 / 0.002059
|
17 |
+
0 natives, 1 public callbacks, 2 function calls were not executed.
|
18 |
+
|
19 |
+
date: Mon Mar 23 12:32:37 2009 map: de_dust2
|
20 |
+
type | name | calls | time / min / max
|
21 |
+
-------------------------------------------------------------------
|
22 |
+
n | register_plugin | 1 | 0.000006 / 0.000006 / 0.000006
|
23 |
+
n | ArraySize | 10000 | 0.021601 / 0.000001 / 0.000063
|
24 |
+
n | ArrayGetString | 690000 | 1.528007 / 0.000001 / 0.000247
|
25 |
+
n | strcmp | 690000 | 1.530929 / 0.000001 / 0.001078
|
26 |
+
n | fopen | 1 | 0.000034 / 0.000034 / 0.000034
|
27 |
+
n | ArrayCreate | 1 | 0.000003 / 0.000003 / 0.000003
|
28 |
+
n | fgets | 70 | 0.000192 / 0.000002 / 0.000025
|
29 |
+
n | strlen | 69 | 0.000161 / 0.000002 / 0.000004
|
30 |
+
n | ArrayPushString | 69 | 0.000153 / 0.000001 / 0.000007
|
31 |
+
n | server_cmd | 1 | 0.000011 / 0.000011 / 0.000011
|
32 |
+
p | plugin_cfg | 1 | 0.023353 / 0.023353 / 0.023353
|
33 |
+
p | plugin_init | 1 | 0.000005 / 0.000005 / 0.000005
|
34 |
+
f | findSteamID | 10000 | 3.196872 / 0.000283 / 0.000774
|
35 |
+
0 natives, 1 public callbacks, 2 function calls were not executed.
|
36 |
+
|
The advantages cellTrie.sma.txt
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#include <amxmodx>
|
3 |
+
#include <amxmisc>
|
4 |
+
#include <celltrie>
|
5 |
+
|
6 |
+
#define PLUGIN "New Plugin"
|
7 |
+
#define AUTHOR "Unknown"
|
8 |
+
#define VERSION "1.0"
|
9 |
+
|
10 |
+
|
11 |
+
public plugin_init()
|
12 |
+
{
|
13 |
+
register_plugin(PLUGIN, VERSION, AUTHOR)
|
14 |
+
}
|
15 |
+
|
16 |
+
public findSteamID(steamID[34],Trie:steamIDs)
|
17 |
+
{
|
18 |
+
new value;
|
19 |
+
TrieGetCell(steamIDs,steamID,value);
|
20 |
+
return value;
|
21 |
+
}
|
22 |
+
|
23 |
+
public plugin_cfg()
|
24 |
+
{
|
25 |
+
new file = fopen("list","r")
|
26 |
+
|
27 |
+
new steamID[34]
|
28 |
+
|
29 |
+
new Trie:steamIDs = TrieCreate()
|
30 |
+
|
31 |
+
while(fgets(file,steamID,33))
|
32 |
+
{
|
33 |
+
steamID[strlen(steamID)-2] = 0;
|
34 |
+
TrieSetCell(steamIDs,steamID,true);
|
35 |
+
}
|
36 |
+
|
37 |
+
new steamIDFind[34] = "STEAM_0:1:1234567";
|
38 |
+
|
39 |
+
for(new i=0;i<10000;i++)
|
40 |
+
{
|
41 |
+
findSteamID(steamIDFind,steamIDs);
|
42 |
+
}
|
43 |
+
|
44 |
+
server_cmd("quit");
|
45 |
+
}
|
The advantages cellTrieResults.txt.txt
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
sdate: Mon Mar 23 12:34:49 2009 map: de_dust2
|
2 |
+
type | name | calls | time / min / max
|
3 |
+
-------------------------------------------------------------------
|
4 |
+
n | register_plugin | 1 | 0.000006 / 0.000006 / 0.000006
|
5 |
+
n | TrieGetCell | 10000 | 0.022582 / 0.000001 / 0.000161
|
6 |
+
n | fopen | 1 | 0.000035 / 0.000035 / 0.000035
|
7 |
+
n | TrieCreate | 1 | 0.000009 / 0.000009 / 0.000009
|
8 |
+
n | fgets | 70 | 0.000196 / 0.000002 / 0.000020
|
9 |
+
n | strlen | 69 | 0.000158 / 0.000001 / 0.000004
|
10 |
+
n | TrieSetCell | 69 | 0.000272 / 0.000002 / 0.000008
|
11 |
+
n | server_cmd | 1 | 0.000013 / 0.000013 / 0.000013
|
12 |
+
p | plugin_cfg | 1 | 0.023321 / 0.023321 / 0.023321
|
13 |
+
p | plugin_init | 1 | 0.000005 / 0.000005 / 0.000005
|
14 |
+
f | findSteamID | 10000 | 0.045496 / 0.000003 / 0.000429
|
15 |
+
0 natives, 1 public callbacks, 2 function calls were not executed.
|
16 |
+
|
17 |
+
date: Mon Mar 23 12:34:57 2009 map: de_dust2
|
18 |
+
type | name | calls | time / min / max
|
19 |
+
-------------------------------------------------------------------
|
20 |
+
n | register_plugin | 1 | 0.000008 / 0.000008 / 0.000008
|
21 |
+
n | TrieGetCell | 10000 | 0.021956 / 0.000001 / 0.000080
|
22 |
+
n | fopen | 1 | 0.000040 / 0.000040 / 0.000040
|
23 |
+
n | TrieCreate | 1 | 0.000009 / 0.000009 / 0.000009
|
24 |
+
n | fgets | 70 | 0.000194 / 0.000002 / 0.000025
|
25 |
+
n | strlen | 69 | 0.000158 / 0.000002 / 0.000010
|
26 |
+
n | TrieSetCell | 69 | 0.000242 / 0.000002 / 0.000007
|
27 |
+
n | server_cmd | 1 | 0.000013 / 0.000013 / 0.000013
|
28 |
+
p | plugin_cfg | 1 | 0.022967 / 0.022967 / 0.022967
|
29 |
+
p | plugin_init | 1 | 0.000005 / 0.000005 / 0.000005
|
30 |
+
f | findSteamID | 10000 | 0.045080 / 0.000003 / 0.000090
|
31 |
+
0 natives, 1 public callbacks, 2 function calls were not executed.
|
The advantages of a trie over an array for strings storage.txt
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Those who are unaware of what a trie is and what's its purpose, when needing a data structure to store strings, use an array. Since you can also use tries for store strings there are best cases of use for each one.
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
What they are:
|
6 |
+
|
7 |
+
An array is a group of sequential bytes in memory subdivided in groups of the same length, being each one of the subdivided a individual place to store data, that you can access by its position in the array (usually referred as index).
|
8 |
+
|
9 |
+
A trie is a collection of data organized in the form of a hierarchy. The level zero is a start point. From there on, each level is a group of strings of length equal to the level number and different from each other. Each string can be associated to a value and to strings in the level below that share its characters. If one is associated to a value, it is stored in the trie.
|
10 |
+
|
11 |
+
From wikipedia:
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
In the tree above there are stored the strings:
|
16 |
+
|
17 |
+
A , i , to , in , tea , ted , ten , inn
|
18 |
+
|
19 |
+
(since they are those who have associated values).
|
20 |
+
|
21 |
+
|
22 |
+
Which one should be used where you can use both:
|
23 |
+
|
24 |
+
An array should be used when you know the index of the string that you want to posteriorly access or if you need to iterate over its values.
|
25 |
+
|
26 |
+
A trie should be used when you want to posteriorly search for a string.
|
27 |
+
|
28 |
+
To show the differences of its usage, in a case where you should use a trie, i created the following situation:
|
29 |
+
|
30 |
+
I want to know if in a list of steam Ids there is a given steam Id. I have a list of 69 steam Ids and the given steam Id is not on the list.
|
31 |
+
|
32 |
+
When comparing algorithms it must be tested what's referred to as "worst case". The worst case is the case on which you force the algorithm to test every possibility. That's why the steam Id is not on the list.
|
33 |
+
|
34 |
+
The code and the profiling results go as attachments.
|
35 |
+
|
36 |
+
A note:
|
37 |
+
|
38 |
+
While the superiority of tries over arrays for this case should be obvious i think that the results for ArrayGetString are not accurate. So or:
|
39 |
+
They are accurate and i am wrong
|
40 |
+
I made something wrong
|
41 |
+
There's something wrong with ArrayGetString
|
42 |
+
There's something wrong with the profiling.
|
43 |
+
Attached Files
|
Touch Stuff.txt
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1. Touch with natives
|
2 |
+
Engine way:
|
3 |
+
PHP Code:
|
4 |
+
#include <amxmodx>
|
5 |
+
#include <amxmisc>
|
6 |
+
#include <engine>
|
7 |
+
|
8 |
+
|
9 |
+
public plugin_init() {
|
10 |
+
register_plugin("Touch Test","0.1","SAMURAI");
|
11 |
+
|
12 |
+
// now registers a touch action to a function.
|
13 |
+
register_touch("touched","toucher","hook_touch");
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
public hook_touch(touched,toucher)
|
18 |
+
{
|
19 |
+
if(is_user_admin(toucher) && is_user_bot(touched))
|
20 |
+
{
|
21 |
+
client_print(0,print_chat,"kbooom")
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
touched = Who are touched by Toucher
|
27 |
+
toucher = Who touch
|
28 |
+
|
29 |
+
If you want to filter touched / toucher
|
30 |
+
An example :
|
31 |
+
Only running hook_touch if a player touch something..
|
32 |
+
PHP Code:
|
33 |
+
register_touch("player","*","hook_touch");
|
34 |
+
|
35 |
+
|
36 |
+
2. Forwards touch:
|
37 |
+
Engine way:
|
38 |
+
PHP Code:
|
39 |
+
#include <amxmodx>
|
40 |
+
#include <amxmisc>
|
41 |
+
#include <engine>
|
42 |
+
|
43 |
+
|
44 |
+
public plugin_init() {
|
45 |
+
register_plugin("Touch test","0.1","SAMURAI");
|
46 |
+
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
// Called when two entities touch/collide.
|
51 |
+
public pfn_touch(ptr,ptd)
|
52 |
+
{
|
53 |
+
new classname[32]
|
54 |
+
entity_get_string(ptr,EV_SZ_classname,classname,31)
|
55 |
+
|
56 |
+
|
57 |
+
if ( equal(classname, "hostage_entity") )
|
58 |
+
{
|
59 |
+
client_print(0,print_chat,"damn touched");
|
60 |
+
// and other stuff
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
Fakemeta way:
|
67 |
+
PHP Code:
|
68 |
+
#include <amxmodx>
|
69 |
+
#include <fakemeta>
|
70 |
+
|
71 |
+
public plugin_init() {
|
72 |
+
register_plugin("Touch Test","0.1","SAMURAI");
|
73 |
+
|
74 |
+
register_forward(FM_Touch,"hook_touch");
|
75 |
+
}
|
76 |
+
|
77 |
+
public hook_touch(ptr,ptd)
|
78 |
+
{
|
79 |
+
new classname[32]
|
80 |
+
pev(ptr,pev_classname,classname,31)
|
81 |
+
|
82 |
+
|
83 |
+
if ( equal(classname, "hostage_entity") )
|
84 |
+
{
|
85 |
+
client_print(0,print_chat,"damn touched");
|
86 |
+
// and other stuff
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
3. Block touch operation:
|
93 |
+
On Engine:
|
94 |
+
To block touch use return PLUGIN_HANDLED;
|
95 |
+
|
96 |
+
On Fakemeta:
|
97 |
+
use return FMRES_SUPERCEDE;
|
98 |
+
|
99 |
+
4. Fake Touch:
|
100 |
+
This will simulates two entities colliding/touching.
|
101 |
+
Engine:
|
102 |
+
PHP Code:
|
103 |
+
fake_touch(Touched,Toucher)
|
104 |
+
Fakemeta:
|
105 |
+
PHP Code:
|
106 |
+
dllfunc(DLLFunc_Touch, touched, toucher)
|
Usage EngFunc_EntitiesInPVS.txt
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
EngFunc_EntitiesInPVS (maybe the same for EngFunc_FindClientInPVS)
|
2 |
+
It returns an entity in PVS (potential visible set) of a player.
|
3 |
+
It never returns worldspawn.
|
4 |
+
|
5 |
+
In that entity returned, you have a set of chained entities using pev_chain.
|
6 |
+
|
7 |
+
Example
|
8 |
+
Code:
|
9 |
+
public whatisonPVS(id)
|
10 |
+
{
|
11 |
+
static next, chain;
|
12 |
+
static class[32];
|
13 |
+
|
14 |
+
next = engfunc(EngFunc_EntitiesInPVS, id);
|
15 |
+
while(next)
|
16 |
+
{
|
17 |
+
pev(next, pev_classname, class, charsmax(class));
|
18 |
+
chain = pev(next, pev_chain);
|
19 |
+
|
20 |
+
server_print("Found entity in player (%i) PVS: ent(%i) class(%s)", id, next, class);
|
21 |
+
if(!chain)
|
22 |
+
break;
|
23 |
+
next = chain;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
So this function iterates over and over every entity until pev_chain is NULL.
|
Using Button Constants.txt
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Usage
|
2 |
+
|
3 |
+
Button constants are generally used to determine when an entity is doing a certain action, such as jumping, attacking, or moving. This is used because +/- commands cannot be hooked by the HL engine (if they are made by the HL engine).
|
4 |
+
For example, this would work:
|
5 |
+
Code:
|
6 |
+
register_concmd("+explode","hook_explode")
|
7 |
+
|
8 |
+
However this would not:
|
9 |
+
Code:
|
10 |
+
register_concmd("+attack","hook_attack")
|
11 |
+
Why? Because the client does not literally send "+attack" over the reliable stream, since this would cause massive lag. Instead, an integer is sent, which is easier on bandwidth.
|
12 |
+
|
13 |
+
|
14 |
+
Constants
|
15 |
+
|
16 |
+
A full list of constants can be found here: http://amxmodx.org/funcwiki.php?go=m...#const_buttons
|
17 |
+
|
18 |
+
|
19 |
+
Implementation
|
20 |
+
|
21 |
+
If, for example, it is desired to check when a player is attacking, one would use the following:
|
22 |
+
Code:
|
23 |
+
#include <amxmodx>
|
24 |
+
#include <engine>
|
25 |
+
|
26 |
+
public plugin_init()
|
27 |
+
{
|
28 |
+
register_plugin("Attack Test","1.0","Hawk552");
|
29 |
+
}
|
30 |
+
|
31 |
+
public client_PreThink(id)
|
32 |
+
{
|
33 |
+
if(entity_get_int(id,EV_INT_BUTTON) & IN_ATTACK)
|
34 |
+
{
|
35 |
+
// do something
|
36 |
+
}
|
37 |
+
}
|
38 |
+
Notice how this uses the & operator, rather than the && operator. This is because a bit value is returned, and the & operator checks if a bit value is contained in another bit value.
|
39 |
+
To set an entity's button, the same type of idea can be implemented:
|
40 |
+
Code:
|
41 |
+
#include <amxmodx>
|
42 |
+
#include <engine>
|
43 |
+
|
44 |
+
public plugin_init()
|
45 |
+
{
|
46 |
+
register_plugin("Attack Test","1.0","Hawk552");
|
47 |
+
}
|
48 |
+
|
49 |
+
public client_PreThink(id)
|
50 |
+
{
|
51 |
+
entity_set_int(id,EV_INT_button,IN_ATTACK);
|
52 |
+
}
|
53 |
+
This sets the client's attack flag to on every time a frame is rendered.
|
54 |
+
To get an entity's buttons, and then ommit a certain button, one would use the following:
|
55 |
+
Code:
|
56 |
+
#include <amxmodx>
|
57 |
+
#include <engine>
|
58 |
+
|
59 |
+
public plugin_init()
|
60 |
+
{
|
61 |
+
register_plugin("Attack Test","1.0","Hawk552");
|
62 |
+
}
|
63 |
+
|
64 |
+
public client_PreThink(id)
|
65 |
+
{
|
66 |
+
entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button) & ~IN_ATTACK);
|
67 |
+
}
|
Using Files to write datavalues(old and new file commands).txt
ADDED
@@ -0,0 +1,351 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
This is a little tutorial about reading/writing files to store something.
|
2 |
+
This Tutorial need basics in Amxx Scripting.
|
3 |
+
I am not so good in explain and writing Tutorials,so the most are writing as code.
|
4 |
+
I dont explain every Command.
|
5 |
+
If there something wrong or better please post.
|
6 |
+
|
7 |
+
Lets begin with the old file commands (easy and short).
|
8 |
+
|
9 |
+
Code:
|
10 |
+
read_file ( const file[], line, text[], len, &txtLen )
|
11 |
+
Read a specific line with given lenght into an array.
|
12 |
+
It returns index of next line or 0 when the end of the file is reached.
|
13 |
+
The number of characters read is stored in txtLen.
|
14 |
+
Code:
|
15 |
+
write_file ( const file[], const text[], [ line ] )
|
16 |
+
Write an array to file to the given line,if line is -1 it write at end of the file
|
17 |
+
|
18 |
+
Code:
|
19 |
+
#include <amxmodx>
|
20 |
+
#include <amxmisc>
|
21 |
+
|
22 |
+
#define PLUGIN "Filehandle"
|
23 |
+
#define VERSION "1.0"
|
24 |
+
#define AUTHOR "Administrator"
|
25 |
+
|
26 |
+
new filename[256]
|
27 |
+
|
28 |
+
public plugin_init() {
|
29 |
+
register_plugin(PLUGIN, VERSION, AUTHOR)
|
30 |
+
|
31 |
+
/*get the config directory of amxx*/
|
32 |
+
get_configsdir(filename,255)
|
33 |
+
format(filename,255,"%s/filehandle.txt",filename)
|
34 |
+
register_concmd("amx_filetestwrite","filewritetest")
|
35 |
+
register_concmd("amx_filetestread","filereadtest")
|
36 |
+
}
|
37 |
+
|
38 |
+
public filewritetest(id){
|
39 |
+
new writedata[128]
|
40 |
+
new steamid[32],name[32],anyvalue,Float:anyfloatvalue
|
41 |
+
|
42 |
+
/*Lets create and copy some dummy data*/
|
43 |
+
get_user_authid(id,steamid,31)
|
44 |
+
get_user_name(id,name,31)
|
45 |
+
anyvalue = 10
|
46 |
+
anyfloatvalue = 5.5
|
47 |
+
|
48 |
+
formatex(writedata,127,"%s %s %d %f",steamid,name,anyvalue,anyfloatvalue)
|
49 |
+
|
50 |
+
/*Now write this data to the file at last line
|
51 |
+
write_file ( const file[], const text[], [ line ] )
|
52 |
+
The line parameter defaults to -1, which appends to the end of the file. Otherwise, a specific line is overwritten.
|
53 |
+
If no file exist write_file create one*/
|
54 |
+
write_file(filename,writedata)
|
55 |
+
}
|
56 |
+
|
57 |
+
public filereadtest(id){
|
58 |
+
new readdata[128],steamid[32],anyvalue,Float:anyfloatvalue,txtlen
|
59 |
+
new parsedsteamid[32],parsedname[32],parsedanyvalue[8],parsedanyfloatvalue[8]
|
60 |
+
|
61 |
+
/*now read the data from the file*/
|
62 |
+
/*It give 2 ways to read a file until end of line*/
|
63 |
+
|
64 |
+
/*The first way*/
|
65 |
+
/*file_size - Returns the size of a file.
|
66 |
+
If flag is 0, size is returned in bytes.
|
67 |
+
If flag is 1, the number of lines is returned.
|
68 |
+
If flag is 2, 1 is returned if the file ends in a line feed.
|
69 |
+
If the file doesn't exist, -1 is returned. */
|
70 |
+
new fsize = file_size(filename,1)
|
71 |
+
for (new line=0;line<=fsize;line++)
|
72 |
+
{
|
73 |
+
/*read_file ( const file[], line, text[], len, &txtLen )*/
|
74 |
+
read_file(filename,line,readdata,127,txtlen)
|
75 |
+
/*We must parse the readata in somthing that we can use*/
|
76 |
+
parse(readdata,parsedsteamid,31,parsedname,31,parsedanyvalue,7,parsedanyfloatvalue,7)
|
77 |
+
|
78 |
+
/*check if steamid the same as in file*/
|
79 |
+
get_user_authid(id,steamid,31)
|
80 |
+
if(equal(steamid,parsedsteamid))
|
81 |
+
{
|
82 |
+
/*steamid is same as in file,the do somthing with the rest of parsed values*/
|
83 |
+
anyvalue = str_to_num(parsedanyvalue)
|
84 |
+
anyfloatvalue = str_to_float(parsedanyfloatvalue)
|
85 |
+
client_print(id,print_chat,"Your saved Steamid:%s Name:%s Value:%d FloatValue:%f",parsedsteamid,parsedname,anyvalue,anyfloatvalue)
|
86 |
+
/*i use break to stop the loop to save more performance.On big files this is good*/
|
87 |
+
break
|
88 |
+
//...
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/*The second way/the better way*/
|
93 |
+
new line = 0
|
94 |
+
while(!read_file(filename,line++,readdata,127,txtlen))
|
95 |
+
{
|
96 |
+
parse(filename,parsedsteamid,31,parsedname,31,parsedanyvalue,7,parsedanyfloatvalue,7)
|
97 |
+
|
98 |
+
get_user_authid(id,steamid,31)
|
99 |
+
if(equal(steamid,parsedsteamid))
|
100 |
+
{
|
101 |
+
anyvalue = str_to_num(parsedanyvalue)
|
102 |
+
anyfloatvalue = str_to_float(parsedanyfloatvalue)
|
103 |
+
client_print(id,print_chat,"Your saved Steamid:%s Name:%s Value:%d FloatValue:%f",parsedsteamid,parsedname,anyvalue,anyfloatvalue)
|
104 |
+
break
|
105 |
+
//...
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
The next are the new file commands(many and very powerfull)
|
111 |
+
|
112 |
+
Lets begin with basics of new file commands and write/read a string inside a file.
|
113 |
+
This is good for textfiles where easily can read the file
|
114 |
+
|
115 |
+
The new file commands dont read linespecific,they use a cursor inside the file to read the data.
|
116 |
+
This cursor position can get with
|
117 |
+
Code:
|
118 |
+
ftell(file)
|
119 |
+
And the cursor can set with
|
120 |
+
Code:
|
121 |
+
fseek ( file, position, start )
|
122 |
+
"position" is an offset from start
|
123 |
+
start can be:
|
124 |
+
Code:
|
125 |
+
SEEK_SET //beginning of the file
|
126 |
+
SEEK_CUR //current cursor position
|
127 |
+
SEEK_END //end of the file
|
128 |
+
Code:
|
129 |
+
rewind ( file )
|
130 |
+
move the cursor position to begin of the file.
|
131 |
+
|
132 |
+
Code:
|
133 |
+
fopen ( filename[], mode[] )
|
134 |
+
Open a file with given filename and mode.
|
135 |
+
It returns a pointer to the file.
|
136 |
+
|
137 |
+
Code:
|
138 |
+
fputs ( file, const text[])
|
139 |
+
Write a string to a text file at current filecursor position.
|
140 |
+
"file" must be a pointer to a file from the fopen command.
|
141 |
+
Code:
|
142 |
+
fprintf ( file, const buffer[], ... )
|
143 |
+
Write a formated string to a text file.Same as the format/formatex command,but for files.
|
144 |
+
|
145 |
+
fputs/fprint dont add a newline at end of the string,so it must set manually.
|
146 |
+
Code:
|
147 |
+
fgets ( file, buffer[], maxlength )
|
148 |
+
Read a line (including newlines) from a text file from current filecursor position until maxlenght is reached or newline/end of file is founded.
|
149 |
+
Code:
|
150 |
+
#include <amxmodx>
|
151 |
+
#include <amxmisc>
|
152 |
+
|
153 |
+
#define PLUGIN "Filehandle"
|
154 |
+
#define VERSION "1.0"
|
155 |
+
#define AUTHOR "Administrator"
|
156 |
+
|
157 |
+
new filename[256]
|
158 |
+
|
159 |
+
public plugin_init() {
|
160 |
+
register_plugin(PLUGIN, VERSION, AUTHOR)
|
161 |
+
|
162 |
+
get_configsdir(filename,255)
|
163 |
+
format(filename,255,"%s/filehandle.txt",filename)
|
164 |
+
register_concmd("amx_filetestwrite","filewritetest")
|
165 |
+
register_concmd("amx_filetestread","filereadtest")
|
166 |
+
}
|
167 |
+
|
168 |
+
public filewritetest(id){
|
169 |
+
new writedata[128]
|
170 |
+
new steamid[32],name[32],anyvalue,Float:anyfloatvalue
|
171 |
+
|
172 |
+
get_user_authid(id,steamid,31)
|
173 |
+
get_user_name(id,name,31)
|
174 |
+
anyvalue = 10
|
175 |
+
anyfloatvalue = 5.5
|
176 |
+
|
177 |
+
/*fopen - Returns a file handle for advanced file functions.
|
178 |
+
Mode uses the standard C library of mode types.
|
179 |
+
The first character can be:
|
180 |
+
"a" - append
|
181 |
+
"r" - read
|
182 |
+
"w" - write
|
183 |
+
|
184 |
+
The second character can be:
|
185 |
+
"t" - text
|
186 |
+
"b" - binary
|
187 |
+
|
188 |
+
You can also append a "+" to specify both read and write.
|
189 |
+
Open a file in append+read+write mode
|
190 |
+
On mode "a+"/"w+" it create a file if there no exist
|
191 |
+
Mode "w+" overwrite a file if one exist*/
|
192 |
+
new filepointer = fopen(filename,"a+")
|
193 |
+
|
194 |
+
/*check if file is open,on an error filepointer is 0*/
|
195 |
+
if(filepointer)
|
196 |
+
{
|
197 |
+
/*It give 2 ways to write a string inside a file*/
|
198 |
+
|
199 |
+
/*First way*/
|
200 |
+
formatex(writedata,127,"%s %s %d %f^n",steamid,name,anyvalue,anyfloatvalue)
|
201 |
+
//The new file commands need to create a newline manual with "^n"
|
202 |
+
|
203 |
+
/*write the string to the file*/
|
204 |
+
/*another commands are:
|
205 |
+
fputc - Writes a char (1 byte) to a file handle.
|
206 |
+
fputf - Writes a float (4 bytes, 8 on AMD64) to a file handle.
|
207 |
+
fputi - Writes an integer (4 bytes) to a file handle.
|
208 |
+
fputl - Writes a long (4 bytes) to a file handle. */
|
209 |
+
fputs(filepointer,writedata)
|
210 |
+
|
211 |
+
/*Second way*/
|
212 |
+
/*fprintf - Writes a line to a file */
|
213 |
+
fprintf(filepointer,"%s %s %d %f^n",steamid,name,anyvalue,anyfloatvalue)
|
214 |
+
|
215 |
+
/*close the file,this is optional,but better is it to close the file*/
|
216 |
+
fclose(filepointer)
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
public filereadtest(id){
|
221 |
+
/*open file in read-mode*/
|
222 |
+
new filepointer = fopen(filename,"r")
|
223 |
+
/*check if file is open,on an error filepointer is 0*/
|
224 |
+
if(filepointer)
|
225 |
+
{
|
226 |
+
new readdata[128],steamid[32],anyvalue,Float:anyfloatvalue
|
227 |
+
new parsedsteamid[32],parsedname[32],parsedanyvalue[8],parsedanyfloatvalue[8]
|
228 |
+
|
229 |
+
/*Read the file until it is at end of file*/
|
230 |
+
/*fgets - Reads a line from a text file -- includes newline!*/
|
231 |
+
while(fgets(filepointer,readdata,127))
|
232 |
+
{
|
233 |
+
parse(readdata,parsedsteamid,31,parsedname,31,parsedanyvalue,7,parsedanyfloatvalue,7)
|
234 |
+
|
235 |
+
get_user_authid(id,steamid,31)
|
236 |
+
if(equal(steamid,parsedsteamid))
|
237 |
+
{
|
238 |
+
anyvalue = str_to_num(parsedanyvalue)
|
239 |
+
anyfloatvalue = str_to_float(parsedanyfloatvalue)
|
240 |
+
client_print(id,print_chat,"Your saved Steamid:%s Name:%s Value:%d FloatValue:%f",parsedsteamid,parsedname,anyvalue,anyfloatvalue)
|
241 |
+
break
|
242 |
+
//...
|
243 |
+
}
|
244 |
+
}
|
245 |
+
fclose(filepointer)
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
To write a file where must save many data ,the plugin growing big and are many work to write with using Parse,str_to_,...
|
250 |
+
Here a little trick that i have learn to use strucs in Pawn.
|
251 |
+
This is very easy to manage the filedata and adding new data,but every change need to change/convert also the file.
|
252 |
+
|
253 |
+
Code:
|
254 |
+
enum enumname{}
|
255 |
+
enum give the variable inside the {} a number.It begin with number 0.
|
256 |
+
With "new variablename[enumname]" it create a variable with the arraylenght of the given enum.
|
257 |
+
Code:
|
258 |
+
fwrite_raw ( file, const stream[], blocksize, mode )
|
259 |
+
Write an array to the file at current cursor position."blocksize" is the size of the array or the lenght who want to write.
|
260 |
+
Mode can be:
|
261 |
+
Code:
|
262 |
+
BLOCK_INT //Good to write any value/char
|
263 |
+
BLOCK_SHORT //For writing values -32767 -> 32767 and chars
|
264 |
+
BLOCK_CHAR //Good for writing chars/values -127 -> 127
|
265 |
+
BLOCK_BYTE //Same as char
|
266 |
+
Code:
|
267 |
+
fread_raw ( file, stream[], blocksize, blocknum )
|
268 |
+
Reads blocknum blocks from a file at current file cursor position until blocksize is reached or end of the file is found.It returns the number of succesfully readed blocks.
|
269 |
+
|
270 |
+
Code:
|
271 |
+
#include <amxmodx>
|
272 |
+
#include <amxmisc>
|
273 |
+
|
274 |
+
#define PLUGIN "Filehandle"
|
275 |
+
#define VERSION "1.0"
|
276 |
+
#define AUTHOR "Administrator"
|
277 |
+
|
278 |
+
new filename[256]
|
279 |
+
|
280 |
+
enum PLAYER_DATABASE
|
281 |
+
{
|
282 |
+
STEAMID[32],
|
283 |
+
NAME[32],
|
284 |
+
ANYVALUE,
|
285 |
+
ANYFLOATVALUE,
|
286 |
+
|
287 |
+
PLAYER_DATABASE_END
|
288 |
+
}
|
289 |
+
new player_data[33][PLAYER_DATABASE]
|
290 |
+
|
291 |
+
public plugin_init() {
|
292 |
+
register_plugin(PLUGIN, VERSION, AUTHOR)
|
293 |
+
|
294 |
+
get_configsdir(filename,255)
|
295 |
+
format(filename,255,"%s/filehandle.txt",filename)
|
296 |
+
register_concmd("amx_filetestwrite","filewritetest")
|
297 |
+
register_concmd("amx_filetestread","filereadtest")
|
298 |
+
}
|
299 |
+
|
300 |
+
public filewritetest(id){
|
301 |
+
/*Lets create and copy some dummy data into data*/
|
302 |
+
get_user_authid(id,player_data[id][STEAMID],31)
|
303 |
+
get_user_name(id,player_data[id][NAME],31)
|
304 |
+
player_data[id][ANYVALUE] = 10
|
305 |
+
/*theres a little problem with enum and floats:player_data[id][ANYFLOATVALUE] = 5.5 return an tag mismatch error
|
306 |
+
this error can be ignored but a better way is using _: in front of the float value*/
|
307 |
+
player_data[id][ANYFLOATVALUE] = _:5.5
|
308 |
+
|
309 |
+
new fp=fopen(filename,"a+")
|
310 |
+
if(fp)
|
311 |
+
{
|
312 |
+
/*There exist 3 commands
|
313 |
+
fwrite - Writes an element to a file (for single chars)
|
314 |
+
fwrite_blocks - Writes a block of data in a file (for unknown,havent get any good results with this)
|
315 |
+
fwrite_raw - Writes blocks of data to a file (for strings/arrays)*/
|
316 |
+
fwrite_raw(fp,player_data[id][PLAYER_DATABASE:0],sizeof(player_data[]),BLOCK_INT)
|
317 |
+
/*Now i explain the fwrite_raw
|
318 |
+
fp is the filepointer
|
319 |
+
player_data[id] is the data from player
|
320 |
+
[PLAYER_DATABASE:0] is the begining of the data who want to write,
|
321 |
+
to write only Steamid it need to use player_data[id][PLAYER_DATABASE:STEAMID]
|
322 |
+
sizeof(player_data[]) is the lenght of data which want to write,
|
323 |
+
to write somthing like only steamid it need "player_data[id][PLAYER_DATABASE:STEAMID],32"
|
324 |
+
*/
|
325 |
+
}
|
326 |
+
fclose(fp)
|
327 |
+
}
|
328 |
+
|
329 |
+
public filereadtest(id){
|
330 |
+
new readdata[PLAYER_DATABASE],steamid[32]
|
331 |
+
new fp=fopen(filename,"r")
|
332 |
+
if(fp)
|
333 |
+
{
|
334 |
+
while(fread_raw(fp,readdata[PLAYER_DATABASE:0],sizeof(player_data[]),1))
|
335 |
+
{
|
336 |
+
get_user_authid(id,steamid,31)
|
337 |
+
if(equal(steamid,readdata[STEAMID]))
|
338 |
+
{
|
339 |
+
player_data[id][ANYVALUE] = readdata[ANYVALUE]
|
340 |
+
player_data[id][ANYFLOATVALUE] = _:readdata[ANYFLOATVALUE]
|
341 |
+
copy(player_data[id][STEAMID],31,readdata[STEAMID])
|
342 |
+
copy(player_data[id][NAME],31,readdata[NAME])
|
343 |
+
client_print(id,print_chat,"Your saved Steamid:%s Name:%s Value:%d FloatValue:%f",readdata[STEAMID],readdata[NAME],readdata[ANYVALUE],readdata[ANYFLOATVALUE])
|
344 |
+
client_print(id,print_chat,"Your saved Data:%s Name:%s Value:%d FloatValue:%f",player_data[id][STEAMID],player_data[id][NAME],player_data[id][ANYVALUE],player_data[id][ANYFLOATVALUE])
|
345 |
+
break
|
346 |
+
//...
|
347 |
+
}
|
348 |
+
}
|
349 |
+
}
|
350 |
+
fclose(fp)
|
351 |
+
}
|
Using Files to write datavalues, filehandle.sma.txt
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <amxmodx>
|
2 |
+
#include <amxmisc>
|
3 |
+
|
4 |
+
#define PLUGIN "Filehandle"
|
5 |
+
#define VERSION "1.0"
|
6 |
+
#define AUTHOR "Administrator"
|
7 |
+
|
8 |
+
new filename[256]
|
9 |
+
|
10 |
+
enum PLAYER_DATABASE
|
11 |
+
{
|
12 |
+
STEAMID[32],
|
13 |
+
NAME[32],
|
14 |
+
ANYVALUE,
|
15 |
+
ANYFLOATVALUE,
|
16 |
+
//add here more values/data
|
17 |
+
PLAYER_DATABASE_END
|
18 |
+
}
|
19 |
+
|
20 |
+
new player_data[33][PLAYER_DATABASE]
|
21 |
+
|
22 |
+
public plugin_init() {
|
23 |
+
register_plugin(PLUGIN, VERSION, AUTHOR)
|
24 |
+
|
25 |
+
get_configsdir(filename,255)
|
26 |
+
format(filename,255,"%s/filehandle.txt",filename)
|
27 |
+
register_concmd("amx_filetestwrite","filewritetest")
|
28 |
+
register_concmd("amx_filetestread","filereadtest")
|
29 |
+
}
|
30 |
+
|
31 |
+
public filewritetest(id){
|
32 |
+
new founded,readdata[PLAYER_DATABASE]
|
33 |
+
get_user_authid(id,player_data[id][STEAMID],31)
|
34 |
+
get_user_name(id,player_data[id][NAME],31)
|
35 |
+
player_data[id][ANYVALUE] = 101
|
36 |
+
player_data[id][ANYFLOATVALUE] = _:9.9
|
37 |
+
|
38 |
+
new fp=fopen(filename,"ab+")
|
39 |
+
if(fp)
|
40 |
+
{
|
41 |
+
while(fread_raw(fp,readdata[PLAYER_DATABASE:0],sizeof(player_data[]),BLOCK_INT))
|
42 |
+
{
|
43 |
+
if(equal(player_data[id][STEAMID],readdata[STEAMID]))
|
44 |
+
{
|
45 |
+
fwrite_raw(fp,player_data[id][PLAYER_DATABASE:0],sizeof(player_data[]),BLOCK_INT)
|
46 |
+
founded = 1
|
47 |
+
break
|
48 |
+
}
|
49 |
+
}
|
50 |
+
if (!founded)
|
51 |
+
fwrite_raw(fp,player_data[id][PLAYER_DATABASE:0],sizeof(player_data[]),BLOCK_INT)
|
52 |
+
}
|
53 |
+
fclose(fp)
|
54 |
+
}
|
55 |
+
|
56 |
+
public filereadtest(id){
|
57 |
+
new steamid[32],founded
|
58 |
+
new fp=fopen(filename,"rb")
|
59 |
+
if(fp)
|
60 |
+
{
|
61 |
+
while(fread_raw(fp,player_data[id][PLAYER_DATABASE:0],sizeof(player_data[]),1))
|
62 |
+
{
|
63 |
+
get_user_authid(id,steamid,31)
|
64 |
+
if(equal(steamid,player_data[id][STEAMID]))
|
65 |
+
{
|
66 |
+
client_print(id,print_chat,"Your saved Data:%s Name:%s Value:%d FloatValue:%f",player_data[id][STEAMID],player_data[id][NAME],player_data[id][ANYVALUE],player_data[id][ANYFLOATVALUE])
|
67 |
+
founded = 1
|
68 |
+
break
|
69 |
+
//...
|
70 |
+
}
|
71 |
+
}
|
72 |
+
if(!founded)
|
73 |
+
{
|
74 |
+
//No Data founded in file
|
75 |
+
//Reset the Data to 0
|
76 |
+
for(new i=0;PLAYER_DATABASE:i<PLAYER_DATABASE_END;PLAYER_DATABASE:i++)
|
77 |
+
{
|
78 |
+
player_data[id][PLAYER_DATABASE:i] = 0
|
79 |
+
}
|
80 |
+
//client_print(id,print_chat,"Data resseted? 0=true :%f,%d,%s,%s",player_data[id][PLAYER_DATABASE:ANYFLOATVALUE],player_data[id][PLAYER_DATABASE:ANYVALUE],player_data[id][PLAYER_DATABASE:STEAMID],player_data[id][PLAYER_DATABASE:NAME])
|
81 |
+
}
|
82 |
+
else founded = 0
|
83 |
+
}
|
84 |
+
fclose(fp)
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
|
89 |
+
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1031\\ f0\\ fs16 \n\\ par }
|
90 |
+
*/
|
set_speak() in Fakemeta.txt
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
This tutorial is for an engine-to-fakemeta conversion for the functions set_speak() and get_speak().
|
2 |
+
|
3 |
+
First, we'll start off by defining the variables.
|
4 |
+
|
5 |
+
Code:
|
6 |
+
#include <amxmodx>
|
7 |
+
#include <fakemeta>
|
8 |
+
|
9 |
+
#define SPEAK_MUTED 0
|
10 |
+
#define SPEAK_NORMAL 1
|
11 |
+
#define SPEAK_ALL 2
|
12 |
+
#define SPEAK_LISTENALL 4
|
13 |
+
#define SPEAK_TEAM 8
|
14 |
+
|
15 |
+
Now, "What is 'SPEAK_TEAM' ?"
|
16 |
+
SPEAK_TEAM is a new one that I have thought up myself.
|
17 |
+
It acts as if alltalk is on, but only for that team.
|
18 |
+
Example:
|
19 |
+
I'm dead, and I can still talk to my alive teammates, but not to the other team.
|
20 |
+
|
21 |
+
Now, we will need to create a variable so each player can have his/her own flag.
|
22 |
+
And, we will need to reset the player's flag to SPEAK_NORMAL when he/she enters.
|
23 |
+
|
24 |
+
Code:
|
25 |
+
new g_iSpeakFlags[33];
|
26 |
+
|
27 |
+
public client_connect(id)
|
28 |
+
{
|
29 |
+
g_iSpeakFlags[id] = SPEAK_NORMAL;
|
30 |
+
}
|
31 |
+
|
32 |
+
We will need some functions to get and set the player's speak mode.
|
33 |
+
|
34 |
+
Code:
|
35 |
+
#define fm_get_speak(%1) g_iSpeakFlags[%1]
|
36 |
+
#define fm_set_speak(%1, %2) g_iSpeakFlags[%1] = %2
|
37 |
+
fm_get_speak(index) - returns a player's speak mode
|
38 |
+
fm_set_speak(index, iSpeakFlag) - sets a player's speak mode
|
39 |
+
|
40 |
+
|
41 |
+
To hook when a player talks, we will need to register the forward FM_Voice_SetClientListening.
|
42 |
+
Code:
|
43 |
+
public plugin_init()
|
44 |
+
{
|
45 |
+
register_forward(FM_Voice_SetClientListening, "fwd_FM_Voice_SetClientListening");
|
46 |
+
}
|
47 |
+
|
48 |
+
Information about the forward:
|
49 |
+
Quote:
|
50 |
+
FM_Voice_SetClientListening, // bool ) (iReceiver, iSender, bool:bListen)
|
51 |
+
Now, we will create our hooked function:
|
52 |
+
Code:
|
53 |
+
public fwd_FM_Voice_SetClientListening(receiver, sender, bool:bListen)
|
54 |
+
{
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
This function is called even when a player isn't talking, so we must filter it out to check if the voice is valid:
|
59 |
+
|
60 |
+
Code:
|
61 |
+
public fwd_FM_Voice_SetClientListening(receiver, sender, bool:bListen)
|
62 |
+
{
|
63 |
+
if(!is_user_connected(sender) || !is_user_connected(receiver))
|
64 |
+
{
|
65 |
+
return FMRES_IGNORED;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
Also, we will need to check if the voice is a default server voice, and the two players don't have any special voice flags.
|
70 |
+
|
71 |
+
Code:
|
72 |
+
public fwd_FM_Voice_SetClientListening(receiver, sender, bool:bListen)
|
73 |
+
{
|
74 |
+
if(!is_user_connected(sender) || !is_user_connected(receiver))
|
75 |
+
{
|
76 |
+
return FMRES_IGNORED;
|
77 |
+
}
|
78 |
+
|
79 |
+
// the speaker has no special speech
|
80 |
+
// and the receiver isn't listening to everyone, so this is a default voice
|
81 |
+
if(g_iSpeakFlags[sender] == SPEAK_NORMAL && g_iSpeakFlags[receiver] != SPEAK_LISTENALL)
|
82 |
+
{
|
83 |
+
return FMRES_IGNORED;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
Now it's time to set the listening.
|
88 |
+
|
89 |
+
Code:
|
90 |
+
public fwd_FM_Voice_SetClientListening(receiver, sender, bool:bListen)
|
91 |
+
{
|
92 |
+
if(!is_user_connected(sender) || !is_user_connected(receiver))
|
93 |
+
{
|
94 |
+
return FMRES_IGNORED;
|
95 |
+
}
|
96 |
+
|
97 |
+
// the speaker has no special speech
|
98 |
+
// and the receiver isn't listening to everyone, so this is a default voice
|
99 |
+
if(g_iSpeakFlags[sender] == SPEAK_NORMAL && g_iSpeakFlags[receiver] != SPEAK_LISTENALL)
|
100 |
+
{
|
101 |
+
return FMRES_IGNORED;
|
102 |
+
}
|
103 |
+
|
104 |
+
new iSpeakValue = 0;
|
105 |
+
// this will be the value to determine if the voice should be sent
|
106 |
+
// (1 for true, 0 for false)
|
107 |
+
|
108 |
+
// Check if the voice SHOULD be sent
|
109 |
+
if(g_iSpeakFlags[sender] == SPEAK_ALL
|
110 |
+
// speaker can talk to everyone
|
111 |
+
// or
|
112 |
+
|| g_iSpeakFlags[receiver] == SPEAK_LISTENALL
|
113 |
+
// receiver can hear anyone
|
114 |
+
// or
|
115 |
+
|| g_iSpeakFlags[sender] == SPEAK_TEAM && get_pdata_int(sender, 114) == get_pdata_int(receiver, 114))
|
116 |
+
// speaker can only talk to team.
|
117 |
+
// get_pdata_int(index, 114) is the fakemeta version of cs_get_user_team(index)
|
118 |
+
{
|
119 |
+
iSpeakValue = 1;
|
120 |
+
}
|
121 |
+
|
122 |
+
// set the voice
|
123 |
+
engfunc(EngFunc_SetClientListening, receiver, sender, iSpeakValue);
|
124 |
+
return FMRES_SUPERCEDE;
|
125 |
+
}
|
126 |
+
|
127 |
+
When you are finished, this should be your full code (without comments):
|
128 |
+
Code:
|
129 |
+
#include <amxmodx>
|
130 |
+
#include <fakemeta>
|
131 |
+
|
132 |
+
#define SPEAK_MUTED 0
|
133 |
+
#define SPEAK_NORMAL 1
|
134 |
+
#define SPEAK_ALL 2
|
135 |
+
#define SPEAK_LISTENALL 4
|
136 |
+
#define SPEAK_TEAM 8
|
137 |
+
|
138 |
+
new g_iSpeakFlags[33];
|
139 |
+
|
140 |
+
#define fm_get_speak(%1) g_iSpeakFlags[%1]
|
141 |
+
#define fm_set_speak(%1, %2) g_iSpeakFlags[%1] = %2
|
142 |
+
|
143 |
+
public plugin_init()
|
144 |
+
{
|
145 |
+
register_forward(FM_Voice_SetClientListening, "fwd_FM_Voice_SetClientListening");
|
146 |
+
}
|
147 |
+
|
148 |
+
public client_connect(id)
|
149 |
+
{
|
150 |
+
g_iSpeakFlags[id] = SPEAK_NORMAL;
|
151 |
+
}
|
152 |
+
|
153 |
+
public fwd_FM_Voice_SetClientListening(receiver, sender, bool:bListen)
|
154 |
+
{
|
155 |
+
if(!is_user_connected(receiver) || !is_user_connected(sender))
|
156 |
+
{
|
157 |
+
return FMRES_IGNORED;
|
158 |
+
}
|
159 |
+
|
160 |
+
if(g_iSpeakFlags[sender] == SPEAK_NORMAL && g_iSpeakFlags[receiver] != SPEAK_LISTENALL)
|
161 |
+
{
|
162 |
+
return FMRES_IGNORED;
|
163 |
+
}
|
164 |
+
|
165 |
+
new iSpeakValue = 0;
|
166 |
+
if(g_iSpeakFlags[sender] == SPEAK_ALL
|
167 |
+
|| g_iSpeakFlags[receiver] == SPEAK_LISTENALL
|
168 |
+
|| g_iSpeakFlags[sender] == SPEAK_TEAM && get_pdata_int(sender, 114) == get_pdata_int(receiver, 114))
|
169 |
+
{
|
170 |
+
iSpeakValue = 1;
|
171 |
+
}
|
172 |
+
|
173 |
+
engfunc(EngFunc_SetClientListening, receiver, sender, iSpeakValue);
|
174 |
+
return FMRES_SUPERCEDE;
|
175 |
+
}
|
set_tasks when they are and when they aren't necessary.txt
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
set_task can sometimes be an extremely useful function, but other times it is really overkill. What few people know is that it is a very expensive operation, the CPU has to literally check every cycle if it is time for the set_task to be executed. Usually, there are ways around a set_task.
|
2 |
+
|
3 |
+
set_task also has the restriction of being unable to be called more than every 0.1 seconds. This means that if you pass 0.01 in parameter 1, it will be clamped at 0.1.
|
4 |
+
|
5 |
+
But what can we do to avoid it? Sometimes you really have to use a set_task, such as here:
|
6 |
+
|
7 |
+
Code:
|
8 |
+
#include <amxmodx>
|
9 |
+
#include <amxmisc>
|
10 |
+
#include <engine>
|
11 |
+
|
12 |
+
public plugin_init()
|
13 |
+
{
|
14 |
+
register_plugin("ROFL","1.0","Hawk552")
|
15 |
+
|
16 |
+
register_event("ResetHUD","EventResetHUD","be")
|
17 |
+
}
|
18 |
+
|
19 |
+
public EventResetHUD(id)
|
20 |
+
set_task(1.0,"DelayedResetHUD",id)
|
21 |
+
|
22 |
+
public DelayedResetHUD(id)
|
23 |
+
DispatchSpawn(id)
|
24 |
+
|
25 |
+
But why? There is no real way to escape delaying the function once without doing something more CPU intensive or unreliable. We could create an ent and make it think in 1 second (which will be covered later), but that not only adds an unnecissary spawn for such a small thing, it also is more unreliable (i.e. the server could crash due to too many ents, or it could be failed to be spawned and the function simply has to end there).
|
26 |
+
|
27 |
+
But there are other times where escaping a set_task is not only easier, but less resource consuming.
|
28 |
+
|
29 |
+
One of the commonly known ways of doing this is the forward client_PreThink / FM_PlayerPreThink. This forward is called every frame on a client before rendering physics. In this forward, you would do things that generally must be constantly updated, like velocity or changing rendering.
|
30 |
+
|
31 |
+
Here is an example:
|
32 |
+
|
33 |
+
Code:
|
34 |
+
#include <amxmodx>
|
35 |
+
#include <amxmisc>
|
36 |
+
#include <engine>
|
37 |
+
|
38 |
+
public plugin_init()
|
39 |
+
register_plugin("ROFL","1.0","Hawk552")
|
40 |
+
|
41 |
+
public client_PreThink(id)
|
42 |
+
{
|
43 |
+
static Float:Velocity[3]
|
44 |
+
entity_get_vector(id,EV_VEC_velocity,Velocity)
|
45 |
+
|
46 |
+
Velocity[2] = -floatabs(Velocity[2])
|
47 |
+
|
48 |
+
entity_set_vector(id,EV_VEC_velocity,Velocity)
|
49 |
+
}
|
50 |
+
|
51 |
+
Why is a set_task unsuitable here? For two reasons: 1) the half-life engine will allow you to have timers anyway (to a varying degree), and 2) it will look very glitchy since if the client has 60 FPS, the server is only checking every 10 frames if their velocity is what it should be.
|
52 |
+
|
53 |
+
One of the less practiced ways of avoiding set_tasks is to spawn an entity, set its nextthink to whatever you want, and register_think/FM_Think it. But when is this necessary? Pretty much whenever you use the "b" flag in set_task, it's better to use this method. It's also preferred when you have already spawned an entity (such as an NPC) and want to make it say, disappear, in x seconds.
|
54 |
+
|
55 |
+
Here is an example:
|
56 |
+
|
57 |
+
Engine:
|
58 |
+
Code:
|
59 |
+
#include <amxmodx>
|
60 |
+
#include <amxmisc>
|
61 |
+
#include <engine>
|
62 |
+
|
63 |
+
new g_Classname[] = "roflmao"
|
64 |
+
|
65 |
+
public plugin_init()
|
66 |
+
{
|
67 |
+
register_plugin("ROFL","1.0","Hawk552")
|
68 |
+
|
69 |
+
new Ent = create_entity("info_target")
|
70 |
+
entity_set_string(Ent,EV_SZ_classname,g_Classname)
|
71 |
+
entity_set_float(Ent,EV_FL_nextthink,20.0)
|
72 |
+
|
73 |
+
register_think(g_Classname,"RoflmaoThink")
|
74 |
+
}
|
75 |
+
|
76 |
+
public RoflmaoThink(Ent)
|
77 |
+
{
|
78 |
+
log_amx("ROFLMAO thinks.")
|
79 |
+
|
80 |
+
entity_set_float(Ent,EV_FL_nextthink,20.0)
|
81 |
+
}
|
82 |
+
|
83 |
+
Fakemeta:
|
84 |
+
Code:
|
85 |
+
#include <amxmodx>
|
86 |
+
#include <amxmisc>
|
87 |
+
#include <fakemeta>
|
88 |
+
|
89 |
+
new g_Classname[] = "roflmao"
|
90 |
+
|
91 |
+
public plugin_init()
|
92 |
+
{
|
93 |
+
register_plugin("ROFL","1.0","Hawk552")
|
94 |
+
|
95 |
+
new Ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
|
96 |
+
set_pev(Ent,pev_classname,g_Classname)
|
97 |
+
set_pev(Ent,pev_nextthink,20.0)
|
98 |
+
|
99 |
+
register_forward(FM_Think,"ForwardThink")
|
100 |
+
}
|
101 |
+
|
102 |
+
public ForwardThink(Ent)
|
103 |
+
{
|
104 |
+
static Classname[33]
|
105 |
+
pev(Ent,pev_classname,Classname,32)
|
106 |
+
|
107 |
+
if(!equal(Classname,g_Classname))
|
108 |
+
return FMRES_IGNORED
|
109 |
+
|
110 |
+
log_amx("ROFLMAO thinks.")
|
111 |
+
|
112 |
+
set_pev(Ent,pev_nextthink,20.0)
|
113 |
+
|
114 |
+
return FMRES_IGNORED
|
115 |
+
}
|
116 |
+
|
117 |
+
This is useful, as said, for escaping the usage of flag "b" on set_task, or executing set_task at the end of the function called.
|
118 |
+
|
119 |
+
The final way to escape a set_task is when using cooldowns. For example, you want a player to be able to use a special attack every 30 seconds.
|
120 |
+
|
121 |
+
Code:
|
122 |
+
#include <amxmodx>
|
123 |
+
#include <amxmisc>
|
124 |
+
#include <fakemeta>
|
125 |
+
|
126 |
+
// this is how often you want your players to be able to use your attack
|
127 |
+
#define ATTACK_COOLDOWN 20.0
|
128 |
+
|
129 |
+
new Float:g_LastAttack[33]
|
130 |
+
// optimization
|
131 |
+
new Float:g_Cooldown = ATTACK_COOLDOWN
|
132 |
+
|
133 |
+
public plugin_init()
|
134 |
+
{
|
135 |
+
register_plugin("ROFL","1.0","Hawk552")
|
136 |
+
|
137 |
+
register_clcmd("myattack","CmdMyAttack")
|
138 |
+
}
|
139 |
+
|
140 |
+
public CmdMyAttack(id)
|
141 |
+
{
|
142 |
+
// to use engine instead, use this:
|
143 |
+
/* new Float:Time = halflife_time() */
|
144 |
+
new Float:Time
|
145 |
+
global_get(glb_time,Time)
|
146 |
+
|
147 |
+
if(!is_user_alive(id) || Time - g_Cooldown < g_LastAttack[id])
|
148 |
+
return
|
149 |
+
|
150 |
+
g_LastAttack[id] = Time
|
151 |
+
|
152 |
+
// your code here
|
153 |
+
}
|