cage help
#1

i found this cage this script but players can easily escape bt /kill and how to send the all cilent 'Players has been been caged [reason .....]

pls some1 help
no one shouldbe be able to get out of cage unless admin uncage him
and message should be sent to all players [u know what i mean right]




Код:
/* -------------------
cage by Rachael
----------------------
*/
 
#include <a_samp>
#include <a_players>
#include <a_irc>
 
#pragma unused sztmp
 
#define COLOR_GREY                              0xAFAFAFAA
#define COLOR_RCON              0x3399FFAA
 
 
enum obj { id, Float:ox, Float:oy, Float:oz, Float:xa, Float:ya, Float:za }
new object_ref[10][obj] =
{
        { 971 , -4.374 , -0.274 , 1.674 , 0.0000 , 0.0000 , 270.0000 },
        { 971 , 0.100 , 4.179 , 1.712 , 0.0000 , 0.0000 , 180.0000 },
        { 971 , 0.000 , -4.724 , 1.674 , 0.0000 , 0.0000 , 0.0000 },
        { 971 , 4.500 , -0.124 , 1.674 , 0.0000 , 0.0000 , 90.0000 },
        { 969 , -4.428 , 4.053 , 5.139 , 270.618 , 0.0000 , 270.0000 },
        { 969 , -1.428 , 4.053 , 5.139 , 270.618 , 0.0000 , 270.0000 },
        { 969 , 1.396 , 4.053 , 5.139 , 270.618 , 0.0000 , 270.0000 },
        { 969 , -4.428 , 4.053 , -1.76 , 270.618 , 0.0000 , 270.0000 },
        { 969 , -1.428 , 4.053 , -1.76 , 270.618 , 0.0000 , 270.0000 },
        { 969 , 1.396 , 4.053 , -1.76 , 270.618 , 0.0000 , 270.0000 }
};
 
new object[120];
new obj_count = 0;
new cage[20][10];
new cage_count= 0;
enum loc { Float:cx, Float:cy, Float:cz }
new cage_pos[20][loc];
new astring[255];
 
stock strtok(const string[], &index)
{
        new length = strlen(string);
        while ((index < length) && (string[index] <= ' '))
        {
                index++;
        }
 
        new offset = index;
        new result[20];
        while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
        {
                result[index - offset] = string[index];
                index++;
        }
        result[index - offset] = EOS;
        return result;
}
 
stock IsNumeric(const string[])
{
        for(new i = 0, j = strlen(string); i < j; i++)
        {
                if(string[i] > '9' || string[i] < '0') return 0;
        }
        return 1;
}
 
stock 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))
                        {
                                userid = INVALID_PLAYER_ID;
                        }
                        else
                        {
                                return userid; // A player was found
                        }
                }
        }
        // They entered [part of] a name or the id search failed (check names just incase)
        new len = strlen(text[pos]);
        new count = 0;
        new aname[MAX_PLAYER_NAME];
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
                if (IsPlayerConnected(i))
                {
                        GetPlayerName(i, aname, sizeof (aname));
                        if (strcmp(aname, text[pos], true, len) == 0) // Check segment of name
                        {
                                if (len == strlen(aname)) // Exact match
                                {
                                        return i; // Return the exact player on an exact match
                                }
                                else // Partial match
                                {
                                        count++;
                                        userid = i;
                                }
                        }
                }
        }
        if (count != 1)
        {
                if (playerid != INVALID_PLAYER_ID)
                {
                        if (count)
                        {
                                SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow search.");
                        }
                        else
                        {
                                SendClientMessage(playerid, 0xFF0000AA, "No matching user found.");
                        }
                }
                userid = INVALID_PLAYER_ID;
        }
        return userid; // INVALID_PLAYER_ID for bad return
}
 
