iMagicBae

Untitled

May 27th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   // Scripted by iMagic
  2. findplayer("Graal2007722").addweapon(this.name);
  3. this.image = "era_fuubaz-energyrifle-icon.png";
  4.  
  5. //#CLIENTSIDE
  6. function onCreated() {
  7.   this.image = "era_fuubaz-energyrifle-icon.png";
  8.  
  9.   // GANIS
  10.   this.gun_idle = "mm_imagic-fuubaz-energyrifle-idle";
  11.   this.gun_walk = "mm_imagic-fuubaz-energyrifle-walk";
  12.   this.gun_fire = "mm_imagic-fuubaz-energyrifle-fire";
  13.   this.gun_reload = "mm_imagic-fuubaz-energyrifle-reload";
  14.   this.gun_bullet = "mm_imagic-fuubaz-energyrifle-bullet";
  15.  
  16.   // STATS
  17.   this.gun_damage = 10;
  18.   this.gun_firerate = 0.45;
  19.   this.gun_freeze = 0.1;
  20.   this.gun_spread = 0.07;
  21.   this.gun_reloadclipsize = 14;
  22.   this.gun_clipsize = 14;
  23.   this.gun_reloadtime = 0.8;
  24.   this.gun_bulletpos = {{-0.6, -1.7},{-2.2, -0.35},{0.6, 1.1},{2.4,-0.7}};
  25. }
  26.  
  27. function onKeyPressed(code, key) {
  28.   if (player.weapon == this.name) {
  29.     if (key == "2") {
  30.       if (!this.isGunEquipped) {
  31.         this.isGunEquipped = true;
  32.         player.chat = "*Plasma Rifle Equipped*";
  33.         player.ani = this.gun_reload;
  34.         replaceani("idle", this.gun_idle);
  35.         replaceani("walk", this.gun_walk);
  36.       } else {
  37.         this.isGunEquipped = false;
  38.         player.ani = "idle";
  39.         player.chat = "*Unequipped*";
  40.         replaceani("idle", "idle");
  41.         replaceani("walk", "walk");
  42.       }
  43.       freezeplayer(0.5);
  44.     }
  45.     if (this.isGunEquipped) {
  46.       if (key == "d") {
  47.         if (!this.isReloading) {
  48.           if (this.gun_clipsize >= 1) {
  49.             if (!this.isShooting) {
  50.               this.isShooting = true;
  51.               player.ani = this.gun_fire;
  52.               temp.angle = getangle(vecx(player.dir), vecy(player.dir)) + random(-this.gun_spread, this.gun_spread);
  53.               setshootparams(this.gun_damage, player.account, "sys_health");
  54.               shoot(player.x + this.gun_bulletpos[player.dir][0], player.y + this.gun_bulletpos[player.dir][1], player.z, temp.angle, 0, 0, this.gun_bullet, "");
  55.               freezeplayer(this.gun_freeze);
  56.               this.gun_clipsize -= 1;
  57.               player.chat = "Clip: " @ this.gun_clipsize @ "/" @ this.gun_reloadclipsize;
  58.               setTimer(this.gun_firerate);
  59.             }
  60.           } else {
  61.             onStartReload();
  62.           }
  63.         }
  64.       }    
  65.     }
  66.   }
  67. }
  68.  
  69. function onStartReload() {
  70.   this.isReloading = true;
  71.   freezeplayer(this.gun_reloadtime);
  72.   player.ani = this.gun_reload;
  73.   this.gun_clipsize = this.gun_reloadclipsize;
  74.   scheduleEvent(this.gun_reloadtime, "onEndReload", "");
  75. }
  76.  
  77. function onEndReload() {
  78.   this.isReloading = false;
  79. }
  80.  
  81. function onTimeout() {
  82.   this.isShooting = false;
  83. }
Add Comment
Please, Sign In to add comment