Saving Code in Notepad file
#1

Hello.
I have made a script in which when you type /addweapon <Name> <Ammo>, it creates that weapon pickup. Now I want to save that code somewhere. Whenever a player uses that command it creates a notepad file and saves the pickup code there so I can use it later to add the code in my script. How can I do that?
Reply
#2

Use dini or something similar to this include. I also recommend you to play around with SQL, it's way better.
Reply
#3

That's the problem. I don't know how to use it.
Reply
#4

So learn it, it's not that hard as it looks like.
Reply
#5

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


Forum Jump:


Users browsing this thread: 3 Guest(s)