stock Name(playerid)  // returns player's name
{
        new pname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pname, sizeof (pname));
        return pname;
}
 
 
public OnPlayerCommandText(playerid,cmdtext[])
{
        if(IsPlayerAdmin(playerid))
        {
            new
                    idx,
                        argument[32]
                ;
 
            argument = strtok(cmdtext,idx);
 
                if(!strcmp(argument,"/cage",true))
                {
                    argument = strtok(cmdtext,idx);
                    if(!strlen(argument))
                    {
                        SendClientMessage(playerid,COLOR_GREY,"USAGE: /cage [playerID/partofname|del|send|up|dn|north|south|east|west]");
                        return 1;
                        }
                    new caged = ReturnUser(argument);
                    if(caged != INVALID_PLAYER_ID)
                    {
                                new Float:playX, Float:playY, Float:playZ;
                                GetPlayerPos(caged,playX,playY,playZ);
                                cage_count++;
                                cage_pos[cage_count][cx] = playX;
                                cage_pos[cage_count][cy] = playY;
                                cage_pos[cage_count][cz] = playZ;
                                for(new i = 0; i <= 9;i++)
                                {
                                    obj_count++;
                                    object[obj_count] = CreateObject(object_ref[i][id],
                                                                                                        playX+object_ref[i][ox],
                                                                                                        playY+object_ref[i][oy],
                                                                                                        playZ+object_ref[i][oz],
                                                                                                        object_ref[i][xa],
                                                                                                        object_ref[i][ya],
                                                                                                        object_ref[i][za]);
                                        cage[cage_count][i] = obj_count;
                                }
                                format(astring,sizeof(astring), "cage %d created",cage_count);
                                SendClientMessage(playerid, COLOR_RCON, astring);
                                return 1;
                        }
                        if(!strcmp(argument,"up",true))
                        {
                            argument = strtok(cmdtext, idx);
                            new cagenum = strval(argument);
                            if(cagenum < 1 || cagenum > cage_count)
                            {
                                SendClientMessage(playerid,COLOR_GREY,"USAGE: /cage up [cage#] [distance]");
                                return 1;
                                }
                                argument = strtok(cmdtext, idx);
                                new Float:distance = floatstr(argument);
                                if(distance <= 0)
                                {
                                SendClientMessage(playerid,COLOR_GREY,"invalid distance [1-1000]");
                                return 1;
                                }
                                for(new i = 0; i <= 9;i++)
                                {
                                MoveObject(object[cage[cagenum][i]],
                                                                cage_pos[cagenum][cx]+object_ref[i][ox],
                                                                cage_pos[cagenum][cy]+object_ref[i][oy],
                                                                cage_pos[cagenum][cz]+object_ref[i][oz]+distance,
                                                                2.0);
                                }
                cage_pos[cagenum][cz] += distance;
                                new movest[128];
                                format(movest,sizeof(movest),"cage %d moved up %.1fm",cagenum,distance);
                                SendClientMessage(playerid,COLOR_RCON,movest);
                                return 1;
                        }
                        if(!strcmp(argument,"dn",true))
                        {
                        argument = strtok(cmdtext, idx);
                        new cagenum = strval(argument);
                        if(cagenum < 1 || cagenum > cage_count)
                        {
                                SendClientMessage(playerid,COLOR_GREY,"USAGE: /cage dn [cage#] [distance]");
                                return 1;
                                }
                                argument = strtok(cmdtext, idx);
                                new Float:distance = floatstr(argument);
                                if(distance <= 0)
                                {
                                    SendClientMessage(playerid,COLOR_GREY,"invalid distance [1-1000]");
                                    return 1;
                                }
                                for(new i = 0; i <= 9;i++)
                                {
                                    MoveObject(object[cage[cagenum][i]],
                                                                cage_pos[cagenum][cx]+object_ref[i][ox],
                                                                cage_pos[cagenum][cy]+object_ref[i][oy],
                                                                cage_pos[cagenum][cz]+object_ref[i][oz]-distance,
                                                                2.0);
                                }
                    cage_pos[cagenum][cz] -= distance;
                                new movest[128];
                                format(movest,sizeof(movest),"cage %d moved down %.1fm",cagenum,distance);
                                SendClientMessage(playerid,COLOR_RCON,movest);
                                return 1;
                        }
                        if(!strcmp(argument,"north",true))
                        {
                            argument = strtok(cmdtext, idx);
                            new cagenum = strval(argument);
                            if(cagenum < 1 || cagenum > cage_count)
                            {
                                SendClientMessage(playerid,COLOR_GREY,"USAGE: /cage north [cage#] [distance]");
                                return 1;
                                }
                                argument = strtok(cmdtext, idx);
                                new Float:distance = floatstr(argument);
                                if(distance <= 0)
                                {
                                    SendClientMessage(playerid,COLOR_GREY,"invalid distance [1-1000]");
                                    return 1;
                                }
                                for(new i = 0; i <= 9;i++)
                                {
                                    MoveObject(object[cage[cagenum][i]],
                                                                        cage_pos[cagenum][cx]+object_ref[i][ox],
                                                                        cage_pos[cagenum][cy]+object_ref[i][oy]+distance,
                                                                        cage_pos[cagenum][cz]+object_ref[i][oz],
                                                                        2.0);
                                }
                    cage_pos[cagenum][cy] += distance;
                                new movest[128];
                                format(movest,sizeof(movest),"cage %d moved north %.1fm",cagenum,distance);
                                SendClientMessage(playerid,COLOR_RCON,movest);
                                return 1;
                        }
                        if(!strcmp(argument,"south",true))
                        {
                            argument = strtok(cmdtext, idx);
                            new cagenum = strval(argument);
                            if(cagenum < 1 || cagenum > cage_count)
                            {
                                SendClientMessage(playerid,COLOR_GREY,"USAGE: /cagesouth [cage#] [distance]");
                                return 1;
                                }
                                argument = strtok(cmdtext, idx);
                                new Float:distance = floatstr(argument);
                                if(distance <= 0)
                                {
                                    SendClientMessage(playerid,COLOR_GREY,"invalid distance [1-1000]");
                                    return 1;
                                }
                                for(new i = 0; i <= 9;i++)
                                {
                                    MoveObject(object[cage[cagenum][i]],
                                                                        cage_pos[cagenum][cx]+object_ref[i][ox],
                                                                        cage_pos[cagenum][cy]+object_ref[i][oy]-distance,
                                                                        cage_pos[cagenum][cz]+object_ref[i][oz],
                                                                        2.0);
                                }
                    cage_pos[cagenum][cy] -= distance;
                                new movest[128];
                                format(movest,sizeof(movest),"cage %d moved south %.1fm",cagenum,distance);
                                SendClientMessage(playerid,COLOR_RCON,movest);
                                return 1;
                        }
                        if(!strcmp(argument,"east",true))
                        {
                            argument = strtok(cmdtext, idx);
                            new cagenum = strval(argument);
                            if(cagenum < 1 || cagenum > cage_count)
                            {
                                SendClientMessage(playerid,COLOR_GREY,"USAGE: /cage east [cage#] [distance]");
                                return 1;
                                }
                                argument = strtok(cmdtext, idx);
                                new Float:distance = floatstr(argument);
                                if(distance <= 0)
                                {
                                    SendClientMessage(playerid,COLOR_GREY,"invalid distance [1-1000]");
                                    return 1;
                                }
                                for(new i = 0; i <= 9;i++)
                                {
                                    MoveObject(object[cage[cagenum][i]],
                                                                        cage_pos[cagenum][cx]+object_ref[i][ox]+distance,
                                                                        cage_pos[cagenum][cy]+object_ref[i][oy],
                                                                        cage_pos[cagenum][cz]+object_ref[i][oz],
                                                                        2.0);
                                }
                    cage_pos[cagenum][cx] += distance;
                                new movest[128];
                                format(movest,sizeof(movest),"cage %d moved east %.1fm",cagenum,distance);
                                SendClientMessage(playerid,COLOR_RCON,movest);
                                return 1;
                        }
                        if(!strcmp(argument,"west",true))
                        {
                            argument = strtok(cmdtext, idx);
                            new cagenum = strval(argument);
                            if(cagenum < 1 || cagenum > cage_count)
                            {
                                SendClientMessage(playerid,COLOR_GREY,"USAGE: /cagewest [cage#] [distance]");
                                return 1;
                                }
                                argument = strtok(cmdtext, idx);
                                new Float:distance = floatstr(argument);
                                if(distance <= 0)
                                {
                                    SendClientMessage(playerid,COLOR_GREY,"invalid distance [1-1000]");
                                    return 1;
                                }
                                for(new i = 0; i <= 9;i++)
                                {
                                    MoveObject(object[cage[cagenum][i]],
                                                                        cage_pos[cagenum][cx]+object_ref[i][ox]+distance,
                                                                        cage_pos[cagenum][cy]+object_ref[i][oy],
                                                                        cage_pos[cagenum][cz]+object_ref[i][oz],
                                                                        2.0);
                                }
                    cage_pos[cagenum][cx] -= distance;
                                new movest[128];
                                format(movest,sizeof(movest),"cage %d moved west %.1fm",cagenum,distance);
                                SendClientMessage(playerid,COLOR_RCON,movest);
                                return 1;
                        }
                        if(!strcmp(argument,"del",true))
                        {
                            argument = strtok(cmdtext,idx);
                            if(!strcmp(argument,"#all",true))
                            {
                                for(new i = 1; i <= cage_count;i++)
                                {
                                    for(new j = 0; j <= 9; j++)
                                    {
                                        cage[i][j] = 0;
                                                }
                                                cage_pos[i][cx] = 0;
                                                cage_pos[i][cy] = 0;
                                                cage_pos[i][cz] = 0;
                                        }
                                        cage_count = 0;
                                        for(new i = 1; i <= obj_count;i++)
                                        {
                                                if(object[i])
                                                {
                                                    DestroyObject(object[i]);
                                                }
                                        }
                                        obj_count = 0;
                                        SendClientMessage(playerid, COLOR_RCON, "all cages destroyed.");
                                        return 1;
                                }
                            new cage_num = strval(argument);
                            if(cage_num < 1 || cage_num > cage_count)
                            {
                                SendClientMessage(playerid, COLOR_GREY, "USAGE: /cage del [cage num|#all]");
                                return 1;
                                }
                                for(new i = 0; i <= 9;i++)
                                {
                                        if(object[cage[cage_num][i]])
                                        {
                                                DestroyObject(object[cage[cage_num][i]]);
                                        object[cage[cage_num][i]] = 0;
                                        cage[cage_num][i] = 0;
                                        }
                                        cage_pos[cage_num][cx] = 0;
                                        cage_pos[cage_num][cy] = 0;
                                        cage_pos[cage_num][cz] = 0;
                                }
                                format(astring,sizeof(astring), "cage number %d destroyed",cage_num);
                                SendClientMessage(playerid, COLOR_RCON, astring);
                                return 1;
                        }
                        if(!strcmp(argument,"send",true))
                        {
                            argument = strtok(cmdtext,idx);
                            new cage_num = strval(argument);
                            if(cage_num < 0 || cage_num > cage_count || cage_pos[cage_num][cx] == 0)
                            {
                                SendClientMessage(playerid, COLOR_GREY, "USAGE: /cagesend [cage num] [player]");
                                return 1;
                                }
                                argument = strtok(cmdtext,idx);
                                new player = ReturnUser(argument);
                                if(player == INVALID_PLAYER_ID)
                                {
                                    SendClientMessage(playerid, COLOR_GREY, "Invalid player ID.");
                                    return 1;
                                }
                                SetPlayerInterior(player,0);
                                SetPlayerVirtualWorld(player,0);
                                SetPlayerPos(player,cage_pos[cage_num][cx],cage_pos[cage_num][cy],cage_pos[cage_num][cz]);
                                format(astring,sizeof(astring), "%s placed inside cage number %d",Name(player),cage_num);
                                SendClientMessage(playerid, COLOR_RCON, astring);
                                return 1;
                        }
                        SendClientMessage(playerid,COLOR_GREY,"USAGE: /cage [playerID/partofname|del|send|up|dn|north|south|east|west]");
                        return 1;
                }
                return 0;
        }
        return 0;
}
 
public OnFilterScriptExit()
{
        for(new i = 1; i <= obj_count;i++)
        {
            DestroyObject(object[i]);
        }
        return 1;
}
Reply


Messages In This Thread
cage help - by ProShooter22 - 02.05.2013, 02:54
Re: cage help - by vvhy - 02.05.2013, 04:18
Re: cage help - by Pottus - 02.05.2013, 05:04
Re: cage help - by [..MonTaNa..] - 02.05.2013, 05:33
Re: cage help - by ProShooter22 - 02.05.2013, 05:36
Re: cage help - by ProShooter22 - 02.05.2013, 05:41
Re: cage help - by [..MonTaNa..] - 02.05.2013, 05:47
Re: cage help - by ProShooter22 - 02.05.2013, 05:59
Re: cage help - by [..MonTaNa..] - 02.05.2013, 12:34
Re: cage help - by ProShooter22 - 02.05.2013, 15:51

Forum Jump:


Users browsing this thread: 1 Guest(s)