#Model Replacement API & SDK

6053 messages · Page 7 of 7 (latest)

delicate glade
#

like if i just pass the suit id through like this everyone will run this themself

#

so itll always be true since no matter what everyone will have the code run and itll be like yup you are wearing the suit youre wearing

#

i must just be fundamentally misunderstanding how this code is run or something

eager mural
#

as its inside of Start() it will run after the object is created for each client so yes

delicate glade
#

yeah so how do i only run it for the player who equipped the suit

eager mural
#

check if its the local player xD

#

but wait

delicate glade
#

that wont work

#

because everyone runs it

eager mural
#

ye

#

i just remembered because its all a local spawn

#

what you tryng to do with this btw?

delicate glade
#

camera height adjustments

#

currently when someone equips a suit its meant to adjust your camera height but it does it to everyone

#

so i want that code to only run for the player who equipped that suit

eager mural
#

well you could add a check for if the local player suitID is the suitid of the suit

#

or well the suitname in your case

#

as that probs be more accurate

delicate glade
#

how would i check that though? like how does the code know its that suit

#

since that function runs for everyone regardless of what suit theyre wearing

eager mural
#

if (StartOfRound.Instance.unlockablesList.unlockables[player.currentSuitID].unlockableName.Equals("Default") ||
StartOfRound.Instance.unlockablesList.unlockables[player.currentSuitID].unlockableName.Equals("Orange suit"))

#

so in the player spot you put in the localplayer

#

and for the.equals the suit name you want

#

aka you can modify this to feed of the config for the suit ya know

delicate glade
#

like this..?

eager mural
#

move the model replacement part to the line below it tabbed once

#

it should auto do it when you add a enter to it but ye

#

just makes it more clear to read what the if statement is doing

delicate glade
#

oh neat

eager mural
#

but other than that it will prevent your function from executing on other clients

delicate glade
#

actually maybe i can just do this

#

so i dont have to keep retyping the name multiple times for each of the 100 suits

#

and every new suit i add

eager mural
#

either works if you got a config use the config value for the suit

delicate glade
#

nope no configs

eager mural
#

and you could just make the entire thing into a function call ya know

#

where you just feed in the suitname into the function and it does the check inside of it

#

so you just got a single function call to use for all your stuff

delicate glade
#

true

#

there we go

#

now the check is in here

#

unless i can somehow move all these overrides somewhere else?

#

though idk if thats possible

delicate glade
#

had to do some trickery since i add spaces for the suit textures ingame but in theory this line should work:
string currentSuit = StartOfRound.Instance.unlockablesList.unlockables[GameNetworkManager.Instance.localPlayerController.currentSuitID].unlockableName.Replace(" ", "");

#

(replaces all spaces with nothing, essentially just removing them)

delicate glade
#

okay nvm ive hit a wall again

#

the problem is when you equip a suit that doesnt have these height adjustments your camera is supposed to be reset to normal, but of course yes this code runs for everyone with the mod so when a player equips one of those suits everyone is set to that height... reasonable idea would be put the same code in but the thing is when this runs youve already swapped suits so i cant check what the suit is gonna magically be in the future

delicate glade
#

nvm it doesnt work at all

#

trying something else

#

with some help i have determined that checking for thisController in playercontrollerb and passing that through works!

eager mural
#

xD

#

OnDestroy you can restore default view too

#

xD