AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Function help (https://forums.alliedmods.net/showthread.php?t=11562)

Hawkie 03-23-2005 10:33

Function help
 
I have never known how and when to use the read_data() function. It says it reads a message from the client, but what message?

xeroblood 03-23-2005 11:20

1 Attachment(s)
Usually used when hooking an event.. using that function can return useful parameters passed on each event, but as far as I know it only returns integer types (like short or byte)

An example of the data for the 'CurWeapon' Event:

(not actual Small C code, just example of the data)
Code:

Name  = CurWeapon
ID      = 68
Size    = 3
Arg1  = BYTE : isActive
Arg2  = BYTE : weapon id
Arg3  = BYTE : ammo


so, if you hook that event, you can do something like:
Code:
#include <amxmodx> public plugin_init() {     // Hook the Event to call our function for each player (flag "b")     // our function only gets called if first arg is 1 (isActive: 1)     // if our weapon was active, then it will meet the "1=1" condition     // and call our function     register_event( "CurWeapon", "event_weapon", "b", "1=1" ) } public event_weapon() {     // we dont need to use first argument in this function (unless u want to)     // since we already used first argument as a condition when registering the event     new iWeaponID = read_data( 2 )     new iAmmo = read_data( 3 )     // some more code...     return PLUGIN_CONTINUE }


I have appended an old list of events and parameters for CS...

v3x 03-23-2005 16:28

Very nice, xero. :)


All times are GMT -4. The time now is 09:57.

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