AlliedModders

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

awpvssniper 06-30-2012 09:44

natives
 
in plugin
PHP Code:

public _get_simon(iPluginiParams

    return 
g_Simon;



include
PHP Code:

native get_simon(); //returns simon ID 


how to use that ?


i want to make that
PHP Code:

public football(id)
{
    static 
model[64]
    
get_user_info(id"model"model63)
    
    
//if get simon
    
return PLUGIN_HANDLED
    


    
static menu
    menu 
menu_create("Меню футбола""mhand")
    
    
menu_additem(menu,"Поделить на команды""1")
    
    
    
menu_additem(menu"Поставить мяч""2")
    
    
menu_additem(menu"Убрать мяч""3")
    
    
menu_display(idmenu)

    return 
PLUGIN_HANDLED
    
    



Liverwiz 06-30-2012 10:17

Re: natives
 
get_simon() should be in a .inc file/include. put at the top of your .sma #include <include> where include is the name of the .inc that that native function is defined in. if that makes sense....

awpvssniper 06-30-2012 11:32

Re: natives
 
i know i need to include

PHP Code:

public football(id)
{
    static 
model[64]
    
get_user_info(id"model"model63)
    
    
//if get simon
    
return PLUGIN_HANDLED
    


    
static menu
    menu 
menu_create("Меню футбола""mhand")
    
    
menu_additem(menu,"Поделить на команды""1")
    
    
    
menu_additem(menu"Поставить мяч""2")
    
    
menu_additem(menu"Убрать мяч""3")
    
    
menu_display(idmenu)

    return 
PLUGIN_HANDLED
    
    


//if get simon - what to type here ?
i want to make that only for player who are simon

Liverwiz 06-30-2012 12:13

Re: natives
 
where is this line defined? The file name...
Code:

native get_simon();
that is what you need to put as #include <filename>

Liverwiz 06-30-2012 12:16

Re: natives
 
or are you looking for this.....

PHP Code:

if(get_simon() == id)    // This is assuming get_simon() returns the player index of 'simon' 


awpvssniper 06-30-2012 13:22

Re: natives
 
Quote:

Originally Posted by Liverwiz (Post 1739771)
or are you looking for this.....

PHP Code:

if(get_simon() == id)    // This is assuming get_simon() returns the player index of 'simon' 


yea looking for that
but don't works server dont want to start
its other function

here is a example with other plugin
PHP Code:


/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <ujbm>

#define PLUGIN "[UJBM] Football"
#define VERSION "1.0"
#define AUTHOR "R_O_O_T"


new Float:ballorigin[3]
new 
Float:g_neta[3]
new 
Float:g_netb[3]
new 
Float:MB[3]
new 
Float:BB[3]

new 
ON 0;
new 
BallOwner 0
new bool:exist true;
new 
bool:remove true;
new 
m_iTrail
new gna
new gnb

new ball[] = "models/jb_ball.mdl"

new BALL_BOUNCE_GROUND[] = "kickball/bounce.wav"
new BALL_KICKED[][] = { "weapons/xbow_hitbod1.wav""weapons/xbow_hitbod2.wav" }
new 
SCORED_GOAL[] = "kickball/goal.wav"

public plugin_precache()
{
    
m_iTrail precache_model("sprites/smoke.spr")
}

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_dictionary("ujbm.txt")
    
register_concmd("jb_football""football_on"ADMIN_KICK)
    
register_concmd("jb_spawnball""create"ADMIN_KICK)
    
    
register_logevent("football_off"2"0=World triggered""1&Restart_Round_")
    
register_logevent("football_off"2"0=World triggered""1=Game_Commencing")
    
register_logevent("football_off"2"0=World triggered""1=Round_Start")
    
RegisterHam(Ham_Killed"player""player_killed"1)
    
    
    new 
Copyright[10] = AUTHOR;
    new 
cfg[255]
    new 
mapname[64]
    
get_mapname(mapname,63)
    
get_configsdir(cfg,255)
    
strcat(cfg,"/football/",255)
    
strcat(cfg,mapname,255)
    if (
file_exists(cfg))
    {
        new 
len 255;
        new 
text[255]
        new 
x[8],y[8],z[8];new r;
        
        
        if (!
read_file(cfg,0,text,63,len)) 
            
exist false;
        else
        {
            
parse(text,r7x,7y,7z,7)
            
ballorigin[0] = str_to_float(x);ballorigin[1] = str_to_float(y);ballorigin[2] = str_to_float(z);        
            if (
== 'R'remove true; else remove false;
            }
////BALL ORIGIN
            
            
            
        
if (!read_file(cfg,1,text,63,len)) exist false;
            else
            {
                
parse(textx,7y,7z,7)
                
g_neta[0] = str_to_float(x);g_neta[1] = str_to_float(y);g_neta[2] = str_to_float(z);        
                }
////GOALNET A
                
                
        
if (!read_file(cfg,2,text,63,len)) exist false;
                else
                {
                    
parse(textx,7y,7z,7)
                    
g_netb[0] = str_to_float(x);g_netb[1] = str_to_float(y);g_netb[2] = str_to_float(z);        
                    }
/// GOALNET B
                    
                    
        
if (!read_file(cfg,3,text,63,len)) exist false;
                    else
                    {
                        
parse(textx,7y,7z,7)
                        
MB[0] = str_to_float(x);MB[1] = str_to_float(y);MB[2] = str_to_float(z);        
                        }
/// minbox
                        
                        
        
if (!read_file(cfg,4,text,63,len)) 
                            
exist false;
                        else
                        {
                            
parse(textx,7y,7z,7)
                            
BB[0] = str_to_float(x);BB[1] = str_to_float(y);BB[2] = str_to_float(z);        
                            }
/// maxbox
                            
                            
                            
} else exist false;
                        
                        
                        
                        
///kids protection

                        ///kids protection
                        
    
engfuncEngFunc_PrecacheModelball)
    
engfuncEngFunc_PrecacheSoundBALL_KICKED[0])
    
engfuncEngFunc_PrecacheSoundBALL_KICKED[1])
    
engfuncEngFunc_PrecacheSoundBALL_BOUNCE_GROUND)
    
