SA-MP Forums Archive
LoadVehs() - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: LoadVehs() (/showthread.php?tid=79720)



LoadVehs() - miokie - 30.05.2009

Im trying to create a little car system at the moment by looking at others and writing my own. But for some reason my LoadVehs Function dosen't work. When LoadVehs is placed under OnGameModeInit And I run my Samp-server.exe it dosen't load my gamemode. Then I try and put it in a command and it just crashes the player.

pawn Код:
LoadVehs()
{
  new i,File:pos=fopen("Vehs.txt", io_read),arrCoords[5][128];
  while(i < sizeof(BoughtVehs))
  {
        BoughtVehs[i][vModel] = strval(arrCoords[0]);
        BoughtVehs[i][bvX] = floatstr(arrCoords[1]);
        BoughtVehs[i][bvY] = floatstr(arrCoords[2]);
        BoughtVehs[i][bvZ] = floatstr(arrCoords[3]);
        BoughtVehs[i][bvA] = floatstr(arrCoords[4]);

        CreateVehicle(BoughtVehs[i][vModel],BoughtVehs[i][bvX],BoughtVehs[i][bvY],BoughtVehs[i][bvZ],BoughtVehs[i][bvA],-1,-1,9999999);
        fclose(pos);
    }
}
Any ideas what could be causing this?
Thanks.


Re: LoadVehs() - Correlli - 30.05.2009

Does Vehs.txt exists in your scriptfiles?


Re: LoadVehs() - Nero_3D - 30.05.2009

Quote:
Originally Posted by Miokie*
Any ideas what could be causing this?
Sure

pawn Код:
LoadVehs()
{
  new i,File:pos=fopen("Vehs.txt", io_read),arrCoords[5][128];
  //all cells of arrCoords are 0 after creation
  while(i < sizeof(BoughtVehs))
  {
        BoughtVehs[i][vModel] = strval(arrCoords[0]);
        BoughtVehs[i][bvX] = floatstr(arrCoords[1]);
        BoughtVehs[i][bvY] = floatstr(arrCoords[2]);
        BoughtVehs[i][bvZ] = floatstr(arrCoords[3]);
        BoughtVehs[i][bvA] = floatstr(arrCoords[4]);
        //strval or floatstr nothing will return 0

        CreateVehicle(BoughtVehs[i][vModel],BoughtVehs[i][bvX],BoughtVehs[i][bvY],BoughtVehs[i][bvZ],BoughtVehs[i][bvA],-1,-1,9999999);
        //CreateVehicle(0, 0.0, 0.0, 0.0, 0.0, -1, -1, 9999999); will crash
        fclose(pos);
    }
}
And there are still some other mistakes


Re: LoadVehs() - miokie - 30.05.2009

Ahh I understand...
Thanks for explaining to me why it is making me crash.