Jump to content
  • 0

pomoc Nahraný čas


DemoroCZ

Dotaz

Zdravím, pomohl by mi prosím někdo opravit tyto chyby? Nevím si s tím rady...

C:\Users\DemoroCZ\pawno\gs4y.pwn(3366) : error 028: invalid subscript (not an array or too many subscripts): "Dni"
C:\Users\DemoroCZ\pawno\gs4y.pwn(3366) : warning 215: expression has no effect
C:\Users\DemoroCZ\pawno\gs4y.pwn(3366) : error 001: expected token: ";", but found "]"
C:\Users\DemoroCZ\pawno\gs4y.pwn(3366) : error 029: invalid expression, assumed zero
C:\Users\DemoroCZ\pawno\gs4y.pwn(3366) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664	 Copyright (c) 1997-2006, ITB CompuPhase

4 Errors.

 

Zde je řádek kde jsou chyby:

format(string,256,"Dní : %d || Hodin : %d || Minut : %d",Dni[playerid],Hodin[playerid],Minut[playerid]);

 

Díky moc předem.

Link to comment
Share on other sites

22 odpovědí na tuto otázku

Recommended Posts

  • 0

Aha... Tak to je jasný..

Pokud používáš "enum", musíš vytvořit: "new TvaCestaKEnum[MAX_PLAYERS][pInfo];" a pak používat: "format(string,256,"Dní : %d || Hodin : %d || Minut : %d",TvaCestaKEnun[playerid][Dni]," ... atp.

Link to comment
Share on other sites

  • 0

Aha... Tak to je jasný..

Pokud používáš "enum", musíš vytvořit: "new TvaCestaKEnum[MAX_PLAYERS][pInfo];" a pak používat: "format(string,256,"Dní : %d || Hodin : %d || Minut : %d",TvaCestaKEnun[playerid][Dni]," ... atp.

 

Aha, díky moc :)

 

E: Mám další problém, tak nechci zakládat další téma.

Tentokrát to není žádný error, ale mám public který je vyvolávanej timerem, který je nastaven na 60 sekund. Ten public by měl vždycky přičíst 1 minutu, pokud už má hráč více jak 59 min, tak nastaví min. na 0, a přidá k hodinám 1, a zase, pokud je více jak 23 hodin, tak nastaví hodiny na 0 a přidá 1 ke dnům, ale tak trochu mi to nefunguje, nevíte prosím někdo co s tím?

 

Zde je public:

public NahranyCas(playerid)
{
							 PlayerInfo[playerid][Minut]++;
						 if (PlayerInfo[playerid][Minut] > 59)
						 {
							 PlayerInfo[playerid][Minut] = 0;
							 PlayerInfo[playerid][Hodin]++;
						 if (PlayerInfo[playerid][Hodin] > 23)
						 {
							 PlayerInfo[playerid][Hodin] = 0;
									 PlayerInfo[playerid][Dni]++;
						 }
}
 return 1;
}

 

Timer v GameModeInit:

SetTimer("NahranyCas",60000,1);

 

Omlouvám se za takovéhle stupidní otázky, ale na pawno jsem ještě amatér.

Link to comment
Share on other sites

  • 0

public NahranyCas(playerid)
{
												    PlayerInfo[playerid][Minut]++;
							    if (PlayerInfo[playerid][Minut] > 59)
									  {
										    PlayerInfo[playerid][Minut] = 0;
										    PlayerInfo[playerid][Hodin]++;
									  }
								    else if (PlayerInfo[playerid][Hodin] > 23)
											 {
										  PlayerInfo[playerid][Hodin] = 0;
											    PlayerInfo[playerid][Dni]++;
											  }
		    return 1;
}

 

Skús to takto :) A napíš ptm.. :)

Link to comment
Share on other sites

  • 0

public NahranyCas(playerid)
{
												 PlayerInfo[playerid][Minut]++;
							 if (PlayerInfo[playerid][Minut] > 59)
									 {
										 PlayerInfo[playerid][Minut] = 0;
										 PlayerInfo[playerid][Hodin]++;
									 }
								 else if (PlayerInfo[playerid][Hodin] > 23)
											 {
										 PlayerInfo[playerid][Hodin] = 0;
											 PlayerInfo[playerid][Dni]++;
											 }
		 return 1;
}

 

