Author Topic: [SOLVED]Integers  (Read 1175 times)

0 Members and 1 Guest are viewing this topic.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
[SOLVED]Integers
« on: August 25, 2009, 03:48:37 pm »
Hai Guyz,

I've been running a saw server since a while. I tried to script something ; failed and then i erased that fail ...
Now look at this error

Thanks for help me.
« Last Edit: August 26, 2009, 09:14:07 pm by VinceBros »

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Division by Zero
« Reply #1 on: August 25, 2009, 03:57:20 pm »
Upload the script antibloodsaw and we can help you.


Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Division by Zero
« Reply #2 on: August 25, 2009, 05:53:38 pm »
Got the problem, i'm just stupid :x

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: [SOLVED]Division by Zero
« Reply #3 on: August 26, 2009, 03:15:49 pm »
* AHEM *
Wtf, many grammar errors in my first spot O.o. I was tired, really.

Sorry for double-post D;..

Well, instead of making another thread i'm just gonna post my question here :3.
I've got some problems with Division again.
By Eg. I got 2 variables, 2 integers.
When i Divide'em like IntToStr(Var[ID])/Var2[ID]) -> It only gives me it through an integer number...
Yes, those are 2 integer variables, but with strings, it gives me Type Mismatch..

Thankz ;)

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: [SOLVED]Division by Zero
« Reply #4 on: August 26, 2009, 03:23:46 pm »
Show the actual code that is giving the errors.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Integers
« Reply #5 on: August 26, 2009, 03:51:25 pm »
say they are strings representing integers.
IntToStr(Var[ID])/Var2[ID]) -> IntToStr(Var[ID])/IntToStr(Var2[ID])

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Integers
« Reply #6 on: August 26, 2009, 07:55:17 pm »
Unfortunately,  Curt. I've already tried this and it keeps giving me Type Mismatch errors.
I can give you the part where the bug is.
Code: [Select]
var
  Killz: array [1..32] of integer;
  Deathz: array [1..32] of integer;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin;
 Killz[Killer] := Killz[Killer] + 1;
 Deathz[Victim] := Deathz[Victim] + 1;
 if Killer = Victim then begin
   Killz[Killer] := Killz[Killer] - 1
 end; 
end;

procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
 if Text = '!spec' then begin
  if GetPlayerStat(ID, 'Team') < 5 then begin
  Command('/setteam5 ' + IntToStr(ID))
 end else
 WriteConsole(ID,'You are already a spectator', RandomColor);
 end;
 if Text = '!ping' then begin
  WriteConsole(0, (IDToName(ID)) + ', Your ping is ' + (GetPlayerStat(ID,'ping')), RandomColor);
 end;
 if (Text = '!rate') then begin
  WriteConsole(0, (IDToName(ID)) + ', Your rate is ' + IntToStr(Killz[ID])/IntToStr(Deathz[ID]) , RandomColor);
 end;
 if (Text ='!rate') and (Killz[ID] = 0) then begin
  WriteConsole(0, (IDToName(ID)) + ', Your rate is ' + IntToStr(Killz[ID])/IntToStr(Deathz[ID]), RandomColor);
 end;     
end;

There is actually much more in this script but there's nothing else attached to that part that i've sent.

Thanks for help anyways guy :)

Offline croat1gamer

  • Veteran
  • *****
  • Posts: 1327
  • OMG CHANGING AVATAR!!! ^ω^
Re: Integers
« Reply #7 on: August 26, 2009, 08:00:47 pm »
Actually, it would help us alot if you would give us the whole, 100%, not changed script that is being used on the server instead of the parts where you suspect is the bug.
Last year, I dreamt I was pissing at a restroom, but I missed the urinal and my penis exploded.

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Integers
« Reply #8 on: August 26, 2009, 08:07:13 pm »
Code: [Select]
WriteConsole(0, (IDToName(ID)) + ', Your rate is ' + IntToStr(Killz[ID])/IntToStr(Deathz[ID]) , RandomColor);Should be
Code: [Select]
WriteConsole(0, (IDToName(ID)) + ', Your rate is ' + IntToStr(Killz[ID]/Deathz[ID]) , RandomColor);

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Integers
« Reply #9 on: August 26, 2009, 08:17:08 pm »
Lulz yes, but i tried Curt's one.
I used that one before, it only gives me integer numbers D;
Strange problem :/. You're kewl guyz, dont give up :p
« Last Edit: August 26, 2009, 08:19:41 pm by VinceBros »

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Integers
« Reply #10 on: August 26, 2009, 08:34:20 pm »
It needs to be floattostring, because if you divide say 5 kills by 3 deaths it does not come out even so try this:
And you cant divide strings...
Code: [Select]
function IntToFloat(Num: integer): single;
begin
result := strtofloat(inttostr(num));
end;

WriteConsole(0, (IDToName(ID)) + ', Your rate is ' + floattostr(roundto(inttofloat(Killz[ID])/inttofloat(Deathz[ID],2))), RandomColor);


Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Integers
« Reply #11 on: August 26, 2009, 08:39:46 pm »
Thanks ALOT. I may do some sex credits for you, thanks againn :D
EDIT: Invalid number of parameters D:
I feel like dumb
EDIT2: Fixed works :D
« Last Edit: August 26, 2009, 09:13:56 pm by VinceBros »