/cage (id) (reason)
#1

I need to add a reason to the /cage cmd.
Ex: /cage (id) (reason)
Ex2: /cage 1 hacking
Ex3: ** ADMIN CAGE: Noobster (2) has been caged - hacking

pawn Code:
dcmd_cage(playerid,params[])
{
    if(AccInfo[playerid][Level] < 4)
    return ErrorMessages(playerid, 5);

    new Index;
    new tmp[256];  tmp  = strtok(params, Index);
    new tmp2[256]; tmp2 = strtok(params, Index);
    new player1 = ReturnUser(tmp);
    new time = strval(tmp2);

    if(!strlen(tmp)) return
    SendClientMessage(playerid, LIGHTBLUE2, "Usage: /cage [PlayerID] [Time]") &&
    SendClientMessage(playerid, orange, "Function: Will hold player in a Cage by specified Time");

    if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
    {

    if(!strlen(tmp2))
    return SendClientMessage(playerid, red, "ERROR: Not specified Time!");

    if(time < 10)
    return SendClientMessage(playerid, red, "ERROR: Time must be greater than 10 Seconds!");

    if(AccInfo[player1][pCaged] == 1)
    return SendClientMessage(playerid, red, "ERROR: Player is already in Cage!");

    new string[128];
    new playername[MAX_PLAYER_NAME];
    new adminname [MAX_PLAYER_NAME];
    SendCommandToAdmins(playerid,"Cage");
    GetPlayerName(player1, playername, sizeof(playername));
    GetPlayerName(playerid, adminname, sizeof(adminname));
    format(string, sizeof(string), "** ADMIN CAGE: %s Has Been Caged", playername);
    SendClientMessageToAll(adminpink, string);
    TogglePlayerControllable(player1, 0);
    AccInfo[player1][pCageTime] = time;
    AccInfo[player1][pCaged] = 1;
    GetPlayerPos(playerid, LPosX[player1], LPosY[player1], LPosZ[player1]);
    SetTimerEx("CagePlayer", 1000, 0, "i", player1);
    SetTimerEx("UnCagePlayer", AccInfo[player1][pCageTime]*1000, 0, "i", player1);
    }
    else return ErrorMessages(playerid, 3);
    return 1;
    }
Reply
#2

Im not sure but yes. Try this one! [Untested]



pawn Code:
dcmd_cage(playerid,params[])
{
    if(AccInfo[playerid][Level] < 4)
    return ErrorMessages(playerid, 5);

    new Index;
    new tmp[256];  tmp  = strtok(params, Index);
    new tmp2[256]; tmp2 = strtok(params, Index);
    new player1 = ReturnUser(tmp);
    new time = strval(tmp2);
    new reason = strval(tmp3);

    if(!strlen(tmp)) return
    SendClientMessage(playerid, LIGHTBLUE2, "Usage: /cage [PlayerID] [Time]") &&
    SendClientMessage(playerid, orange, "Function: Will hold player in a Cage by specified Time");

    if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
    {

    if(!strlen(tmp2))
    return SendClientMessage(playerid, red, "ERROR: Not specified Time!");

    if(time < 10)
    return SendClientMessage(playerid, red, "ERROR: Time must be greater than 10 Seconds!");

    if(AccInfo[player1][pCaged] == 1)
    return SendClientMessage(playerid, red, "ERROR: Player is already in Cage!");

    if(!strlen(tmp3))
    return SendClientMessage(playerid, red, "ERROR: You must enter a reason!");

    new string[128];
    new playername[MAX_PLAYER_NAME];
    new adminname [MAX_PLAYER_NAME];
    SendCommandToAdmins(playerid,"Cage");
    GetPlayerName(player1, playername, sizeof(playername));
    GetPlayerName(playerid, adminname, sizeof(adminname));
    format(string, sizeof(string), "** ADMIN CAGE: %s Has Been Caged", playername);
    SendClientMessageToAll(adminpink, string);
    TogglePlayerControllable(player1, 0);
    AccInfo[player1][pCageTime] = time;
    AccInfo[player1][pCaged] = 1;
    GetPlayerPos(playerid, LPosX[player1], LPosY[player1], LPosZ[player1]);
    SetTimerEx("CagePlayer", 1000, 0, "i", player1);
    SetTimerEx("UnCagePlayer", AccInfo[player1][pCageTime]*1000, 0, "i", player1);
    }
    else return ErrorMessages(playerid, 3);
    return 1;
}
Reply
#3

Quote:
Originally Posted by Ballu Miaa
View Post
Im not sure but yes. Try this one! [Untested]



