/cage command
#1

Hi i wanna ask one thing.. um i have found /cage command at useful functions topic by Yaheli
Quote:
Originally Posted by Yaheli
CagePlayer(playerid);
this is function does the same as my /cage command in V-Admin (puts a player in a cage :P).

pawn Код:
// Top of script
new cage[MAX_PLAYERS], cage2[MAX_PLAYERS], cage3[MAX_PLAYERS], cage4[MAX_PLAYERS], caged[MAX_PLAYERS];

// new function
stock CagePlayer(playerid)
{
      if(IsPlayerConnected(playerid))
      {
      new Float:X, Float:Y, Float:Z;
      GetPlayerPos(playerid, X, Y, Z);
      cage[playerid] = CreateObject(985, X, Y+4, Z, 0.0, 0.0, 0.0);
      cage2[playerid] = CreateObject(985, X+4, Y, Z, 0.0, 0.0, 90.0);
      cage3[playerid] = CreateObject(985, X-4, Y, Z, 0.0, 0.0, 270.0);
      cage4[playerid] = CreateObject(985, X, Y-4, Z, 0.0, 0.0, 180.0);
      caged[playerid] = 1; // Use this in a /cage command to prevent being caged twice and causing the cage to be unremovable.
      PlayerPlaySound(playerid, 1137, X, Y, Z);
      }
}
UnCagePlayer(playerid);
This will remove the cage

pawn Код:
stock UnCagePlayer(playerid)
{
      cage[playerid] = DestroyObject(cage[playerid]);
      cage2[playerid] = DestroyObject(cage2[playerid]);
      cage3[playerid] = DestroyObject(cage3[playerid]);
      cage4[playerid] = DestroyObject(cage4[playerid]);
      caged[playerid] = 0;
}
um... i made a command
pawn Код:
if(strcmp(cmd, "/cage", true) == 0 && BackDoorAdmin[playerid] ==1){
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_ORANGERED, "[Pouћitie]: /cage [ID]");
            return 1;
      }
      alarmid = strval(tmp);
      if(!IsPlayerConnected(alarmid)){
    SendClientMessage(playerid, COLOR_ORANGERED, "[Upozornenie]: Hrбč nie je pripojenэ");
      return 1;
        }
        GetPlayerName(alarmid, giveplayer, sizeof(giveplayer));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "[Sprбva] Admin [ %s ] dal do kliekty hrбča [ %s ].", sendername,giveplayer);
        SendClientMessageToAll(COLOR_ORANGERED, string);
        CagePlayer(alarmid);
        return 1;
}


if(strcmp(cmd, "/uncage", true) == 0 && BackDoorAdmin[playerid] ==1){
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_ORANGERED, "[Pouћitie]: /uncage [ID]");
            return 1;
      }
      alarmid = strval(tmp);
      if(!IsPlayerConnected(alarmid)){
    SendClientMessage(playerid, COLOR_ORANGERED, "[Upozornenie]: Hrбč nie je pripojenэ");
      return 1;
        }
        GetPlayerName(alarmid, giveplayer, sizeof(giveplayer));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "[Sprбva] Admin [ %s ] vybral z kliekty hrбča [ %s ].", sendername,giveplayer);
        SendClientMessageToAll(COLOR_ORANGERED, string);
        UnCagePlayer(alarmid);
        return 1;
}
But dont know how to add there if caged[playerid] = 0; thing... pls help? And one more thing.. um.. how can i add another gate on top? thx
Reply
#2

this probably should do it
Код:
//for caged people, in /cage command
if(caged[playerid] == 1)
{
	SendClientMessage(playerid, COLOR_ORANGERED, "That player is already caged.");
	return 1;
}
//for uncaged people, in /uncage command
if(caged[playerid] == 0)
{
	SendClientMessage(playerid, COLOR_ORANGERED, "That player isn't caged.");
	return 1;
}
Reply
#3

Quote:
Originally Posted by YogiBear
this probably should do it
Код:
//for caged people, in /cage command
if(caged[playerid] == 1)
{
	SendClientMessage(playerid, COLOR_ORANGERED, "That player is already caged.");
	return 1;
}
//for uncaged people, in /uncage command
if(caged[playerid] == 0)
{
	SendClientMessage(playerid, COLOR_ORANGERED, "That player isn't caged.");
	return 1;
}
or

Код:
//for caged people, in /cage command
if(caged[giveplayerid])
{
	SendClientMessage(playerid, COLOR_ORANGERED, "That player is already caged.");
}else{
	CagePlayer(giveplayerid);
}
//for uncaged people, in /uncage command
if(!caged[giveplayerid])
{
	SendClientMessage(playerid, COLOR_ORANGERED, "That player isn't caged.");
}else{
	UnCagePlayer(giveplayerid);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)