You seem a bit confused at how exactly vars "work".
Say for example you have a script tile in A-map, the var number is 4011 and the var value is 0000 (in script form, var value 0000 is displayed as 0x0)
What this is saying, is the script will only activate if the var 4011 is set to 0 (and all vars are set to 0 at the start of the game)
So when, at the end of the script, you use the command "setvar 4011 0x1". From this point on, the var 4011 will stay at value 0x1 (or 0001 in a-map terms) until you dictate otherwise.
It's good to know this as vars can be used to make a sequence of events by just changing one var. So now that your script has changed var 4011 to 0x1, the first script tile will no longer trigger because var 4011 is no longer at value 0x0.
So you can use another script tile that you intend to be launched later on in the game, but only after the rival battle, you would set that tile scipts var number to 4011 (same as before) but this time giving it a var value of 0001 (0x1 in script form). This script won't run from the beginning, but only after the initial rival battle, at the end of which you'll have set var 4011 to 0x1.
I hope this rambling guide will help you understand better combined with KitSuv's.
Another note on vars. It can be confusing that sometimes you'll see vars behave completely differently (such as when renaming Pokemon). This is because, like flags, some vars have very speficic uses. Have a look here:
https://www.pokecommunity.com/threads/302347 to see which flags and vars do what. You can also find out which ones are "safe" to use there.
It's not just script tiles that can use vars effectively. Talking to people scripts can use them also. E.g.
#dynamic 0x800000
#org @start
checkvar 4011 0x1
if 0x1 goto @finished
Msgbox "Hello I am an example"
setvar 0x4011 0x1
release
end
#org @finished
Msgbox "Hey you already spoke to me"
release
end
In this example, it checks if var 4011 is at value 0x1
It sees that it isn't, as it is at value 0x0
It then shows the first message, and sets the var 4011 to 0x1
You talk to the npc again, it checks if 4011 is set to 0x1
It is, because you told it to at the end of the script the first time you spoke to them
It now goes to the script @finished and shows the second message instead.
(note I was lazy writing the example and of course msgbox scripts don't look like that lol)
This can be used for many story and "quest" purposes.