new script milestone....i guess - a dynamic script
Posted: Sat Jul 09, 2011 12:42 am
have figured out a way to make a script that is somewhat dynamic in its interaction with *all* players on the world when activated by one player.
i don't have the script completed yet, but will try and post it when its done.
anyway, details are as follows:
1 event, not counting events that trigger it. also needs playerlogin and playerlogout events
its size would vary depending on the amount of actions it can perform
it runs *repeatedly* every x seconds, but *only* for players online at the time
playervars used, 1 to detect online status
servervars used, varies based on locations for the script to effect
also need a way to see a players location. this could be via a playervar or via existing town, spawnzone, or team vars.
how it works (theoretical, but should work based on current script options):
starting/stopping:
when a player logs in, the playerlogin event sets an 'online playervar' to 1 then activates the dynamic script.
if a player logs off, is kicked, or autokicked, a playerlogout script will set their 'online playervar' back to 0 and the script stops running for them
Input:
a player performs an action on the world which activates a script
this script would set a 'location servervar' to a value based on the action performed. each action would have a different number for the var to represent
then the output portion does its thing:
-the dynamic script runs every x seconds as long as a players 'online playervar' remains at 1
-the script checks the players location var (or town, spawnzone, etc) to see if it can use it
-if there is an entry in the script for that location, it checks the 'location servervar' for that area to see if there are any actions to perform
i-f it finds that there are, it sends the player a *msg about it or does whatever else is wanted, other players not matching the location will see no messages from the script
-the script then waits x seconds, almost as long as the script loop time to make sure -the script had a chance to run ran for every player online
-the script then sets the 'location servervar' back to 0
-the script reruns every x seconds for the player repeatedly checking to see if there are any new actions to perform for the player in their location
an example:
I'm making this script for the Tower of Terror combat world to add realism and ambiance to it. will likely be adding a version of it to delivery zone as well
-the 20 'floors' of the play area are linked to a playervar with a value of 1-20
-if a player is on floor 7 and 'searches a trashcan' (activating the trigger), the script for the trashcan will set the servervar for floor 7 to 1.
-the dynamic script, running for every player, will see that the servervar for floor 7 is set to 1 and any players who have their playervar set to 7 will receive a message 'you hear a rustling noise coming from somewhere on the floor' to add a bit of ambient realism and indicate to them that they are not alone. players not on floor 7 would get ignored by the script
main issue with this script is that only 1 action can happen at a time per location per script run cycle or messages wont get sent out for some. this is fixed by either making the cycles very fast (like running every 1 or 2 seconds) or by doubling/tripling the vars for each location and modifying the inputs to see of a var is already in use before using a 2nd or 3rd var. the output size would also need to be doubled or tripled then as well to have it check each of those extra vars
i don't have the script completed yet, but will try and post it when its done.
anyway, details are as follows:
1 event, not counting events that trigger it. also needs playerlogin and playerlogout events
its size would vary depending on the amount of actions it can perform
it runs *repeatedly* every x seconds, but *only* for players online at the time
playervars used, 1 to detect online status
servervars used, varies based on locations for the script to effect
also need a way to see a players location. this could be via a playervar or via existing town, spawnzone, or team vars.
how it works (theoretical, but should work based on current script options):
starting/stopping:
when a player logs in, the playerlogin event sets an 'online playervar' to 1 then activates the dynamic script.
if a player logs off, is kicked, or autokicked, a playerlogout script will set their 'online playervar' back to 0 and the script stops running for them
Input:
a player performs an action on the world which activates a script
this script would set a 'location servervar' to a value based on the action performed. each action would have a different number for the var to represent
then the output portion does its thing:
-the dynamic script runs every x seconds as long as a players 'online playervar' remains at 1
-the script checks the players location var (or town, spawnzone, etc) to see if it can use it
-if there is an entry in the script for that location, it checks the 'location servervar' for that area to see if there are any actions to perform
i-f it finds that there are, it sends the player a *msg about it or does whatever else is wanted, other players not matching the location will see no messages from the script
-the script then waits x seconds, almost as long as the script loop time to make sure -the script had a chance to run ran for every player online
-the script then sets the 'location servervar' back to 0
-the script reruns every x seconds for the player repeatedly checking to see if there are any new actions to perform for the player in their location
an example:
I'm making this script for the Tower of Terror combat world to add realism and ambiance to it. will likely be adding a version of it to delivery zone as well
-the 20 'floors' of the play area are linked to a playervar with a value of 1-20
-if a player is on floor 7 and 'searches a trashcan' (activating the trigger), the script for the trashcan will set the servervar for floor 7 to 1.
-the dynamic script, running for every player, will see that the servervar for floor 7 is set to 1 and any players who have their playervar set to 7 will receive a message 'you hear a rustling noise coming from somewhere on the floor' to add a bit of ambient realism and indicate to them that they are not alone. players not on floor 7 would get ignored by the script
main issue with this script is that only 1 action can happen at a time per location per script run cycle or messages wont get sent out for some. this is fixed by either making the cycles very fast (like running every 1 or 2 seconds) or by doubling/tripling the vars for each location and modifying the inputs to see of a var is already in use before using a 2nd or 3rd var. the output size would also need to be doubled or tripled then as well to have it check each of those extra vars