02.03.2016, 21:01
Quote:
I see. Can you suggest how to execute this properly? The interest income and +score every hour?
|
Код:
enum pInfo { pSecs, pMins, pHours } new PlayerInfo[MAX_PLAYERS][pInfo]; public OnGameModeInit() { SetTimer("PlayedHours", 1000, 1); //sets timer to call every 1 second return 1; } //saving public OnPlayerDisconnect(playerid, reason) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Mins",PlayerInfo[playerid][pMins]); INI_WriteInt(File,"Hours",PlayerInfo[playerid][pHours]); INI_WriteInt(File,"Secs",PlayerInfo[playerid][pSecs]); INI_Close(File); return 1; } //loading public LoadUser_data(playerid,name[],value[]) { INI_Int("Mins",PlayerInfo[playerid][pMins]); INI_Int("Hours",PlayerInfo[playerid][pHours]); INI_Int("Secs",PlayerInfo[playerid][pSecs]); return 1; } forward PlayedHours(playerid); public PlayedHours(playerid) { PlayerInfo[playerid][pSecs] ++; // +1 second evertime timer "playedhours" calls if(PlayerInfo[playerid][pSecs]>=60)//untill reaches 60 { PlayerInfo[playerid][pSecs]=0; //resets seconds to 0 PlayerInfo[playerid][pMins]++; // +1 min } if(PlayerInfo[playerid][pMins]>=60) //untill reaches 60 { PlayerInfo[playerid][pMins]=0; //resets minutes to 0 PlayerInfo[playerid][pHours]++; // +1 hour //reward the player for completeing 1 hour } }