29.12.2009, 08:55
pawn Код:
if (strcmp("/coord", cmdtext, true, 10) == 0)
{
//new t = playerid; why this ?
new str[70]; //does not need to be 256, look below
new file[MAX_PLAYER_NAME+30]; //30 is if you're putting it in a subdirectory in /scriptfiles/
//new Float:Pos[MAX_PLAYERS][4]; if you're making this an array for all players and all time use, then make iit global. If its created for one time use only (like in this cmd) and then never used again, then do like below
new Float:Pos[4];
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
GetPlayerFacingAngle(playerid,Pos[3]);
format(str, 70,"x= %.4f y= %.4f z= %.4f a= %.4f",Pos[0],Pos[1],Pos[2],Pos[3]);
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(str, 70,"x= %.4f y= %.4f z= %.4f a= %.4f\nVehicleID = %d",Pos[0],Pos[1],Pos[2],Pos[3], GetPlayerVehicleID(playerid));
//29 non placeholder characters + 5*5character places for the floats + (MAX)4 character places for the vehid, if you really have 2k vehicles on the server = 58
//thats almost 200 cells going to waste !
format(file, MAX_PLAYER_NAME+30, "/Player Info/%s", pName); //creating the file path
new File:Handler = fopen(file, io_write); //this will create a file and write into it. If the file already exists, it will write over it
fwrite(Handler, str); //writing to the file
fclose(Handler);
SendClientMessage(playerid, 0xFF0000AA, "Thank You Your Coords And Vehicle ID Have Ben Saved");
return 1;
}

