1. Hey!
    4 example i need to use:
    webrequest.EnqueueGet(url, (code, response) => Work(response, code, 1, ip), this);

    How can i thn get variables of string Work() (results of string Work())??

    4 example in Work i return "Clear" or .. "Error"

    Something like.. that, yeah.

    Plz help ^)
     
    Last edited by a moderator: Oct 13, 2017
  2. Wulf

    Wulf Community Admin

    Not sure what you're asking for exactly, but here's another web request example:
    Code:
    webrequest.Enqueue(url, (code, response) =>
    {
        var work = Work();
        if (work == "whatever") Puts("Hello!");
        Puts(response);
    }, this);
     
  3. wait..
    Code:
    object CanClientLogin(Network.Connection conn)
            {
                    // Bla bla bla
                    webrequest.EnqueueGet(url, (code, response) => Work(response, code, 1, ip), this);
                    // How 2 get HERE what returned Work ?
            }        string Work(string response, int code, int urlID, string ip)
            {
                if (code != 200 || string.IsNullOrEmpty(response))
                {
                    PrintError(GetMsg("Connection: Error"), 1);
                    return "Retry";
                }
               
                // Bla bla other code
                return "Dont know";
            }
    [DOUBLEPOST=1507911326][/DOUBLEPOST]or how 2 do something like that?
     
  4. Wulf

    Wulf Community Admin

    You can't use web requests in CanClientLogin if you expect to get a response in time. CanClientLogin cannot wait for a web request response.
     
  5. :( i just want a response that i have in some ms and to work with this response(
     
  6. Wulf

    Wulf Community Admin

    If you want to do a web request on connection, you'd need to use a hook such as OnPlayerConnected that isn't time sensitive.
     
  7. but i need to do something when user just clicks connect - to block him / ..

    or OnPlayerConnected calls when player clicks Connect? No? If no, when?
     
    Last edited by a moderator: Oct 13, 2017
  8. Wulf

    Wulf Community Admin

    It's after they connected, but that's the earliest you can use a web request and kick them.
     
  9. ok, thx.
    [DOUBLEPOST=1507912114][/DOUBLEPOST]So i neeed to type void OnPlayerConnected .. and just kick player if i need?
    [DOUBLEPOST=1507912295][/DOUBLEPOST]and so, u didnt answer. How to get all what string Work() returns if i call this using webrequest.EnqueueGet(url, .. blabla.. => Work(blabla), this); ?
     
  10. Wulf

    Wulf Community Admin

    You can only return one thing, and I showed how to store that in my example. The code and response are already available in the callback where my example calls the method, even included an example output of the response.
     
  11. Code:
        {
       // Bla bla bla
                    webrequest.EnqueueGet(url, (code, response) => Work(response, code, 1, ip), this);
                    // How 2 get HERE what returned Work ?
            }        string Work(string response, int code, int urlID, string ip)
            {
                if (code != 200 || string.IsNullOrEmpty(response))
                {
                    PrintError(GetMsg("Connection: Error"), 1);
                    return "Retry";
                }
              
                // Bla bla other code
                return "Dont know";
            }
    [DOUBLEPOST=1507912419][/DOUBLEPOST]ok, wait :)
     
  12. Wulf

    Wulf Community Admin

    You made your callback the Work method, so you're not going to be able to get anything after the webrequest call line. The callback is where the info from the web request handling is available, not outside of it.
     
  13. Code:
    void OnPlayerConnected(Network.Message packet)
            {
                // blablabla
                if (webUse1)
                {
                    webrequest.EnqueueGet(url, (code, response) =>
                    {
                        var work = Work(response, code, 1, ip);
                        while (work == "Retry")
                        {
                            Thread.Sleep(5000);
                        }
                    }, this);
                }
            }
    [DOUBLEPOST=1507912806][/DOUBLEPOST]Something like that?
     
  14. hey? :)
     
  15. You can't use System.Threading via RustPlugin.
    And you don't need to do it.
    All you need to do - it's just check him with webrequest and kick him if you need it.
     
  16. but if the server wont answer what i will do? Say Welcome to the server, cheater? And so, what is the difference between RustPlugin and Covalence Plugin?
     
  17. What are we talking about?
    webrequest means, that you will request some server. Request can be canceled, of course.
     
  18. If server (to which i send webrequest) will not answer (Error or anything else) and i need to use webrequest again white it will not be able, what do i need to use? (4 example WebRequest No Answer -> Wait 5s -> WebRequest No Answer -> Wait 5s -> WebRequest ANSWER! done)
    [DOUBLEPOST=1508082097][/DOUBLEPOST]Sorr 4 bad english :) (webrequest.EnqueueGet - I use that)
     
  19. 1. CSharpPlugin.timer
    2. Coroutine via MonoBehaviour
    3. QueueWorkerThread
     
  20. Okay, thx. And what if I will use System.Thread... ? It will freeze all server or just will do nothing?