AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help]Weapon (https://forums.alliedmods.net/showthread.php?t=243418)

iTwEkY 07-04-2014 05:45

[Help]Weapon
 
Hi, I'm new and I need a tutorial how to make a plugin from a gun Furien server ..
In short: I want to make a weapon of Leon Dias is the classic zombie in one please help me with this problem, Thanks

My language is Romanian.:wink:

EDIT: Give me a tutorial , please.

Thank You .

HamletEagle 07-04-2014 08:06

Re: [Help]Weapon
 
You want to know how to create a cso weapon ?

Porta0123 07-04-2014 09:35

Re: [Help]Weapon
 
https://forums.alliedmods.net/showthread.php?t=197854 | this post is in spanish... you can use the translator or something else...

https://forums.alliedmods.net/showth...78286?p=178286 | and here in english but its a plugin , you can get the source and try to change it

iTwEkY 07-04-2014 13:37

Re: [Help]Weapon
 
Quote:

Originally Posted by HamletEagle (Post 2161791)
You want to know how to create a cso weapon ?

No, I Furien server and the gun is for zombie plague and want to do server Furien author weapon is Leon Dias

JokerQH 07-04-2014 15:52

Re: [Help]Weapon
 
Guys let me explain what this guy want.He want a tutorial to transform a zombie mode weapon of dias in a normal mode weapon.
@iTwEkY :To transform a ZP weapon in a normal one is quite difficult good luck

HamletEagle 07-05-2014 05:18

Re: [Help]Weapon
 
Quote:

Originally Posted by JokerQH (Post 2162000)
Guys let me explain what this guy want.He want a tutorial to transform a zombie mode weapon of dias in a normal mode weapon.
@iTwEkY :To transform a ZP weapon in a normal one is quite difficult good luck

You are wrong, it's very easy. Please post here plugins sources and we will convert them for you.

iTwEkY 07-05-2014 07:58

Re: [Help]Weapon
 
Quote:

Originally Posted by HamletEagle (Post 2162242)
You are wrong, it's very easy. Please post here plugins sources and we will convert them for you.

Code:

#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <engine>
#include <hamsandwich>

new g_k1ase[33]
new g_k1ases_loaded[33]
new g_ammo[33]
new g_lastweap[33]
new g_tmp
new g_hegren
/// new MaxPlayers

new cvar_crazynade,cvar_knockback,cvar_trail,cvar_radius,cvar_damage,cvar_bonus,cvar_reload,cvar_remove

new gmsgDeathMsg
new gMsgID

new m_iTrail;
new xplode;


#define ICON_HIDE 0
#define ICON_SHOW 1
#define COST 2   
#define TMPCOST 10
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))

public plugin_init() {
  register_plugin("[ZP] Extra Item : K1ASES","0.1","AMDEM")

 
//  register_logevent("RoundEnd",2,"1=Round_End")
  register_event("DeathMsg","player_die","abd") 
  register_event("CurWeapon","handle_gun","be","1=1")
  RegisterHam(Ham_Killed, "player", "player_die")
  RegisterHam(Ham_Spawn, "player", "player_spawn")
 
 
  register_forward(FM_CmdStart, "forward_CmdStart")
  register_forward(FM_SetModel, "forward_setmodel")
 
  register_dictionary("k1ases.txt")
 
  cvar_crazynade = register_cvar("zp_tmpk1ases_crazynade","0") //Выстреливать с силой гранату?
  cvar_knockback = register_cvar("zp_tmpk1ases_conc","10.0")//Сила отдачи при выстреле?
  cvar_trail    = register_cvar("zp_tmpk1ases_trail","1")  //Включить цветовую полусу за гранатой?
  cvar_radius        = register_cvar("zp_tmpk1ases_rad","50")  //Радиус Повреждения?
  cvar_damage        = register_cvar("zp_tmpk1ases_dmg","5000")  //Урон от гранаты
  cvar_bonus          = register_cvar("zp_tmpk1ases_bonus","6")  //Сколько дасться АММО за убийство с гранаты?
  cvar_reload    = register_cvar("zp_tmpk1ases_reloadtime","0.5") //Время между выстрелами?
  cvar_remove    = register_cvar("zp_tmpk1ases_remove","0") // Убирать эффект оружия на след раунд?
 
  g_tmp = zp_register_extra_item("K1ASES",TMPCOST,ZP_TEAM_HUMAN)
  g_hegren = zp_register_extra_item("Гранаты для K1ASES",COST, ZP_TEAM_HUMAN)
  gmsgDeathMsg = get_user_msgid("DeathMsg")
  gMsgID = get_user_msgid("StatusIcon")
       
}
public plugin_precache()         
{
  precache_model("models/k1ases/v_k1ases.mdl")
  precache_model("models/k1ases/p_k1ases.mdl")
  precache_model("models/k1ases/w_k1ases.mdl")
  precache_model("models/k1ases/grenade.mdl")
  precache_sound("k1ases/k1ases_lg_exp.wav")
  precache_sound("k1ases/k1ases_lg_fire.wav")

  m_iTrail = precache_model("sprites/k1ases/k1ases.spr")
  xplode = precache_model("sprites/k1ases/k1ases_explode.spr")
}


