Senior Member
|
08-27-2014
, 02:24
Making a native
|
#1
|
PHP Code:
#include <translator>
#include <amxmod>
#include <VexdUM>
new g_cvarAmxAutoUnStuckEffects
new g_cvarAmxAutoUnStuckDelay
new const Float:size[][3] =
{
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}
const g_size = sizeof(size)
public plugin_init()
{
register_plugin(_T("Automatic Unstuck"), "1.6", "NL)Ramon(NL")
g_cvarAmxAutoUnStuckEffects = register_cvar("amx_autounstuck_effects", "1")
g_cvarAmxAutoUnStuckDelay = register_cvar("amx_autounstuck_delay", "8")
//set_task(1.0, "checkstuck", 0, "", 0, "b")
}
public plugin_natives()
{
register_library("Automatic Unstuck Natives")
register_native("au_check_stuck", "_au_check_stuck")
}
public _au_check_stuck(id)
{
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o
if(is_user_alive(id))
{
entity_get_vector(id, EV_VEC_origin, origin)
hull = (entity_get_int(id, EV_INT_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
return
}
if(is_user_stuck(origin, hull, id) && !(entity_get_int(id, EV_INT_movetype) == MOVETYPE_NOCLIP) && !(entity_get_int(id, EV_INT_solid) & SOLID_NOT))
{
entity_get_vector(id, EV_VEC_mins, mins)
vec[2] = origin[2]
for(o = 0; o < g_size; o++)
{
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if(!is_user_stuck(vec, hull, id))
{
entity_set_origin(id, vec)
effects(id)
entity_set_vector(id, EV_VEC_velocity, Float:{0.0, 0.0, 0.0})
o = g_size
}
}
}
return
}
is_user_stuck(const Float:origin[3], hull, id) {
return (trace_hull(origin, hull, id, 0) & 2) ? true : false
}
effects(id) {
//ColorChat(id, "^4[SH]^1 You should be unstucked now!")
client_print(id, print_chat, "You should be unstucked now!")
message_begin(MSG_ONE_UNRELIABLE, 105, {0,0,0}, id)
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id, "spk fvox/blip.wav")
}
This plugin was made to auto unstuck players. I tried to use function "checkstuck" as a native, so I renamed it to "_au_check_stuck". The problem is that I'm getting this errors:
Code:
L 08/22/2014 - 15:03:27: Invalid player id 134
L 08/22/2014 - 15:03:27: [AMXX] Displaying debug trace (plugin "automatic_unstuck.amxx")
L 08/22/2014 - 15:03:27: [AMXX] Run time error 10: native error (native "client_print")
L 08/22/2014 - 15:03:27: [AMXX] [0] automatic_unstuck.sma::effects (line 82)
L 08/22/2014 - 15:03:27: [AMXX] [1] automatic_unstuck.sma::_au_check_stuck (line 65)
L 08/22/2014 - 15:03:27: Unhandled dynamic native error
L 08/22/2014 - 15:03:27: [AMXX] Displaying debug trace (plugin "sh_tyrael.amxx")
L 08/22/2014 - 15:03:27: [AMXX] Run time error 10: native error (native "au_check_stuck")
L 08/22/2014 - 15:03:27: [AMXX] [0] sh_tyrael.sma::remove_banishment (line 103)
PHP Code:
//Tyrael - by Mydas
/*
tyrael_level 4
tyrael_chance 0.15 - chance to Banish an opponent
tyrael_banishtime 3 - amount of time the banishment lasts
tyrael_cooldown 6 - how long till he can banish someone again
*/
#include <amxmod>
#include <superheromod>
#include <aunat>
// VARIABLES
new gHeroName[]="Tyrael"
new bool:gHasTyraelPowers[SH_MAXSLOTS + 1]
new tyraelCooldown
new bool:gRoundEnd
public plugin_init()
{
register_plugin("SUPERHERO Tyrael", "1.0", "Mydas")
register_cvar("tyrael_level", "4" )
shCreateHero(gHeroName, "Banish", "Temporarily teleports your attackers to the netherworld", false, "tyrael_level" )
register_srvcmd("tyrael_init", "tyrael_init")
shRegHeroInit(gHeroName, "tyrael_init")
register_event("ResetHUD","newRound","b")
register_event("Damage", "tyrael_damage", "b", "2!0")
// ROUND END
register_logevent("round_end", 2, "1=Round_End")
register_logevent("round_end", 2, "1&Restart_Round_")
register_cvar("tyrael_chance", "0.15")
register_cvar("tyrael_banishtime", "3")
register_cvar("tyrael_cooldown", "6")
}
public round_end()
{
gRoundEnd = true
}
public tyrael_init()
{
new temp[6]
read_argv(1,temp,5)
new id=str_to_num(temp)
read_argv(2,temp,5)
new hasPowers=str_to_num(temp)
gHasTyraelPowers[id] = (hasPowers!=0)
tyraelCooldown=get_cvar_num("tyrael_cooldown")
}
public newRound(id)
{
gPlayerUltimateUsed[id]=false
gRoundEnd = false
}
public tyrael_damage(id)
{
if (!gHasTyraelPowers[id] || gPlayerUltimateUsed[id] || gRoundEnd) return PLUGIN_CONTINUE
//new damage = read_data(2)
new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
if (is_user_alive(id) && attacker!=id && random_num(1, 100)<=floatround(100*get_cvar_float("tyrael_chance"))) {
new origin[3]
get_user_origin(attacker, origin)
origin[2]-=3000
set_user_origin(attacker, origin)
new str[32]
get_user_name(attacker, str, 32)
client_print(id, print_center, "%s has been banished for attacking you", str)
get_user_name(id, str, 32)
client_print(attacker, print_center, "You have been banished for attacking %s", str)
new parm[1]
parm[0]=attacker
set_task(get_cvar_float("tyrael_banishtime"), "remove_banishment", attacker, parm, 1)
ultimateTimer(id, tyraelCooldown * 1.0)
}
return PLUGIN_CONTINUE
}
public remove_banishment(parm[])
{
new id = parm[0]
new origin[3]
get_user_origin(id, origin)
origin[2]+=3000
set_user_origin(id, origin)
if(is_user_alive(id))
au_check_stuck(id)
}
|
|