AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ingame Motd Edit (https://forums.alliedmods.net/showthread.php?t=317687)

tepegoz 07-24-2019 11:30

Ingame Motd Edit
 
I want this
to say "/add text" - add text(line) to motd.txt
to say "/remove text - remove text(line) from motd.txt

HTML Code:

#include <amxmodx>
#include <cstrike>

public plugin_init()
{
        register_plugin("Rules", "1.0", "NewNamePT")
        register_clcmd("say /kurallar","ShowMotd")
}

public ShowMotd(id)
{
 show_motd(id, "motd.txt")
}
 public client_authorized(id)
{
 //set_task(30.0, "PrintText" ,id)
}
public PrintText(id)
{
 client_print(id, print_chat, "[Rules] Write /rules to view the server rules.")
}


OciXCrom 07-24-2019 15:37

Re: Ingame Motd Edit
 
To add text, you can use either use "fopen", "fputs" and the other file-reading functions or use only the "write_file" function if the other method is too compilcated for you.

For removing text, you can read all of the file's contents and store it into a dynamic array. Make sure NOT to read the line you want to remove. Then simply rewrite the file by looping the array and pushing all of the text inside it.


All times are GMT -4. The time now is 17:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.