How to make this CMD -
Ballu Miaa - 26.02.2012
Hello everyone,
I want to make a Command which will store string into a text file located inside pawno/include folder of my Server?
How can i locate the Directory in which it will locate the file and will store the string (data) into the file.
Please give me suggestions or help me to code this?
Thanks
Ballu Miaa
Re: How to make this CMD -
Ballu Miaa - 26.02.2012
I was thinking so i made this command to save the CreateVehicle() function which will be added on a file in the scriptfiles folder. But how can i make this same cmd to save this data to a file with the same name but with the directory " pawno/includes ". This is a tested Command and works fine! Please help me to change the directory of saving!
pawn Код:
COMMAND:addveh(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new color1,color2,vehicleid = GetPlayerVehicleID(playerid),string[80];
if(sscanf(params, "dd",color1,color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /addveh [Color1] [Color2]");
if(color1 < 0 || color1 > 250) return SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 250 !");
if(color2 < 0 || color2 > 250) return SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 250 !");
new Float:X,Float:Y,Float:Z,Float:A,File:pos;
GetVehiclePos(vehicleid,X,Y,Z);
GetVehicleZAngle(vehicleid,A);
pos = fopen("LSveh.txt", io_append);
format(string, 256, "CreateVehicle(%d ,%f, %f, %f, %f, %d,%d,5 * 60 * 1000);\n",GetVehicleModel(vehicleid), X, Y, Z, A,color1,color2);
fwrite(pos, string);
fclose(pos);
format(string, sizeof(string), "Vehicle Model %d Created At Location : %f, %f, %f",GetVehicleModel(vehicleid), X,Y,Z);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}
else return SendClientMessage(playerid, COLOR_GRAD3, "You are not authorised to use this Command");
}
else return SendClientMessage(playerid,COLOR_GRAD3,"You need to be in a Vehicle to use this Command.");
}
NOTE: Should i change this command to this?? O.o
pawn Код:
COMMAND:addveh(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new color1,color2,vehicleid = GetPlayerVehicleID(playerid),string[80];
if(sscanf(params, "dd",color1,color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /addveh [Color1] [Color2]");
if(color1 < 0 || color1 > 250) return SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 250 !");
if(color2 < 0 || color2 > 250) return SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 250 !");
new Float:X,Float:Y,Float:Z,Float:A,File:pos;
GetVehiclePos(vehicleid,X,Y,Z);
GetVehicleZAngle(vehicleid,A);
pos = fopen("pawno/include/LSveh.txt", io_append); // Or pos = fopen("pawno\include\LSveh.txt", io_append); Or something else??
format(string, 256, "CreateVehicle(%d ,%f, %f, %f, %f, %d,%d,5 * 60 * 1000);\n",GetVehicleModel(vehicleid), X, Y, Z, A,color1,color2);
fwrite(pos, string);
fclose(pos);
format(string, sizeof(string), "Vehicle Model %d Created At Location : %f, %f, %f",GetVehicleModel(vehicleid), X,Y,Z);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}
else return SendClientMessage(playerid, COLOR_GRAD3, "You are not authorised to use this Command");
}
else return SendClientMessage(playerid,COLOR_GRAD3,"You need to be in a Vehicle to use this Command.");
}
Re: How to make this CMD -
Madd Kat - 26.02.2012
try it like this
pawn Код:
"../pawno/include/LSveh.txt
Re: How to make this CMD -
Ballu Miaa - 27.02.2012
Quote:
Originally Posted by Madd Kat
try it like this
pawn Код:
"../pawno/include/LSveh.txt
|
Should i use this!!
pawn Код:
pos = fopen("pawno/include/LSveh.txt", io_append);
Or
pawn Код:
pos = fopen("..pawno/include/LSveh.txt", io_append);
Re: How to make this CMD -
[HK]Ryder[AN] - 27.02.2012
pawn Код:
pos = fopen("..pawno/include/LSveh.txt", io_append);
This one
Re: How to make this CMD -
Ballu Miaa - 27.02.2012
Thanks to both of you! (Repped+ to both)