Disable Commands in jail.
#1

Hi, in my server - everyone can use teleport commands etc, and is there a way to disable ALL commands while in jail?


This is my /jail command so far
pawn Код:
if(strcmp(cmd, "/jail", true) == 0)
    {
        new tmp2[256];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /jail [playerid] [time]");
        tmp2 = strtok(cmdtext, idx);
        new money = strval(tmp2);
        if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /jail [playerid] [time]");
        new playa;
        playa = ReturnUser(tmp);
        if(PlayerInfo[playerid][pAdmin] < 2) return DenyMessage(playerid, 2);
        if(!IsPlayerConnected(playa)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Player ID.");
        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playa][pAdmin]) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You can't jail a higher level Admin !");
        if(playa != INVALID_PLAYER_ID)
        {
            PlayerInfo[playa][pPrisonTime] = money;
            PlayerInfo[playa][pPrison] = 1;
            GetPlayerName(playa, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            ResetPlayerWeapons(playa);
            GameTextForPlayer(playa, "~r~Busted", 3000, 3);
            SetPlayerInterior(playa, 3); //(0 eller 3)
            SetPlayerPos(playa, 198.5319,162.3093,1003.0300); //(579.90295410156, -3190.4956054688, 11.467748641968) (198.5319,162.3093,1003.0300)
            format(string, sizeof(string), "\"%s\" has been jailed by Admin \"%s\" for %d seconds.", giveplayer, sendername, money);
            SendClientMessageToAll(COLOR_YELLOW, string);
            SetTimerEx("UnJail",PlayerInfo[playa][pPrisonTime]*1000,0,"d",playa);
        }
        return 1;
    }
    if(strcmp(cmd, "/unjail", true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unjail [playerid]");
        new playa = ReturnUser(tmp);
        if(PlayerInfo[playerid][pAdmin] < 2) return DenyMessage(playerid, 2);
        if(!IsPlayerConnected(playa)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Player ID.");
        if(playa != INVALID_PLAYER_ID)
        {
            GetPlayerName(playa, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            SetPlayerWorldBounds(playerid,20000.0000,-20000.0000,20000.0000,-20000.0000); //Reset world to player
            SetPlayerInterior(playa, 0);
            SetPlayerPos(playa, 645.0193,-3114.3647,10.9957);
            format(string, sizeof(string), "\"%s\" has been un-jailed by Admin \"%s\".", giveplayer, sendername);
            SendClientMessageToAll(COLOR_YELLOW, string);
        }
        return 1;
    }
Reply
#2

Yeah i'll make an example


pawn Код:
// Variable
new jailed[MAX_PLAYERS];
// Command
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
    if(jailed[playerid] = 1)
    {
             SendClientMessage(playerid,COLOR,"[Server]: Your in jail, you can't use commands");
             return 0;
             }
            // other coding here
            return 1;
}
Reply
#3

Quote:
Originally Posted by Steven82
Посмотреть сообщение
Yeah i'll make an example


pawn Код:
// Variable
new jailed[MAX_PLAYERS];
// Command
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
    if(jailed[playerid] = 1)
    {
             SendClientMessage(playerid,COLOR,"[Server]: Your in jail, you can't use commands");
             return 0;
             }
            // other coding here
            return 1;
}
So that code will disable all /cmds?
Reply
#4

You got to place it in all cmds, just this part though

pawn Код:
if(jailed[playerid] = 1)    
{            
 SendClientMessage(playerid,COLOR,"[Server]: Your in jail, you can't use commands");            
 return 0;            
}
Reply
#5

Or what you could do is put it over all your other commands under OnPlayerCommandText. Like so:
pawn Код:
OnPlayerCommandText
if(jailed[playerid] = 1)    
{            
 SendClientMessage(playerid,COLOR,"[Server]: Your in jail, you can't use commands");            
 return 0;  
}
else
{
     //Rest of your commands here
}
Reply
#6

Go ahead and try it.
Reply
#7

You do not need to place it in every command.

Add this at the top of OnPlayerCommandText

pawn Код:
if (PlayerInfo[playerid][pPrison] == 1)    
{            
    return SendClientMessage(playerid, 0xFF000000, "ERROR: You cannot use commands whilst in jail.");
}
Reply
#8

Quote:
Originally Posted by bigcomfycouch
Посмотреть сообщение
You do not need to place it in every command.

Add this at the top of OnPlayerCommandText

pawn Код:
if (PlayerInfo[playerid][pPrison] == 1)    
{            
    return SendClientMessage(playerid, 0xFF000000, "ERROR: You cannot use commands whilst in jail.");
}
He needs to make PlayerInfo variables now, and now he needs to make an enum like a file based register login system. My way was harder for putting it in every script but my way doesn't require all the variables and confusion to new scripters. No offense, it looks like you just copioed that right out of your script or someone else's.
Reply
#9

Quote:
Originally Posted by bigcomfycouch
Посмотреть сообщение
You do not need to place it in every command.

Add this at the top of OnPlayerCommandText

pawn Код:
if (PlayerInfo[playerid][pPrison] == 1)    
{            
    return SendClientMessage(playerid, 0xFF000000, "ERROR: You cannot use commands whilst in jail.");
}
I can still use CMDS, like for example /menu, and then I can choose a teleport.
Reply
#10

Quote:
Originally Posted by Steven82
Посмотреть сообщение
He needs to make PlayerInfo variables now, and now he needs to make an enum like a file based register login system. My way was harder for putting it in every script but my way doesn't require all the variables and confusion to new scripters. No offense, it looks like you just copioed that right out of your script or someone else's.
He already have the variables.
PlayerInfo is the enum.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)