Vehicles
#1

Hi.. I'm doing script, when I restart my gamemode, that all vehicles would stay in the same positions like before restarting.. Here is the script:
Код:
public OnGameModeExit()
{
  for(new k = 0; k < MAX_VEHICLES; k++)
  {
  new string[128];
	new Float:X, Float:Z, Float:Y;
	GetVehiclePos(k, X, Y, Z);
	new File:pos=fopen("positions.txt", io_append);
	format(string, 256, "GetVehiclePos", X, Y, Z);
	fwrite(pos, string);
	fclose(pos);
	}
	return 1;
}
I don't know where is positions.txt file. Can you tell is this good script? And how to load that file when my servers turns on.
Reply
#2

https://sampwiki.blast.hk/wiki/File_Functions
Reply
#3

Quote:
Originally Posted by Swift_
I've tried to do like in this web, but file doesn't creates.. Can you tell me what's wrong?
Reply
#4

Eh, I don't know howto use files manually (.ini) so I can't help you there. Just manually make the file in the scriptfiles folder.
Reply
#5

So no one knows how to do that after restar cars would stay in the same place like before restart?
Reply
#6

format(string, 256, "GetVehiclePos", X, Y, Z); - There's one of your problems...

Another fail is the fact you use io_append. If the file doesn't exist, this wont do squat. Use io_write or read the wiki..
Reply
#7

Quote:
Originally Posted by Weirdosport
format(string, 256, "GetVehiclePos", X, Y, Z); - There's one of your problems...

Another fail is the fact you use io_append. If the file doesn't exist, this wont do squat. Use io_write or read the wiki..
Ok.. I changed to io_write. Bu how can I fix it: format(string, 256, "GetVehiclePos", X, Y, Z); ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)