Author Topic: Score Placement  (Read 1681 times)

0 Members and 1 Guest are viewing this topic.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Score Placement
« on: February 23, 2009, 05:07:50 pm »
I am adding placement to my RPG script, but am having some problems. I am trying to make it where if the player's kills is greater than the old spot (t) then it bumps all the lower places down and puts him in that place. but it does not work atall. I did have it working where it would not bump lower scores down but it would work a little bit. Anyway here is a peice from procedure settopstats:

Code: [Select]
procedure SetTopStats(ID: byte; stat: string);
var t,oldscore: integer; bump: boolean; oldname: string;
begin
bump := false;
if stat = 'kills' then begin
for t := 1 to 20 do begin
if (players[ID].kills > strtoint(readini('accounts/topscores.ini','kills',inttostr(t*10),'0'))) AND (bump = false) then begin
oldname := readini('accounts/topscores.ini','kills',inttostr(t),'0');
oldscore := strtoint(readini('accounts/topscores.ini','kills',inttostr(t*10),'0'));
inisetvalue(topscores,'kills',inttostr(t),getplayerstat(ID,'name'));
inisetvalue(topscores,'kills',inttostr(t*10),inttostr(players[ID].kills));
inisetvalue(topscores,'kills',inttostr(t+1),oldname);
inisetvalue(topscores,'kills',inttostr((t+1)*10),inttostr(oldscore));
bump := true;
end;
if bump then begin
inisetvalue(topscores,'kills',inttostr(t+2),readini('accounts/topscores.ini','kills',inttostr(t+3),'0'));
inisetvalue(topscores,'kills',inttostr((t+2)*10),readini('accounts/topscores.ini','kills',inttostr((t+3)*10),'0'));
end;
end;
end;
if stat = 'deaths' then begin
for t := 1 to 20 do begin
if (players[ID].deaths > strtoint(readini('accounts/topscores.ini','deaths',inttostr(t*10),'0'))) AND (bump = false) then begin
oldname := readini('accounts/topscores.ini','deaths',inttostr(t),'0');
oldscore := strtoint(readini('accounts/topscores.ini','deaths',inttostr(t*10),'0'));
inisetvalue(topscores,'deaths',inttostr(t),getplayerstat(ID,'name'));
inisetvalue(topscores,'deaths',inttostr(t*10),inttostr(players[ID].deaths));
inisetvalue(topscores,'deaths',inttostr(t+1),oldname);
inisetvalue(topscores,'deaths',inttostr((t+1)*10),inttostr(oldscore));
bump := true;
end;
if bump then begin
inisetvalue(topscores,'deaths',inttostr(t+2),readini('accounts/topscores.ini','deaths',inttostr(t+3),'0'));
inisetvalue(topscores,'deaths',inttostr((t+2)*10),readini('accounts/topscores.ini','deaths',inttostr((t+3)*10),'0'));
end;
end;
end;
if stat = 'streak' then begin
for t := 1 to 20 do begin
if (players[ID].streak > strtoint(readini('accounts/topscores.ini','streak',inttostr(t*10),'0'))) AND (bump = false) then begin
oldname := readini('accounts/topscores.ini','streak',inttostr(t),'0');
oldscore := strtoint(readini('accounts/topscores.ini','streak',inttostr(t*10),'0'));
inisetvalue(topscores,'streak',inttostr(t),getplayerstat(ID,'name'));
inisetvalue(topscores,'streak',inttostr(t*10),inttostr(players[ID].streak));
inisetvalue(topscores,'streak',inttostr(t+1),oldname);
inisetvalue(topscores,'streak',inttostr((t+1)*10),inttostr(oldscore));
bump := true;
end;
if bump then begin
inisetvalue(topscores,'streak',inttostr(t+2),readini('accounts/topscores.ini','streak',inttostr(t+3),'0'));
inisetvalue(topscores,'streak',inttostr((t+2)*10),readini('accounts/topscores.ini','streak',inttostr((t+3)*10),'0'));
end;
end;
end;
if stat = 'caps' then begin
for t := 1 to 20 do begin
if (players[ID].caps > strtoint(readini('accounts/topscores.ini','caps',inttostr(t*10),'0'))) AND (bump = false) then begin
oldname := readini('accounts/topscores.ini','caps',inttostr(t),'0');
oldscore := strtoint(readini('accounts/topscores.ini','caps',inttostr(t*10),'0'));
inisetvalue(topscores,'caps',inttostr(t),getplayerstat(ID,'name'));
inisetvalue(topscores,'caps',inttostr(t*10),inttostr(players[ID].caps));
inisetvalue(topscores,'caps',inttostr(t+1),oldname);
inisetvalue(topscores,'caps',inttostr((t+1)*10),inttostr(oldscore));
bump := true;
end;
if bump then begin
inisetvalue(topscores,'caps',inttostr(t+2),readini('accounts/topscores.ini','caps',inttostr(t+3),'0'));
inisetvalue(topscores,'caps',inttostr((t+2)*10),readini('accounts/topscores.ini','caps',inttostr((t+3)*10),'0'));
end;
end;
end;
inisave('accounts/topscores.ini',topscores);
end;

