| ConnorMcLeod |
03-14-2009 16:52 |
Re: HamOnControl
Example of what you can do with Ham_OnControls and Ham_Use :
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Drive"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"
/*
TRAIN_ACTIVE 128
TRAIN_NEW 192
TRAIN_OFF 0
TRAIN_NEUTRAL 1
TRAIN_SLOW 2
TRAIN_MEDIUM 3
TRAIN_FAST 4
TRAIN_BACK 5
*/
#define TRAIN_ACTIVE 0x80
#define TRAIN_NEW 0xc0
#define TRAIN_OFF 0x00
#define TRAIN_NEUTRAL 0x01
#define TRAIN_SLOW 0x02
#define TRAIN_MEDIUM 0x03
#define TRAIN_FAST 0x04
#define TRAIN_BACK 0x05
#define m_iTrain 350
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_OnControls, "func_vehicle", "FuncVehicle_OnControls", 1)
RegisterHam(Ham_Use, "func_vehicle", "FuncVehicle_Use", 1)
}
public FuncVehicle_OnControls(iVehicle, id)
{
// id has taken control on iVehicle
new szModel[64]
pev(iVehicle, pev_model, szModel, charsmax(szModel))
client_print(id, print_center, "Good Drive %s :)", szModel[0] == '*' ? "" : "on %s", szModel)
}
public FuncVehicle_Use(iVehicle, id, iCaller, iUseType, Float:fValue)
{
// id is driving iVehicle
// fValue
// 30.0 = turning right
// 20.0 = turning left
// 1.0 = forward
// -1.0 = back
static szMessage[64], n
n = 0
switch( fValue )
{
case 20.0:n += formatex(szMessage, charsmax(szMessage), "Turning left")
case 30.0:n += formatex(szMessage, charsmax(szMessage), "Turning right")
}
switch( get_pdata_int(id, m_iTrain, 5) )
{
case TRAIN_SLOW:n += formatex(szMessage[n], charsmax(szMessage)-n, " Driving Slow")
case TRAIN_MEDIUM:n += formatex(szMessage[n], charsmax(szMessage)-n, " Driving Medium")
case TRAIN_FAST:n += formatex(szMessage[n], charsmax(szMessage)-n, " Driving Fast")
case TRAIN_BACK:n += formatex(szMessage[n], charsmax(szMessage)-n, " Driving BackWards")
}
client_print(id, print_center, szMessage)
}
|