21.07.2012, 19:48
how to do Experience System to climb a 1 Experience for 1 minute and with textdraws please tell me how to do this for ages looking for and can not find
#define EXPERIENCE_FOR_NEXT_LEVEL 5*60*60*1000 // for 5 hours
new gPlayerExperience[MAX_PLAYERS];
OnGameModeInit()
{
SetTimer("EveryMinuteTimer",60*1000,true);
//...
}
forward public EveryMinuteTimer();
public EveryMinuteTimer();
{
new i;
for(i=0;i<MAX_PLAYERS;i++)
{
if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid))continue;
if(++gPlayerExperience[playerid]==EXPERIENCE_FOR_NEXT_LEVEL)
{
gPlayerExperience[playerid]=0;
PlayerInfo[playerid][pLevel]++;
}
//You can here show player textdraw so it looks like on the Screen shoot
// "Experience: gPlayerExperience[playerid]/EXPERIENCE_FOR_NEXT_LEVEL"(Ie: Experience: 30/300000000)
}
}
OnPlayerDiscconnect(playerid,reason)
{
//save stats, ATTENTION -save both gPlayerExperience[playerid] and PlayerInfo[playerid][pLevel]
gPlayerExperience[playerid]=0;
PlayerInfo[playerid][pLevel]=0;
}
forward 5HoursLevelUp(playerid); SetTimerEx("5HoursLevelUp", 18000000, true,"i",playerid); // Level up each 5 hours, put on OnPlayerConnect public 5HoursLevelUp(playerid) { PlayerInfo[playerid][pLevel] += 1; // Adds 1 more level to pLevel var (Y_INI saving system) return 1; } new pLevel = PlayerInfo[playerid][pLevel]; gLevel = TextDrawCreate(320.0, 240.0, pLevel); // Well, tweak it as your likeing TextDrawShowForPlayer(playerid, gLevel); // OnPlayerConnect, also use a TextDraw string updater