SA-MP Forums Archive
Deny All commands exept 2 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Deny All commands exept 2 (/showthread.php?tid=296648)



Deny All commands exept 2 - Super_Panda - 12.11.2011

While the player is in jail i dont want him to be able to use any cmd just /help & /ask
pawn Код:
if (GetPlayerVirtualWorld[playerid] == 1)
{
        SendClientMessage(playerid, 0xFF0000AA, "You cannot use any command just /help & /ask");
    return 0;
}



Re: Deny All commands exept 2 - MadeMan - 12.11.2011

Nice. Anything wrong?


Re: Deny All commands exept 2 - [03]Garsino - 12.11.2011

Quote:
Originally Posted by Super_Panda
Посмотреть сообщение
While the player is in jail i dont want him to be able to use any cmd just /help & /ask
pawn Код:
if (GetPlayerVirtualWorld[playerid] == 1 && strcmp(cmdtext, "/help") && strcmp(cmdtext, "/ask")) return SendClientMessage(playerid, 0xFF0000AA, "You cannot use any command just /help & /ask");
That should work.


Respuesta: Deny All commands exept 2 - Super_Panda - 12.11.2011

pawn Код:
C:\Users\Alex\Desktop\Untitled.pwn(133) : warning 235: public function lacks forward declaration (symbol "OnPlayerCommandReceived")
C:\Users\Alex\Desktop\Untitled.pwn(135) : error 028: invalid subscript (not an array or too many subscripts): "GetPlayerVirtualWorld"
C:\Users\Alex\Desktop\Untitled.pwn(135) : warning 215: expression has no effect
C:\Users\Alex\Desktop\Untitled.pwn(135) : error 001: expected token: ";", but found "]"
C:\Users\Alex\Desktop\Untitled.pwn(135) : error 029: invalid expression, assumed zero
C:\Users\Alex\Desktop\Untitled.pwn(135) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if (GetPlayerVirtualWorld[playerid] == 10 && strcmp(cmdtext, "/help") && strcmp(cmdtext, "/ask")) return SendClientMessage(playerid, 0xFF0000AA, "You cannot use any command just /help & /ask");
    {


    }
    return 1;
}



Re: Deny All commands exept 2 - [03]Garsino - 12.11.2011

1) Use OnPlayerCommandText, not OnPlayerCommandReceived.
2) It's GetPlayerVirtualWorld(playerid) not GetPlayerVirtualWorld[playerid]


Re: Deny All commands exept 2 - Calgon - 12.11.2011

In short, this should work:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (GetPlayerVirtualWorld(playerid) == 10 && !strcmp(cmdtext, "/help") && !strcmp(cmdtext, "/ask")) {
        SendClientMessage(playerid, 0xFF0000AA, "You cannot use any command just /help & /ask");
        return 0;
    }
   
    return 1;
}
[03]Garsino must have accidentally typed the wrong brackets and forgotten the exclamation mark before strcmp() or == 0 at the end, and was thinking you were using a more modern command processor (zcmd).


Respuesta: Deny All commands exept 2 - Super_Panda - 12.11.2011

That'll work for strcmp I need it for DCMD or SSCANF


Re: Deny All commands exept 2 - whitedragon - 12.11.2011

easy is check in help command that player is jail you return that he can't use it


Re: Deny All commands exept 2 - [03]Garsino - 12.11.2011

Quote:
Originally Posted by Calgon
Посмотреть сообщение
[03]Garsino must have accidentally typed the wrong brackets and forgotten the exclamation mark before strcmp() or == 0 at the end, and was thinking you were using a more modern command processor (zcmd).
Nope... Look at the posts he posted (first post for example). I just copied his code and added the extra checks. Oh and; your code is wrong. He want to deny every command except /help and /faq. Your code blocks the only command he didn't want to block.

Super_Panda: OnPlayerCommandText can be used with DCMD. And SSCANF is not a command processor...


Re: Deny All commands exept 2 - Calgon - 12.11.2011

Ah, my bad. Sorry.