pawn Code:
dcmd_cage(playerid,params[])
{
    if(AccInfo[playerid][Level] < 4)
    return ErrorMessages(playerid, 5);

    new Index;
    new tmp[256];  tmp  = strtok(params, Index);
    new tmp2[256]; tmp2 = strtok(params, Index);
    new player1 = ReturnUser(tmp);
    new time = strval(tmp2);
    new reason = strval(tmp3);

    if(!strlen(tmp)) return
    SendClientMessage(playerid, LIGHTBLUE2, "Usage: /cage [PlayerID] [Time]") &&
    SendClientMessage(playerid, orange, "Function: Will hold player in a Cage by specified Time");

    if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
    {

    if(!strlen(tmp2))
    return SendClientMessage(playerid, red, "ERROR: Not specified Time!");

    if(time < 10)
    return SendClientMessage(playerid, red, "ERROR: Time must be greater than 10 Seconds!");

    if(AccInfo[player1][pCaged] == 1)
    return SendClientMessage(playerid, red, "ERROR: Player is already in Cage!");

    if(!strlen(tmp3))
    return SendClientMessage(playerid, red, "ERROR: You must enter a reason!");

    new string[128];
    new playername[MAX_PLAYER_NAME];
    new adminname [MAX_PLAYER_NAME];
    SendCommandToAdmins(playerid,"Cage");
    GetPlayerName(player1, playername, sizeof(playername));
    GetPlayerName(playerid, adminname, sizeof(adminname));
    format(string, sizeof(string), "** ADMIN CAGE: %s Has Been Caged", playername);
    SendClientMessageToAll(adminpink, string);
    TogglePlayerControllable(player1, 0);
    AccInfo[player1][pCageTime] = time;
    AccInfo[player1][pCaged] = 1;
    GetPlayerPos(playerid, LPosX[player1], LPosY[player1], LPosZ[player1]);
    SetTimerEx("CagePlayer", 1000, 0, "i", player1);
    SetTimerEx("UnCagePlayer", AccInfo[player1][pCageTime]*1000, 0, "i", player1);
    }
    else return ErrorMessages(playerid, 3);
    return 1;
}
It doesnt say the reason. it's just blank
EDIT: i changed this line
pawn Code:
format(string, sizeof(string), "** ADMIN CAGE: %s Has Been Caged - %s",playername,params[4]);
and it worked. Thanks for the help!
Reply
#4

And how can i get this to say Caged for (time) seconds

pawn Code:
public CagePlayer(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new Index;
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        SetPlayerPos(playerid, X, Y, Z+5);
        cage[playerid] = CreateObject(985, X, Y+4, Z+5, 0.0, 0.0, 0.0);
        cage2[playerid] = CreateObject(985, X+4, Y, Z+5, 0.0, 0.0, 90.0);
        cage3[playerid] = CreateObject(985, X-4, Y, Z+5, 0.0, 0.0, 270.0);
        cage4[playerid] = CreateObject(985, X, Y-4, Z+5, 0.0, 0.0, 180.0);
        cage5[playerid] = CreateObject(985, X, Y+1.8, Z+3.5, 90.0, 0.0, 0);
        cage6[playerid] = CreateObject(985, X, Y+1.8, Z+10, 90.0, 0.0, 0);
        TogglePlayerControllable(playerid, 1);
        PlayerPlaySound(playerid,1137,0.0,0.0,0.0);
        GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~r~Caged ~n~for  seconds",3000, 3, tmp2);
    }
}
Reply
#5

Set timers. Example:
pawn Code:
// Top of the script
forward RemoveCageForPlayer(playerid);

// Example in the command
if(sscanf(params,"i",seconds))
{
    // The cage code
    SetTimerEx("RemoveCageForPlayer",seconds * 1000,false,"i",playerid);
}

// Somewhere in the code
public RemoveCageForPlayer(playerid)
{
    // Cage removal code
}
Reply
#6

Quote:
Originally Posted by googamalugafoo
can you help me with a command. im trying to add a reason to why the player is being caged.

https://sampforum.blast.hk/showthread.php?tid=303717
You should use sscanf and this would be much simpler. Oh and just so you're aware, it may be a good idea to change from dcmd to zcmd because dcmd is much slower (kind of like Dini and y_ini).
Reply
#7

as realcop228 stated above i would definetely use zcmd so let me show you a cage command using zcmd and sscanf:
pawn Code:
CMD:cage(playerid,params[])
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1,"ERROR:You are not Rcon Administrator to use this command!");
else
{
new pid,pname[MAX_PLAYERS],string[128],reason[50];
GetPlayerName(playerid,pname,sizeof(pname));
if(sscanf(params,"rs[50]",pid,reason)) return SendClientMessage(playerid,-1,"SYNTAX ERROR:/cage [playerid] [reason]");
else if(!IsPlayerConnected(pid)||pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"ERROR:This player isn't connected");
else
{
format(string,sizeof(string),"ADMIN CAGE:%s has been caged-%s",pname,reason);
SendClientMessageToAll(-1,string);
CagePlayer(playerid);
}
}
return 1;
hope i helped
Reply
#8

Quote:
Originally Posted by vassilis
View Post
as realcop228 stated above i would definetely use zcmd so let me show you a cage command using zcmd and sscanf:
pawn Code:
CMD:cage(playerid,params[])
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1,"ERROR:You are not Rcon Administrator to use this command!");
else
{
new pid,pname[MAX_PLAYERS],string[128],reason[50];
GetPlayerName(playerid,pname,sizeof(pname));
if(sscanf(params,"rs[50]",pid,reason)) return SendClientMessage(playerid,-1,"SYNTAX ERROR:/cage [playerid] [reason]");
else if(!IsPlayerConnected(pid)||pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"ERROR:This player isn't connected");
else
{
format(string,sizeof(string),"ADMIN CAGE:%s has been caged-%s",pname,reason);
SendClientMessageToAll(-1,string);
CagePlayer(playerid);
}
}
return 1;
hope i helped
can i use both zcmd and dcmd commands in same script?
Reply
#9

Quote:
Originally Posted by googamalugafoo
View Post
can i use both zcmd and dcmd commands in same script?
I don't believe so.
Reply
#10

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)