PartyGame 0 Odesláno: 15. Duben, 2021 Share Odesláno: 15. Duben, 2021 Zdravím komunito, poprosil bych Vás, kdo by mi pomohl poradit s tímto kódem. Jedná se o chat, když hráč má VIP, a hráč co nemá VIP, jestli tento kód je dobře (podmínky) Jelikož mě to nějak blblo když jsem to měl else { a neměl jsem tam else if(HaveVIP(i) == 0), zda je to dobře tento kód nebo by to někdo udělal jinak? Děkuji za odpovědi. if(HaveVIP(i) == 1) { format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); } else if(HaveVIP(i) == 0) { format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); } Link to comment Share on other sites More sharing options...
0 DeLeTeCZ 17 Odesláno: 15. Duben, 2021 Share Odesláno: 15. Duben, 2021 nemělo by to být HaveVIP(playerid) ? :D Link to comment Share on other sites More sharing options...
0 PartyGame 0 Odesláno: 15. Duben, 2021 Author Share Odesláno: 15. Duben, 2021 playerid? 1 Link to comment Share on other sites More sharing options...
0 PartyGame 0 Odesláno: 15. Duben, 2021 Author Share Odesláno: 15. Duben, 2021 Právě že nad tím mám ForMaxPlayer(i) { if(HaveVIP(i) == 1) { Link to comment Share on other sites More sharing options...
0 PartyGame 0 Odesláno: 15. Duben, 2021 Author Share Odesláno: 15. Duben, 2021 Dobře, takže tedy takhle: if(HaveVIP(playerid) == 1) { format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); } else if(HaveVIP(playerid) == 0) { format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string) } 1 Link to comment Share on other sites More sharing options...
0 DeLeTeCZ 17 Odesláno: 15. Duben, 2021 Share Odesláno: 15. Duben, 2021 Tak nějak nechápu proč tam máš cyklus pro všechny hráče, pokud se jedná o zprávu do chatu Link to comment Share on other sites More sharing options...
0 PartyGame 0 Odesláno: 15. Duben, 2021 Author Share Odesláno: 15. Duben, 2021 No však jedná se o zprávu do chatu, takže (i), takže tedy takto? ForMaxPlayer(i) { if(HaveVIP(playerid) == 1) { format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); } else if(HaveVIP(playerid) == 0) { format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); } } Link to comment Share on other sites More sharing options...
0 DeLeTeCZ 17 Odesláno: 15. Duben, 2021 Share Odesláno: 15. Duben, 2021 (upraveno) Chápu pokud to posíláš přes SendClientMessage, tak ano, jinak by to mělo stačit takto public OnPlayerText(playerid, text[]) { if(HaveVIP(playerid) == 1) { format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,text); } else if(HaveVIP(playerid) == 0) { format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,text) } SendClientMessageToAll(-1,STR); return 0; } Edited 15. Duben, 2021 by DeLeTeCZ 1 Link to comment Share on other sites More sharing options...
0 DeLeTeCZ 17 Odesláno: 15. Duben, 2021 Share Odesláno: 15. Duben, 2021 (upraveno) Ještě dodám, že i pokud to chceš z nějakého důvodu přes SendClientMessage tak i tak, jak to máš ty se to zbytečně formátuje při každém průchou cyklu public OnPlayerText(playerid, text[]) { if(HaveVIP(playerid) == 1) { format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,text); } else if(HaveVIP(playerid) == 0) { format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,text) } ForMaxPlayers(i) { SendClientMessage(i,-1,STR); } return 0; } Edited 15. Duben, 2021 by DeLeTeCZ 1 Link to comment Share on other sites More sharing options...
0 PartyGame 0 Odesláno: 15. Duben, 2021 Author Share Odesláno: 15. Duben, 2021 Však tento můj kod není dobře? ForMaxPlayer(i) { if(HaveVIP(playerid) == 1) { format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); } else if(HaveVIP(playerid) == 0) { format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); } } Link to comment Share on other sites More sharing options...
0 PartyGame 0 Odesláno: 15. Duben, 2021 Author Share Odesláno: 15. Duben, 2021 Opravuji, takto: ForMaxPlayer(i) { if(HaveVIP(playerid) == 1) { new STR[456]; format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); SCM(i, GetPlayerColor(playerid), STR); } else if(HaveVIP(playerid) == 0) { new STR[456]; format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); SCM(i, GetPlayerColor(playerid), STR); } } Link to comment Share on other sites More sharing options...
0 DeLeTeCZ 17 Odesláno: 15. Duben, 2021 Share Odesláno: 15. Duben, 2021 Tak fungovat to bude, jen je zbytečné tu zprávu formátovat při každém průchodu cyklu, když to stačí jednou (viz, můj předchozí příspěvek) Link to comment Share on other sites More sharing options...
0 Scydo 397 Odesláno: 15. Duben, 2021 Share Odesláno: 15. Duben, 2021 (upraveno) před 45minutami, PartyGame said: nebo by to někdo udělal jinak? Já bych to udělal jinak, protože máš dvě podmínky pokud ale nemáš jinak. // Někdo napsal do chatu: public OnPlayerText(playerid, text[]) { /* playerid = ID toho hráče, co napsal do chatu, text[] = Text toho hráče co napsal do chatu */ // Jestliže má vip: if (HaveVIP(playerid) == 1) { // <--- Zde máš svoje "pokud" // Tak mu formátujeme zprávu, že jde o VIP hráče: format(STR, sizeof(STR), "[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, PlayerName(playerid), playerid,string); } //V případě ale, že ho nemá: else { // <--- Zde máš svoje "jinak" // Tak se formátuje obyčejná zpráva: format(STR, sizeof(STR), "[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8,PlayerName(playerid), playerid, string); } // Tak či tak, se jedna ze formátovaných zpráv všem na serveru napíše: SendClientMessageToAll(0xA9C4E400, STR); return 0; } Edited 15. Duben, 2021 by Scydo 1 2 Link to comment Share on other sites More sharing options...
0 Paulee 16 Odesláno: 16. Duben, 2021 Share Odesláno: 16. Duben, 2021 (upraveno) před 13hodinami, PartyGame said: Opravuji, takto: ForMaxPlayer(i) { if(HaveVIP(playerid) == 1) { new STR[456]; format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); SCM(i, GetPlayerColor(playerid), STR); } else if(HaveVIP(playerid) == 0) { new STR[456]; format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string); SCM(i, GetPlayerColor(playerid), STR); } } Jde vidět, že to cpeš do zdrojáku od PW a nevíš co to dělá. ForMaxPlayer je definice cyklu for, který projede všechny hráče na serveru a to je kravina. ForMaxPlayer u PW používal například pro to aby administrátoři viděli příkazy co hráči píšou, PMka a podobně. Takže cyklus zahoď a postupuj podle návodu od @Scydo Edited 16. Duben, 2021 by Paulee 1 Link to comment Share on other sites More sharing options...
0 PartyGame 0 Odesláno: 16. Duben, 2021 Author Share Odesláno: 16. Duben, 2021 To je naprostá kravina :D 3 Link to comment Share on other sites More sharing options...
Dotaz
PartyGame 0
Zdravím komunito,
poprosil bych Vás, kdo by mi pomohl poradit s tímto kódem.
Jedná se o chat, když hráč má VIP, a hráč co nemá VIP, jestli tento kód je dobře (podmínky)
Jelikož mě to nějak blblo když jsem to měl else { a neměl jsem tam else if(HaveVIP(i) == 0), zda je to dobře tento kód nebo by to někdo udělal jinak?
Děkuji za odpovědi.
Link to comment
Share on other sites
14 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