I’ve been messing with the workshop for a while in basic stuff, but I wanted to make modes that contain more complicated things, susch as variables.
I know that if you set variable as a hero or a number it helps you a lot, and from what I understood so far, you can set a global variable as a number and then base your rules with the variable instead of the number
I tried to set global variables as random heroes, and then make actions on the global variables themselves.
these are the first actions I made -
set global variable(A, random value in array, (allowed heroes (event player)))
set global variable(B, random value in array, (allowed heroes (event player)))
and in the second rule -
has spawned(global variable(A)) == true
and the action is kill
I thought that one of the 2 heroes I enabled will die instantly when spawned, but nothing happened
is it just a mistake or did i missunderstood the whole global variable point?
pls help D:
There might be an issue with the order, or that you execute the first two actions too early. If you share your gamecode I could take a look into it to find the issue.
0DJVB
it’s just a test mode for the variables, when one of the heroes is using primary they should die
Here it is: 25YK9
But I dont know whether it is the behaviour you want. Now each player has an individual hero wich is allowed and one that isnt (will kill him on primary fire).
The explanation: At first you are trying to set the global variable A to a random allowed hero. But it is performed in an each player rule, wich gets executed for each player in the match individually. So you overwrite the variable multiple times. I changed it to a player variable of event player, wich is directly tied to the player who is executing the rule. So for each player his personal variable A has an individual random hero of the allowed heros array.
In the second rule you want to check if the player is on the random hero and firing primary right? But you need to do that in 2 different conditions. The first checks whether the event player is using his primary fire and the second condition checks whether the player is playing the randomly chosen hero.
You can imagine it this way. Each player has a set of variables = a set of storage for data. All the values in the variables belong to the player. But also the match/server/gamemode has a set of variables, wich are the global variables.
Theoretically player 1 could store his values in the variables of player 2 etc. But as this would be very confusing, it is a good idea to use the variables as if it was restricted that way, that each player could only access his own variables and only the global variables could be used by everyone.
Ok, i think i kinda get it now, differences between player variables and global ones.
thank you btw!
edit:
i managed to set 2 variables for 2 different players, A & B
i also did an action that causes the hero of variable A to die when he’s crouching
and the hero of variable B to die when he’s moving.
here is the code: 868FF
the problem is that sometimes the game sets the 2 variables on the same hero (when he’s crouching and when he’s moving he will die)
can I do that each player gets a different variable, with different effects, like a role?