snake3321 1 Odesláno: 24. Březen, 2016 Share Odesláno: 24. Březen, 2016 Zdravím, rád bych se zeptal jak napawnit kód, který zakáže všem hráčům s proměnnou třeba 10 psaní jakýchkoliv příkazů, potřebuji to použít pro svůj jail systém... Předem děkuji. Link to comment Share on other sites More sharing options...
0 Lukasz 336 Odesláno: 24. Březen, 2016 Share Odesláno: 24. Březen, 2016 OnPlayerCommandText if( promenna == 10) return 1; Link to comment Share on other sites More sharing options...
0 DNLS 31 Odesláno: 24. Březen, 2016 Share Odesláno: 24. Březen, 2016 (upraveno) if(strcmp("/tvujprikaz", cmdtext)) { if(povol == true) { SCM(playerid, -1, "Příkaz je zakázaný"); return 0; y } return 1; } Edited 24. Březen, 2016 by Daniels Link to comment Share on other sites More sharing options...
0 snake3321 1 Odesláno: 24. Březen, 2016 Author Share Odesláno: 24. Březen, 2016 Hráči mohou bez problémů psát příkazy, kód přikládám níže, každopádně mi to něják nedává smysl, potřebuji, aby hráči prostě nemohli psát příkazy například /lv, /ls nebo /sf, prostě žádnej příkaz... Kód: public OnPlayerCommandText(playerid, cmdtext[]) { if(prikazy[playerid] == 10) { SendClientMessage(playerid, 0xFF0000AA, "Zde nemůžeš psát příkazy!"); return 0; } return 1; } Link to comment Share on other sites More sharing options...
0 Scydo 397 Odesláno: 24. Březen, 2016 Share Odesláno: 24. Březen, 2016 OnPlayerCommandText() Return Values: Return 1 if the command was processed, otherwise 0. ~> Takže Luky má pravdu: OnPlayerCommandText if( promenna == 10) return 1; Link to comment Share on other sites More sharing options...
0 snake3321 1 Odesláno: 24. Březen, 2016 Author Share Odesláno: 24. Březen, 2016 Ani tak nefunguje Link to comment Share on other sites More sharing options...
0 The hidden face 77 Odesláno: 24. Březen, 2016 Share Odesláno: 24. Březen, 2016 Používáš nějaký Command systém nebo standard strcmp? Link to comment Share on other sites More sharing options...
0 snake3321 1 Odesláno: 24. Březen, 2016 Author Share Odesláno: 24. Březen, 2016 Používám ZCMD. Link to comment Share on other sites More sharing options...
0 The hidden face 77 Odesláno: 24. Březen, 2016 Share Odesláno: 24. Březen, 2016 http://forum.sa-mp.com/showthread.php?t=91354: Important: Since v0.3 OnPlayerCommandText cannot be used anymore (also ZCMD_NO_CALLBACK option has been removed), but there are two new callbacks instead: OnPlayerCommandReceived(playerid, cmdtext[]) This one is called when someone sends a command. If you return 0 here, the command won't be performed. OnPlayerCommandPerformed(playerid, cmdtext[], success) And this one gets called after command execution, here if you do "return 0" the player will see standard "Unknown command" message. The "success" parameter is equal to value returned by command function returns (if it doesn't exist success will be 0).Note that it's not necessary to add these callbacks to your script if you don't use them. Link to comment Share on other sites More sharing options...
0 snake3321 1 Odesláno: 24. Březen, 2016 Author Share Odesláno: 24. Březen, 2016 Dobrá, jak to mám prosím zakódovat do pawna? Link to comment Share on other sites More sharing options...
0 The hidden face 77 Odesláno: 24. Březen, 2016 Share Odesláno: 24. Březen, 2016 (upraveno) public OnPlayerCommandReceived(playerid, cmdtext[]) { if(prikazy[playerid] == 10) { SendClientMessage(playerid, 0xFF0000AA, "Zde nemůžeš psát příkazy!"); return 0; } return 1; } Edited 24. Březen, 2016 by GaRGoyLeS Link to comment Share on other sites More sharing options...
0 snake3321 1 Odesláno: 24. Březen, 2016 Author Share Odesláno: 24. Březen, 2016 Stále to nefunguje.. Link to comment Share on other sites More sharing options...
0 The hidden face 77 Odesláno: 25. Březen, 2016 Share Odesláno: 25. Březen, 2016 Ukaž kód, kde nahráváš do prikazy[playerid] hodnotu 10... Link to comment Share on other sites More sharing options...
0 snake3321 1 Odesláno: 25. Březen, 2016 Author Share Odesláno: 25. Březen, 2016 Prakticky to funguje, až na to, že mi to tam automaticky hodí proměnnou na 10 a příkazy mi prostě nefungujou... Přídávám kód: public zavrit(playerid) { iOdpocet = 30; GameTextForPlayer(playerid, "~g~30", 1000, 3); nasodpocett[playerid] = SetTimerEx("nasodpocet", 1000, 1, "i", playerid); SetPlayerPos(playerid, -837.91528320313, -970.12078857422, 1619.0187988281); SetPlayerInterior(playerid, 1); ResetPlayerWeapons(playerid); SendClientMessage(playerid, 0xFF0000AA, "Byl jsi uvězněn na 30 sekund za pokus o sebevraždu!"); TextDrawHideForPlayer(playerid, Textdraw0); TextDrawHideForPlayer(playerid, Textdraw1); TextDrawHideForPlayer(playerid, Textdraw2); TextDrawHideForPlayer(playerid, Textdraw3); TextDrawHideForPlayer(playerid, Textdraw4); CancelSelectTextDraw(playerid); KillTimer(sebekill[playerid]); KillTimer(zavritt[playerid]); prikazy[playerid] = 10; return 1; } public nasodpocet(playerid) { if(iOdpocet != 0) { iOdpocet--; format(sString, sizeof(sString), "~g~%d", iOdpocet); GameTextForPlayer(playerid, sString, 1000, 3); } else { KillTimer(nasodpocett[playerid]); SetPlayerPos(playerid, 2375.9997558594, 1941.6708984375, 11.65625); SetPlayerInterior(playerid, 0); SendClientMessage(playerid, 0x00FF00AA, "Byl jsi propuštěn!"); prikazy[playerid] = 0; } return 1; } public OnPlayerCommandReceived(playerid, cmdtext[]) { if(prikazy[playerid] == 10) { SendClientMessage(playerid, 0xFF0000AA, "Zde nemůžeš psát příkazy!"); return 0; } return 1; } Link to comment Share on other sites More sharing options...
0 Paulee 16 Odesláno: 25. Březen, 2016 Share Odesláno: 25. Březen, 2016 Tak když, při vyvolání příkazu dáš prikazy[playerid] na 10 a pod tím máš tu podmínku, tak je asi jasné že ti ten prikaz zavřít nepůjde A co teda chceš ?? Link to comment Share on other sites More sharing options...
0 Scydo 397 Odesláno: 25. Březen, 2016 Share Odesláno: 25. Březen, 2016 Prakticky to funguje, až na to, že mi to tam automaticky hodí proměnnou na 10 a příkazy mi prostě nefungujou.. KillTimer(zavritt[playerid]); prikazy[playerid] = 10; /* <---------------- */ return 1; } ~> Automaticky se rozhodně nenastaví... Link to comment Share on other sites More sharing options...
0 The hidden face 77 Odesláno: 25. Březen, 2016 Share Odesláno: 25. Březen, 2016 Nevím proč ti to nejde... Chyba musí být u tebe někde jinde (zkoukni jestli náhodou nemanipuluješ s proměnnou prikazy ještě někde jinde), já si ten tvůj kód zkopčil a vyzkoušel a vše funguje, jak má. Link to comment Share on other sites More sharing options...
0 snake3321 1 Odesláno: 25. Březen, 2016 Author Share Odesláno: 25. Březen, 2016 Píšu, že on funguje, ale funguje pořád aniž by měl dotyčný proměnnou prikazy na 10... Ihned po připojení na server, kde se žádná proměnná nenastavuje prostě nemůže hráč psát jakékoliv příkazy... Pokusím se to něják poupravit ještě, dal jsem sem vše co obsahuje proměnnou příkazy. Kdyžtak dám tedy vědět... Link to comment Share on other sites More sharing options...
0 Scydo 397 Odesláno: 25. Březen, 2016 Share Odesláno: 25. Březen, 2016 Prakticky to funguje, až na to, že mi to tam automaticky hodí proměnnou na 10 a příkazy mi prostě nefungujou.. KillTimer(zavritt[playerid]); prikazy[playerid] = 10; /* <---------------- */ return 1; } ~> Automaticky se rozhodně nenastaví... Link to comment Share on other sites More sharing options...
0 snake3321 1 Odesláno: 25. Březen, 2016 Author Share Odesláno: 25. Březen, 2016 Problém byl ten, že se to nastavovalo celý úplně naopak, takže když byla proměnná na 0 nešlo to, ale jen když byla proměnná na 10, což jsme tam měli my, tak jen tak to fungovalo, takže bych musel hráčovi nastavovat proměnnou na 10 aby mu to fungovalo, to jsem logicky neudělal a místo proměnné 10 jsem tam dal 0, vyřešil jsem to takto: public OnPlayerCommandReceived(playerid, cmdtext[]) { if(prikazy[playerid] == 0) { return 0; } else SendClientMessage(playerid, 0xFF0000AA, "Zde nemůžeš psát příkazy!"); return 1; } Link to comment Share on other sites More sharing options...
Dotaz
snake3321 1
Zdravím,
rád bych se zeptal jak napawnit kód, který zakáže všem hráčům s proměnnou třeba 10 psaní jakýchkoliv příkazů, potřebuji to použít pro svůj jail systém... Předem děkuji.
Link to comment
Share on other sites
19 odpovědí na tuto otázku
Recommended Posts