public zp_user_infected_post(id) 
{       
  if(g_k1ase[id])
  client_print(id,print_chat,"[ZP] Вы должны купить Гранатомет K1ASES снова.")
  ammo_hud(id,0)
  g_k1ase[id] = 0
  g_ammo[id] = 0
}

public client_connect(id)     
{
  g_k1ase[id] = 0
  g_k1ases_loaded[id] = 1
  g_ammo[id] = 0   
}


public player_die(id)       
{
  if(g_k1ase[id])
  ammo_hud(id,0)
  g_ammo[id] = 0
  g_k1ase[id] = 0
  client_print(id,print_chat,"[ZP] Смерть...")
  return PLUGIN_CONTINUE
}


public player_spawn(id) 
{
            if ( get_pcvar_num(cvar_remove) == 1 &&  g_k1ase[id] )
            {
                      ammo_hud(id,0)
                      g_k1ase[id] = 0
                      g_ammo[id] = 0
            }
                 
}

public zp_extra_item_selected(player, itemid)
{
    if (itemid == g_hegren)
    {
        if(!g_k1ase[player])
        {
            client_print(player, print_chat, "[ZP] Сначала нужно купить гранатомёт K1ASES")
            zp_set_user_ammo_packs(player, zp_get_user_ammo_packs(player)+ COST )
           
            return;
        }
       
        ammo_hud(player,0);
        g_ammo[player] += 8
        client_print(player, print_chat, "[ZP] Вы купили 8 гранат.")
        ammo_hud(player,1);
    }
   
    if(itemid == g_tmp)
    {   
        if(g_k1ase[player] && user_has_weapon(player, CSW_TMP))
        {
        client_print(player, print_chat, "[ZP] У Вас уже есть гранатомёт K1ASES.")
        zp_set_user_ammo_packs(player, zp_get_user_ammo_packs(player)+ TMPCOST )

        return;
        }
        fm_give_item(player,"weapon_tmp")
        fm_give_item(player,"ammo_9mm")
        fm_give_item(player,"ammo_9mm")
        fm_give_item(player,"ammo_9mm")
        fm_give_item(player,"ammo_9mm")
        client_print(player, print_chat,"[ZP]  Вы купили гранатомёт K1ASES.")
        client_print(player, print_chat,"[ZP] Можно покупать гранаты только если они закончились.")
        g_k1ase[player] = true
        g_ammo[player] = 8
        ammo_hud(player,1)
    }
   



public forward_setmodel(entity, model[])
{
  if (!is_valid_ent(entity))
  {
    return FMRES_IGNORED
  }

  if (equal(model, "models/w_tmp.mdl"))
  {
    new classname[11]
    entity_get_string(entity, EV_SZ_classname, classname, 10)
 
    //client_print(0, print_chat, "Model: %s Classname: %s", model, classname)

    if (equal(classname, "weaponbox"))
    {
      //client_print(0, print_chat, "Setting model")

      entity_set_model(entity, "models/k1ases/w_k1ases.mdl")

      return FMRES_SUPERCEDE
    }
  }

  return FMRES_IGNORED
}

public forward_CmdStart(id, uc_handle, seed)
{
  if(is_user_alive(id) && !zp_get_user_zombie(id) && get_user_weapon(id) == CSW_TMP)
  {
    if (entity_get_int(id, EV_INT_button) & IN_ATTACK2)
    {
      launch_nade(id)
      return FMRES_IGNORED
    }
  }
  return FMRES_IGNORED
}


public handle_gun(id)
{
  new clip, ammo
  new weap = get_user_weapon(id,clip,ammo)

  if(weap == CSW_TMP && g_lastweap[id] != weap && g_k1ase[id] )
  {
    ammo_hud(id,1)
    //client_print(id, print_chat, "Setting Model")
    entity_set_string(id, EV_SZ_viewmodel, "models/k1ases/v_k1ases.mdl")
    entity_set_string(id, EV_SZ_weaponmodel, "models/k1ases/p_k1ases.mdl")
  }
  else if(!g_k1ase[id] || weap != CSW_TMP )
  {
    ammo_hud(id,0)
  }
  g_lastweap[id] = weap

  return PLUGIN_HANDLED
}

public launch_nade(id)
{
  if(g_k1ase[id] == 0 || g_k1ases_loaded[id] == 0 || !(is_user_alive(id)))
    return PLUGIN_CONTINUE

  if(g_ammo[id] == 0)
  {
    client_print(id, print_center, "[ZP] У Вас закончились гранаты")
    return PLUGIN_CONTINUE
  }

  entity_set_int(id, EV_INT_weaponanim, 3)

  new Float: Origin[3], Float: Velocity[3], Float: vAngle[3], Ent

  entity_get_vector(id, EV_VEC_origin , Origin)
  entity_get_vector(id, EV_VEC_v_angle, vAngle)

  //client_print(id, print_center, "Origin: %f-%f-%f", Origin[0], Origin[1], Origin[2])
  //client_print(id, print_center, "vAngle: %f-%f-%f", vAngle[0], vAngle[1], vAngle[2])

  Origin[2] = Origin[2] + 10

  Ent = create_entity("info_target")

  if (!Ent) return PLUGIN_HANDLED

  entity_set_string(Ent, EV_SZ_classname, "k1ases_nade")
  entity_set_model(Ent, "models/k1ases/grenade.mdl")

  new Float:MinBox[3] = {-1.0, -1.0, -1.0}
  new Float:MaxBox[3] = {1.0, 1.0, 1.0}
  entity_set_vector(Ent, EV_VEC_mins, MinBox)
  entity_set_vector(Ent, EV_VEC_maxs, MaxBox)

  entity_set_origin(Ent, Origin)
  entity_set_vector(Ent, EV_VEC_angles, vAngle)

  entity_set_int(Ent, EV_INT_effects, 2)
  entity_set_int(Ent, EV_INT_solid, 1)
  entity_set_int(Ent, EV_INT_movetype, 10)
  entity_set_edict(Ent, EV_ENT_owner, id)

  VelocityByAim(id, 2500 , Velocity)
  entity_set_vector(Ent, EV_VEC_velocity ,Velocity)
       
  emit_sound(id,CHAN_VOICE,"k1ases/k1ases_lg_fire.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)

  g_k1ases_loaded[id] = 0

  ammo_hud(id,0)
  g_ammo[id]--
  ammo_hud(id,1)

  new parm[1]
  parm[0] = Ent

  if(get_pcvar_num(cvar_trail))
    set_task(0.2, "grentrail",id,parm,1)
 
  parm[0] = id
 
  set_task(get_pcvar_float(cvar_reload), "k1ases_reload",id+9910,parm,1)

  return PLUGIN_CONTINUE
}

public k1ases_reload(parm[])

  g_k1ases_loaded[parm[0]] = 1
}

public vexd_pfntouch(pToucher, pTouched)
{
  new szClassName[32]

  if ( pToucher > 0)
  {
    entity_get_string(pToucher, EV_SZ_classname, szClassName, 31)
  }
  if(equal(szClassName, "k1ases_nade"))
  {
    if(!pTouched && get_pcvar_num(cvar_crazynade))
      return

    new damradius = get_pcvar_num(cvar_radius)
    new maxdamage = get_pcvar_num(cvar_damage)
   
    new tkill = 0
    new Float:fl_vExplodeAt[3]
    entity_get_vector(pToucher, EV_VEC_origin, fl_vExplodeAt)
    new vExplodeAt[3]
    vExplodeAt[0] = floatround(fl_vExplodeAt[0])
    vExplodeAt[1] = floatround(fl_vExplodeAt[1])
    vExplodeAt[2] = floatround(fl_vExplodeAt[2])
    new oid = entity_get_edict(pToucher, EV_ENT_owner)
    new origin[3],dist,i,Float:dRatio,damage

    for ( i = 0; i < 32; i++)
    {
      if((is_user_alive(i)))
      {
        get_user_origin(i,origin)
        dist = get_distance(origin,vExplodeAt)
        if (dist <= damradius)
        {         
          dRatio = floatdiv(float(dist),float(damradius))
          damage = maxdamage - floatround(floatmul(float(maxdamage),dRatio))

          set_velocity_from_origin(i, fl_vExplodeAt, get_pcvar_float(cvar_knockback)*damage)
 
          if(cvar_exists("mp_friendlyfire"))
          {
            if(i == oid)
              do_victim(i, oid, damage, 2)
            else if( get_cvar_num("mp_friendlyfire"))
            {
              if(get_user_team(i) == get_user_team(oid)) tkill = 1
              do_victim(i,oid,damage,tkill)
            }
            else
            {
              if(get_user_team(i) != get_user_team(oid))
              {
                do_victim(i,oid,damage,0)
              }                                         
            }
          }
          else if(i == oid)
            do_victim(i, oid, damage, 2)
          else
              do_victim(i,oid,damage,0)         
        }
      }
    }

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(17)
    write_coord(vExplodeAt[0])
    write_coord(vExplodeAt[1])
    write_coord(vExplodeAt[2] + 60)
    write_short(xplode)
    write_byte(20)
    write_byte(200)
    message_end()

    emit_sound(pToucher, CHAN_WEAPON, "k1ases/k1ases_lg_exp.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
   
    remove_entity(pToucher)
  }
}

do_victim(victim,attacker,damage,tk)
{
  new namek[32],namev[32],authida[35],authidv[35],teama[32],teamv[32]
  get_user_name(victim,namev,31)
  get_user_name(attacker,namek,31)
  get_user_authid(victim,authidv,34)
  get_user_authid(attacker,authida,34)
  get_user_team(victim,teamv,31)
  get_user_team(attacker,teama,31)

  new Float:fl_dmg = float(damage)

  if(damage >= get_user_health(victim))
  {
    set_msg_block(gmsgDeathMsg,BLOCK_SET)
    fakedamage(victim, "grenade", fl_dmg, DMG_BLAST) 
    set_msg_block(gmsgDeathMsg,BLOCK_NOT)

    if(is_user_alive(victim))
      return

    message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0)
    write_byte(attacker)
    write_byte(victim)
    write_byte(0)
    write_string("grenade")
    message_end()
    if(tk == 1)   
    {
      client_print(attacker,print_center, "Вы убили своего.")
      log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"grenade^"",
                                namek,get_user_userid(attacker),authida,teama,namev,get_user_userid(victim),authidv,teamv)
    }
    else if(tk == 2)
    {
      log_message("^"%s<%d><%s><%s>^" killed self with ^"grenade^"",
                                namek,get_user_userid(attacker),authida,teama)
    }
    else
    {
      new money = zp_get_user_ammo_packs(attacker)
      zp_set_user_ammo_packs(attacker, money + get_pcvar_num(cvar_bonus) )
    }   
  }
  else
  {
    fakedamage(victim, "grenade", fl_dmg, DMG_BLAST)

    if(tk == 1)
    {
        client_print(0,print_chat,"Вы атаковали своего.")
    }
  }
}

 
ammo_hud(id, sw)
{
  new s_sprite[33]
  format(s_sprite,32,"number_%d",g_ammo[id])
 
  if(sw)
  {
    message_begin( MSG_ONE, gMsgID, {0,0,0}, id )
    write_byte( ICON_SHOW ) // status
    write_string( s_sprite ) // sprite name
    write_byte( 0 ) // red
    write_byte( 0 ) // green
    write_byte( 150 ) // blue
    message_end()
  }
  else
  {
    message_begin( MSG_ONE, gMsgID, {0,0,0}, id )
    write_byte( ICON_HIDE ) // status
    write_string( s_sprite ) // sprite name
    write_byte( 0 ) // red
    write_byte( 0 ) // green
    write_byte( 150 ) // blue
    message_end()
  }
}