engfuncEngFunc_PrecacheSoundSCORED_GOAL)
    
engfuncEngFunc_PrecacheModel"models/chick.mdl")
    if (
Copyright[6] != 'T' || Copyright[2] != 'O' || Copyright[0] != 'R' ||  Copyright[4] != 'O' )
        return 
PLUGIN_HANDLED                
                        
                        
    register_touch
("PwnBall""player""ball_touch")
    
register_touch("PwnBall""*",            "touchWorld")
    
register_touch("PwnBall""goalnet_a",        "touch_goalnet_a")
    
register_touch("PwnBall""goalnet_b",        "touch_goalnet_b")
                        
                        
                        
                        
    if(
exist)
    {
        
log_amx("starting football...")
    
        if (
removedestroy;
        
create(0)
        
Make_GoalNets()
    }
    return 
PLUGIN_CONTINUE
                    
}
                    

public 
destroy()
    
{
new 
ent


//    while((
ent find_ent_in_sphere(-1,ballorigin30.0)
//!= 0)
//{
if (is_valid_ent(ent)) remove_entity(ent)
//}


}
new 
aball
public create(id)

{
if (!
cmd_access(id,ADMIN_IMMUNITY,0,0)) return PLUGIN_HANDLED

if (aballremove_entity(aball)
new 
entity create_entity("info_target")
if (
entity) {
    
    
entity_set_string(entity,EV_SZ_classname,"PwnBall")
    
entity_set_model(entityball)
    
    
entity_set_int(entityEV_INT_solidSOLID_BBOX)
    
entity_set_int(entityEV_INT_movetypeMOVETYPE_BOUNCE)
    
    new 
Float:MinBox[3]
    new 
Float:MaxBox[3]
    
MinBox[0] = -10.0
    MinBox
[1] = -10.0
    MinBox
[2] = 0.0
    MaxBox
[0] = 10.0
    MaxBox
[1] = 10.0
    MaxBox
[2] = 96.0
    
    entity_set_vector
(entityEV_VEC_minsMinBox)
    
entity_set_vector(entityEV_VEC_maxsMaxBox)
    
    
//        glow(entity,ballcolor[0],ballcolor[1],ballcolor[2],10)
    
    
entity_set_float(entity,EV_FL_framerate,0.0)
    
entity_set_int(entity,EV_INT_sequence,1)
}
//save our entity ID to aball variable
if(exist)
{
    
entity_set_origin(entity,ballorigin)
    
set_pev(gnapev_effectsEF_NODRAW)
    
set_pev(gnbpev_effectsEF_NODRAW)
    
}
else
{
    new 
simon get_simon()
    if (
is_user_alive(simon))
    {
        
BallOwner simon
    
}
    
    
}

aball entity
RegisterHamFromEntity
(Ham_Think,entity,"ball_think")
set_pev(entitypev_nextthinkget_gametime()+0.03);



//glow(entity,200,1,1,1)



//entity_set_float(entity,EV_FL_nextthink,halflife_time() + 0.1)
return PLUGIN_HANDLED



}
/*
public velocity_by_aim2(id, )

vReturn[0] = floatcos( vAngles[1], degrees ) * fDistance 
vReturn[1] = floatsin( vAngles[1], degrees ) * fDistance 
vReturn[2] = floatsin( -vAngles[0], degrees ) * fDistance 

*/

public ball_touch(entityid)
{
    
        if (!
is_user_alive(id) || !is_valid_ent(entity)) return PLUGIN_CONTINUE

        
new button entity_get_int(idEV_INT_button)
        new 
usekey = (button IN_USE)
        if (
usekey
        {
            
//set_pev(aball, pev_nextthink, get_gametime()+0.03)
            
BallOwner id;
            
            
entity_set_float(entity,EV_FL_framerate,1.0)
            
            
            
            
message_beginMSG_BROADCASTSVC_TEMPENTITY )
            
write_byteTE_BEAMFOLLOW )
            
write_short(entity// entity
            
write_short(m_iTrail)  // model
            
write_byte)       // lifeffffff
            
write_byte)        // width
            
            
write_byterandom_num (10254))      // r, g, b
            
