Saving Code in Notepad file
#6

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
You can simply create files.. Here's an example command (using ZCMD!)

pawn Код:
CMD:testfile(playerid, params[])
{
    if (!IsPlayerAdmin(playerid)) return 0; //Only RCON admins can use this command
    new str[128];
    GetPlayerName(playerid, str, MAX_PLAYER_NAME);
    format(str, 30, "%s.txt", str); //username.txt
    new File:usrFile = fopen(str, io_write); //'io_write' : If you use the command again, all previous text will be destroyed
    fwrite(usrFile, "Hello world!\nThis is just some kind of file that doesn't make sense"); //Write into 'usrFile'
    fclose(usrFile); //Close file!!!
    new File:tmpFile = fopen("allcreatedfiles.txt", io_append); //Also create 'allcreatedfiles.txt' ('io_append': When writing, no text will be removed!
    GetPlayerName(playerid, str, MAX_PLAYER_NAME);
    format(str, 128, "%s created a file!\r\n", str); //playername created a file!
    fwrite(tmpFile, str);
    fclose(tmpFile);
    return 1;
}
If 'Kwarde' and 'Player' would use this command (both admins), this would happen (considering that 'scriptfiles' folder exist and that both players are admin:

* 3 files get created: 'Kwarde.txt', 'Player.txt' and 'allcreatedfiles.txt'
* 'Kwarde.txt' and 'Player.txt' would contain:
Hello world!
This is just some kind of file that doesn't make sense
* 'allcreatedfiles.txt' would contain:
Kwarde created a file!
Player created a file!

I hope it makes sense to you
Very helpful. Thanks
Reply


Messages In This Thread
Saving Code in Notepad file - by [DX]Aru12345 - 10.05.2013, 11:29
Re: Saving Code in Notepad file - by Konewka - 10.05.2013, 11:51
Re: Saving Code in Notepad file - by [DX]Aru12345 - 10.05.2013, 11:53
Re: Saving Code in Notepad file - by Konewka - 10.05.2013, 12:31
Re: Saving Code in Notepad file - by Kwarde - 10.05.2013, 12:52
Re: Saving Code in Notepad file - by [DX]Aru12345 - 10.05.2013, 14:17

Forum Jump:


Users browsing this thread: 2 Guest(s)