Author Topic: Adding ammo and the Spas  (Read 871 times)

0 Members and 1 Guest are viewing this topic.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Adding ammo and the Spas
« on: February 12, 2009, 01:48:46 am »
Sorry for all the threads but I am having a problem with LootAmmo in my RPG script, every hit there is a chance to regain some ammo. It works fine for every gun except the shotgun. It always makes the shotgun have 0 ammo instead of current ammo+looted ammo, wich is a very bad problem.

Here is my code:
OnPlayerDamage (relevent part)
Code: [Select]
if players[Shooter].lootammo > 0 then if random(alootammo[players[shooter].lootammo].brange,25) >= 0 then begin
ammo := round(strtoint(inigetvalue(weapons,WeaponNameByNum(getplayerstat(shooter,'primary')),'Ammo','100'))/2) +round(random(strtoint(inigetvalue(weapons,WeaponNameByNum(getplayerstat(shooter,'primary')),'Ammo','100'))/-4,strtoint(inigetvalue(weapons,WeaponNameByNum(getplayerstat(shooter,'primary')),'Ammo','100'))/4));
Faddammo(shooter,ammo);
end;

Faddammo:
Code: [Select]
procedure Faddammo(ID: byte; ammo: integer);
var fammo, buff1: integer;
begin
fammo := ammo;
buff1 := strtoint(inigetvalue(weapons,WeaponNameByNum(getplayerstat(ID,'primary')),'Ammo','10'));
if fammo = 0 then fammo := 1;
if (getplayerstat(ID,'ammo') + ammo) > buff1 then fammo := (buff1 - getplayerstat(ID,'ammo'));
Forceweapon(ID,getplayerstat(ID,'primary'),getplayerstat(ID,'secondary'),getplayerstat(ID,'ammo')+fammo);
if getplayerstat(ID,'alive') then WriteConsole(ID,'Looted -:- ' + inttostr(fammo) + ' ammo',$ff5555ff);
{WriteConsole(ID,'Debugging',$ff5555ff);
WriteConsole(ID,'fammo = ' + inttostr(fammo),$ff5555ff);
WriteConsole(ID,'your ammo = ' + inttostr(getplayerstat(ID,'ammo')),$ff5555ff);
WriteConsole(ID,'max ammo = ' + inttostr(buff1),$ff5555ff);}
end;

Why does it mess up only on the Spas? Also how many pelets does the spas fire?(need this to decrease the chace of crits fatalhits and loots)

Thank You


Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Adding ammo and the Spas
« Reply #1 on: February 12, 2009, 07:08:42 am »
I was bored so I made this...
Code: [Select]
procedure IncAmmo(ID: byte);
var Max, aAdd: byte;
begin
  Max:= StrToInt(ReadINI('weapons_realistic.ini',WeaponNameByNum(GetPlayerStat(ID,'Primary')),'Ammo','7'));
  aAdd:= Random(1,Max-GetPlayerStat(ID,'Ammo')+1);
  ForceWeapon(ID, GetPlayerStat(ID,'Primary'), GetPlayerStat(ID,'Secondary'), GetPlayerStat(ID,'Ammo')+aAdd);
  WriteConsole(ID,'+' + IntToStr(aAdd),$FFFFFF);
end;
...and it works for all weapons(I tried only on dealges and shotgun but it should work 4 all).

Quote
Also how many pelets does the spas fire?(need this to decrease the chace of crits fatalhits and loots)
Shoot and do /pause.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Adding ammo and the Spas
« Reply #2 on: February 12, 2009, 05:22:30 pm »
I will try it, but there is no difference between
Code: [Select]
ForceWeapon(ID, GetPlayerStat(ID,'Primary'), GetPlayerStat(ID,'Secondary'), GetPlayerStat(ID,'Ammo')+aAdd);and
Code: [Select]
Forceweapon(ID,getplayerstat(ID,'primary'),getplayerstat(ID,'secondary'),getplayerstat(ID,'ammo')+fammo);besides capitalization.
In my debugging it shows correct max ammo and ammo to be added. I dont see what the actual problem is...


Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Adding ammo and the Spas
« Reply #3 on: February 13, 2009, 12:43:50 am »
make sure you're not going over the max ammo limit, as the only reason i see for the spas reloading is that. Not sure how all your magic works, so cant help much with the code atm (no time to dig, sorry)