02.06.2010, 05:36
Hey,
I was playing around with a Homes System and everytime I started the server, I would lag alot.
It once froze my computer to where I had to Press the Restart button.
Its because of a Timer, but I have know reason why.
Can someone help me.
This is all to do with the Timer!
At top of Gamemode.
new Timer[1];
On Gamemodeinit
Timer[0] = SetTimerEx("ReadPlayerHouseData", 1000, true, "%i", i);
And ReadPlayerHouseData
public ReadPlayerHouseData(playerid)
{
new string[256], house[64];
for(new h = 0; h <= MAX_HOUSES; h++){
format(house, sizeof(house), "/Houses/%d.dini.save", h);
if(dini_Exists(house)){
if(HouseInfo[h][hSellable] == 1){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])) {
format(string, sizeof(string), "~g~ Mafia HQ Available ~n~~w~Owner:~y~ %s~n~~w~Level:~r~ %d~n~~w~Sell Price:~r~ %d~n~~w~Rent Cost:~r~ %d", HouseInfo[h][hName], HouseInfo[h][hLevel], HouseInfo[h][hSell], HouseInfo[h][hRent]);
GameTextForPlayer(playerid,string, 1500, 3);
}
} else if(HouseInfo[h][hSellable] == 0){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])) {
if(HouseInfo[h][hName] == TERMIN@TOR)
{
format(string, sizeof(string), "~w~The Black Mafia HQ ~n~~w~Level:~r~ %d~n~~w~Rent Cost:~r~ %d", HouseInfo[h][hLevel], HouseInfo[h][hRent]);
GameTextForPlayer(playerid,string, 1500, 3);
}
format(string, sizeof(string), "~w~Owner:~y~ %s~n~~w~Level:~r~ %d~n~~w~Rent Cost:~r~ %d", HouseInfo[h][hName], HouseInfo[h][hLevel], HouseInfo[h][hRent]);
GameTextForPlayer(playerid,string, 1500, 3);
} } } }
}
It really laggy when I try it, any ideas?
Any Errors in the SetTimerEx?
I was playing around with a Homes System and everytime I started the server, I would lag alot.
It once froze my computer to where I had to Press the Restart button.
Its because of a Timer, but I have know reason why.
Can someone help me.
This is all to do with the Timer!
At top of Gamemode.
new Timer[1];
On Gamemodeinit
Timer[0] = SetTimerEx("ReadPlayerHouseData", 1000, true, "%i", i);
And ReadPlayerHouseData
public ReadPlayerHouseData(playerid)
{
new string[256], house[64];
for(new h = 0; h <= MAX_HOUSES; h++){
format(house, sizeof(house), "/Houses/%d.dini.save", h);
if(dini_Exists(house)){
if(HouseInfo[h][hSellable] == 1){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])) {
format(string, sizeof(string), "~g~ Mafia HQ Available ~n~~w~Owner:~y~ %s~n~~w~Level:~r~ %d~n~~w~Sell Price:~r~ %d~n~~w~Rent Cost:~r~ %d", HouseInfo[h][hName], HouseInfo[h][hLevel], HouseInfo[h][hSell], HouseInfo[h][hRent]);
GameTextForPlayer(playerid,string, 1500, 3);
}
} else if(HouseInfo[h][hSellable] == 0){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])) {
if(HouseInfo[h][hName] == TERMIN@TOR)
{
format(string, sizeof(string), "~w~The Black Mafia HQ ~n~~w~Level:~r~ %d~n~~w~Rent Cost:~r~ %d", HouseInfo[h][hLevel], HouseInfo[h][hRent]);
GameTextForPlayer(playerid,string, 1500, 3);
}
format(string, sizeof(string), "~w~Owner:~y~ %s~n~~w~Level:~r~ %d~n~~w~Rent Cost:~r~ %d", HouseInfo[h][hName], HouseInfo[h][hLevel], HouseInfo[h][hRent]);
GameTextForPlayer(playerid,string, 1500, 3);
} } } }
}
It really laggy when I try it, any ideas?
Any Errors in the SetTimerEx?