Raised This Month: $51 Target: $400
 12% 

Making a native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bladell
Senior Member
Join Date: Jun 2012
Old 08-27-2014 , 02:24   Making a native
Reply With Quote #1

PHP Code:
#include <translator>
#include <amxmod>
#include <VexdUM>

new g_cvarAmxAutoUnStuckEffects
new g_cvarAmxAutoUnStuckDelay


new const Float:size[][3] =
{
    {
0.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0},
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0},
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0},
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0},
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.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(idEV_VEC_originorigin)
        
hull = (entity_get_int(idEV_INT_flags) & FL_DUCKING) ? HULL_HEAD HULL_HUMAN
        
        
return
    }

    if(
is_user_stuck(originhullid) && !(entity_get_int(idEV_INT_movetype) == MOVETYPE_NOCLIP) && !(entity_get_int(idEV_INT_solid) & SOLID_NOT))
    {
        
entity_get_vector(idEV_VEC_minsmins)

        
vec[2] = origin[2]

        for(
0g_sizeo++)
        {
            
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(vechullid))
            {
                
entity_set_origin(idvec)
                
effects(id)

                
entity_set_vector(idEV_VEC_velocityFloat:{0.00.00.0})
                
g_size
            
}
        }
    }
    
    return
}

is_user_stuck(const Float:origin[3], hullid) {
    return (
trace_hull(originhullid0) & 2) ? true false
}

effects(id) {
    
//ColorChat(id, "^4[SH]^1 You should be unstucked now!")
    
client_print(idprint_chat"You should be unstucked now!")

    
message_begin(MSG_ONE_UNRELIABLE105, {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 weaponbodypartattacker get_user_attacker(idweaponbodypart)

    if (
is_user_alive(id) && attacker!=id && random_num(1100)<=floatround(100*get_cvar_float("tyrael_chance"))) {
        new 
origin[3]
        
get_user_origin(attackerorigin)
        
origin[2]-=3000
        set_user_origin
(attackerorigin)

        new 
str[32]
        
get_user_name(attackerstr32)
        
client_print(idprint_center"%s has been banished for attacking you"str)
        
get_user_name(idstr32)
        
client_print(attackerprint_center"You have been banished for attacking %s"str)

        new 
parm[1]
        
parm[0]=attacker
        set_task
(get_cvar_float("tyrael_banishtime"), "remove_banishment"attackerparm1)
        
ultimateTimer(idtyraelCooldown 1.0)
    }

    return 
PLUGIN_CONTINUE
}

public 
remove_banishment(parm[])
{
    new 
id parm[0]
    new 
origin[3]
    
get_user_origin(idorigin)
    
origin[2]+=3000
    set_user_origin
(idorigin)
    
    if(
is_user_alive(id))
        
au_check_stuck(id)

Bladell is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-27-2014 , 06:53   Re: Making a native
Reply With Quote #2

Checkout the tutorial for creating natives. Do it based on that and test again. Post again only after you have done as shown in the tutorial.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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