Join the forums now, and start posting to receive access to our Scripts Vault!
You hit Monster1 for 4 damage! (5 left)Monster1 hit you for 2 damage! (6 left)You hit Monster1 for 3 damage! (2 left)Monster1 hit you for 3 damage! (3 left)You hit Monster1 for 5 damage! (-3 left)You killed Monster!You gained 3 EXP and 5 Gold!
Strategy GamesNow, these games are much harder to code, and also much harder to learn and play. These types of games come in many different forms, but they usually have similar cores:Ticks and/or TurnsTicks are events that run every so often, maybe every 10 minutes or every 30 minutes. Between each tick, you may perform whatever action you want, but not much of it is processed until the tick occurs. If you attack somebody, the results only come in on the tick. If you buy soldiers or other stuff, that will only have an effect once the tick has happened. These games are more 'strategic' since you have time to think what action you want to perform, and try to predict what enemy players might do.Turns are also a limiting factor. Every time you perform an action, your own number of 'turns' decreases. Once it has reached zero, you must wait for a 'reset' where your turns will be reset or added to. Maybe different actions take up different amounts of turn for variation. Bigger actions take more turns, while smaller actions can be performed more times since they only take up a few turns. The strategic part of this type of game is in deciding what you will spend your turns on. After you have decided, there may still be other limiting factors, such as cash or skill level. Different requirements for different actions make sure you think out your actions carefully.Strategy games often require heavy use of 'cron jobs'. Cron jobs are actions run by the server at certain times. In CPanel, you can set different files to be run every so often, or at specific times. This is useful so that the ticks happen at the right time, regularly. Often, your cron files will be one of the largest files in your game because all the tick processing happens in that file. Everything from small purchasing actions to calculating the complete results in hundreds of battles.
<?php$s = (int) date("s");$m = (int) date("i");$t = (1+intval($m/10+($s-1)/600))*600-$m*60-$s;printf("Time until next tick: %02d:%02d", $t / 60, $t % 60); ?>
<script type='text/javascript'> var t = '<? =date("H:i:s")?>';</script>
<form name="frmticker" style="display: inline"><input type="text" name="tick" READONLY style="text-align: center;width: 110px; border: 0px; background-color: transparent; color: #aaaaaa; font-family: tahoma; font-size: 8pt;"></form>
<body onLoad="initTicker();">
<script type='text/javascript'>// Init varsvar tArr = t.split(':')var mins = parseInt(tArr[1])var secs = parseInt(tArr[2])var muliplier;if( mins >= 0 && mins < 10 ) muliplier = 1;if( mins >= 10 && mins < 20 ) muliplier = 2;if( mins >= 20 && mins < 30 ) muliplier = 3;if( mins >= 30 && mins < 40 ) muliplier = 4;if( mins >= 40 && mins < 50 ) muliplier = 5;if( mins >= 50 && mins < 60 ) muliplier = 6;var tmins = (muliplier * 10) - mins - 1;var tsecs = 60 - secs;// Start the timer, will call the timer function every secondfunction initTicker() { var doTime = setInterval('timer()',1000);}// timer function to decriment time and display on pagefunction timer() { tsecs--; if(tsecs < 0) { tmins--; tsecs = 59; } if(tmins < 0) tmins = 9; if( (tmins == 0 && tsecs < 5) || (tmins == 9 && tsecs > 50) ) document.frmticker.tick.value = "Processing" else document.frmticker.tick.value = "tick: " + ((tmins < 10) ? '0' : '') + tmins + ':' + ((tsecs < 10) ? '0' : '') + tsecs;}</script>