[UnSovled] /Coord Command Saving To File
#10

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;
    }
Reply


Messages In This Thread
[UnSovled] /Coord Command Saving To File - by fsnameless - 28.12.2009, 05:23
Re: [Question] Creating A file - by dice7 - 28.12.2009, 08:43
Re: [Question] Creating A file - by fsnameless - 28.12.2009, 21:36
Re: [Question] Creating A file - by Abernethy - 28.12.2009, 21:39
Re: [Question] Creating A file - by dice7 - 28.12.2009, 22:06
Re: [Question] Creating A file - by fsnameless - 28.12.2009, 22:09
Re: [Question] Creating A file - by fsnameless - 29.12.2009, 00:05
Re: [Question] Creating A file - by xspeedasx - 29.12.2009, 07:19
Re: [Question] Creating A file - by retart441 - 29.12.2009, 07:21
Re: [Question] Creating A file - by dice7 - 29.12.2009, 08:55

Forum Jump:


Users browsing this thread: 1 Guest(s)