10.05.2013, 12:52
You can simply create files.. Here's an example command (using ZCMD!)
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
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;
}
* 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