hey guys well im making a strategy browser based mmorpg, and what i need help with,
1. Display of current hourly production,
2. Display of current resources.
-do i just connect this straight to the db and collect the data and make it present?
3. Build a building, raise your hourly production, and on each upgrade raises production.
-how would i go about, how a building a building would go into a database, would i have to give them id tags, example. warehouse is 1, and it should have a level, and everytime the level increases so does your maximum capacitiy.
The display of hourly production should be easy.
Help with script.A hourly production script.
15 Replies - 917 Views - Last Post: 08 September 2008 - 11:44 AM
Replies To: Help with script.
#2
Re: Help with script.
Posted 08 September 2008 - 10:44 AM
if your trying to make a game like travian or tribal wars ... --- good luck lol
if i was you id make a couple of variables
have
$resource1 = 10;
$resource2 = 15;
$resource3 = 20;
youd need to look into i think cron to do this effectively and if you wanted to have it so it was constantly updating rather than lump sum at the end or start of hour you would have to then create a simple formula
rps=resource per second
$rps = $resource1/3600;
in this case rps = 0.00277777777777.... etc
$rps*60 = $rpm;
this is equal to 0.166666662
you would then i think find out how long it would take to get 1 resource
1/$rpm;
this is about 6 mins so you would then run a cron to add to your total 1 every 6 mins
if you need anything explaining just ask
if i was you id make a couple of variables
have
$resource1 = 10;
$resource2 = 15;
$resource3 = 20;
youd need to look into i think cron to do this effectively and if you wanted to have it so it was constantly updating rather than lump sum at the end or start of hour you would have to then create a simple formula
rps=resource per second
$rps = $resource1/3600;
in this case rps = 0.00277777777777.... etc
$rps*60 = $rpm;
this is equal to 0.166666662
you would then i think find out how long it would take to get 1 resource
1/$rpm;
this is about 6 mins so you would then run a cron to add to your total 1 every 6 mins
if you need anything explaining just ask
#3
Re: Help with script.
Posted 08 September 2008 - 10:51 AM
can you explain the resource 1, resource 2, resource 3 part.
can you give me examples of tables to make in mysql?
can you give me examples of tables to make in mysql?
#4
Re: Help with script.
Posted 08 September 2008 - 11:00 AM
ok so you would have a table like
table name = production
player id | player name | resource1 production | resource2 production | resource3 production | resource1 total | resource2 total | resource3 total
this means that when you assign a certain production to each level you can then go when you upgrade resource 1 say by making it lvl 2 this gives you an extra 10 per hour
mysql_query("UPDATE production SET resource1 production = resource1 production + 10 WHERE player id = '".$_session['id']."'");
remember these are just examples properly plan them out to fit you when you want to make it
i suggest now you read up on cron as i dont know how to use cron
then have a go at making it yourself and then repost when you get problems
the resource 1 2 and 3 are just your seperate resources
you might have metal wood and stone for example
table name = production
player id | player name | resource1 production | resource2 production | resource3 production | resource1 total | resource2 total | resource3 total
this means that when you assign a certain production to each level you can then go when you upgrade resource 1 say by making it lvl 2 this gives you an extra 10 per hour
mysql_query("UPDATE production SET resource1 production = resource1 production + 10 WHERE player id = '".$_session['id']."'");
remember these are just examples properly plan them out to fit you when you want to make it
i suggest now you read up on cron as i dont know how to use cron
then have a go at making it yourself and then repost when you get problems
the resource 1 2 and 3 are just your seperate resources
you might have metal wood and stone for example
#5
Re: Help with script.
Posted 08 September 2008 - 11:04 AM
thanks mate that was really helpful.
also another question.
how would i go about making there resource capacity limit, making it that you cant get over your storage limit?
and aswell as the production part goes is it a function? since it always is working?
also another question.
how would i go about making there resource capacity limit, making it that you cant get over your storage limit?
and aswell as the production part goes is it a function? since it always is working?
#6
Re: Help with script.
Posted 08 September 2008 - 11:10 AM
do it however suits you
if you put it into a function and use parameters then you could use the same script for all your resources just change the differant parameters for each resource
if you have to build a building like a warehouse and the capacity was 1000 and you had 1000 of resource 1 then you would first need to find out resource1 total (you should already have this in a variable to make your life easy when displaying how many resources they have )
if you put it into a function and use parameters then you could use the same script for all your resources just change the differant parameters for each resource
if you have to build a building like a warehouse and the capacity was 1000 and you had 1000 of resource 1 then you would first need to find out resource1 total (you should already have this in a variable to make your life easy when displaying how many resources they have )
$capacity = 1000;
if($resource1 total > $capacity){
$resource1total = $capacity
}
#7
Re: Help with script.
Posted 08 September 2008 - 11:13 AM
mate, thanks for that.
also would you know anything about the map system in tribalwars/travian?
also would you know anything about the map system in tribalwars/travian?
#8
Re: Help with script.
Posted 08 September 2008 - 11:20 AM
well dont know about tribal wars as i only play travian
but i would think (not sure)
but you would have lots of differant images stored and then just display them when approriate
for example in travian there are 3 differant images for a village
>500
>250
>100
i believe
so you could do a check and see what pop that village is and show the corresponding image for the result
as for empty sqyares that could be random between differant pics or if you dont want to draw lots of differat styles you could just have 1 and do
$village = 1; // there is a village on that square if 0 the square is empty
if($village == 1){
show village pic
}else{
show abandoned pic
}
but i would think (not sure)
but you would have lots of differant images stored and then just display them when approriate
for example in travian there are 3 differant images for a village
>500
>250
>100
i believe
so you could do a check and see what pop that village is and show the corresponding image for the result
as for empty sqyares that could be random between differant pics or if you dont want to draw lots of differat styles you could just have 1 and do
$village = 1; // there is a village on that square if 0 the square is empty
if($village == 1){
show village pic
}else{
show abandoned pic
}
#9
Re: Help with script.
Posted 08 September 2008 - 11:24 AM
mate your a life saver,
how about the coordinates, would i have to supply the maximum numbers, say like
1000 to 1000
-1000 to -1000
then give our coordinates to the villages that register new?
how about the coordinates, would i have to supply the maximum numbers, say like
1000 to 1000
-1000 to -1000
then give our coordinates to the villages that register new?
#10
Re: Help with script.
Posted 08 September 2008 - 11:28 AM
a 1000x1000 is very big unless you intend to have fast troops etc bad idea i would only have it in the beginning 100x100 to see how everything goes thats still10000 squares
you could make a mysql table in databas with like playerid and village coords then everytime a player gets a new village add a row to the table with like
playerid village coords
x xx|xx
you could make a mysql table in databas with like playerid and village coords then everytime a player gets a new village add a row to the table with like
playerid village coords
x xx|xx
#11
Re: Help with script.
Posted 08 September 2008 - 11:31 AM
and to display the image's onto the screen would i need to do heavy javascript?
#12
Re: Help with script.
Posted 08 September 2008 - 11:34 AM
why use java
just save them to the database or wherever and then use an img tag
<img src="pica.jpg" alt="picture a" height="100px" width ="100px"
just save them to the database or wherever and then use an img tag
<img src="pica.jpg" alt="picture a" height="100px" width ="100px"
#13
Re: Help with script.
Posted 08 September 2008 - 11:36 AM
yeah wouldnt that slow the server, when loading that many tiles at same time, doing the way you suggested?
#14
Re: Help with script.
Posted 08 September 2008 - 11:37 AM
well if you only had it show about 5x5 squares not really
for a game like that youd need a fast server anyway so it wouldnt make much differance unless every one looks at there map at the same time
for a game like that youd need a fast server anyway so it wouldnt make much differance unless every one looks at there map at the same time
#15
Re: Help with script.
Posted 08 September 2008 - 11:42 AM
hmm, your right.
also, with the map, cant we just make it run off a program, say a map hosting program throug visual basic, link it to that, instead of loading it on the website it will load off like a link from the server?
also, with the map, cant we just make it run off a program, say a map hosting program throug visual basic, link it to that, instead of loading it on the website it will load off like a link from the server?
|
|

New Topic/Question
Reply




MultiQuote




|