Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name AK47
- @persist [Clip ShootTime Reload ReloadTime AmmoInsta] [Bullet]:entity [Ak47]:gtable
- if(first()){
- runOnTick(1)
- runOnLast(1)
- #entity():propNotSolid(1)
- #entity():setAlpha(0)
- #print(owner():attachments())
- Ak47 = gTable("Ak47" + owner():name(),1)
- if(Ak47["spawned",number]){
- print("Ak47 is already spawned!")
- selfDestruct()
- }
- Ak47["spawned",number] = 1
- if(Ak47["Ammo",number] <= 90){
- Ak47["Ammo",number] = 90
- }
- AmmoInsta = Ak47["Ammo",number]
- Clip = 30
- hint("Ammo : " + Ak47["Ammo",number]:toString(),2)
- if(holoModelAny() == 1){
- holoCreate(1,owner():attachmentPos("anim_attachment_RH") - vec(0,0,5) + owner():eye() * 9,vec(1),owner():attachmentAng("anim_attachment_RH"),vec(255),"models/weapons/w_rif_ak47.mdl")
- holoAlpha(1,0)
- holoParentAttachment(1,owner(),"anim_attachment_RH")
- }
- }
- findIncludePlayerProps(owner())
- findByModel("models/bull/gates/capacitor_mini.mdl")
- BulletC = findToArray()
- if(BulletC:count() > 5){
- BulletC[1,entity]:propDelete()
- }
- if(owner():weapon():type() == "weapon_ar2"){
- A1 = owner():keyAttack1()
- A2 = owner():keyAttack2()
- R = owner():keyReload()
- if(holoModelAny() == 1){
- holoAlpha(1,255)
- #holoPos(1,owner():attachmentPos("anim_attachment_RH") - vec(0,0,5) + owner():eye() * 9)
- #holoAng(1,owner():attachmentAng("anim_attachment_RH"))
- owner():weapon():setAlpha(0)
- }
- if(changed(A1) & A1 & Reload == 0){
- if(Clip > 0){
- Bullet = propSpawn("models/bull/gates/capacitor_mini.mdl",owner():shootPos() + owner():eye() * 70,0)
- Bullet:setTrails(5,1,1,"trails/laser",vec(255,255,0),200)
- Bullet:setMass(5000)
- Bullet:propGravity(0)
- Bullet:applyForce(owner():eye() * 200000000)
- owner():soundPlay(1,1,"Weapon_AK47.Single")
- Clip = Clip - 1
- }
- }
- if(A1 & Reload == 0){
- ShootTime = ShootTime + 1
- if(ShootTime == 7){
- ShootTime = 0
- if(Clip > 0){
- Bullet = propSpawn("models/bull/gates/capacitor_mini.mdl",owner():shootPos() + owner():eye() * 70,0)
- Bullet:setTrails(10,5,1,"trails/laser",vec(255,255,0),200)
- Bullet:setMass(5000)
- Bullet:propGravity(0)
- Bullet:applyForce(owner():eye() * 200000000)
- owner():soundPlay(1,0.5,"Weapon_AK47.Single")
- Clip = Clip - 1
- }
- }
- }
- if(changed(R) & R & Reload == 0 & Clip != 30 & Ak47["Ammo",number] > 0){
- Reload = 1
- Ak47["Ammo",number] = Ak47["Ammo",number] + Clip
- Clip = 0
- owner():soundPlay(2,1,"Weapon_AK47.Clipout")
- }
- if(Reload == 1){
- ReloadTime = ReloadTime + 1
- if(ReloadTime == 50){
- owner():soundPlay(2,1,"Weapon_AK47.Clipin")
- }
- if(ReloadTime == 70){
- Reload = 0
- ReloadTime = 0
- owner():soundPlay(3,1,"Weapon_AK47.BoltPull")
- if(Ak47["Ammo",number] < 30){
- Clip = Ak47["Ammo",number]
- Ak47["Ammo",number] = 0
- hint("Ammo out. Clip : " + Clip:toString(),2)
- }
- else{
- Clip = 30
- Ak47["Ammo",number] = Ak47["Ammo",number] - 30
- hint("Ammo : " + Ak47["Ammo",number]:toString(),2)
- }
- }
- }
- }
- else{
- Reload = 0
- ReloadTime = 0
- for(B = 1,BulletC:count()){
- BulletC[1,entity]:propDelete()
- }
- if(holoModelAny() == 1){
- holoAlpha(1,0)
- }
- }
- if(changed(Ak47["Ammo",number]) & !first() & Reload == 0){
- if(Ak47["Ammo",number] > AmmoInsta){
- hint("Ammo get( " + (Ak47["Ammo",number] - AmmoInsta) + " ). Remaining : " + Ak47["Ammo",number],2)
- }
- AmmoInsta = Ak47["Ammo",number]
- }
- if(changed(owner():isAlive()) & owner():isAlive() & !first()){
- hint("You are dead! Ammo reset to 90.",5)
- Ak47["Ammo",number] = 90
- Clip = 30
- }
- if(last()){
- Ak47["spawned",number] = 0
- }
Advertisement
Add Comment
Please, Sign In to add comment