Jump to content
  • 0

pomoc Help [ Síla ]


PR0VO

Dotaz

Zdar, zkoušel jsem udělat v pawnu takovou věc, že u boxovacího pytle můžete napsat /sila a začnete cvičit.

Po minutě cvičení získáte 10 zkušeností + 1 sílu. Můj problém je, že když jsou na serveru 2 hráči a hráč příjde k Box.P, začne cvičit ale už nikdy nepřestane. Pokud jsem na serveru jen já sám, tak jde všechno dobře. Poraďte prosím :d

 

Takže toto je samotný příkaz pro cvičení síly :

 

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/sila", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, 768.7636,13.7306,1000.6998))
{
 if(Novacek[playerid] == 1)
 {
 if(CviciSilu[playerid] == 0)
{
 TimerSila[playerid] = SetTimer("Finish",60000,false);
 TogglePlayerControllable(playerid,0);
 CviciSilu[playerid] = 1;
 ApplyAnimation(playerid,"ped","FightA_3",4.1,1,1,1,1,1,1);
 SendClientMessage(playerid,0xFFFFFF,"{FFFFFF}[ Posilovna ] {FFFF00}Začal jste cvičit sílu, za minutu docvičíte !");
}
 }
}
if(IsPlayerInRangeOfPoint(playerid, 3.0, 771.0608,13.7301,1000.6982))
{
 if(Novacek[playerid] == 1)
{
 if(CviciSilu[playerid] == 0)
{
 TimerSila[playerid] = SetTimer("Finish",60000,false);
 TogglePlayerControllable(playerid,0);
 CviciSilu[playerid] = 1;
 ApplyAnimation(playerid,"ped","FightA_3",4.1,1,1,1,1,1,1);
 }
 }
}
if(IsPlayerInRangeOfPoint(playerid, 3.0, 767.2446,-2.5302,1000.7188))
{
 if(Novacek[playerid] == 1)
{
 if(CviciSilu[playerid] == 0)
 {
 TimerSila[playerid] = SetTimer("Finish",60000,false);
 TogglePlayerControllable(playerid,0);
 CviciSilu[playerid] = 1;
 ApplyAnimation(playerid,"ped","FightA_3",4.1,1,1,1,1,1,1);
 SendClientMessage(playerid,0xFFFFFF,"{FFFFFF}[ Posilovna ] {FFFF00}Začal jste cvičit sílu, za minutu docvičíte !");
 }
 }
}
if(IsPlayerInRangeOfPoint(playerid, 3.0, 769.5557,-2.5641,1000.7239))
{
 if(Novacek[playerid] == 1)
 {
 if(CviciSilu[playerid] == 0)
 {
 TimerSila[playerid] = SetTimer("Finish",60000,false);
 TogglePlayerControllable(playerid,0);
 CviciSilu[playerid] = 1;
 ApplyAnimation(playerid,"ped","FightA_3",4.1,1,1,1,1,1,1);
 }
 }
}
return 1;
}
if (strcmp("/port", cmdtext, true, 10) == 0) //Toto mám jen na port k posilovně
{
 SetPlayerPos(playerid,2223.0186,-1727.4327,13.3943);
 return 1;
}
return 0;
}

 

Toto mám v publicu :

 

public Finish(playerid)
{
new string[256];
TogglePlayerControllable(playerid,1);
Sila[playerid]+=1;
CviciSilu[playerid] = 0;
Uroven[playerid]+=10;
SetProgressBarValue(BarSila,Sila[playerid]);
UpdateProgressBar(BarSila,playerid);
SetProgressBarValue(Zkusenosti,Uroven[playerid]);
UpdateProgressBar(Zkusenosti,playerid);
ClearAnimations(playerid);
KillTimer(TimerSila[playerid]);
format(string,sizeof(string),"{FFFFFF}[ Posilovna ] {00FF40}Úspěšně jste dokončil sílu na %d bod.",Sila[playerid]);
SendClientMessage(playerid,0xFFFFFF,string);
}

Link to comment
Share on other sites

9 odpovědí na tuto otázku

Recommended Posts

  • 0

Miesto SetTimer použi SetTimerEx (najdi na wiki).

 

Problém totiž nastáva v tom že v timery nikde neurčuješ čomu sa bude rovnať playerid, takže má defaultne 0 (ID 0).

V SetTimerEx sa dá playerid nastaviť...

Link to comment
Share on other sites

  • 0

Celou wiki mi posílat nemusíš. Vždyť já tam animace sám hledám. Jen jsem si chtěl ušetřit to hledání. Ale děkuju :d

 

Miesto TimerSila[playerid] = SetTimer("Finish",60000,false);

použi

SetTimerEx("Finish",60000,false,"i",playerid);

 

a zmaž si premenu TimerSila[MAX_PLAYERS] lebo ta je zbytočná

 

 

:facepalm: ja tam už som npr. skoro minútu ty tam prídeš, mne sa vyvolá timer že už mi ubehla minúta, a tebe skončí tiež (nefér... nelogické... blbosť... nezmysel...)

Jak ten Timer vypnu ? Protože pokud hráč při cvičení zemře, stejně se mu přidá síla.

Link to comment
Share on other sites

  • 0
  • Administrátor

co třeba KillTimer(idtimeru)

 

TimerSila[playerid] = SetTimerEx("Finish",60000,false,"i",playerid);

 

KillTimer(TimerSila[playerid]);

Link to comment
Share on other sites

  • 0

co třeba KillTimer(idtimeru)

 

TimerSila[playerid] = SetTimerEx("Finish",60000,false,"i",playerid);

 

KillTimer(TimerSila[playerid]);

Tak to samozřejmě vím, ale u tohoto SetTimerEx("Finish",60000,false,"i",playerid); ? To mám udělat někam nahoru Timer[MAX_PLAYERS];

a Timer[playerid] = SetTimerEx("Finish",60000,false,"i",playerid); ? a pak jen KillTimer(Timer); ? :d

Link to comment
Share on other sites

  • 0

Načo chceš killnuť timer, ktorý sa vyvolá IBA RAZ? (http://wiki.sa-mp.com/wiki/SetTimerEx viz parameter repeating) riešil by som to kontrolou či je pri pytli... (vyvolá sa timer, skontroluje, či stojí pri pytli...)

To už je jedno. Udělal jsem, že pokud hráč cvičí, nikdo ho zabít nemůže a ani /kill nemůže dát. Snad tohle pomohlo.

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