What is wrong with this. (I made it late last nite so my tiredness my have made me make a dumb mistake.)

EDIT: Side Question: How much health is a full vest? 100?

EDIT2: Another Side Problem: I keep getting the error
  • [Error] ZRPG -> (OnPlayerKill): '' is not a valid integer value

every time someone kills someone else, I have figured out that it is caused by settopstats (above) what is wrong?
Code: [Select]
settopstats(victim,'deaths')
settopstats(killer,'kills');
settopstats(killer,'streak');

Thank You.
« Last Edit: February 23, 2009, 08:49:32 pm by Hacktank »


Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Score Placement
« Reply #1 on: February 24, 2009, 06:29:07 pm »
About the last issue, look at where you are doing strtoint and make absolutely sure that there is an integer being put there.
Your readINI calls are probably what's doing that. Do a bit of testing and find out which time you are doing strtoint on a blank string.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Score Placement
« Reply #2 on: February 24, 2009, 08:10:18 pm »
None of them are blank, all of them are set to 0. Im testing a hopefull fix rite now but I am getting the errors:
  • [Error] ZRPG -> (OnPlayerDamage): Type Mismatch
  • [Error] ZRPG -> (OnPlayerDamage): Stack overflow
  • [Error] ZRPG -> (OnPlayerDamage): Exception: [stack overflow,type mismatch]

For some reason. It is causing my server to crash and i have no idea what is causing them, i havent ever had those before.

Code: [Select]
function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;
var vamphp, ammo, vesthp: integer; ragem: single;
begin
if not (IGB[shooter].sdmg) AND (damage > 0) then result := round(strtofloat(inttostr(damage)) * IGB[shooter].bdamage);
if IGB[shooter].sdmg then result := damage;
if damage <= 0 then result := damage;
vesthp := 0;
ragem := 1;
if getplayerstat(shooter,'vest') > 0 then vesthp := 100;
if getplayerstat(victim,'human') then if IGB[shooter].kazi then dodamage(shooter,3900);
if damage < 3900 then if damage > 0 then if getplayerstat(shooter,'human') then begin
if shooter <> victim then begin
if players[Shooter].fatalHon = 'on' then if random(afatalH[players[shooter].fatalH].brange,10) >= 0 then players[Shooter].fataldmg := 2000;
if players[Shooter].crit > 0 then if random(acrit[players[shooter].crit].brange,25) >= 0 then players[Shooter].critm := 2;
end;
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;
if players[Shooter].ragetime > 0 then ragem := arage[players[shooter].rage].dmgm;
result := round(ragem * ((Players[Shooter].dmgm + players[shooter].critm) * (IGB[Shooter].BDamage * ((strtofloat(inttostr(Damage + players[shooter].fataldmg)) * (150 / strtofloat(inttostr(IGB[victim].BHealth + players[victim].health))))))));
if players[shooter].vamp > 0 then begin
vamphp := round(strtofloat(inttostr(result))*avamp[players[shooter].vamp].hpp);
if vamphp > ((150 - getplayerstat(shooter,'health')) + (vesthp - getplayerstat(shooter,'vest'))) then vamphp := ((150 - getplayerstat(shooter,'health')) + (vesthp - getplayerstat(shooter,'vest')));
dodamage(shooter,-vamphp);
end;
if players[shooter].fataldmg <> 0 then begin
  WriteConsole(shooter,'The power of mana surges through you, you got a fatal hit!',$ffFF1111);
  WriteConsole(victim,getplayerstat(shooter,'name') + ' hit you with a fatal hit!',$ffFF1111);
  players[shooter].fataldmg := 0;