write_byte105 )    // r, g, b
            
write_byte180 )      // r, g, b
            
write_byte106 )     // brightness
            
message_end()
            
            return 
PLUGIN_CONTINUE
        

        if (
BallOwner <= 0
        {
            new 
Float:velocity[3]
            if (
get_speed(entity) < 300.0)
            {
                
                
velocity_by_aim(idrandom_num(200500), velocity)
                
entity_set_vector(entity,EV_VEC_velocity,velocity)
                
entity_set_float(entity,EV_FL_framerate,0.6)
            }
        }
        return 
PLUGIN_CONTINUE    
    
}
    new 
button
    
new button_use
    
new button_forward
    
public ball_think(ent
    {
        
entity_set_float(entEV_FL_nextthinkget_gametime() + 0.02
        if(!
is_valid_ent(ent) || BallOwner <= 0)
            return 
PLUGIN_CONTINUE 
        
        
if (is_user_alive(BallOwner))
        {
            
//if get_speed(BallOwner > 200.0) entity_set_float(ent,EV_FL_framerate,1.0)
            //set_pev(ent, pev_nextthink, get_gametime()+0.03);
            
button entity_get_int(BallOwnerEV_INT_button)
            
button_use = (button IN_USE)
            
button_forward = (button IN_FORWARD)
            if (!
button_use)
            {            
                
                
emit_sound(BallOwnerCHAN_WEAPONBALL_KICKED[random_num(0,1)], 1.0ATTN_NORM0PITCH_NORM)
                
                
                new 
Float:velocity[3]
                
                
entity_get_vector(ent,EV_VEC_origin,velocity)
                
velocity[2] += 13.0
                entity_set_vector
(ent,EV_VEC_origin,velocity)
                
//
                
                
if (button_forward)
                    
velocity_by_aim(BallOwnerrandom_num(10001200), velocity)
                else
                    
velocity_by_aim(BallOwnerrandom_num(8001000), velocity)
                
                if (
velocity[2] < 30.0velocity[2] = 100.0// for better aiming
                //client_print(0,print_chat, "%f %f %f",velocity[0],velocity[1],velocity[2])
                
entity_set_vector(ent,EV_VEC_velocity,velocity)
                
                
BallOwner 0
                
                entity_set_float
(ent,EV_FL_framerate,1.0)
                return 
PLUGIN_CONTINUE
                
                
//entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.1) 
            
}
            
            if (
button_forward)
                
ball_infront(BallOwner75.0)
            else
                
ball_infront(BallOwner45.0)
        }
        
        return 
PLUGIN_CONTINUE
        
    
}
    
    
    public 
ball_infront(idFloat:dist) {
        
        new 
Float:nOrigin[3]
        new 
Float:vAngles[3// plug in the view angles of the entity
        
new Float:vReturn[3// to get out an origin fDistance away
        
new Float:testorigin[3]
        
        
entity_get_vector(aball,EV_VEC_origin,testorigin)
        
entity_get_vector(id,EV_VEC_origin,nOrigin)
        
entity_get_vector(id,EV_VEC_v_angle,vAngles)
        
        
        
vReturn[0] = floatcosvAngles[1], degrees ) * dist
        vReturn
[1] = floatsinvAngles[1], degrees ) * dist
        
        vReturn
[0] += nOrigin[0]
        
vReturn[1] += nOrigin[1]
        
        
testorigin[0] = vReturn[0]
        
testorigin[1] = vReturn[1]
        
testorigin[2] = nOrigin[2]
        new 
flags entity_get_int(idEV_INT_flags)
        if(
flags FL_DUCKING)
            
testorigin[2] -= 5.0
        
else
            
testorigin[2] -= 28.0
        
        
        entity_set_vector
(aball,EV_VEC_velocity,Float:{ 0.010.010.01 } )
        
entity_set_origin(aball,testorigin)
        
        
/*
        //Sets the angle to face the same as the player.
        new Float:ang[3]
        entity_get_vector(id,EV_VEC_angles,ang)
        ang[0] = 0.0
        ang[1] -= 90.0
        ang[2] = 0.0
        entity_set_vector(aball,EV_VEC_angles,ang)
        */
    
}
    
    
    
    public 
touchWorld(ballworld) {
        if (
world == aball || is_user_connected(world)) 
            return 
PLUGIN_CONTINUE
        
if (exist && (world == gna || world == gnb))
        
//// I don't check with a classname because of perfomance
            
return PLUGIN_CONTINUE
        
new Float:v[3]
        
entity_get_vector(ballEV_VEC_velocityv)
        if (
vector_length(v) > 8.0)
        {
            
v[0] = (v[0] * 0.85)
            
v[1] = (v[1] * 0.85)
            
v[2] = (v[2] * 0.85)
            
entity_set_vector(ballEV_VEC_velocityv)
        }
        if(
v[2] < -150.0)
        {
            
emit_sound(ballCHAN_ITEMBALL_BOUNCE_GROUND1.0ATTN_NORM0PITCH_NORM)
        }
        if(
vector_length(v) < 45.0)
        {
            
entity_set_float(ball,EV_FL_framerate,0.0)
            
        }
        
        else
            
        if(
vector_length(v) < 100.0)
        {
            
entity_set_float(ball,EV_FL_framerate,0.7)
        }
        
        
//    client_print(0,print_console, "%f",vector_length(v))
        
        
return PLUGIN_HANDLED
    
}
    
    
    
    
    
    
    
    public 
Make_GoalNets()
        
{
    
gna create_entity("info_target")
    
    if (
gna) {
        
entity_set_string(gna,EV_SZ_classname,"goalnet_a")
        
entity_set_model(gna"models/chick.mdl")
        
entity_set_int(gnaEV_INT_solidSOLID_BBOX)
        
entity_set_int(gnaEV_INT_movetypeMOVETYPE_NONE)
        
        
        
        
entity_set_vector(gnaEV_VEC_minsMB)
        
entity_set_vector(gnaEV_VEC_maxsBB)        
        
set_entity_visibility(gna0)
        
entity_set_origin(gna,g_neta)
        
//glow(gn,234,1,1,1)
        
    
}
    
    
gnb create_entity("info_target")
    
    if (
gnb) {
        
entity_set_string(gnb,EV_SZ_classname,"goalnet_b")
        
entity_set_model(gnb"models/chick.mdl")
        
entity_set_int(gnbEV_INT_solidSOLID_BBOX)
        
entity_set_int(gnbEV_INT_movetypeMOVETYPE_NONE)
        
        
        
entity_set_vector(gnbEV_VEC_minsMB)
        
entity_set_vector(gnbEV_VEC_maxsBB)        
        
set_entity_visibility(gnb0)
        
entity_set_origin(gnb,g_netb)
        
//glow(gn,234,1,1,1)
    
}
    
}


stock fm_set_rendering(entityfx kRenderFxNone255255255render kRenderNormalamount 16
{
    static 
Float:color[3]; color[2] = float(b), color[0] = float(r), color[1] = float(g)
    
    
set_pev(entitypev_renderfxfx)
    
set_pev(entitypev_rendercolorcolor)
    
set_pev(entitypev_rendermode,  render)
    
set_pev(entitypev_renderamt,   float(amount))
    
    return 
1
}


public 
touch_goalnet_a(ballworld)
{
    if (
ON != 1)return PLUGIN_CONTINUE
    emit_sound
(ballCHAN_ITEMSCORED_GOAL1.0ATTN_NORM0PITCH_NORM)
    
set_hudmessage(0255255, -1.0, -1.006.06.0)
    
show_hudmessage(0"%L"LANG_SERVER"UJBM_FOOTBALL_A")
    
set_pev(worldpev_effectsEF_BRIGHTLIGHT)
    
fm_set_rendering(worldkRenderFxGlowShell150150250kRenderTransAlpha0)
    
remove_entity(ball)
    
set_task(3.0"create")
    return 
PLUGIN_CONTINUE    
}

public 
touch_goalnet_b(ballworld)
{
    if (
ON != 1)return PLUGIN_CONTINUE    
    emit_sound
(ballCHAN_ITEMSCORED_GOAL1.0ATTN_NORM0PITCH_NORM)
    
set_hudmessage(0255255, -1.0, -1.006.06.0)
    
show_hudmessage(0"%L"LANG_SERVER"UJBM_FOOTBALL_A")
    
set_pev(worldpev_effectsEF_BRIGHTLIGHT)
    
fm_set_rendering(worldkRenderFxGlowShell150150250kRenderTransAlpha0)
    
remove_entity(ball)
    
set_task(3.0"create")
    
    return 
PLUGIN_CONTINUE    
}





public 
football_on()
    
{
    if (!
ONON 1; else football_off()
    
set_hudmessage(422550, -1.00.4006.04.0)
    
show_hudmessage(0"%L"LANG_SERVER"UJBM_FOOTBALL")
    
    return 
PLUGIN_CONTINUE    
}

public 
football_off()
    
{
    
ON 0;    
    
BallOwner 0;
    
remove_entity(aball)
    if (
existcreate(0)
    return 
PLUGIN_CONTINUE    
}


public 
player_killed(victimattackershouldgib)
{
    if (
victim == BallOwner)    BallOwner 0
}



/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/ 


awpvssniper 07-01-2012 12:51

Re: natives
 
I download a plugin that use native, people says that plugin works at them... why it don't works for me ?
that is plugin http://rghost.ru/38975859 I use UJBM and that plugin JbReasons 2.4 by Devil Mikki
and it says
( 5) Load fails: Module/Library "AutoFreeday" required for plugin. Check modules.

I use amxx 1.8.2 and all modules are on , plugin jbreasons it's on, but UJBM dont work of error
( 5) Load fails: Module/Library "AutoFreeday" required for plugin. Check modules.


All times are GMT -4. The time now is 15:16.

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