Jump to content
  • 0

pomoc Ukládání výsledků


Vpr

Dotaz

Čáu lidi jsem tady zas :d mám problěm že tento kod nevytváří složku,potřeboval bych aby vytvořil složku a zapsal výsledky. KOD zde

		
		stock WriteLog(){
		new st[128];
		new Year, Month, Day;
		getdate(Year, Month, Day);
		format(st,128,"cw/%s.vs.%s.%d.%d.%d.txt",TeamName[TEAM_HOME],TeamName[TEAM_AWAY],Day,Month,Year);
		if(!fexist(st)){
		 fcreate(st);
		}
		new File:f = fopen(st,io_append);
		format(st,128,"%s vs %s - %d. round\r\n",TeamName[TEAM_HOME],TeamName[TEAM_AWAY],TeamRounds[TEAM_HOME]+TeamRounds[TEAM_AWAY]);
		fwrite(f,st);
		fwrite(f,"==============================================\r\nTeam Home\r\n");
		ForPlayers(i){
		if(Team[i] == TEAM_HOME){
		new Float:ratio;
		if(Deaths[i] == 0) ratio = Kills[i];
		else ratio = float(Kills[i])/float(Deaths[i]);
		format(st,128,"%s > Kills: %02d  |  Deaths: %02d | TeamKills: %02d |  Ratio: %0.2f\r\n",Jmeno(i),Kills[i],Deaths[i],TeamKills[i],ratio);
		fwrite(f,st);

		}
		}
		fwrite(f,"Team Away\r\n");
		ForPlayers(i){
		if(Team[i] == TEAM_AWAY){
		new Float:ratio;
		if(Deaths[i] == 0) ratio = Kills[i];
		else ratio = float(Kills[i])/float(Deaths[i]);
		format(st,128,"%s > Zabiti: %02d  |  Smrti: %02d | TeamKilly: %02d |  Ratio: %0.2f\r\n",Jmeno(i),Kills[i],Deaths[i],TeamKills[i],ratio);
		fwrite(f,st);

		}
		}
		fwrite(f,"==============================================\r\n");
		format(st,128,"Kolo: %02d:%02d | Celkove: %02d:%02d : Kola: %02d:%02d\r\n",TeamScore[TEAM_HOME],TeamScore[TEAM_AWAY],TeamTotal[TEAM_HOME],TeamTotal[TEAM_AWAY],TeamRounds[TEAM_HOME],TeamRounds[TEAM_AWAY]);
		fwrite(f,st);
		fwrite(f,"==============================================\r\n\r\n\r\n");
		fclose(f);

}

Díky za pomoc,zatím čáu.

Link to comment
Share on other sites

3 odpovědí na tuto otázku

Recommended Posts

  • 0

pokud pouzivas io_append tak

 

io_append    Appends (adds) to file, write-only. If the file does not exist, it is created.

http://wiki.sa-mp.com/wiki/Fopen

 

tj fcreate tam mit nemusis (jen pripominka k optimalizaci, kod ti to neopravi :) )

 

A co se stane? Predpokladam ze ti crashne server ze? Protoze nikde nevidim podminku o tom jestli si obdrzel pristup k souboru. (neco jako

 if(!f) return print("naser si");

:d ). A jak uz bylo receno pawn funkce neumi vytvaret slozky, ty uz musis mit pred zapisem vytvorene.

Edited by ATomas
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...