I’m trying to make a logic variable for each player and I want to edit it. For example:(if x=y): set Agent’s variable to true. Can help on this, been struggling to make this work
Hey again, will try to do simpler this time :
@editable Spawners : []player_spawner_device = array{}
var MyLogicMap : [player]logic = map{}
# In your OnBegin
for (Spawner : Spawners):
Spawner.SpawnedEvent.Subscribe(OnPlayerSpawned)
# Outside OnBegin
OnPlayerSpawned(Agent: agent):void=
if(Player := player[Agent]):
option{set MyLogicMap[Player] = false}
You’ll then check your map using :
if(MyLogicMap[Player]?):
# Do code
Yeah I think I understand that now, just one thing, what dot
you mean by check your map. t
Thanks a lot for helping
Check that the value of your logic for player is either true or false.
if(MyLogicMap[Player]?):
# My Value For Player is TRUE
else:
# My Value For Player is FALSE
I’m trying to call that in another function but Player is not defined. Do I need to rewrite this inside of this function?
if(Player := player[Agent]):
option{set MyLogicMap[Player] = false}
Can you paste the error that’s showing, paste your code too if you can, I’m pretty sure that Player is defined in this case
OnPlayerSpawned(Agent: agent):void=
if(Player := player[Agent]):
option{set DidPlayerVoteMap1[Player] = false}
option{set DidPlayerVoteMap2[Player] = false}
voteMgt1(Agent:agent):void=
if(DidPlayerVoteMap1[Player]?):
Print("Already voted on this map")
else:
if(DidPlayerVoteMap2[Player]?):
set VotesForMap1 += 1
set VotesForMap2 -= 1
ScoreManager1.SetScoreAward(VotesForMap1)
ScoreManager2.SetScoreAward(VotesForMap2)
Switch1.TurnOn(Agent)
Switch2.TurnOff(Agent)
else:
set VotesForMap1 += 1
ScoreManager1.SetScoreAward(VotesForMap1)
Switch1.TurnOn(Agent)
The votemgt1 function checks for if the player voted if he didnt, does what’s inside else.
The error is: Unknown identifier ‘Player’
Replace by if(Player := player[Agent], DidPlayerVoteMap1[Player]?):
Maybe take a lesson or two about Verse also when you have time because these are pretty basic skills.
Also as an explanation, Player
is not declared in this scope, you only have access to Agent
, but you need a player
. Since player
variables are children of agent
variables, you can try to convert from agent to player doing player[Agent]