need help with textdraws + REP
#1

sup guys, can you help me here ?
I would like to make Player's alive time in this textdraw but I don't know how
+ saving the Alive time on disconnect/load on connect
the alive time is going like this
Alive Time 000:00:00
when player spawn have alive time 5 seconds

Alivetime hours, minutes, seconds
please I need that little thing
I didn't tried to code anything because I don't know so thanks in advande
pawn Код:
stats[15] = TextDrawCreate(517.800231, 92.759986, "Alive_Time:000:00:00");
TextDrawLetterSize(stats[15], 0.227999, 1.170666);
TextDrawAlignment(stats[15], 1);
TextDrawColor(stats[15], -1);
TextDrawSetShadow(stats[15], 0);
TextDrawSetOutline(stats[15], 0);
TextDrawBackgroundColor(stats[15], 255);
TextDrawFont(stats[15], 1);
TextDrawSetProportional(stats[15], 1);
TextDrawSetShadow(stats[15], 0);
Reply
#2

Lite Example:
PHP код:
new p_alivetimes[MAX_PLAYERS];
public 
OnPlayerSpawn(playerid) {
     
p_alivetimes[playerid] = GetTickCount(); // Reset time
     
return true;
}
public 
OnPlayerUpdate(playerid) {
     new 
msg[256];
     
format(msgsizeof(msg), "Alive_Time: %d seconds", (GetTickCount()-p_alivetimes[playerid]) / 1000); // Last time from spawn
     
TextDrawSetString(stats[15], msg);
     return 
true;

or

Extended:
PHP код:
new p_alivetimes[MAX_PLAYERS];
new 
Text:stats;
public 
OnGameModeInit() {
    
// Other options...
    // Create TextDraws
    
stats TextDrawCreate(517.80023192.759986"Alive_Time:000:00:00");
    
TextDrawLetterSize(stats0.2279991.170666);
    
TextDrawAlignment(stats1);
    
TextDrawColor(stats, -1);
    
TextDrawSetShadow(stats0);
    
TextDrawSetOutline(stats0);
    
TextDrawBackgroundColor(stats255);
    
TextDrawFont(stats1);
    
TextDrawSetProportional(stats1);
    
TextDrawSetShadow(stats0);
    return 
true;
}
public 
OnGameModeExit() {
    
TextDrawHideForAll(stats);
    
TextDrawDestroy(stats);
    return 
true;
}
public 
OnPlayerDisconnect(playeridreason) {
     
TextDrawHideForPlayer(playeridstats);
     return 
true;

public 
OnPlayerSpawn(playerid) {
     
TextDrawShowForPlayer(playeridstats);
     
p_alivetimes[playerid] = GetTickCount(); // Reset time
     
return true;
}
public 
OnPlayerUpdate(playerid) {
     new 
msg[256];
     
format(msgsizeof(msg), "Alive_Time: %d seconds", (GetTickCount()-p_alivetimes[playerid]) / 1000); // Last time from spawn
     
TextDrawSetString(statsmsg);
     return 
true;

Reply
#3

not what im looking for :/
can you re edit in game must show
Hours minutes seconds
after 60 sec 1 min
after 60 min alive 1 hour
etc etc if you can get me
example
Alive time 1:10
like a real clock but alive time
when he die the stuff restart to 00:00
Reply
#4

Quote:
Originally Posted by CraTzy
Посмотреть сообщение
not what im looking for :/
can you re edit in game must show
Hours minutes seconds
after 60 sec 1 min
after 60 min alive 1 hour
etc etc if you can get me
example
Alive time 1:10
like a real clock but alive time
when he die the stuff restart to 00:00
To do this, you need a converter from milliseconds > hours and minutes. You wrote that you need to show a method TextDrawShow, I brought him.
Reply
#5

well I aint have so intelligence to script it :P so I asked you if you can help me or anyone else who see the post im crappy at scripting this stuff , mapping Is okay, making clickable textdraws too but the convecting etc not so ..
Reply
#6

Okey

PHP код:

/*
 * native ConvertSeconds(time_seconds, &hours, &minutes, &seconds);
 */
stock ConvertSeconds(time_seconds, &hours, &minutes, &seconds) { 
    new 
tmp;
    
tmp time_seconds 86400;
    
hours tmp 3600;
    
tmp time_seconds 3600;
    
minutes tmp 60;
    
seconds tmp 60;        
    
// printf("ConvertSeconds %d TO %02d:%02d:%02d", time_seconds, hours, minutes, seconds);
}
new 
p_alivetimes[MAX_PLAYERS];
new 
Text:stats;
public 
OnGameModeInit() {
    
// Other options...
    // Create TextDraws
    
stats TextDrawCreate(517.80023192.759986"Alive_Time:000:00:00");
    
TextDrawLetterSize(stats0.2279991.170666);
    
TextDrawAlignment(stats1);
    
TextDrawColor(stats, -1);
    
TextDrawSetShadow(stats0);
    
TextDrawSetOutline(stats0);
    
TextDrawBackgroundColor(stats255);
    
TextDrawFont(stats1);
    
TextDrawSetProportional(stats1);
    
TextDrawSetShadow(stats0);
    return 
true;
}
public 
OnGameModeExit() {
    
TextDrawHideForAll(stats);
    
TextDrawDestroy(stats);
    return 
true;
}
public 
OnPlayerDisconnect(playeridreason) {
     
TextDrawHideForPlayer(playeridstats);
     return 
true;

public 
OnPlayerSpawn(playerid) {
     
TextDrawShowForPlayer(playeridstats);
     
p_alivetimes[playerid] = GetTickCount(); // Reset time
     
return true;
}
public 
OnPlayerUpdate(playerid) {
     new  
         
hours
         
minutes
         
seconds,
         
msg[256];
     
ConvertSeconds(((GetTickCount()-p_alivetimes[playerid]) / 1000), hoursminutesseconds);
     
format(msgsizeof(msg), "Alive_Time: %02d:%02d:%02d"hoursminutesseconds); // Last time from spawn
     
TextDrawSetString(statsmsg);
     return 
true;

Add

PHP код:
stock ConvertSeconds(time_seconds, &hours, &minutes, &seconds) { 
    new 
tmp;
    
tmp time_seconds 86400;
    
hours time_seconds 3600// Remove restriction 24 hours
    
tmp time_seconds 3600;
    
minutes tmp 60;
    
seconds tmp 60;        
    
printf("ConvertSeconds %d TO %02d:%02d:%02d"time_secondshoursminutesseconds);

Reply
#7

thanks +repped you
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)