Jump to content
  • 0

pomoc Zákaz příkazů?


snake3321

Dotaz

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

  • 0


if(strcmp("/tvujprikaz", cmdtext))
{
        if(povol == true)
        {
           SCM(playerid, -1, "Příkaz je zakázaný");
           return 0; y
        }
        return 1;

}

Edited by Daniels
Link to comment
Share on other sites

  • 0

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

  • 0

 

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

  • 0

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

  • 0

public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(prikazy[playerid] == 10)
{
SendClientMessage(playerid, 0xFF0000AA, "Zde nemůžeš psát příkazy!");
return 0;
}
return 1;
}
Edited by GaRGoyLeS
Link to comment
Share on other sites

  • 0

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

  • 0

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

  • 0

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

  • 0

 

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

  • 0

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

Guest
This topic is now closed to further replies.
×
×
  • Create New...