IchNar 0 Odesláno: 5. Říjen, 2017 Share Odesláno: 5. Říjen, 2017 Popis problému: Ako mám spraviť,že každú nahratú hodinu dostane hráč niečo? Chyby/varování kompilátoru a při běhu: -- Kód: -- Dodatečné poznámky: -- Link to comment Share on other sites More sharing options...
0 Kubko 22 Odesláno: 5. Říjen, 2017 Share Odesláno: 5. Říjen, 2017 (upraveno) public OnPlayerConnect(playerid) { gTime[playerid] = 0; // Vyresetujeme hodnotu našej glob. premennej // Predpokladám, že budeš mať v pláne nahratý čas aj ukladať a načítať (aby nestratil nahratý čas po odpojení) return 1; } public OnGameModeInit() { SetTimer("Minute", 60000, true); // Opakujúci sa timer, ktorý sa bude vyvolávať v jedno minútovom intervale return 1; } forward Minute(); public Minute() { for(new i, j = GetPlayerPoolSize(); i <= j; i++) { if(IsPlayerConnected(i) && !(++gTime[i] % 60)) //ID je pripojené a práve nahralo (ďalších) 60 minút {// Ak máš nejaký login, tak by som k podmienkam vyššie pridal ešte kontrolu na prihláseného hráča SendClientMessage(i, -1, "* Práve si nahral hodinu."); } } } Edited 5. Říjen, 2017 by Kubko Link to comment Share on other sites More sharing options...
0 IchNar 0 Odesláno: 6. Říjen, 2017 Author Share Odesláno: 6. Říjen, 2017 Nejako mi to nefunguje :////...Počkal som hodinu a nič. //sekundovy timer public TextdrawTimer(playerid) { if(noc > 0) { new str[42]; noc --; format(str,sizeof(str),"%s",TimeConvert(noc)); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],str); } if(sprcha > 0) { new str[42]; sprcha --; format(str,sizeof(str),"%s",TimeConvert(sprcha)); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],str); } if(volnycas2 > 0) { new str[42]; volnycas2 --; format(str,sizeof(str),"%s",TimeConvert(volnycas2)); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],str); } if(Obed2 > 0) { new str[42]; Obed2 --; format(str,sizeof(str),"%s",TimeConvert(Obed2)); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],str); } if(Praca > 0) { new str[42]; Praca --; format(str,sizeof(str),"%s",TimeConvert(Praca)); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],str); } if(volnycas > 0) { new str[42]; volnycas --; format(str,sizeof(str),"%s",TimeConvert(volnycas)); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],str); } if(Obed > 0) { new str[42]; Obed --; format(str,sizeof(str),"%s",TimeConvert(Obed)); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],str); } if(!(++NahratyCas[playerid] % 60)) { Peniaze[playerid] += 10.00; SendClientMessage(playerid,COLOR_RED,"YAYYYY"); } new string[24],str[24],str2[31],str3[24],str4[24],str5[24],str6[42]; new minuty,sekundy,hodiny; new dni,roky,mesiace; new Float:HP,Float:AR; GetPlayerHealth(playerid,HP); GetPlayerArmour(playerid,AR); gettime(hodiny,minuty,sekundy); getdate(roky,mesiace,dni); format(str,sizeof(str),"%.1f%",AR); format(string,sizeof(string),"%.1f%",HP); format(str2,sizeof(str2),"%s",GetWeaponNameByID(GetPlayerWeapon(playerid))); format(str3,sizeof(str3),"%i",GetPlayerAmmo(playerid)); format(str4,sizeof(str4),"%02d:%02d:%02d",hodiny,minuty,sekundy); format(str5,sizeof(str5),"%02d.%02d.%02d",dni,mesiace,roky); format(str6,sizeof(str6),"%.2f",Peniaze[playerid]); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][2],string); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][4],str); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][18],str2); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][20],str3); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][24],str4); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][25],str5); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][21],str6); PlayerTextDrawSetPreviewModel(playerid,TDEditor_PTD[playerid][23],GetPlayerSkin(playerid)); return 1; } //Takto ho ukladam DOF2_SetInt(Hrac,"NahratyCas",NahratyCas[playerid] += (gettime() - Player_ConnectTime[playerid])); Link to comment Share on other sites More sharing options...
0 Quiter 99 Odesláno: 6. Říjen, 2017 Share Odesláno: 6. Říjen, 2017 (upraveno) if(!(++NahratyCas[playerid] % 60)) { Peniaze[playerid] += 10.00; SendClientMessage(playerid,COLOR_RED,"YAYYYY"); } Tá podmienka sa mi nejako nepáči... Nikdy som taký zápis nevidel, radšej si ju sprav normálne a vyskúšaj to NahratyCas[playerid]++; if(NahratyCas[playerid]%60 == 0) { Peniaze[playerid] += 10.00; SendClientMessage(playerid,COLOR_RED,"YAYYYY"); } Edited 6. Říjen, 2017 by Quiter Link to comment Share on other sites More sharing options...
0 Hlavní moderátor vEnd 279 Odesláno: 6. Říjen, 2017 Hlavní moderátor Share Odesláno: 6. Říjen, 2017 Tá podmienka sa mi nejako nepáči... Nikdy som taký zápis nevidel, radšej si ju sprav normálne a vyskúšaj to Je správná. Když se operátor ++ či -- dají před proměnnou (prefixový zápis), tak se nejprve zvýší/sníží hodnota a pak teprve se provádí ostatní operace a úkony. Link to comment Share on other sites More sharing options...
0 IchNar 0 Odesláno: 6. Říjen, 2017 Author Share Odesláno: 6. Říjen, 2017 Mne to proste nejako nefunguje,keď sa prihlásim tak mi to len na začiatku napíše 4-krát tu správu a potom nič.A keď sa registrujem tak každú sekundu mi to píše a dáva peniaze. Link to comment Share on other sites More sharing options...
0 Kubko 22 Odesláno: 7. Říjen, 2017 Share Odesláno: 7. Říjen, 2017 Tvoj timer sa opakuje každú sekundu, nie minútu. if(!(++NahratyCas[playerid] % 3600)) 1 Link to comment Share on other sites More sharing options...
0 ATomas 286 Odesláno: 8. Říjen, 2017 Share Odesláno: 8. Říjen, 2017 (upraveno) Kdo ty lidi uci tyhle prasarny ? format(str,sizeof(str),"%.1f%",AR); format(string,sizeof(string),"%.1f%",HP); format(str2,sizeof(str2),"%s",GetWeaponNameByID(GetPlayerWeapon(playerid))); format(str3,sizeof(str3),"%i",GetPlayerAmmo(playerid)); format(str4,sizeof(str4),"%02d:%02d:%02d",hodiny,minuty,sekundy); format(str5,sizeof(str5),"%02d.%02d.%02d",dni,mesiace,roky); format(str6,sizeof(str6),"%.2f",Peniaze[playerid]); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][2],string); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][4],str); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][18],str2); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][20],str3); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][24],str4); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][25],str5); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][21],str6); Jinak bych doporucil si to oprintovat, aby jsi videl jak se ten kod chova public TextdrawTimer(playerid) { //kdyz to mas v globalni promene urcite je potreba to hracum zobrazit do jejich vlastniho TD, nebyl by lepsi jeden td pro vsechny ? //kdyz to zobrazujes vzdy do jednoho a toho sameho td, neslo by to vymyslet cele nejak lepe? tj to mit v jedne promene? if(--noc > 0) PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],TimeConvert(noc)); if(--sprcha > 0) PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],TimeConvert(sprcha)); if(--volnycas2 > 0) PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],TimeConvert(volnycas2)); if(--Obed2 > 0) PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],TimeConvert(Obed2)); if(--Praca > 0) PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],TimeConvert(Praca)); if(--volnycas > 0) PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],TimeConvert(volnycas)); if(--Obed > 0) PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][26],TimeConvert(Obed)); printf("playerid=%d nahratycas=%d",playerid,NahratyCas[playerid]); if(!(++NahratyCas[playerid] % 60*60)) { Peniaze[playerid] += 10.00; SendClientMessage(playerid,COLOR_RED,"YAYYYY"); } new string[42],minuty,sekundy,hodiny,dni,roky,mesiace,Float:HP,Float:AR; GetPlayerHealth(playerid,HP); GetPlayerArmour(playerid,AR); gettime(hodiny,minuty,sekundy); getdate(roky,mesiace,dni); format(string,sizeof(string),"%.1f%",HP); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][2],string); format(string,sizeof(string),"%.1f%",AR); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][4],string); format(string,sizeof(string),"%s",GetWeaponNameByID(GetPlayerWeapon(playerid))); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][18],string); format(string,sizeof(string),"%i",GetPlayerAmmo(playerid)); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][20],string); format(string,sizeof(string),"%02d:%02d:%02d",hodiny,minuty,sekundy); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][24],string); format(string,sizeof(string),"%02d.%02d.%02d",dni,mesiace,roky); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][25],string); format(string,sizeof(string),"%.2f",Peniaze[playerid]); PlayerTextDrawSetString(playerid,TDEditor_PTD[playerid][21],string); PlayerTextDrawSetPreviewModel(playerid,TDEditor_PTD[playerid][23],GetPlayerSkin(playerid)); return 1; } Edited 8. Říjen, 2017 by ATomas 1 Link to comment Share on other sites More sharing options...
0 IchNar 0 Odesláno: 9. Říjen, 2017 Author Share Odesláno: 9. Říjen, 2017 Díky moc pomohlo .Môžte LOCK. Link to comment Share on other sites More sharing options...
Dotaz
IchNar 0
Popis problému:
Ako mám spraviť,že každú nahratú hodinu dostane hráč niečo?
Chyby/varování kompilátoru a při běhu:
--
Kód:
Dodatečné poznámky:
--
Link to comment
Share on other sites
8 odpovědí na tuto otázku
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now