Xeno Posted January 26, 2012 Share Posted January 26, 2012 Would it be possible to get text from a website and insert it on a memo automatically? So say if I had a webpage with just text on it, and edited it a bit, it would automatically change the memo ingame. Is this possible? If so, please tell me how ;3 Thanks, Xeno. Link to comment
Castillo Posted January 26, 2012 Share Posted January 26, 2012 You would need to update it with a timer or something. Link to comment
Xeno Posted January 26, 2012 Author Share Posted January 26, 2012 Could I make a command which loads the webpage instead? Link to comment
Castillo Posted January 26, 2012 Share Posted January 26, 2012 I don't get what do you mean. I actually never sent data from a webpage to MTA server. Link to comment
Cadu12 Posted January 26, 2012 Share Posted January 26, 2012 It is possible, use callRemote, PHP and setTimer every time. Link to comment
Xeno Posted January 26, 2012 Author Share Posted January 26, 2012 It is possible, use callRemote, PHP and setTimer every time. Seems to complicated for me... I'll just update the GUI every once and a while... Thanks guys! Link to comment
BriGhtx3 Posted January 27, 2012 Share Posted January 27, 2012 You can also just use SQL oO Link to comment
FatalTerror Posted January 27, 2012 Share Posted January 27, 2012 (edited) It is possible, use callRemote, PHP and setTimer every time. callRemote + setTimer = Suicide If you want get a text from your website, try something like that Client-side: thememo = guiCreateMemo(0.5,0.5,1,1, "", false) addEvent("WriteOnTheMemo", true) addEventHandler("WriteOnTheMemo", getRootElement(), function(text) if text then guiSetText(thememo, tostring(text)) end end) Server side: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() setTimer(getWebsite, 10000, 0) end) function result(content) if content then triggerClientEvent("WriteOnTheMemo", getRootElement(), content) end end function getWebsite() local tralala = 1 callRemote("http://www.yourwebsite.com/file.php", result, tralala) end <?php include("mtalibrary.php"); $input = mta::getInput(); $tralala = $input[0]; if($tralala == 1){ // You get your informations about your website etc // and you return the content $content = "My website !"; mta::doReturn($content); } ?> Edited January 27, 2012 by Guest Link to comment
Xeno Posted January 27, 2012 Author Share Posted January 27, 2012 With that example Fatal, if I had a blank webpage with "hello" on it, it would show up in the Memo as "Hello"?? Link to comment
FatalTerror Posted January 27, 2012 Share Posted January 27, 2012 With that example Fatal, if I had a blank webpage with "hello" on it, it would show up in the Memo as "Hello"?? Hm yes it's possible. But it will be plain text You can do it using the PHP function file_get_contents Look this example i made: <?php // PHP File $content = file_get_contents('mypage.php'); if(isset($content)){ echo html2text($content); } else{ echo "No content "; } function html2text($html) { $tags = array ( 0 => '~<h[123][^>]+>~si', 1 => '~<h[456][^>]+>~si', 2 => '~<table[^>]+>~si', 3 => '~<tr[^>]+>~si', 4 => '~<li[^>]+>~si', 5 => '~<br[^>]+>~si', 6 => '~<p[^>]+>~si', 7 => '~<div[^>]+>~si', ); $html = preg_replace($tags,"\n",$html); $html = preg_replace('~</t(d|h)>\s*<t(d|h)[^>]+>~si',' - ',$html); $html = preg_replace('~<[^>]+>~s','',$html); // reducing spaces $html = preg_replace('~ +~s',' ',$html); $html = preg_replace('~^\s+~m','',$html); $html = preg_replace('~\s+$~m','',$html); // reducing newlines $html = preg_replace('~\n+~s',"\n",$html); return $html; } ?> It work perfectly... Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now