Page 1 of 1

I need a script for get player's profile info

Posted: Wed May 13, 2020 7:46 pm
by Elhombreserio
I'm noob in C#, if anybody has an script for get profile(refer to clothes, accessory) please share!!
Thanks in advance :D 8-)

Re: I need a script for get player's profile info

Posted: Wed May 13, 2020 10:26 pm
by Odex64
JakSparro98 wrote:
Sat Jul 07, 2018 9:41 pm
MrWheatley wrote:
Wed Jul 04, 2018 8:44 pm
JakSparro98 wrote:
Wed Jul 04, 2018 5:59 pm

The Skin attribute in the IProfile class can change the skin color, you need to copy the current player profile, change the copy and then re-assing the latter to the player with SetProfile. You will only get the skin color changed keeping the clothings.

Provide your current code if you need help about implementing this function.
So I have to get they player's profile or the custom one, and what exactly do I have to change?
This is what I came up with but it only changes the skin to the default color.

Code: Select all

        public void ButtonPressed (TriggerArgs args)
        {
            foreach (IPlayer ply in Game.GetPlayers ())
            {
                if (args.Sender is IPlayer)
                {
                    IObject a = Game.CreateObject ("PlayerProfileInfo", new Vector2 (0, 0));
                    a.CustomId = "a";
                    ply.SetProfile (((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId ("a")).GetProfile ());
                    IProfile ScoutProfile = new IProfile ();
                    ScoutProfile.Accesory = new IProfileClothingItem ("DogTag", "ClothingGray");
                    ScoutProfile.Head = new IProfileClothingItem ("Cap", "ClothingGray");
                    ScoutProfile.ChestUnder = new IProfileClothingItem ("TShirt", "ClothingRed");
                    ScoutProfile.Hands = new IProfileClothingItem ("FingerlessGloves", "ClothingLightGray");
                    ScoutProfile.Legs = new IProfileClothingItem ("Pants", "ClothingGray");
                    ScoutProfile.Feet = new IProfileClothingItem ("ShoesBlack", "ClothingLightGray");
                    ply.SetProfile (ScoutProfile);
                }
            }
        }
Since you're changing the entire player profile with a costum one you only need to add ScoutProfile.Skin=new IProfileClothingItem("Normal","Skin4"); before ply.SetProfile (ScoutProfile);

You can choose the skin type from Skin0 to Skin4.

With just a brief research on forums you can find some scripts about clothes and Skins, however since you're a newbie I'll slightly edit the code so you can use it almost anywhere.

Code: Select all

public void ButtonPressed(TriggerArgs args)
{
    foreach(IPlayer ply in Game.GetPlayers())
        if(args.Sender is IPlayer)
            ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("myskin")).GetProfile());
}
Just open map editor, place a button and type "ButtonPressed" in ScriptMethod box; then create a (Player Profile Info) and name it "myskin" in "CustomID" box.

From now on, whenever you press that button you will get your custom profile.

Re: I need a script for get player's profile info

Posted: Fri May 15, 2020 2:39 am
by Elhombreserio
Thanks man!!, but I need the same but with multiple player spawn (For example 4 players :D )

Re: I need a script for get player's profile info

Posted: Fri May 15, 2020 1:47 pm
by Odex64
Here's a very simple script for 4 players

Code: Select all

public void Button1(TriggerArgs args)
{
    IPlayer ply = (IPlayer) args.Sender;
    ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("skin1")).GetProfile());
}
public void Button2(TriggerArgs args)
{
    IPlayer ply = (IPlayer) args.Sender;
    ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("skin2")).GetProfile());
}
public void Button3(TriggerArgs args)
{
    IPlayer ply = (IPlayer) args.Sender;
    ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("skin3")).GetProfile());
}
public void Button4(TriggerArgs args)
{
    IPlayer ply = (IPlayer) args.Sender;
    ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("skin4")).GetProfile());
}
Just type "Button1" in Script Method for the first button, then "Button2" for the second and so on...
Remember to place 4 Profile Infos and assign them "skin1", "skin2" CustomID etc..

If you want to add more skins copy and paste the first piece of code and change its number, ex: Copy the Button1 code and change it to Button5 and skin5

Re: I need a script for get player's profile info

Posted: Mon May 18, 2020 9:27 pm
by Elhombreserio
:), the script gives me an error
look https://i.imgur.com/S2dVmBA.png :roll:

Re: I need a script for get player's profile info

Posted: Mon May 18, 2020 10:12 pm
by Odex64
Use the following code:

Code: Select all

public void ButtonPressed(TriggerArgs args)
{
    IPlayer ply = (IPlayer) args.Sender;
    switch (((IObject) args.Caller).CustomId)
    {
        case "1":
            ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("Skin1")).GetProfile());
            break;

        case "2":
            ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("Skin2")).GetProfile());
            break;

        case "3":
            ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("Skin3")).GetProfile());
            break;

        case "4":
            ply.SetProfile(((IObjectPlayerProfileInfo) Game.GetSingleObjectByCustomId("Skin4")).GetProfile());
            break;

        default:
            Game.ShowChatMessage("Error", Color.Cyan);
            break;
    }
}
Paste this code in your map, then place 4 Buttons and type "ButtonPressed" in Script Method for all the buttons; then type "1" in Object ID for the first button, "2" in Object ID for the second button, and so on..

and place 4 PlayerProfileInfo and type "Skin1" in Object ID (for the first ProfileInfo); type "Skin2" in Object ID for the second ProfileInfo, etc..

Now you're finally done. I hope..

Re: I need a script for get player's profile info

Posted: Mon May 18, 2020 10:45 pm
by Elhombreserio
Don't work For my Map But Thanks Anyway

Re: I need a script for get player's profile info

Posted: Mon May 18, 2020 10:46 pm
by Odex64
Elhombreserio wrote:
Mon May 18, 2020 10:45 pm
Don't work For my Map But Thanks Anyway
Add me on discord:
Hidden Content
This board requires you to be registered and logged-in to view hidden content.