Skús to takto :) A napíš ptm.. :)

 

Stále nefunguje...

Link to comment
Share on other sites

  • 0

Počuj inač ten timer.. Nemal by si dať do OnPlayerConnect ? :d šak to má počítať hráčov pripojený čas a hento tak počíta že keď zapneš server hneď sa ten timer pustí.. :d

Link to comment
Share on other sites

  • 0

public NahranyCas(playerid)

{

PlayerInfo[playerid][Minut]++;

if (PlayerInfo[playerid][Minut] == 60)

{

PlayerInfo[playerid][Minut] = 0;

PlayerInfo[playerid][Hodin]+1;

}

else if (PlayerInfo[playerid][Hodin] == 24)

{

PlayerInfo[playerid][Hodin] = 0;

PlayerInfo[playerid][Dni]+1;

}

return 1;

}

 

Takto ?..

Link to comment
Share on other sites

  • 0

PlayerInfo[playerid][Hodin]+1; neviem či takto pričíta 1 ten premene.. Samizdá že sa to robí takto PlayerInfo[playerid][Hodin]++; alebo PlayerInfo[playerid][Hodin] += 1;

Link to comment
Share on other sites

  • 0

public NahranyCas(playerid)

{

PlayerInfo[playerid][Minut]++;

if (PlayerInfo[playerid][Minut] == 60)

{

PlayerInfo[playerid][Minut] = 0;

PlayerInfo[playerid][Hodin]+1;

}

else if (PlayerInfo[playerid][Hodin] == 24)

{

PlayerInfo[playerid][Hodin] = 0;

PlayerInfo[playerid][Dni]+1;

}

return 1;

}

 

Takto ?..

 

Stále nefunguje + 2 warningy:

C:\Users\DemoroCZ\pawno\gs4y.pwn(3666) : warning 215: expression has no effect
C:\Users\DemoroCZ\pawno\gs4y.pwn(3671) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 Copyright (c) 1997-2006, ITB CompuPhase

2 Warnings.

Link to comment
Share on other sites

  • 0

Stále nefunguje + 2 warningy:

C:\Users\DemoroCZ\pawno\gs4y.pwn(3666) : warning 215: expression has no effect
C:\Users\DemoroCZ\pawno\gs4y.pwn(3671) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 Copyright (c) 1997-2006, ITB CompuPhase

2 Warnings.

 

namiesto PlayerInfo[playerid][Dni]+1; daj PlayerInfo[playerid][Dni]++;

Link to comment
Share on other sites

  • 0

Hmm :/ :d

 

public NahranyCas(playerid)

{

PlayerInfo[playerid][Minut]++;

if (PlayerInfo[playerid][Minut] == 60)

{

PlayerInfo[playerid][Minut] = 0;

PlayerInfo[playerid][Hodin]+1;

}

else if (PlayerInfo[playerid][Hodin] == 24)

{

PlayerInfo[playerid][Hodin] = 0;

PlayerInfo[playerid][Dni]+1;

}

return 1;

}

 

Ty totiž při každý "sekundě" sčítáš minuty.. Tzn., že po 1 minutě ti přibude jedna hodina.. Ne ,.. ? .)

 

public NahranyCas(playerid)

{

new Seconds;

Seconds ++;

if(Seconds == 60)

{

PlayerInfo[playerid][Minut]++;

Seconds = 0;

}

else if(PlayerInfo[playerid][Minut] == 60)

{

PlayerInfo[playerid][Hodin] ++;

PlayerInfo[playerid][Minut] = 0;

 

else if(PlayerInfo[playerid][Hodin]== 24)

{

PlayerInfo[playerid][Dni]++;

PlayerInfo[playerid][Hodin] =0;

}

return 1;

}

Link to comment
Share on other sites

  • 0

Hmm :/ :d

 

public NahranyCas(playerid)

{

PlayerInfo[playerid][Minut]++;

if (PlayerInfo[playerid][Minut] == 60)

{

PlayerInfo[playerid][Minut] = 0;

PlayerInfo[playerid][Hodin]+1;

}

else if (PlayerInfo[playerid][Hodin] == 24)

{

PlayerInfo[playerid][Hodin] = 0;

PlayerInfo[playerid][Dni]+1;

}

return 1;

}

 

Ty totiž při každý "sekundě" sčítáš minuty.. Tzn., že po 1 minutě ti přibude jedna hodina.. Ne ,.. ? .)

 

public NahranyCas(playerid)

{

new Seconds;

Seconds ++;

if(Seconds == 60)

{

PlayerInfo[playerid][Minut]++;

Seconds = 0;

}

else if(PlayerInfo[playerid][Minut] == 60)

{

PlayerInfo[playerid][Hodin] ++;

PlayerInfo[playerid][Minut] = 0;

 

else if(PlayerInfo[playerid][Hodin]== 24)

{

PlayerInfo[playerid][Dni]++;

PlayerInfo[playerid][Hodin] =0;

}

return 1;

}

 

No ono právě nepřibude nic...

 

E: Taky nefunguje

Link to comment
Share on other sites

  • 0

Tak skús SetTimerEx dať do OnPlayerConnect.. Skúšaj všeliake možnosti.. Nemôžeš sa furt spoliehať že mi ti tu pomôžeme.. Skús dať ten settimerex do connectu a jak to nepôjde stále tak potom už neviem čo s tým je

Link to comment
Share on other sites

  • 0
  • Hlavní moderátor

takže do OnGameModeInit

SetTimer("NahranyCas",60000,true);

 

a public:

public NahranyCas()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
 if(IsPlayerConnected(i))
 {
	 PlayerInfo[i][Minut]++;
	 if(PlayerInfo[i][Minut] > 59)
	 {
			 PlayerInfo[i][Minut] = 0;
			 PlayerInfo[i][Hodin]++;
	 }
	 if(PlayerInfo[i][Hodin] > 23)
	 {
		 PlayerInfo[i][Hodin] = 0;
		 PlayerInfo[i][Dni]++;
	 }
   }
}
}

Link to comment
Share on other sites

  • 0

#include <a_samp>
#define MAX_PLAYERS_EX 200 //pro optimalizaci sem dej počet slotů kolik jich používáš...
new Den[MAX_PLAYERS_EX]; //proměnná do které se budou zapisovat dny
new Hodina[MAX_PLAYERS_EX]; //hodiny...
new Minuta[MAX_PLAYERS_EX]; //minuty...
forward MinutaTimer(); //předdefinování/vytvoření funkce (public) ve které se budou přičítat hodnoty
public MinutaTimer() //samotná funkce
{
for(new i; i<MAX_PLAYERS_EX; i++) //cyklus, který projede všechny čísla (v tomto případě ID hráče), a zkontroluje jak jsou na tom podle podmínek jak jsou níže
{ //větvení za cyklem
 if(Minuta[i] == 59) //pokud má 59 Minut
 { //větvení, protože do podmínky potřebujeme dát více jak jeden příkaz
	 if(Hodina[i] == 23) //pokud má 23 hodin
	 { //větvení, protože do podmínky potřebujeme dát více jak jeden příkaz
		 Den[i]++; //přičte den k proměnné
		 Hodina[i] = 0; //nastaví Hodiny na 0 a pojede od znova
		 Minuta[i] = 0; //nastaví Minuty -----------||----------
		 return 1; //ukončí funkci aby nepokračovala, jinak by pokračovala a dělala to co je níže...
	 } //uzavření, protože zde končí příkazy podmínky
  Hodina[i]++; //přičte Hodinu
  Minuta[i] = 0; //nastaví Minuty na 0 a jede od znovu
  return 1; //ukončí funkci aby nepokračovala, stejné jako nahoře...
 } //uzavření, protože zde končí příkazy podmínky
 Minuta[i]++;
} //uzavření, končí cyklus
return 1; //na konci každé funkce (publicu) musí být return 1;
}
public OnGameModeInit()
{
SetTimer("MinutaTimer",60*1000,true); //Timer:
/*
"MinutyTimer" - název co se bude spouštět, tedy naše funkce
60*1000 - čas, za jak dlouho se funkce spustí, udává se v milisekundách, tedy 1000 (sekunda má 1000 milisekund) krát 60, může se tam napsat 60000
true - bool, jestli se timer opakuje nebo ne, v našem případě je opakucjící protože po skončení jedné minuty chceme aby pokračovala další minuta
*/
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

 

Předej oznamuji toto jem neudělal já udělal to pro mě Hip

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...