Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

PlayerPortraits spawned with scripting show up with correct IProfile in Map Editor, but with a random one outside of it

Share questions, scripts and tutorials related to the ScriptAPI in SFD.
Forum rules
By using the forum you agree to the following rules.
Post Reply
MCS
Meatbag
Posts: 1
Joined: Sat Dec 24, 2022 1:42 pm

PlayerPortraits spawned with scripting show up with correct IProfile in Map Editor, but with a random one outside of it

Post by MCS » Sat Dec 24, 2022 2:07 pm

I have a simple script that creates a PlayerPortrait, and gives it a PlayerProfileInfo (by getting the appropriate IObjectPlayerProfileInfo from the map). This works fine in the editor, but if I start a game with this map, the portraits are randomized.
Things I've tried:
  • If I manually set the PlayerPortrait to use the profileinfo from the map, it works just fine. (However I need to be able to use scripts to change the playerprofileinfo)
  • If I set the Players skin to the profileinfo, it works--> It's not the PlayerProfileInfos getting randomized
  • If I check how many possible profiles the portrait has (.GetProfileInfos.Length), it returns 1 (which is correct), and if I don't add the profileinfo it is 0 (which is also what it should be)
Simple code to demonstrate:

Code: Select all

public void OnStartup() {
	IObjectPlayerPortrait portrait=(IObjectPlayerPortrait)Game.CreateObject("BgPlayerPortrait00");
	portrait.SetProfileInfo(Game.GetObject<IObjectPlayerProfileInfo>("profile"));
}
Create a blank world with an IObjectPlayerProfileInfo with a customid of "profile", and run this script to test.
Has anyone encountered anythin similar before? What could be causing it?
1 x

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Sun Dec 25, 2022 4:23 am

That sounds exactly like a bug. Plenty of things that work in the editor, but if you are hosting a real game scripts can fail. Just like if you spawn a player via PlayerSpawnTrigger and set his FacingDirection to (-1), in the editor it works, but hosted game it will always face toward (1). If i recall correctly.
Or setting Primary and secondary Target with CameraAreaTrigger via script.
These things can cause you serious headaches and waste your time.
0 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

User avatar
Odex64
Superfighter
Superfighter
Posts: 172
Joined: Sat Jul 29, 2017 12:39 pm
Title: Content Creator
SFD Account: Odex64
Started SFD: PreAlpha
Location: Italy
Gender:
Age: 22

Post by Odex64 » Sun Dec 25, 2022 9:20 am

Technically it should work just fine if you're hosting an "offline" game too. Many things don't work due to synchronization issues I guess; in fact when hosting a server your PC behaves as a server AND client

But yeah, bugs like that were annoying when I used to script.
0 x
Image

Post Reply