Author Topic: Type mismatch...  (Read 1515 times)

0 Members and 1 Guest are viewing this topic.

Offline MR-93

  • Major(1)
  • Posts: 15
Type mismatch...
« on: June 28, 2008, 07:43:30 pm »
I got this error:
Code: [Select]
(565:39): Type mismatch
some lines from there...
Code: [Select]
  if Text = '/tele 1' then begin
    MovePlayer(ID,TeleeX[1],TeleeY[1]);
  end;
  if Text = 'Tele 2' then begin
    MovePlayer(ID,TeleeX[2],TeleeY[2]);
  end;
  if Text = 'Tele 3' then begin
    MovePlayer(ID,TeleeX[3],TeleeY[3]);
  end;

var... if you need...
Code: [Select]
  TeleeX, TeleeY: array[1..3] of string;
and whats wrong with this?

Offline amb2010

  • Camper
  • ***
  • Posts: 264
  • Fear the dot ...
Re: Type mismatch...
« Reply #1 on: June 28, 2008, 07:47:51 pm »
MovePlayers works with singles not strings :P Also im guessing this is an admin/player command thing so you might want to add some / to the Tele2 and Tele3.
« Last Edit: June 28, 2008, 07:49:50 pm by amb2010 »
And as the lyrics go in the United State's national anthem: "America, f**k YEAH!".

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Type mismatch...
« Reply #2 on: June 28, 2008, 08:26:26 pm »
This is all based on arrays of strings, which is bad in the first place...
Code: [Select]
if Text = '/tele 1' then begin
  MovePlayer(ID, StrToInt(TeleeX[1]), StrToInt(TeleeY[1]));
end;
if Text = '/tele 2' then begin
  MovePlayer(ID, StrToInt(TeleeX[2]), StrToInt(TeleeY[2]));
end;
if Text = '/tele 3' then begin
  MovePlayer(ID, StrToInt(TeleeX[3]), StrToInt(TeleeY[3]));
end;

Or, even better... (you should start using this)
Code: [Select]
case Text of
  '/tele 1': MovePlayer(ID, StrToInt(TeleeX[1]), StrToInt(TeleeY[1]));
  '/tele 2': MovePlayer(ID, StrToInt(TeleeX[2]), StrToInt(TeleeY[2]));
  '/tele 3': MovePlayer(ID, StrToInt(TeleeX[3]), StrToInt(TeleeY[3]));
end;

If you're gonna go with arrays of integers/singles then you need to put StrToInt around the ReadINI's.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Type mismatch...
« Reply #3 on: June 28, 2008, 09:25:36 pm »
I think it'd be better to set the variable to TeleeX, TeleeY: array[1..3] of single; and when setting those values, doing Var := StrtoFloat(ReadINI(...))

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Type mismatch...
« Reply #4 on: June 28, 2008, 11:12:39 pm »
Doesn't look like the script needs much precision, integer should be enough...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Type mismatch...
« Reply #5 on: June 29, 2008, 09:46:43 am »
Doesn't look like the script needs much precision, integer should be enough...
lol that wasn't my point, but true; my point was to not set the strings to floats/integers every single time you want to move a player

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Type mismatch...
« Reply #6 on: June 29, 2008, 01:25:30 pm »
That was my point too... ("This is all based on arrays of strings, which is bad in the first place...") But if he's already using it for other stuff, he might not want to change it.