AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   amxx plugin read from file (https://forums.alliedmods.net/showthread.php?t=159359)

florin123 06-16-2011 07:18

amxx plugin read from file
 
hello. can someone help me make a plugin that when i type on chat /readfile, the plugins reads a .txt file from a web address e.g http://www.cite.com/text.txt and displays it on chat.

Thanx!

florin123 06-16-2011 08:44

Re: amxx plugin read from file
 
L.E: i managed to change a plugin to do what i want, but there is another problem. If i change the text in the file, the content shown in game is updated only if i change the map. i want on the same map, if i change the content of txt file to update

jimaway 06-16-2011 09:51

Re: amxx plugin read from file
 
if you want to display in chat you have to use sockets, if you want to use in motd:
Quote:

<html>
<head>
<title>Motd</title>
</head>
<body bgcolor="#000000" scroll="no">
<meta http-equiv="Refresh" content="0;url=http://www.cite.com/text.txt ">
</body>
</html>

florin123 06-16-2011 10:11

Re: amxx plugin read from file
 
i only want chat. So the fact is i have a radio station and everytime the song changes it uploads the name to music.txt from amxmodx/configs.

And when i write on chat /song i want a plugin that reads from music.txt and display on chat current song. But till now it only shows me the same song even if music.txt changes. In game it updates only at changemap

Devil259 06-16-2011 10:28

Re: amxx plugin read from file
 
Code:
#include < amxmodx > new const UrlFile[ ] = "http://www.cite.com/text.txt" public plugin_init( ) {      register_clcmd( "say /readfile" , "ClientCommand_ReadFile" ) } public ClientCommand_ReadFile( id ) {      show_motd( id , UrlFile ) }

You can try this, but replace the url of your site in the constant. (line 3)

florin123 06-16-2011 10:47

Re: amxx plugin read from file
 
thank you! it works, but can you make it write on chat not motd?

Devil259 06-16-2011 10:54

Re: amxx plugin read from file
 
Use client_print( ) or show_hudmessage( ).

Exolent[jNr] 06-16-2011 11:13

Re: amxx plugin read from file
 
You would have to download the file to your server using sockets module, then read the text from the file and display it in the message.
Putting the URL in the client_print() or show_hudmessage() would only display the URL.

Devil259 06-16-2011 11:17

Re: amxx plugin read from file
 
Quote:

Originally Posted by Exolent[jNr] (Post 1489405)
Putting the URL in the client_print() or show_hudmessage() would only display the URL.

I would say he can copy the text in the print or hudmessage.

florin123 06-16-2011 12:06

Re: amxx plugin read from file
 
i don`t need to download because i have a ftp script that updates music.txt everytime the song changes. All i need to do is read the contents when a player writes on chat /song .


All times are GMT -4. The time now is 23:33.

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