30.06.2014, 11:38
If your computer doesn't allow SA-MP to use file permissions, which can result in /save not working, here's a command that will save your position, or camera into a file (scriptfiles/debug.txt). This can also be helpful to get positions for SetPlayerCameraPos and SetPlayerCameraLookAt.
pawn Код:
CMD:dsave(playerid, params[])
{
new swhat[12], string[126], desc[126], Float:X, Float:Y, Float:Z, Float:A, vw = GetPlayerVirtualWorld(playerid), interior = GetPlayerInterior(playerid);
if(sscanf(params, "s[12]s[126]", swhat, desc)) return SendClientMessage(playerid, -1, "DEBUG: /dsave [position / camera] [description]");
if(strcmp(swhat, "position", true) == 0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
new File:fdebug = fopen("debug.txt", io_append);
new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, X, Y, Z);
GetVehicleZAngle(vehicleid, A);
format(string, sizeof(string), "VEHICLE POSITION: %f, %f, %f, %f // %s\r\n", X, Y, Z, A, desc);
fwrite(fdebug, string);
fclose(fdebug);
SendClientMessage(playerid, -1, "DEBUG: Your vehicles position has been saved to debug.txt");
return 1;
}
else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
new File:fdebug = fopen("debug.txt", io_append);
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
format(string, sizeof(string), "ON FOOT POSITION: %f, %f, %f, %f, %d, %d // %s\r\n", X, Y, Z, A, vw, interior, desc);
fwrite(fdebug, string);
fclose(fdebug);
SendClientMessage(playerid, -1, "DEBUG: Your on-foot position has been saved to debug.txt");
return 1;
}
else
{
SendClientMessage(playerid, -1, "DEBUG: You are not on-foot or in any vehicle.");
return 1;
}
}
else if(strcmp(swhat, "camera", true) == 0)
{
new File:fdebug = fopen("debug.txt", io_append);
new Float: x2, Float: y2, Float: z2, Float:x3, Float: y3, Float:z3;
GetPlayerCameraPos(playerid, X, Y, Z);
GetPlayerCameraFrontVector(playerid, x2, y2, z2);
format(string, sizeof(string), "CAMERA POSITION: %f, %f, %f // %s\r\n", X, Y, Z, desc);
fwrite(fdebug, string);
const Float:fScale = 1.0;
x3 = X + floatmul(x2, fScale);
y3 = Y + floatmul(y2, fScale);
z3 = Z + floatmul(z2, fScale);
format(string, sizeof(string), "CAMERA LOOKAT: %f, %f, %f // %s\r\n", x3, y3, z3, desc);
fwrite(fdebug, string);
fclose(fdebug);
SendClientMessage(playerid, -1, "DEBUG: Your camera position and lookat has been saved.");
return 1;
}
else
{
SendClientMessage(playerid, -1, "DEBUG: /dsave [position / camera] [description]");
}
return 1;
}