Chris

Code : Tout sélectionner
;Voir l'aide pour ParseDate() et FormatDate()
;/Dé-Commente une des parties ci-dessous, et commente l'autre
;- Partie 1 : Dans cette partie, HeureMaintenant > que HeureAvant
; HeureMaintenant = ParseDate("%hh:%ii:%ss","23:12:00")
; HeureAvant = ParseDate("%hh:%ii:%ss","22:57:00")
;- Partie 2 : Dans cette partie, HeureAvant > que HeureMaintenant
HeureMaintenant = ParseDate("%hh:%ii:%ss","22:57:00")
HeureAvant = ParseDate("%hh:%ii:%ss","23:12:00")
Difference.f = Int(Abs(HeureMaintenant - HeureAvant))
Diff$ = FormatDate("%hh:%ii:%ss",Difference)
Debug Diff$
Code : Tout sélectionner
D1$="10"
H1$="10"
M1$="00"
D2$="11"
H2$="12"
M2$="00"
HeureAvant = ParseDate("%dd:%hh:%ii",D1$+":"+H1$+":"+M1$)
HeureMaintenant = ParseDate("%dd:%hh:%ii",D2$+":"+H2$+":"+M2$)
Difference = HeureMaintenant - HeureAvant
Diff$ = FormatDate("%dd:%hh:%ii",Difference)
Debug Diff$
Code : Tout sélectionner
A.f=150/60
Debug Str(A)
Debug A
Code : Tout sélectionner
A.f=150/60
Debug Str(A)
Debug A
MaVariable$ = StrF(A)
Debug MaVariable$
Code : Tout sélectionner
;- Pour que la fonction retrouve ses petits, tu dois lui fournir une date complète
;- sinon, elle se croit en 1970
D1$="10" ;10/04/2004 10:00
M1$="04"
Y1$="2004"
H1$="10"
Mn1$="00"
D2$="11" ;11/04/2004 12:00
M2$="04"
Y2$="2004"
H2$="12"
Mn2$="00"
;- Pour commencer, construit tes chaines à l'extérieur: C'est le plus simple
Date1$ = D1$+"/"+M1$+"/"+Y1$
Date2$ = D2$+"/"+M2$+"/"+Y2$
Heure1$ = H1$+":"+Mn1$
Heure2$ = H2$+":"+Mn2$
;- Calcule la différence de date indépendamment de celle de l'heure
DateAvant = ParseDate("%dd/%mm/%yyyy",Date1$)
DateMaintenant = ParseDate("%dd/%mm/%yyyy",Date2$)
;- La valeur retournée est en secondes : 1 Jour = 86400 secondes (60*60*24)
DiffDate = Abs(DateMaintenant-DateAvant)/86400 ; C'est la différence recherchée
;- Ensuite, calcul de la différence entre les heures
HeureAvant = ParseDate("%hh:%ii",Heure1$)
HeureMaintenant = ParseDate("%hh:%ii",Heure2$)
Difference = Abs(HeureMaintenant - HeureAvant)
Diff$ = FormatDate("%hh:%ii",Difference)
;- Affichage du résultat
Debug "Différence = "+Str(DiffDate)+" jour et "+Diff$+" heures"
Code : Tout sélectionner
Structure Player
PLAYER_ENTER_Day.s
PLAYER_ENTER_Mon.s
PLAYER_ENTER_Yea.s
PLAYER_ENTER_Hou.s
PLAYER_ENTER_Min.s
PLAYER_LEAVE_Day.s
PLAYER_LEAVE_Mon.s
PLAYER_LEAVE_Yea.s
PLAYER_LEAVE_Hou.s
PLAYER_LEAVE_Min.s
PLAYER_NAME.s
PLAYER_FRAG.l
PLAYER_DEATH.l
PLAYER_CONN.l
PLAYER_RANK.l
EndStructure
Dim Player.Player(99)
If ReadFile(0, "Log1.log")
While Eof(0)=0
;thx to nico who have helped me for that
First$ = Trim(ReadString())
;-killed
Position = FindString(First$, Chr(34)+" killed "+Chr(34), 1)
If Position <> 0
Position2 = FindString(First$, "<", Position)
If Position2 <> 0
PLAYER_NAME$ = Mid(First$, Position+10, Position2-Position-10)
Result = FindString(PLAYER_LIST$, PLAYER_NAME$, 1)
If Result <> 0
For k=0 To 99
If Player(k)\PLAYER_NAME = PLAYER_NAME$
Player(k)\PLAYER_DEATH = Player(k)\PLAYER_DEATH + 1
EndIf
Next
Else
PLAYER_LIST$=PLAYER_LIST$+"/"+PLAYER_NAME$
PLAYER_NUMBER=PLAYER_NUMBER+1
Player(PLAYER_NUMBER)\PLAYER_NAME = PLAYER_NAME$
Player(PLAYER_NUMBER)\PLAYER_DEATH = Player(PLAYER_NUMBER)\PLAYER_DEATH + 1
EndIf
EndIf
EndIf
Position = FindString(First$, Chr(34)+" has been killed by "+Chr(34), 1)
If Position <> 0
Position2 = FindString(First$, "<", Position)
If Position2 <> 0
PLAYER_NAME$ = Mid(First$, Position+22, Position2-Position-22)
Result = FindString(PLAYER_LIST$, PLAYER_NAME$, 1)
If Result <> 0
For k=0 To 99
If Player(k)\PLAYER_NAME = PLAYER_NAME$
Player(k)\PLAYER_FRAG = Player(k)\PLAYER_FRAG + 1
EndIf
Next
Else
PLAYER_LIST$=PLAYER_LIST$+"/"+PLAYER_NAME$
PLAYER_NUMBER=PLAYER_NUMBER+1
Player(PLAYER_NUMBER)\PLAYER_NAME = PLAYER_NAME$
Player(PLAYER_NUMBER)\PLAYER_FRAG = Player(PLAYER_NUMBER)\PLAYER_FRAG + 1
EndIf
EndIf
EndIf
Wend
CloseFile(0)
Debug "Number of player : "+Str(PLAYER_NUMBER)
Debug "Players : "+PLAYER_LIST$
Debug Player(1)\PLAYER_NAME
Debug Player(1)\PLAYER_FRAG
Debug Player(1)\PLAYER_DEATH
Else
MessageRequester("PureBasic", "Error: Can't read the file", 0)
EndIf