initial import of bulk include for events and messages
authorDavid Anderson <dvander@alliedmods.net>
Wed Feb 14 17:49:18 2007 +0000 (2007-02-14)
changeset 4939760e66d1a23
parent 492 6533d89c8ef6
child 494 9b57583cc80b
initial import of bulk include for events and messages
this is not in sourcemod.inc until it's done
plugins/include/eventsmsgs.inc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/eventsmsgs.inc	Wed Feb 14 17:49:18 2007 +0000
     1.3 @@ -0,0 +1,240 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * ===============================================================
     1.7 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 + * ===============================================================
     1.9 + *
    1.10 + *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
    1.11 + * or modified under the Terms and Conditions of its License Agreement, which is found 
    1.12 + * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    1.13 + * may change at any time.  To view the latest information, see:
    1.14 + *   http://www.sourcemod.net/license.php
    1.15 + *
    1.16 + * Version: $Id$
    1.17 + */
    1.18 + 
    1.19 +#if defined _eventsmsgs_included
    1.20 + #endinput
    1.21 +#endif
    1.22 +#define _eventsmsgs_included
    1.23 +
    1.24 +enum UserMsg
    1.25 +{
    1.26 +	INVALID_MESSAGE_ID = -1,
    1.27 +};
    1.28 +
    1.29 +#define USERMSG_PASSTHRU		(1<<0)		/**< Message will pass through other SourceMM plugins */
    1.30 +#define USERMSG_PASSTHRU_ALL	(1<<1)		/**< Message will pass through other SourceMM plugins AND SourceMod */
    1.31 +
    1.32 +//:NOTE: none of this is implemented yet, remove this notice and add to sourcemod.inc once it's done!
    1.33 +//:NOTE: for DS, add main event natives below EndMessage but above bf_ stuff
    1.34 +
    1.35 +/**
    1.36 + * Returns the ID of a given message, or -1 on failure.
    1.37 + *
    1.38 + * @param msg			String containing message name (case sensitive).
    1.39 + * @return				A message index, or INVALID_MESSAGE_ID on failure.
    1.40 + */
    1.41 +native UserMsg:GetUserMessageId(const String:msg[]);
    1.42 +
    1.43 +/**
    1.44 + * Starts a usermessage (network message).
    1.45 + * @note Only one message can be active at a time.
    1.46 + *
    1.47 + * @param msg			Message index to start.  
    1.48 + * @param clients		Array containing player indexes to broadcast to.
    1.49 + * @param numClients	Number of players in the array.
    1.50 + * @return				A handle to a bf_write bit packing structure, or
    1.51 + *						INVALID_HANDLE on failure.
    1.52 + */
    1.53 +native Handle:StartMessage(UserMsg:msg, clients[], numClients, flags);
    1.54 +
    1.55 +/**
    1.56 + * Ends a previously started user message (network message).
    1.57 + *
    1.58 + * @noreturn
    1.59 + */
    1.60 +native EndMessage();
    1.61 +
    1.62 +/** 
    1.63 + * Writes a single bit to a writable bitbuffer (bf_write).
    1.64 + *
    1.65 + * @param bf			bf_write handle to write to.
    1.66 + * @param bit			Bit to write (true for 1, false for 0).
    1.67 + * @noreturn
    1.68 + * @error				Invalid or incorrect Handle.
    1.69 + */
    1.70 +native BfWriteBool(Handle:bf, bool:bit);
    1.71 + 
    1.72 +/**
    1.73 + * Writes a byte to a writable bitbuffer (bf_write).
    1.74 + *
    1.75 + * @param bf			bf_write handle to write to.
    1.76 + * @param byte			Byte to write (value will be written as 8bit).
    1.77 + * @noreturn
    1.78 + * @error				Invalid or incorrect Handle.
    1.79 + */
    1.80 +native BfWriteByte(Handle:bf, byte);
    1.81 +
    1.82 +/**
    1.83 + * Writes a byte to a writable bitbuffer (bf_write).
    1.84 + *
    1.85 + * @param bf			bf_write handle to write to.
    1.86 + * @param chr			Character to write.
    1.87 + * @noreturn
    1.88 + * @error				Invalid or incorrect Handle.
    1.89 + */
    1.90 +native BfWriteChar(Handle:bf, chr);
    1.91 +
    1.92 +/**
    1.93 + * Writes a 16bit integer to a writable bitbuffer (bf_write).
    1.94 + *
    1.95 + * @param bf			bf_write handle to write to.
    1.96 + * @param num			Integer to write (value will be written as 16bit).
    1.97 + * @noreturn
    1.98 + * @error				Invalid or incorrect Handle.
    1.99 + */
   1.100 +native BfWriteShort(Handle:bf, num);
   1.101 +
   1.102 +/**
   1.103 + * Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
   1.104 + *
   1.105 + * @param bf			bf_write handle to write to.
   1.106 + * @param num			Integer to write (value will be written as 16bit).
   1.107 + * @noreturn
   1.108 + * @error				Invalid or incorrect Handle.
   1.109 + */
   1.110 +native BfWriteWord(Handle:bf, num);
   1.111 +
   1.112 +/**
   1.113 + * Writes a normal integer to a writable bitbuffer (bf_write).
   1.114 + *
   1.115 + * @param bf			bf_write handle to write to.
   1.116 + * @param num			Integer to write (value will be written as 32bit).
   1.117 + * @noreturn
   1.118 + * @error				Invalid or incorrect Handle.
   1.119 + */
   1.120 +native BfWriteNum(Handle:bf, num);
   1.121 +
   1.122 +/**
   1.123 + * Writes a floating point number to a writable bitbuffer (bf_write).
   1.124 + *
   1.125 + * @param bf			bf_write handle to write to.
   1.126 + * @param num			Number to write.
   1.127 + * @noreturn
   1.128 + * @error				Invalid or incorrect Handle.
   1.129 + */
   1.130 +native BfWriteFloat(Handle:bf, Float:num);
   1.131 +
   1.132 +/**
   1.133 + * Writes a string to a writable bitbuffer (bf_write).
   1.134 + *
   1.135 + * @param bf			bf_write handle to write to.
   1.136 + * @param string		Text string to write.
   1.137 + * @noreturn
   1.138 + * @error				Invalid or incorrect Handle.
   1.139 + */
   1.140 +native BfWriteString(Handle:bf, const String:string[]);
   1.141 +
   1.142 +/**
   1.143 + * Writes an entity to a writable bitbuffer (bf_write).
   1.144 + * @note This is a wrapper around BfWriteShort().
   1.145 + *
   1.146 + * @param bf			bf_write handle to write to.
   1.147 + * @param ent			Entity index to write.
   1.148 + * @noreturn
   1.149 + * @error				Invalid or incorrect Handle, or invalid entity.
   1.150 + */
   1.151 +native BfWriteEntity(Handle:bf, ent);
   1.152 +
   1.153 +/**
   1.154 + * Writes a bit angle to a writable bitbuffer (bf_write).
   1.155 + *
   1.156 + * @param bf			bf_write handle to write to.
   1.157 + * @param angle			Angle to write.
   1.158 + * @param numBits		Optional number of bits to use.
   1.159 + * @noreturn
   1.160 + * @error				Invalid or incorrect Handle.
   1.161 + */
   1.162 +native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
   1.163 +
   1.164 +/**
   1.165 + * Writes a coordinate to a writable bitbuffer (bf_write).
   1.166 + *
   1.167 + * @param bf			bf_write handle to write to.
   1.168 + * @param coord			Coordinate to write.
   1.169 + * @noreturn
   1.170 + * @error				Invalid or incorrect Handle.
   1.171 + */
   1.172 +native BfWriteCoord(Handle:bf, Float:coord);
   1.173 +
   1.174 +/**
   1.175 + * Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
   1.176 + *
   1.177 + * @param bif			bf_write handle to write to.
   1.178 + * @param coord			Coordinate array to write.
   1.179 + * @noreturn
   1.180 + * @error				Invalid or incorrect Handle.
   1.181 + */
   1.182 +native BfWriteVecCoord(Handle:bf, Float:coord[3]);
   1.183 +
   1.184 +/**
   1.185 + * Writes a 3D normal vector to a writable bitbuffer (bf_write).
   1.186 + *
   1.187 + * @param bif			bf_write handle to write to.
   1.188 + * @param vec			Vector to write.
   1.189 + * @noreturn
   1.190 + * @error				Invalid or incorrect Handle.
   1.191 + */
   1.192 +native BfWriteVecNormal(Handle:bf, Float:vec[3]);
   1.193 +
   1.194 +/**
   1.195 + * Writes a 3D angle vector to a writable bitbuffer (bf_write).
   1.196 + *
   1.197 + * @param bif			bf_write handle to write to.
   1.198 + * @param angles		Angle vector to write.
   1.199 + * @noreturn
   1.200 + * @error				Invalid or incorrect Handle.
   1.201 + */
   1.202 +native BfWriteAngles(Handle:bf, Float:angles[3]);
   1.203 +
   1.204 +/**
   1.205 + * Starts a usermessage (network message) that broadcasts to all clients.
   1.206 + *
   1.207 + * @param msg			Message index to start.
   1.208 + * @param flags			Optional flags to set.
   1.209 + * @return				A handle to a bf_write bit packing structure, or
   1.210 + *						INVALID_HANDLE on failure.
   1.211 + */
   1.212 +stock Handle:StartMessageAll(UserMsg:msg, flags=0)
   1.213 +{
   1.214 +	new maxClients = GetMaxClients();
   1.215 +	new total = 0;
   1.216 +	new clients[maxClients];
   1.217 +	for (new i=1; i<=maxClients; i++)
   1.218 +	{
   1.219 +		if (IsClientConnected(i))
   1.220 +		{
   1.221 +			clients[total++] = i;
   1.222 +		}
   1.223 +	}
   1.224 +	return StartMessage(msg, clients, total, flags);
   1.225 +}
   1.226 +
   1.227 +/**
   1.228 + * Starts a simpler usermessage (network message) for one client.
   1.229 + *
   1.230 + * @param msg			Message index to start.
   1.231 + * @param client		Client to send to.
   1.232 + * @param flags			Optional flags to set.
   1.233 + * @return				A handle to a bf_write bit packing structure, or
   1.234 + *						INVALID_HANDLE on failure.
   1.235 + */
   1.236 +stock Handle:StartMessageOne(UserMsg:msg, client, flags=0)
   1.237 +{
   1.238 +	new players[1];
   1.239 +	
   1.240 +	players[0] = client;
   1.241 +	
   1.242 +	return StartMsesage(msg, players, 1, flags);
   1.243 +}