How to make this CMD
#1

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
Reply
#2

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.");
    }
Reply
#3

try it like this

pawn Код:
"../pawno/include/LSveh.txt
Reply
#4

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);
Reply
#5

pawn Код:
pos = fopen("..pawno/include/LSveh.txt", io_append);
This one
Reply
#6

Thanks to both of you! (Repped+ to both)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)