AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   substring ! substr(txt,start,end) ? (https://forums.alliedmods.net/showthread.php?t=128242)

ÜnLoCo 05-30-2010 09:52

substring ! substr(txt,start,end) ?
 
Hello Guys :D
as you see i'm looking for something simple and useful !
let's say i read this html
http://graph.facebook.com/4
and i want to get just the "name" variable !
which is the function to do that ?
i'm not asking for ready to paste code but just the usage of the function !
the closest thing i got from searching is regex_substr !
is there a simpler way ?
thank youu

Bugsy 05-30-2010 10:39

Re: substring ! substr(txt,start,end) ?
 
Take a look at these; strfind will return the position of a string within a string.

http://www.amxmodx.org/funcwiki.php?go=inc&id=5

ÜnLoCo 05-30-2010 13:06

Re: substring ! substr(txt,start,end) ?
 
Thank You
i had to use regex and strtok !
i do a request by ID and get the name of the user
anybody find his code .. thanks !

PHP Code:

new g_Socket1;
public 
getPlayerDetails(id,fbacc)
{
    new 
Error;
    
g_Socket1 socket_open("graph.facebook.com",80,SOCKET_TCP,Error);

    
    new 
Data1[512];
    
formatex(Data1,511,"GET /%d/ HTTP/1.1^r^nHost:graph.facebook.com^r^nConnection: close^r^n^r^n",fbacc);
    
socket_send(g_Socket1,Data1,511);
    new 
params[2];
    
params[0] = id;
    
params[1] = fbacc;
    
set_task0.5 "CheckForData1" TASK_RECV1 params2"b");
}

public 
CheckForData1(args[])
{
    static 
Data[256]; 
    if ( 
socket_changeg_Socket1 ) )
    {
        
socket_recvg_Socket1 Data 255 );
        {    
            if ( 
containiData "first_name" ) != -1){
            new 
pattern[] = "^"name^":^"(.+)^",^"f"
 
        new num, error[128]
        //str = string
        //pattern = pattern to use
        //num = special return case code
        //error = if there's an error, it will go here
        //127 - error's max length
        new Regex:re = regex_match(Data, pattern, num, error, 127)
        if (re >= REGEX_OK){
            new str2[64]
            new i=0
            regex_substr(re, i, str2, 63)
            new left[200]
            new right[200]
            strtok(str2,left,199,right,199,':')
            strtok(right,left,199,right,199,',')
            new Html[200]
            new fba = args[1]
            new id = args[0]
            format(Html,199,"
<div align=center><b>%s</b><br/><img src=^"http://graph.facebook.com/%d/picture?type=large^"/><br/><i>Copy Profile Link From Console !</i></div>",left,fba)
            show_motd(id,Html,"
Add As Friend")
        }
        remove_task( TASK_RECV1 );
        return PLUGIN_HANDLED;
      }   
        }
    }


getPlayerDetails(id,fbacc) will give you this
//fbacc is the facebook account ID of that user (connected from here http://apps.facebook.com/noexitpro/ )
//id is .. you know

http://www.easy-upload.net/fichiers/...0530165647.png

i still have some problems with weird chars !
it's the next step :o


All times are GMT -4. The time now is 05:19.

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