Originally Posted by FS}Nameless [LDR
]
well i want the file to create a file not open one =P |
Originally Posted by FS}Nameless [LDR
]
well i want the file to create a file not open one =P |
if (strcmp("/coord", cmdtext, true, 10) == 0)
{
new t = playerid;
new str[256];
new Float:Pos[MAX_PLAYERS][4];
GetPlayerPos(t,Pos[t][0],Pos[t][1],Pos[t][2]);
GetPlayerFacingAngle(t,Pos[t][3]);
format(str, 256,"x= %.4f y= %.4f z= %.4f a= %.4f",Pos[t][0],Pos[t][1],Pos[t][2],Pos[t][3]);
SendClientMessage(playerid, 0xFF0000AA, "Thank You Your Coords And Vehicle ID Have Ben Saved");
return 1;
}
#include Dini.inc
OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/coord", cmdtext, true, 6) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)){SendClientMessage(playerid,0xff0000aa,"You must be in a vehicle!"); return 1;}
new t = playerid;
new str[256], file[256], name[MAX_PLAYER_NAME];
new Float:Pos[MAX_PLAYERS][4];
GetPlayerPos(t,Pos[t][0],Pos[t][1],Pos[t][2]);
GetPlayerFacingAngle(t,Pos[t][3]);
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, 256,"x= %.4f y= %.4f z= %.4f a= %.4f",Pos[t][0],Pos[t][1],Pos[t][2],Pos[t][3]); // you won't need that.
SendClientMessage(playerid, 0xFF0000AA, "Thank You Your Coords And Vehicle ID Have Ben Saved");
format(file,256,"userpos/%s.ini",name);
if(!dini_Exists(file)){ dini_Create(file);}
dini_FloatSet(file,"x",Pos[t][0]);
dini_FloatSet(file,"y",Pos[t][1]);
dini_FloatSet(file,"z",Pos[t][2]);
dini_FloatSet(file,"a",Pos[t][3]);
dini_IntSet(file,"vehid",GetPlayerVehicleID(playerid));
return 1;
}
return 1;
}
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;
}