Jump to content

Memo to webpage


Xeno

Recommended Posts

Posted

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.

Posted

You would need to update it with a timer or something.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I don't get what do you mean.

I actually never sent data from a webpage to MTA server.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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!

Posted (edited)
It is possible, use callRemote, PHP and setTimer every time.

callRemote + setTimer = Suicide :mrgreen:

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 by Guest

Paid developer. Twitter: @willia_am -

http://www.williamdasilva.fr
Posted
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 :roll:

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...

pageloader.jpg

Paid developer. Twitter: @willia_am -

http://www.williamdasilva.fr

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...