added datamap property offset native

added clientofuserid native for fast userid to client id translation
fixed a memory leek (some tries weren't being deleted)
added createdialog native
added 2 million inetchannelinfo wrappers

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40688
This commit is contained in:
Borja Ferrer
2007-04-12 00:45:53 +00:00
parent 4ecb7a985f
commit 21923d7871
16 changed files with 757 additions and 33 deletions
+114
View File
@@ -18,6 +18,13 @@
#endif
#define _clients_included
enum NetFlow
{
NetFlow_Outgoing = 0, /**< Outgoing traffic */
NetFlow_Incoming, /**< Incoming traffic */
NetFlow_Both /**< Incoming and outgoing traffic */
};
/**
* Called on client connection.
*
@@ -380,3 +387,110 @@ native GetClientDeaths(client);
* @error Invalid client index, client not in game, or no mod support.
*/
native GetClientFrags(client);
/**
* Returns the client's send data rate in bytes/sec.
*
* @param client Player's index.
* @return Data rate.
* @error Invalid client index, client not in game, or fake client.
*/
native GetDataRate(client);
/**
* Returns if a client is timing out
*
* @param client Player's index.
* @return True if client is timing out, false otherwise.
* @error Invalid client index, client not in game, or fake client.
*/
native bool:IsTimingOut(client);
/**
* Returns the client's connection time in seconds.
*
* @param client Player's index.
* @return Connection time.
* @error Invalid client index, client not in game, or fake client.
*/
native Float:GetTimeConnected(client);
/**
* Returns the client's current latency (RTT), more accurate than GetAvgLatency but jittering.
*
* @param client Player's index.
* @param flow Traffic flowing direction.
* @return Latency.
* @error Invalid client index, client not in game, or fake client.
*/
native Float:GetLatency(client, NetFlow:flow);
/**
* Returns the client's average packet latency in seconds.
*
* @param client Player's index.
* @param flow Traffic flowing direction.
* @return Average latency.
* @error Invalid client index, client not in game, or fake client.
*/
native Float:GetAvgLatency(client, NetFlow:flow);
/**
* Returns the client's average packet loss, values go from 0 to 1 (for percentages).
*
* @param client Player's index.
* @param flow Traffic flowing direction.
* @return Average packet loss.
* @error Invalid client index, client not in game, or fake client.
*/
native Float:GetAvgLoss(client, NetFlow:flow);
/**
* Returns the client's average packet choke, values go from 0 to 1 (for percentages).
*
* @param client Player's index.
* @param flow Traffic flowing direction.
* @return Average packet choke.
* @error Invalid client index, client not in game, or fake client.
*/
native Float:GetAvgChoke(client, NetFlow:flow);
/**
* Returns the client's data flow in bytes/sec.
*
* @param client Player's index.
* @param flow Traffic flowing direction.
* @return Data flow.
* @error Invalid client index, client not in game, or fake client.
*/
native Float:GetAvgData(client, NetFlow:flow);
/**
* Returns the client's average packet frequency in packets/sec.
*
* @param client Player's index.
* @param flow Traffic flowing direction.
* @return Packet frequency.
* @error Invalid client index, client not in game, or fake client.
*/
native Float:GetAvgPackets(client, NetFlow:flow);
/**
* Translates an userid index to the real player index.
*
* @param userid Userid value.
* @return Client value.
* @error Returns 0 if invalid userid.
*/
native GetClientOfUserId(userid);
/**
* Executes a client command on the server without being networked.
*
* @param client Index of the client.
* @param fmt Format of the client command.
* @param ... Format parameters
* @noreturn
* @error Invalid client index, or client not connected.
*/
native FakeClientCommand(client, const String:fmt[], any:...);
+162 -8
View File
@@ -289,6 +289,16 @@ native SetEntDataVector(entity, offset, const Float:vec[3], bool:changeState=fal
*/
native FindSendPropOffs(const String:cls[], const String:prop[]);
/**
* Given an entity, finds a datamap property offset.
* This information is cached for future calls.
*
* @param entity Entity index.
* @param prop Property name.
* @return An offset, or -1 on failure.
*/
native FindDataMapOffs(entity, const String:prop[]);
/**
* Wrapper function for finding a send property for a particular entity.
*
@@ -320,11 +330,29 @@ stock GetEntSendPropOffs(ent, const String:prop[])
*/
stock GetEntProp(entity, PropType:type, const String:prop[], size=4)
{
new offs = GetEntSendPropOffs(entity, prop);
new offs;
switch (type)
{
case Prop_Send:
{
offs = GetEntSendPropOffs(entity, prop);
}
case Prop_Data:
{
offs = FindDataMapOffs(entity, prop);
}
default:
{
ThrowError("Invalid Property type %d", type);
}
}
if (offs == -1)
{
ThrowError("Property \"%s\" not found for entity %d", prop, entity);
}
return GetEntData(entity, offs, size);
}
@@ -340,11 +368,29 @@ stock GetEntProp(entity, PropType:type, const String:prop[], size=4)
*/
stock SetEntProp(entity, PropType:type, const String:prop[], value, size=4)
{
new offs = GetEntSendPropOffs(entity, prop);
new offs;
switch (type)
{
case Prop_Send:
{
offs = GetEntSendPropOffs(entity, prop);
}
case Prop_Data:
{
offs = FindDataMapOffs(entity, prop);
}
default:
{
ThrowError("Invalid Property type %d", type);
}
}
if (offs == -1)
{
ThrowError("Property \"%s\" not found for entity %d", prop, entity);
}
return SetEntData(entity, offs, value, size, true);
}
@@ -359,11 +405,29 @@ stock SetEntProp(entity, PropType:type, const String:prop[], value, size=4)
*/
stock Float:GetEntPropFloat(entity, PropType:type, const String:prop[])
{
new offs = GetEntSendPropOffs(entity, prop);
new offs;
switch (type)
{
case Prop_Send:
{
offs = GetEntSendPropOffs(entity, prop);
}
case Prop_Data:
{
offs = FindDataMapOffs(entity, prop);
}
default:
{
ThrowError("Invalid Property type %d", type);
}
}
if (offs == -1)
{
ThrowError("Property \"%s\" not found for entity %d", prop, entity);
}
return GetEntDataFloat(entity, offs);
}
@@ -379,11 +443,29 @@ stock Float:GetEntPropFloat(entity, PropType:type, const String:prop[])
*/
stock SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value)
{
new offs = GetEntSendPropOffs(entity, prop);
new offs;
switch (type)
{
case Prop_Send:
{
offs = GetEntSendPropOffs(entity, prop);
}
case Prop_Data:
{
offs = FindDataMapOffs(entity, prop);
}
default:
{
ThrowError("Invalid Property type %d", type);
}
}
if (offs == -1)
{
ThrowError("Property \"%s\" not found for entity %d", prop, entity);
}
return SetEntDataFloat(entity, offs, value, true);
}
@@ -398,11 +480,29 @@ stock SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value)
*/
stock GetEntPropEnt(entity, PropType:type, const String:prop[])
{
new offs = GetEntSendPropOffs(entity, prop);
new offs;
switch (type)
{
case Prop_Send:
{
offs = GetEntSendPropOffs(entity, prop);
}
case Prop_Data:
{
offs = FindDataMapOffs(entity, prop);
}
default:
{
ThrowError("Invalid Property type %d", type);
}
}
if (offs == -1)
{
ThrowError("Property \"%s\" not found for entity %d", prop, entity);
}
return GetEntDataEnt(entity, offs);
}
@@ -418,11 +518,29 @@ stock GetEntPropEnt(entity, PropType:type, const String:prop[])
*/
stock SetEntPropEnt(entity, PropType:type, const String:prop[], other)
{
new offs = GetEntSendPropOffs(entity, prop);
new offs;
switch (type)
{
case Prop_Send:
{
offs = GetEntSendPropOffs(entity, prop);
}
case Prop_Data:
{
offs = FindDataMapOffs(entity, prop);
}
default:
{
ThrowError("Invalid Property type %d", type);
}
}
if (offs == -1)
{
ThrowError("Property \"%s\" not found for entity %d", prop, entity);
}
return SetEntDataEnt(entity, offs, other, true);
}
@@ -440,11 +558,29 @@ stock SetEntPropEnt(entity, PropType:type, const String:prop[], other)
*/
stock GetEntPropVector(entity, PropType:type, const String:prop[], Float:vec[3])
{
new offs = GetEntSendPropOffs(entity, prop);
new offs;
switch (type)
{
case Prop_Send:
{
offs = GetEntSendPropOffs(entity, prop);
}
case Prop_Data:
{
offs = FindDataMapOffs(entity, prop);
}
default:
{
ThrowError("Invalid Property type %d", type);
}
}
if (offs == -1)
{
ThrowError("Property \"%s\" not found for entity %d", prop, entity);
}
return GetEntDataVector(entity, offs, vec);
}
@@ -462,10 +598,28 @@ stock GetEntPropVector(entity, PropType:type, const String:prop[], Float:vec[3])
*/
stock SetEntPropVector(entity, PropType:type, const String:prop[], const Float:vec[3])
{
new offs = GetEntSendPropOffs(entity, prop);
new offs;
switch (type)
{
case Prop_Send:
{
offs = GetEntSendPropOffs(entity, prop);
}
case Prop_Data:
{
offs = FindDataMapOffs(entity, prop);
}
default:
{
ThrowError("Invalid Property type %d", type);
}
}
if (offs == -1)
{
ThrowError("Property \"%s\" not found for entity %d", prop, entity);
}
return SetEntDataVector(entity, offs, vec, true);
}
+12 -4
View File
@@ -45,6 +45,14 @@ struct Plugin
#include <functions>
#include <timers>
enum DialogType
{
DialogType_Msg = 0, /**< just an on screen message */
DialogType_Menu, /**< an options menu */
DialogType_Text, /**< a richtext dialog */
DialogType_Entry /**< an entry box */
};
/**
* Declare this as a struct in your plugin to expose its information.
* Example:
@@ -388,15 +396,15 @@ native bool:PrecacheSound(const String:sound[], bool:preload=false);
native bool:IsSoundPrecached(const String:sound[]);
/**
* Executes a client command on the server without being networked.
* Creates different types of ingame messages.
*
* @param client Index of the client.
* @param fmt Format of the client command.
* @param ... Format parameters
* @param kv KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
* @param type Message type to display ingame.
* @noreturn
* @error Invalid client index, or client not connected.
*/
native FakeClientCommand(client, const String:fmt[], any:...);
native CreateDialog(client, Handle:kv, DialogType:type);
#include <helpers>
#include <entity>