|
发表于 2009-2-7 23:21:43
|
显示全部楼层
来自 中国–广东–广州–白云区
源码.在这里
#include <amxmodx>
#include <fakemeta_util>
#pragma semicolon 1
#define MODEL "models/ladder.mdl"
// ladder dimensions
new Float:gLadderMinY[3] = {-32.0,-4.0,-32.0};
new Float:gLadderMaxY[3] = { 32.0, 4.0, 32.0};
new bool:gOnLadder[33];
public plugin_init() {
register_plugin("Ladder", "1.0", "xPaw");
register_clcmd("say .ladder", "cmdCreateLadder");
register_clcmd("say .removeladder", "cmdDeleteLadder");
register_forward( FM_PlayerPreThink, "fwdPlayerPreThink", 0 );
register_forward( FM_Touch, "fwdTouch" );
}
public plugin_precache()
precache_model( MODEL );
public fwdPlayerPreThink(id) {
if ( is_user_alive(id)) {
if( gOnLadder[id] ) {
new Float:velocity[3];
pev(id, pev_velocity, velocity);
if ( (pev(id, pev_button) & IN_FORWARD) && (velocity[0] == 0.0 || velocity[1] == 0.0) ) {
velocity[2] = 250.0;
set_pev(id, pev_velocity, velocity);
}
gOnLadder[id] = false;
}
new ent, body;
get_user_aiming(id, ent, body, 320);
if (isLadder(ent)) {
set_hudmessage(0, 25, 255, -1.0, -0.90, 0, 1.0, 1.0, 0.2, 0.2, 1);
show_hudmessage(id, "First In-Game Ladder.");
}
}
}
public fwdTouch(ent, id) {
if (is_user_alive(id) && isLadder(ent)) {
set_pev(id, pev_movetype, MOVETYPE_FLY);
gOnLadder[id] = true;
// Velocity way
new Float:velocity[3];
pev(id, pev_velocity, velocity);
if ( (pev(id, pev_button) & IN_FORWARD) && (velocity[0] == 0.0 || velocity[1] == 0.0) ) {
velocity[2] = 250.0;
set_pev(id, pev_velocity, velocity);
}
}
}
public cmdCreateLadder( id ) {
if (get_user_flags(id) & ADMIN_KICK) {
new Float:vOrigin[3];
new origin[3];
//get the origin of the player and add Z offset
get_user_origin(id, origin, 3);
IVecFVec(origin, vOrigin);
vOrigin[2] += 4.0;
createLadder( vOrigin );
client_print(id, print_chat, "* You Spawned Ladder, Have Fun! :-)");
}
}
public cmdDeleteLadder(id) {
if (get_user_flags(id) & ADMIN_KICK) {
new ent, body;
get_user_aiming(id, ent, body);
if (isLadder(ent)) {
fm_remove_entity(ent);
client_print(id, print_chat, "* You Removed Ladder.");
}
}
}
createLadder( Float:vOrigin[3] ) {
new ent = fm_create_entity( "info_target" );
if (fm_is_valid_ent(ent)) {
set_pev(ent, pev_classname, "xpaw_ladder");
set_pev(ent, pev_solid, SOLID_BBOX);
set_pev(ent, pev_movetype, MOVETYPE_NONE);
new Float:vSizeMin[3];
new Float:vSizeMax[3];
new Float:vAngles[3];
vSizeMin = gLadderMinY;
vSizeMax = gLadderMaxY;
vAngles[0] = 90.0;
vAngles[2] = 90.0;
//adjust size min/max vectors depending on scale
for (new i = 0; i < 3; ++i) {
if (vSizeMin[i] != 4.0 && vSizeMin[i] != -4.0)
vSizeMin[i] *= 1.0;
if (vSizeMax[i] != 4.0 && vSizeMax[i] != -4.0)
vSizeMax[i] *= 1.0;
}
fm_entity_set_model(ent, MODEL);
set_pev(ent, pev_angles, vAngles);
fm_entity_set_size(ent, vSizeMin, vSizeMax);
fm_entity_set_origin(ent, vOrigin);
return ent;
}
return 0;
}
bool:isLadder(ent) {
if (fm_is_valid_ent(ent)) {
new szClassname[32];
pev(ent, pev_classname, szClassname, 32);
if (equal(szClassname, "xpaw_ladder"))
return true;
}
return false;
} |
|