end;
if players[shooter].critm <> 0 then begin
  WriteConsole(shooter,'The power of mana sparks through you, you got a critical hit!',$ffFF1111);
  WriteConsole(victim,getplayerstat(shooter,'name') + ' hit you with a critical hit!',$ffFF1111);
  players[shooter].critm := 0;
end;
if (IGB[Victim].mirror) then if (getplayerstat(victim,'alive')) then Mirror(victim,shooter,strtoint(inigetvalue(weapons,WeaponNameByNum(getplayerstat(shooter,'primary')),'BulletStyle','1')),result,strtoint(inigetvalue(weapons,WeaponNameByNum(getplayerstat(shooter,'primary')),'speed','10')));
if IGB[Victim].sdmg then if result / 4 < round(1+(getplayerstat(Shooter,'health') + getplayerstat(Shooter,'vest')) / IGB[victim].BDamage) then DoDamageBy(shooter,victim,result/4);
if IGB[Victim].sdmg then if result / 4 > round(1+(getplayerstat(Shooter,'health') + getplayerstat(Shooter,'vest')) / IGB[victim].BDamage) then DoDamageBy(shooter,victim,((getplayerstat(Shooter,'health') + getplayerstat(Shooter,'vest'))-1));
end
if (IGB[Victim].BShowHP) AND (getplayerstat(victim,'health') > 0) then ShowHP(Victim,Shooter);
end;


Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Score Placement
« Reply #3 on: February 24, 2009, 08:20:56 pm »
You need to learn a bit of debugging.
What I do when I get a bug like this in a big long function is to isolate it. I usually do this by commenting out the program one line at a time, each time checking if the bug remains. Of course you need to maintain logic (don't comment out an begin without commenting out an end for instance) to make sure that you don't make new bugs. Once you've found what line is causing your problems here then post that instead of a giant function.

Offline N. Escalona

  • Major(1)
  • Posts: 24
  • Pretentious Nutknot
Re: Score Placement
« Reply #4 on: February 24, 2009, 08:29:40 pm »
I went to your wikilink and then found this while wikiing around. Just wanted to share.

Quote from: The_Jargon_File
schroedinbug: A design or implementation bug in a program that doesn't manifest until someone reading source or using the program in an unusual way notices that it never should have worked, at which point the program promptly stops working for everybody until fixed. Though (like bit rot) this sounds impossible, it happens; some programs have harbored latent schroedinbugs for years.
Do you want to see me crawl across the floor to you?
Do you want to hear me beg you to take me back?
I'd gladly do it because
I don't want to fade away.

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Score Placement
« Reply #5 on: February 25, 2009, 12:15:48 am »
I went to your wikilink and then found this while wikiing around. Just wanted to share.

Quote from: The_Jargon_File
schroedinbug: A design or implementation bug in a program that doesn't manifest until someone reading source or using the program in an unusual way notices that it never should have worked, at which point the program promptly stops working for everybody until fixed. Though (like bit rot) this sounds impossible, it happens; some programs have harbored latent schroedinbugs for years.
lulz...

hacktank, also stick a lot of writeln()'s telling you whats actually going on (outputing inermideate values etc).

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Score Placement
« Reply #6 on: February 25, 2009, 02:14:31 am »
Ok I have everything I asked about working, thanks guys. One last thing: Since you can only have one draw text up at a time I wanted to make a full screen drawtext that displays all the timers and such I need it to. How do I add an 'enter' character so it will skip a line in the drawtext? One turely last thing: How can you make certian bot not camp when it sees a barret or a ruger? Ive seen it on some zombie servers where the one type of zombie ignores the barret while the others are paralized with fear.
« Last Edit: February 25, 2009, 02:34:54 am by Hacktank »


Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Score Placement
« Reply #7 on: February 25, 2009, 02:55:22 am »
chr(10)
or was it chr(13)? Ah nevermind, it's one of those.

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Score Placement
« Reply #8 on: February 25, 2009, 03:43:20 am »
Ok I have everything I asked about working, thanks guys. One last thing: Since you can only have one draw text up at a time I wanted to make a full screen drawtext that displays all the timers and such I need it to. How do I add an 'enter' character so it will skip a line in the drawtext?
chr(13) + chr(10) aka #13#10 (recommend to make a global constant :F )
One turely last thing: How can you make certian bot not camp when it sees a barret or a ruger? Ive seen it on some zombie servers where the one type of zombie ignores the barret while the others are paralized with fear.
tried Camping=0 in the botfile?

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Score Placement
« Reply #9 on: February 25, 2009, 05:08:50 pm »
Ok I have everything I asked about working, thanks guys. One last thing: Since you can only have one draw text up at a time I wanted to make a full screen drawtext that displays all the timers and such I need it to. How do I add an 'enter' character so it will skip a line in the drawtext?
chr(13) + chr(10) aka #13#10 (recommend to make a global constant :F )
One turely last thing: How can you make certian bot not camp when it sees a barret or a ruger? Ive seen it on some zombie servers where the one type of zombie ignores the barret while the others are paralized with fear.
tried Camping=0 in the botfile?

Thanks. The camping in the botfile, to my knolage, determines weather or not they camp at map preset camp spots like bunkers. I have tried many values between 0 and 10000. If I turn the bot intelegence down alot they dont camp atall and if it is high they do camp soo..


Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Score Placement
« Reply #10 on: February 26, 2009, 12:40:28 am »
iono... this bot camps on ruger/ret:
Code: [Select]
Accuracy=0
Shoot_Dead=0
Grenade_Frequency=10000
Camping=255

this one doesnt:
Code: [Select]
Accuracy=0
Shoot_Dead=1
Grenade_Frequency=10000
Camping=0
also, the first one will keep running if theres one of the second kind nearby :F


Edit: last lines of soldat.ini if that matters:
Code: [Select]
[BOTS]
Difficulty=100
Chat=1
Raycasting_Quality=12
« Last Edit: February 26, 2009, 12:43:56 am by danmer »

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Score Placement
« Reply #11 on: February 27, 2009, 07:55:03 pm »
iono... this bot camps on ruger/ret:
Code: [Select]
Accuracy=0
Shoot_Dead=0
Grenade_Frequency=10000
Camping=255

this one doesnt:
Code: [Select]
Accuracy=0
Shoot_Dead=1
Grenade_Frequency=10000
Camping=0
also, the first one will keep running if theres one of the second kind nearby :F


Edit: last lines of soldat.ini if that matters:
Code: [Select]
[BOTS]
Difficulty=100
Chat=1
Raycasting_Quality=12

I tried that but none of the bots camp with those settings. Demon has the second set and Zombie has the first but they both just ignore it.