Cuff/Uncuff
#1

I seem to have been failing to make a cuff and uncuff cmd always plenty of errors please help me D: my gteams are


if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != ARMY && gTeam[playerid] != FBI)
Reply
#2

pawn Code:
if(gTeam[playerid] != COP || gTeam[playerid] != SWAT || gTeam[playerid] != ARMY || gTeam[playerid] != FBI)  return SendClientMessage(playerid, COLOR_[yourcolor], "Your not allowed to cuff");

if(gTeam[playerid] == COP || gTeam[playerid] == SWAT || gTeam[playerid] == ARMY || gTeam[playerid] == FBI)  {
// command effect
return 1;
}
Reply
#3

i managed to make this but whenever i try to cuff a player i get cuffed myself

pawn Code:
if(!strcmp(cmd,"/cuff",true))
{
cmd=strtok(cmdtext,idx);
if(!strlen(cmd)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /cuff playerid");
TogglePlayerControllable(playerid,0);
GameTextForPlayer(playerid, "~y~ hand cuffs!",2500,3);
return true;
}
Reply
#4

Its not that easy making a cmd with exxample: /ban [ID]
Reply
#5

um any ideas how to fix that cmd?
Reply
#6

pawn Code:
if(!strcmp(cmdtext,"/cuff",true))
  {
   if(gTeam[playerid] = COP || gTeam[playerid] = SWAT || gTeam[playerid] = ARMY || gTeam[playerid] = FBI)
   {
    new giveplayerid;
    tmp=strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /cuff playerid");
    giveplayerid = ReturnUser(tmp);
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,COLOR_GREY,"Invalid player id.");
    TogglePlayerControllable(giveplayerid,0);
    GameTextForPlayer(giveplayerid, "~y~ You have been Cuffed!",2500,3);
   }
   return 1;
  }
and Paste this on top

pawn Code:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21) // Strip out leading spaces
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos])) // Check whole passed string
    {
        // If they have a numeric name you have a problem (although names are checked on id failure)
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
            {
                /*if (playerid != INVALID_PLAYER_ID)
                {
                    SendClientMessage(playerid, 0xFF0000AA, "User not connected");
                }*/

                userid = INVALID_PLAYER_ID;
            }
            else
            {
                return userid; // A player was found
            }
        }
        /*else
        {
            if (playerid != INVALID_PLAYER_ID)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
            }
            userid = INVALID_PLAYER_ID;
        }
        return userid;*/

        // Removed for fallthrough code
    }
Reply
#7

I'd suggest you moving to dcmd to make commands with parameters.
But if you insist:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new tmp[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp("/cuff", cmd, true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /cuff [playerid]");
        if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,0xFF0000FF,"Player is not connected");

        TogglePlayerControllable(strval(tmp),0);
        GameTextForPlayer(strval(tmp), "~y~ hand cuffs!",2500,3);
        return 1;
    }
    return 0;
}
Reply
#8

thank you so much it works now and for fast response
Reply
#9

Welcome
Reply
#10

pawn Code:
if(strcmp("/uncuff", cmd, true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /uncuff [playerid]");
        if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,0xFF0000FF,"Player is not connected");

        TogglePlayerControllable(strval(tmp),1);
        GameTextForPlayer(strval(tmp), "~y~ hands uncuffed!",2500,3);
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)