/////////////////////
//Thantik's he-conc functions
stock get_velocity_from_origin( ent, Float:fOrigin[3], Float:fSpeed, Float:fVelocity[3] )
{
    new Float:fEntOrigin[3];
    entity_get_vector( ent, EV_VEC_origin, fEntOrigin );

    // Velocity = Distance / Time

    new Float:fDistance[3];
    fDistance[0] = fEntOrigin[0] - fOrigin[0];
    fDistance[1] = fEntOrigin[1] - fOrigin[1];
    fDistance[2] = fEntOrigin[2] - fOrigin[2];

    new Float:fTime = ( vector_distance( fEntOrigin,fOrigin ) / fSpeed );

    fVelocity[0] = fDistance[0] / fTime;
    fVelocity[1] = fDistance[1] / fTime;
    fVelocity[2] = fDistance[2] / fTime;

    return ( fVelocity[0] && fVelocity[1] && fVelocity[2] );
}


// Sets velocity of an entity (ent) away from origin with speed (speed)

stock set_velocity_from_origin( ent, Float:fOrigin[3], Float:fSpeed )
{
    new Float:fVelocity[3];
    get_velocity_from_origin( ent, fOrigin, fSpeed, fVelocity )

    entity_set_vector( ent, EV_VEC_velocity, fVelocity );

    return ( 1 );
}

