Coordinate Saving Problem
#1

I'm working on a roleplay script right now, and I'm going from scratch. I have made some file saving for simple stuff such as Admin, Password, Kills, Score, etc. Now the problem is that no matter what, when you login you spawn at 0.0, 0.0, 0.0. Maybe a forth of the time you'll spawn where you actually logged out at. It also has a impact on the hospital script. When you die, it sets your camera to outside All Saints and starts a 30 second timer. After the timer it, charges you $100 and is suppose to spawn you outside the doors. Instead you spawn at 0.0, 0.0, 0.0. It's really annoying and I need some help. Just ask me what you need to see and I'll post it. Any and all help is appreciated.
Reply
#2

Are you saving them as a float?
Reply
#3

Quote:
Originally Posted by Adamrcook
I'm working on a roleplay script right now, and I'm going from scratch. I have made some file saving for simple stuff such as Admin, Password, Kills, Score, etc. Now the problem is that no matter what, when you login you spawn at 0.0, 0.0, 0.0. Maybe a forth of the time you'll spawn where you actually logged out at. It also has a impact on the hospital script. When you die, it sets your camera to outside All Saints and starts a 30 second timer. After the timer it, charges you $100 and is suppose to spawn you outside the doors. Instead you spawn at 0.0, 0.0, 0.0. It's really annoying and I need some help. Just ask me what you need to see and I'll post it. Any and all help is appreciated.
Good luck!
Reply
#4

Yes, and here are some sections of how I'm doing it.
Ignore brackets off and etc. as it's just the copy and paste deformation.

Код:
public SetPlayerSpawn(playerid)
{
	SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][pVirWorld]);
 	SetPlayerInterior(playerid,PlayerInfo[playerid][pInt]);
	SetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z] + 1);
	return 1
}
Код:
	{	fwrite(account, file); }
				if ((PlayerInfo[playerid][pPos_x]==0.0 && PlayerInfo[playerid][pPos_y]==0.0 && PlayerInfo[playerid][pPos_z]==0.0))
				{
				  PlayerInfo[playerid][pPos_x] = 1449.2389;
					PlayerInfo[playerid][pPos_y] = -2286.5237;
					PlayerInfo[playerid][pPos_z] = 13.5469;
				}
				format(file, sizeof file, "Pos_x=%.1f\n", PlayerInfo[playerid][pPos_x]);
				{	fwrite(account, file); }
  				format(file, sizeof file, "Pos_y=%.1f\n", PlayerInfo[playerid][pPos_y]);
				{	fwrite(account, file); }
				format(file, sizeof file, "Pos_z=%.1f\n", PlayerInfo[playerid][pPos_z]);
				{	fwrite(account, file); }
Код:
	new Float:x, Float:y, Float:z;
	   			GetPlayerPos(playerid,x,y,z);
					PlayerInfo[playerid][pPos_x] = x;
					PlayerInfo[playerid][pPos_y] = y;
					PlayerInfo[playerid][pPos_z] = z;
					format(file, sizeof file, "Pos_x=%.1f\n", PlayerInfo[playerid][pPos_x]);
					{	fwrite(account, file); }
	  				format(file, sizeof file, "Pos_y=%.1f\n", PlayerInfo[playerid][pPos_y]);
					{	fwrite(account, file); }
					format(file, sizeof file, "Pos_z=%.1f\n", PlayerInfo[playerid][pPos_z]);
					{	fwrite(account, file); }
Код:
if (strfind(passres, "Pos_z") != -1)
				{
					value = GetFileValue(pass);
					PlayerInfo[playerid][pPos_z] = strval(value);
				}
				if (strfind(passres, "Pos_x") != -1)
				{
					value = GetFileValue(pass);
					PlayerInfo[playerid][pPos_x] = strval(value);
				}
				if (strfind(passres, "Pos_y") != -1)
				{
					value = GetFileValue(pass);
					PlayerInfo[playerid][pPos_y] = strval(value);
Reply
#5

Quick update I've discovered the problem, the cord saving WILL work until you die. Then you spawn at 0.0,0.0,0.0 no matter what. I think it has to do with the hospital script i have. Which is below. Any help now?

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	SendClientMessage(playerid, RED, "You are in Intensive Care, please calm down and wait");
 	SetPlayerPos(playerid,1173.5985,-1323.3386,15.1953);
 	SetPlayerFacingAngle( playerid, 269.4324 );
 	TogglePlayerControllable(playerid, false);
 	SetPlayerCameraPos(playerid, 1198.6255, -1348.5658, 17.7985);
 	SetPlayerCameraLookAt(playerid, 1173.5985, -1323.3386, 15.1953);
 	timer1 = SetTimer("hospital", 15000 , true); // 15 Seconds
	return 1;
}
public hospital(playerid)
{
     GivePlayerMoney(playerid, -100);
  	SendClientMessage(playerid, RED, "You are healthy again, your bill comes to $100, be safe out there");
  	TogglePlayerControllable(playerid, true);
  	SetPlayerHealth(playerid, 100.0);
  	SetPlayerPos(playerid,1173.5985,-1323.3386,15.1953);
 	SetPlayerFacingAngle( playerid, 269.4324 );
     SpawnPlayer(playerid);
  	KillTimer(timer1);
  	return 1;
}
Reply
#6

hope you get help
Reply
#7

Quote:
Originally Posted by XCultz
hope you get help
Stop spamming.

And Adamrcook, this won't be that useful but it's a way of using less variables, do this:

pawn Код:
GetPlayerPos(playerid,PlayerInfo[playerid][pPos_x],PlayerInfo[playerid][pPos_y],PlayerInfo[playerid][pPos_z]);
Reply


Forum Jump:


Users browsing this thread: