Jump to content
  • 0

pomoc Nefunkční Script (Settimerex)


ForestCZE

Dotaz

Zdravím vás :) Mám tento script:

 

forward PrubehZivota(playerid);

 

V loginu:

 

SetTimerEx("PrubehZivota", 60000, true, "i", playerid);

 

A nakonec public

 


public PrubehZivota(playerid)
{
new t_zivot[128];
if(Minuta[playerid] <= 9){
format(t_zivot, sizeof(t_zivot), "%d:0%d", Hodina[playerid], Minuta[playerid]);
}else{
format(t_zivot, sizeof(t_zivot), "%d:%d", Hodina[playerid], Minuta[playerid]);
}

   if(Hodina[playerid] <= 0 && Minuta[playerid] <= 0){
   KillTimer(cashrace);
 GameTextForPlayer(playerid, "Konec Hry", 3000, 2);
SetPlayerHealth(playerid, 0.0);
}

if(Minuta[playerid] <= 0 && Hodina[playerid] > 0){
Hodina[playerid]--;
Minuta[playerid] = 60;
}

Minuta[playerid]--;
TextDrawHideForPlayer(playerid, Zivot);
TextDrawSetString(Zivot, t_zivot);
TextDrawShowForPlayer(playerid, Zivot);
}

 

Když jsem na serveru sám, tudíž ID 0, tak je všecko v pohodě. Jakmile se připojí ID 1, tak to začne dělat neplechu. Mně jako ID 0 to ukazuje jednou čas můj, podruhé čas ID 1 a takhle se to střídá. ID 1 to samé. Jednou vidí svůj čas, po druhé čas ID 0. Kde je problém? Děkuji :)

Link to comment
Share on other sites

8 odpovědí na tuto otázku

Recommended Posts

  • 0

Teď jsem to otestoval s tim for playerid .. problém částečně vyřešen :( Už se to nestřídá, ale po provedení publicu .. ID 0 vidí čas ID 1 :(

 

EDIT: ID 1 má čas v pohodě a ID 0 se zobrazí čas hráče s ID 1

Link to comment
Share on other sites

  • 0

Ako máš takto kód

 

 

public PrubehZivota()

{

new t_zivot[128];

for(new playerid; playerid < MAX_PLAYERS;playerid++){

if(IsPlayerConnected(playerid)){

if(TimerStopped[playerid] == 0){

if(Minuta[playerid] <= 9){

 

tak takto

 

 

public PrubehZivota()

{

new t_zivot[128];

for(new playerid; playerid < MAX_PLAYERS;playerid++){

if(IsPlayerConnected(playerid)){

if(TimerStopped[playerid] == 0){

printf("%s(%d) minuta %d",Jmeno(playerid),playerid,minuta[playerid]);

if(Minuta[playerid] <= 9){

 

A co se má stát? Promin, vypadam jako deb*l, ale ja opravdu nevim :X .. mam to takto:

 


public PrubehZivota()
{
new t_zivot[128];
   for(new playerid; playerid < MAX_PLAYERS; playerid++){
if(IsPlayerConnected(playerid)){
if(Mrtvy[playerid] == false){
printf("%s(%d) minuta %d",Nick(playerid), playerid, Minuta[playerid]);
format(t_zivot, sizeof(t_zivot), "%02d:%02d", Hodina[playerid], Minuta[playerid]);

if(Hodina[playerid] <= 0 && Minuta[playerid] <= 0){
 GameTextForPlayer(playerid, "Konec Hry", 3000, 2);
SetPlayerHealth(playerid, 0.0);
}

if(Minuta[playerid] <= 0 && Hodina[playerid] > 0){
Hodina[playerid]--;
Minuta[playerid] = 60;
}

Minuta[playerid]--;
TextDrawHideForPlayer(playerid, Zivot);
TextDrawSetString(Zivot, t_zivot);
TextDrawShowForPlayer(playerid, Zivot);
}
}
}
}

Link to comment
Share on other sites

  • 0

no v serverlogu budeš mať hodnoty premien, a podľa toho pohľadať, kde je asi chyba

 


[22:54:07] Forest(0) minuta 18
[22:54:07] Sendie(1) minuta 19
[22:55:10] Forest(0) minuta 17
[22:55:10] Sendie(1) minuta 18
[22:56:12] Forest(0) minuta 16
[22:56:12] Sendie(1) minuta 36
[22:57:14] Forest(0) minuta 15
[22:57:14] Sendie(1) minuta 35
[22:58:16] Forest(0) minuta 14
[22:58:16] Sendie(1) minuta 34
[22:59:18] Forest(0) minuta 13
[22:59:18] Sendie(1) minuta 33
[23:00:21] Forest(0) minuta 12
[23:00:21] Sendie(1) minuta 32
[23:01:23] Forest(0) minuta 11
[23:01:23] Sendie(1) minuta 31

Link to comment
Share on other sites

  • 0

počkať tam nieje chyba v minute, zmaž ten printf máš chybu v textdrawe... máš ho iba pre jedného hráča (globálny) použi http://wiki.sa-mp.co...ePlayerTextDraw a všetky tunkcie zmeň na "Player"

 

Teď jsem si ty proměnné dal vypsat i do chatu a tam je to ok stejně jako v logu. Máš pravdu je chyba v TextDraw :)

Link to comment
Share on other sites

  • 0

Chyba je uplne v necem jinem, sice mas na serveru dva hrace, ale mas pro ne jenom jeden textdraw :)

 

TextDrawHideForPlayer(playerid, Zivot);

TextDrawSetString(Zivot, t_zivot);

TextDrawShowForPlayer(playerid, Zivot);

 

 

Takze bud:

 

new Text:Zivot[MAX_PLAYERS];

 

a potom

 

TextDrawHideForPlayer(playerid, Zivot[playerid]);

TextDrawSetString(Zivot[playerid], t_zivo);

TextDrawShowForPlayer(playerid, Zivot[playerid]);

//Pokud ma hrac textdraw zobrazeny, staci pouzit SetString samostatne a zmena se projevi i tak

 

Zde nesmis zapomenout text znicit jakmikle se hrac pripoji, nebo si v OnGameModeInit vytvorit vsechny textdrawy pro vsechny hrace najednou

 

nebo pouzijes PlayerTextDraw Ten se automaticky znici s odpojenim hrace.

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