1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

Closed API.getPlayerByName return null always

Discussion in 'Solved & Closed' started by ATomas, May 3, 2017.

  1. ATomas

    ATomas Active Member

    Messages:
    61
    Likes Received:
    1
    Joined:
    Apr 4, 2017
    Title:
    API.getPlayerByName return null always
    What's wrong?:
    API.getPlayerByName return null always in client side (JavaScript)
    What should normally happen?:
    Normaly return data in Client type
    How to reproduce the issue:
    repair it
     
  2. BigJay

    BigJay Well-Known Member Donator Support

    Messages:
    131
    Likes Received:
    29
    Joined:
    Jan 23, 2017
    Can you provide any further information? A snippet of your code?
     
  3. ATomas

    ATomas Active Member

    Messages:
    61
    Likes Received:
    1
    Joined:
    Apr 4, 2017
    This is code:

    Code:
    API.onChatCommand.connect(function(msg)
    {
        if(msg == "/show")
        {
            var mynick = "ATomasRZE";
            var me = API.getPlayerByName(mynick);
            var name = API.getPlayerName(me);
            API.sendChatMessage("me="+me+" name="+name);
        }
    });
    Result is:
    "me=[oject HostObject] name=null"
     
  4. BigJay

    BigJay Well-Known Member Donator Support

    Messages:
    131
    Likes Received:
    29
    Joined:
    Jan 23, 2017
    It looks as though it should work. I will test it when I am home for you to see if I get the same result.
     
  5. Icaro

    Icaro Active Member

    Messages:
    59
    Likes Received:
    36
    Joined:
    Oct 20, 2016
    Iirc on the clientside this method uses social club names. It does work.
     
  6. ATomas

    ATomas Active Member

    Messages:
    61
    Likes Received:
    1
    Joined:
    Apr 4, 2017
    "ATomasRZE" it's my social club nickname, but getPlayerByName doesn't work.
     
  7. T3charmy

    T3charmy Member

    Messages:
    6
    Likes Received:
    1
    Joined:
    Dec 4, 2016
    I looked into the code regarding this. Here's how it works: You do not look for them by social club name, you use what their in-game username is and the player you're requesting has to be in stream range.
     
  8. Nildius

    Nildius Member

    Messages:
    13
    Likes Received:
    0
    Joined:
    Sep 30, 2016
    Same problem here. How can i solve that?

    Im using getPlayerByName with my own name and the function returns null

    Can you help me pls?
     
  9. T3charmy

    T3charmy Member

    Messages:
    6
    Likes Received:
    1
    Joined:
    Dec 4, 2016
    I will look closer into the code behind this and get back to you on this.
     
  10. Nildius

    Nildius Member

    Messages:
    13
    Likes Received:
    0
    Joined:
    Sep 30, 2016
    Thanks for your answer. The function works great if the parameter is another user. If i send my own name to "getPlayerByName", the function returns null.

    I know this may sound ridiculous because if I want to get my player, I can use getLocalPlayer, but I tried to test getPlayerByName with my name and didn't work.

    If that is correct I think the documentation should say it

    Sorry for my bad English. I'm from Argentina :=)
     
    Last edited: May 30, 2017
  11. GabEPL

    GabEPL New Member

    Messages:
    3
    Likes Received:
    0
    Joined:
    Apr 18, 2017

Share This Page