Page 3 of 6 FirstFirst 1 2 3 4 5 ... LastLast
Results 21 to 30 of 51

Thread: Writing to file?

  1. #21
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    260

    Default

    Please explain how this could happen. Provide your code that produces this outcome, because I'd have to put in some intentional effort to replicate your result. Maybe I just don't know what you mean.
    Originally Posted by Bale View Post
    It doesn't happen. I was wondering if there was a way to MAKE it happen...

  2. #22
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,273

    Default

    Yes. Sure. Build the string yourself.

    Code:
    string player_list;
    foreach player in clannies {
       if(length(player_list) > 0)
          player_list += ", ";
       player_list += player
    }

    Then do whatever you wish with that string. My advice should stop there because I don't know where you're going with this. But for example, if you want to use player_list as the information to save to a file, then you need a key (the date?) to use as the first field. Like...

    Code:
    string [string] save_data;
    file_to_map("whosinclan.txt", save_data );
    
    string player_list;
    foreach player in who_clan() {
       if(length(player_list) > 0)
          player_list += ", ";
       player_list += player
    }
    
    save_data[ now_to_string("yyMMddHHmmss" ) ] = player_list;
    map_to_file( save_data, "whosinclan.txt");

  3. #23
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,755

    Default

    PHP Code:
    {
    boolean [stringclannies who_clan();
    foreach 
    clannie in clannies {

    map_to_fileclannies "whosinclan.txt" );

    Originally Posted by Pazleysox View Post
    Do I read that wrong, or does it really write (and rewrite) the enire file N times (where N is number of clannies)?

  4. #24
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    260

    Default

    Do I read that wrong, or does it really write (and rewrite) the enire file N times (where N is number of clannies)?
    Originally Posted by xKiv View Post
    Yep, hadn't noticed that before. Lol!

  5. #25
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    260

    Default

    Can I k-mail the contents of a map?

  6. #26
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,273

    Default

    Technically you could, but I really don't think it would be advantageous, especially since important tab characters will be removed. Unless you didn't care about the person receiving the kmail being able to reliably reconstitute the map, in which case.. Yay, go for it!

    As with most of your questions I just don't have the context to be sure my answer is right for your needs. Perhaps you could try telling us the problem so that we can find a good solution rather than ask if your solution will answer an unknown problem.

  7. #27
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    260

    Default

    I'm working on a chatbot for my clan. Someone brought up today that they would love to have a list of players that have helped in Dreadsylvania in the past, and what class they currently are now. (Knowing their level too would be really nice)

    I've figured out how to code players names, and class, into a map. I don't think figuring out what level someone is with all the custom titles though.

    I want the bot to do a search, and send the requester a printout when requested.

  8. #28
    Developer
    Join Date
    Aug 2009
    Posts
    2,709

    Default

    Checking said player's clan is much easier than checking profile.

    searchplayer.php also works.

  9. #29
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    260

    Default

    Checking said player's clan is much easier than checking profile.

    searchplayer.php also works.
    Originally Posted by heeheehee View Post
    PHP Code:
    string page visit_url("searchplayer.php?searching=Yep.&searchstring="+playerName+"&searchlevel=&searchranking=&hardcoreonly=0");
    string page visit_url("searchplayer.php?searching=Yep.&searchstring="+url_encode(player)+"&searchlevel=&searchranking=&hardcoreonly=0")

    I found these 2 snippets of code in the forums. Neither of them work, because the searchplayer.php opens in a new tab, which mafia doesn't like, and if I force it in a mini browser, I get logged off...

    I can't figure out how to check a players clan.

    PHP Code:
    ashref clan

    void chat_clan
    ( string )
    void chat_clanstringstring )
    int get_clan_id( )
    int [itemget_clan_lounge( )
    string get_clan_name( )
    int [stringget_clan_rumpus( )
    boolean [stringwho_clan( ) 
    Code:
    string get_clan_name()
    
    Returns the clan name for the logged-in character.
    played around with this for a bit today... Couldn't figure it out.
    Last edited by Pazleysox; 04-05-2017 at 12:53 PM. Reason: php

  10. #30
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    260

    Default

    Ok, I've figured out how to get the info I want into a map, I've figured out how to recall that info, and I've figured out how to send it via k-mail.

    I'm trying now to figure out how to get all the data onto one line, separated with "," like the code above that Bale gave me.

    I'm also still trying to figure out how to get players level.
    PHP Code:
    int [itemmap;
    map[$item[adder]] = 0;
    boolean [stringmyclass;
    string [intordinal;
    string [intmy_list;
    string paz visit_url"showplayer.php?who=352918".to_string() );
    {

        if(
    paz.contains_text $class[sauceror])) 
        {    
    ordinal [0] = "paz is a sauceror";    }
        if(
    paz.contains_text $class[pastamancer]))
        {    
    ordinal [0] = "paz is a pastamancer";    }
        if(
    paz.contains_text $class[disco bandit]))
        {    
    ordinal [0] = "paz is a disco bandit";    }
        if(
    paz.contains_text $class[accordion thief]))
        {    
    ordinal [0] = "paz is a accordion thief";    }
        if(
    paz.contains_text $class[turtle tamer]))
        {    
    ordinal [0] = "paz is a turtle tamer";    }
        if(
    paz.contains_text $class[seal clubber]))
        {    
    ordinal [0] = "paz is a seal clubber";    }

        
    string cowmanbob visit_url"showplayer.php?who=840337".to_string() );
    {
        if(
    cowmanbob.contains_text $class[sauceror])) 
        {    
    ordinal [1] = "cowmanbob is a sauceror";    }
    map_to_file ordinal"searchplayerbot.txt");
    print(
    "File mapped");

    file_to_map"searchplayerbot.txt" my_list);
    for 
    i from 0 to (count(my_list) - 1) {
       print( 
    my_list[i] );
        
    kmail("pazsox"my_list[i], 0map); 
    Now I'm sure those who understand coding better than I do can make this easier, but I figured it out on my own, and I'm quite happy with that.

    Here's my output:
    Code:
    searchplayerbot.txt
    0	paz is a seal clubber
    1	cowmanbob is a sauceror
    
    k-mail:New! From PazSox (#352918) [reply] [quoted]
    Date: Wednesday, April 05, 2017, 10:52AM
    
        cowmanbob is a sauceror
    
    	New! From PazSox (#352918) [reply] [quoted]
    Date: Wednesday, April 05, 2017, 10:52AM
    
        paz is a seal clubber
    I would like to see:
    cowmanbob is a sauceror, pazsox is a seal clubber, etc...
    Last edited by Pazleysox; 04-05-2017 at 03:53 PM. Reason: [/code]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •