ItsDeltin / Overwatch-Script-To-Workshop

Converts scripts to Overwatch workshops.
207 stars 24 forks source link

can't set player var with the type of Player[] #450

Closed Erythritee closed 1 year ago

Erythritee commented 1 year ago
void get_infect(in Player | Player[] p){

    p.isInfect[0] = 1;
    p.isInfect[1] = TotalTimeElapsed();
}

and get :The variable 'isInfect' cannot be set in the current context

when I remove the Player[] , it worked so how could I set the player var with the Player[] type in function?

ItsDeltin commented 1 year ago

Hello, sorry for the late response. Replace in with ref.

void get_infect(ref Player | Player[] p) {

    p.isInfect[0] = 1;
    p.isInfect[1] = TotalTimeElapsed();
}

https://github.com/ItsDeltin/Overwatch-Script-To-Workshop/wiki/Methods,-Macros-and-Subroutines#ref

Erythritee commented 11 months ago

but is still can't use like this:

void Show(ref Player | Player[] p){
    p.showCursor = true;
}

rule: 'My Rule'
{
    Show(AllPlayers());
}

Expected a variable.