public grentrail(parm[])
{
  new gid = parm[0]

  if (gid)
  {
    message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
    write_byte( TE_BEAMFOLLOW )
    write_short(gid) // entity
    write_short(m_iTrail)  // model
    write_byte( 10 )      // life
    write_byte( 5 )        // width
    write_byte( 255 )      // r, g, b
    write_byte( 255 )    // r, g, b
    write_byte( 255 )      // r, g, b
    write_byte( 100 ) // brightness
               
    message_end() // move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS)
  }
}

stock fm_give_item(index, const item[]) {
        if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
                return 0;

        new ent = fm_create_entity(item);
        if (!pev_valid(ent))
                return 0;

        new Float:origin[3];
        pev(index, pev_origin, origin);
        set_pev(ent, pev_origin, origin);
        set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
        dllfunc(DLLFunc_Spawn, ent);

        new save = pev(ent, pev_solid);
        dllfunc(DLLFunc_Touch, ent, index);
        if (pev(ent, pev_solid) != save)
                return ent;

        engfunc(EngFunc_RemoveEntity, ent);

        return -1;
}


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


mottzi 07-05-2014 08:08

Re: [Help]Weapon
 
Quote:

Originally Posted by HamletEagle (Post 2162242)
You are wrong, it's very easy. Please post here plugins sources and we will convert them for you.

http://makeameme.org/media/created/o...nopleaseno.jpg

There is a special section on this website for requests like this if you didn't know: Suggestions / Requests

I strongly doubt that there exists a tutorial for such a specific problem. You should rather lern basic concepts of plugin-coding to achieve something like this.


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

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