Author Topic: Summoner-RPG (need help)  (Read 804 times)

0 Members and 1 Guest are viewing this topic.

DarkCrusade

  • Guest
Summoner-RPG (need help)
« on: January 04, 2011, 06:46:57 am »
Hey guys, this is no real announcement, but I am working on a new RPG-subgamemode. Every player has his own "pet", a bot which he is connected with and both gain experience and strength. I started with a simple accountsystem for players, and when I added one for the pets I seem to have made some mistakes which I really cannot find.

Whenever I create a new account, one is created for me and one for my pet. The errorlog says '' is not a valid integer value and no account is created for my pet, though a bot joins my team. I cannot find a single line in my functions which uses a string as an integer, maybe you have more luck..

link

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Summoner-RPG (need help)
« Reply #1 on: January 04, 2011, 11:11:54 am »
i think they call it debugging.

Step 1:
Code: (pascal) [Select]
procedure create(ID:Byte; Name,Password:String);
begin
  writeln('-- create init');
  if not fileExists('Accounts/'+Name+'.txt') then begin
  writeln('-- create saving');
    saveAccount(ID,Name,Password);
  writeln('-- create loading');
    loadAccount(ID,Name,Password);
    writeConsole(ID,'*** Account successfully created ***',accountCl);
  writeln('-- create createpet');
    createPet(Name);
   writeln('-- create summonpet');
   summonPet(ID);
  end else writeConsole(ID,'*** Account already exists ***',errorCl);
  writeln('-- create done');
end;

console output:
Quote
-- create init
-- create saving
-- create loading
 
  • [Error] ZS -> (OnPlayerCommand): '' is not a valid integer value
=> error is in the load procedure






Step 2:
Code: (pascal) [Select]
function loadAccount(ID:Byte; Name,Password:String):Byte;
var AccountData:String;
begin
  result:=0;
  writeln('-- load init');
  if (FileExists('Accounts/'+Name+'.txt')) then begin
   writeln('-- load read');
   AccountData:=readAccount(Name);
    if (GetPiece(AccountData,' ',0)=Password) then begin
    writeln('-- load fill record');
      player[ID].accountName:=Name;
      player[ID].accountPassword:=Password;
      player[ID].level:=strToInt(getPiece(AccountData,' ',1));
      player[ID].ep:=strToInt(getPiece(AccountData,' ',2));
      player[ID].statPoints:=strToInt(getPiece(AccountData,' ',3));
      player[ID].skillPoints:=strToInt(getPiece(AccountData,' ',4));
      player[ID].money:=strToInt(getPiece(AccountData,' ',5));
      player[ID].petPoints:=strToInt(getPiece(AccountData,' ',6));
    writeln('-- load summon pet');
      summonPet(ID);
    end else result:=2;
  end else result:=1;
    writeln('-- load done');
end;


console output:
Quote
-- create init
-- create saving
-- create loading
-- load init
-- load read
-- load fill record
-- load summon pet
 
  • [Error] ZS -> (OnPlayerCommand): '' is not a valid integer value
=> error is in (surprise surprise) summonpet





Step 3:
get to at least this stage and make sure Data contains what you want
Code: (pascal) [Select]
procedure summonPet(ID:Byte);
var Data:String; pID:Byte;
begin
  writeln('-- summonpet init');
  Data:=readAccount(player[ID].accountName+'_');
  writeln('-- data: ' + data);
  writeln('-- summonpet addbot');
  pID:=command('/addbot'+intToStr(getPlayerStat(ID,'Team'))+' Zombie');
  player[ID].petID:=pID;
  pet[pID].level:=strToInt(getPiece(Data,' ',0));
  pet[pID].ep:=strToInt(getPiece(Data,' ',1));
  pet[pID].ownerID:=ID;
  writeConsole(ID,'petID:'+intToStr(pID)+' - lvl:'+intToStr(pet[pID].level)+' - ep:'+intToStr(pet[pID].ep),$FFFFFF);
end;


console output:
Quote
-- create init
-- create saving
-- create loading
-- load init
-- load read
-- load fill record
-- load summon pet
-- summonpet init
-- data:
-- summonpet addbot
 
  • [Error] ZS -> (OnPlayerCommand): '' is not a valid integer value
=> data is blank because you are reading some file that does not exist.

Now i don't know what exactly you were going to read there etc, but my guess is that a piece of an empty string can not really be converted into an integer, so the server errors out


oslo, writing and reading the file in createaccount makes no sense to me, i hope it's there just for debugging purposes |:
« Last Edit: January 04, 2011, 11:35:55 am by dnmr »

DarkCrusade

  • Guest
Re: Summoner-RPG (need help)
« Reply #2 on: January 04, 2011, 12:17:53 pm »
I was confused, because my code really is flawless - except for the fact that the pet is summoned in loadAccount but created afterwards the way my createAccount function works >_>"