Help about Police Commands
#1

Hi guys, how can I make a pullover command for law enforcement? It will show the suspect a gametext.. Oh and how about detain command? The police car must be near at the police officer. To arrest ''detained'' suspects, the cop must be in a ''checkpoint'' to /arrest. Kinda hard to explain lol, but u can find it in some roleplay servers what I mean..
Reply
#2

here it goes, it's really simple

pawn Код:
CMD:pullover(playerid,params[])
{
    new string[128];
    new ID;
    new pname[MAX_PLAYER_NAME];
    new tname[MAX_PLAYER_NAME];
    if(gTeam[playerid] == TEAM_CIVIL) //To check if player is NOT a law enforcement, "use your team defining"
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] Only law enforcement officers can use this command.");
        return 1;
    }
    if(sscanf(params, "u", ID)) //you must have sscanf2 installed in order to use this command, if not request a normal one, I'll post
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /pullover (Player Name/ID)");
        return 1;
    }
    if(!IsPlayerConnected(ID)) //if you entered a wrong ID
    {
        format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(playerid == ID) //if you're asking yourself to pull over
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot ask yourself to pull over.");
        return 1;
    }
        //removed isspawned for you.
    GetPlayerName(playerid,pname,sizeof(pname));
    GetPlayerName(ID,tname,sizeof(tname));
    if(GetDistanceBetweenPlayers(playerid,ID) > 30) //stock below
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is too far away to ask them to pull over.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(IsPlayerInAnyVehicle(ID) == 0) //doesn't need defining, checking if ID is not in a vehicle
    {
        format(string,sizeof(string),"[ERROR] %s(%d) must be in a vehicle in order to ask them to pull over.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
//finally through all stages, now the stage of pulling them over
    format(string,sizeof(string),"[POLICE] Law Enforcement Officer %s(%d) asked you to pull over.",pname,playerid);
    SendClientMessage(ID,COLOR_BLUE,string);
    format(string, sizeof(string), "~b~pull over!");
    GameTextForPlayer(ID, string, 2000, 5);

    format(string,sizeof(string),"[POLICE] You have asked %s(%d) to pull over.",tname,ID);
    SendClientMessage(playerid,COLOR_BLUE,string);
    return 1;
}

//GetDistanceBetweenPlayers
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
    {
        return -1.00;
    }
    GetPlayerPos(p1,x1,y1,z1);
    GetPlayerPos(p2,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
Reply
#3

Quote:
Originally Posted by Vanter
Посмотреть сообщение
here it goes, it's really simple

pawn Код:
CMD:pullover(playerid,params[])
{
    new string[128];
    new ID;
    new pname[MAX_PLAYER_NAME];
    new tname[MAX_PLAYER_NAME];
    if(gTeam[playerid] == TEAM_CIVIL)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] Only law enforcement officers can use this command.");
        return 1;
    }
    if(sscanf(params, "u", ID))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /pullover (Player Name/ID)");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(playerid == ID)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot ask yourself to pull over.");
        return 1;
    }
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] You must be spawned in order to use this command.");
        return 1;
    }
    GetPlayerName(playerid,pname,sizeof(pname));
    GetPlayerName(ID,tname,sizeof(tname));
    if(IsSpawned[ID] == 0)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is not spawned in order to ask them to pull over.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,ID) > 30)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is too far away to ask them to pull over.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(IsPlayerInAnyVehicle(ID) == 0)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) must be in a vehicle in order to ask them to pull over.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    format(string,sizeof(string),"[POLICE] Law Enforcement Officer %s(%d) asked you to pull over.",pname,playerid);
    SendClientMessage(ID,COLOR_BLUE,string);
    format(string, sizeof(string), "~b~pull over!");
    GameTextForPlayer(ID, string, 2000, 5);

    format(string,sizeof(string),"[POLICE] You have asked %s(%d) to pull over.",tname,ID);
    SendClientMessage(playerid,COLOR_BLUE,string);
    return 1;
}
Not really helpfull for him.
You just copied something out of a script.
You just some things in here he probally doesn't have/use.
Reply
#4

Quote:
Originally Posted by Facerafter
Посмотреть сообщение
Not really helpfull for him.
You just copied something out of a script.
You just some things in here he probally doesn't have/use.
like what exactly? the only thing needs definition is IsSpawned, I removed half the command.
This is helpful and working

note: it's from my gamemode and done it myself
Reply
#5

Vanter, i from texts and all your command see, its taken from stevo Cops And Robbers Gm!
Reply
#6

Quote:
Originally Posted by Vanter
Посмотреть сообщение
like what exactly? the only thing needs definition is IsSpawned, I removed half the command.
This is helpful and working

note: it's from my gamemode and done it myself
IsSpawned
and as far as i know GetDistanceBetweenPlayers isn't a native function (It isn't in the wiki.)
Also you don't know if hes using gTeam, ZCMD or sscanf.
Reply
#7

We're not talking about fags here, if he's not willing to improve or edit the code I gave, then he's not willing to even be a scripter if so.
Reply
#8

Quote:
Originally Posted by Vanter
Посмотреть сообщение
We're not talking about fags here, if he's not willing to improve or edit the code I gave, then he's not willing to even be a scripter if so.
This topic is for people that wanted help
And if he could have done it himself he would have made it him self don't you think?

Im just saying you could have explained a bit more with it. And notify him he had to made some changes to make it work. Or have removed that parts
Reply
#9

this is helping, not script request.
anyways I'll edit it for him to be more understandable
Reply
#10

CMD detain

pawn Код:
if(strcmp(cmd, "/detain", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if() // here your cop
            {
                if(IsPlayerInAnyVehicle(playerid))
                {
                    SendClientMessage(playerid, COLOR_GREY, "   Cannot use this while being in the Car !");
                    return 1;
                }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /detain [playerid/PartOfName] [seatid]");
                giveplayerid = ReturnUser(tmp);
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /detain [playerid/PartOfName] [seatid]");
                new seat = strvalEx(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        if(seat < 1 || seat > 3)
                        {
                            SendClientMessage(playerid, COLOR_GREY, "   Seat cannot be below 1 or above 3 !");
                            return 1;
                        }
                        if(/*here your cop*/(giveplayerid))
                        {
                            SendClientMessage(playerid, COLOR_GREY, "   You can't Detain Cops !");
                            return 1;
                        }
                        if(IsPlayerInAnyVehicle(giveplayerid))
                        {
                            SendClientMessage(playerid, COLOR_GREY, "   Suspect is in a Car, get him out first !");
                            return 1;
                        }
                        if(ProxDetectorS(8.0, playerid, giveplayerid))
                        {
                            if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "   You cannot Detain yourself !"); return 1; }
                            if(PlayerCuffed[giveplayerid] == 2)
                            {
                                new carid = gLastCar[playerid];
                                if(IsInvalidDetainVehicle(carid)) { SendClientMessage(playerid, COLOR_GREY, "   You can't Detain someone in that vehicle !"); return 1; }
                                //foreach(Player, i)
                                for(new i; i<MAX_PLAYERS; i++)
                                {
                                    if(IsPlayerInAnyVehicle(i))
                                    {
                                        if(GetPlayerVehicleID(i) == 596) // you can change it
                                        {
                                            if(GetPlayerVehicleSeat(i) == seat)
                                            {
                                                format(string, sizeof(string), "   That seat is occupied by %s !", PlayerName(i));
                                                SendClientMessage(playerid, COLOR_GREY, string);
                                                return 1;
                                            }
                                        }
                                    }
                                }
                                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                                GetPlayerName(playerid, sendername, sizeof(sendername));
                                format(string, sizeof(string), "* You were detained by %s.", sendername);
                                SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
                                format(string, sizeof(string), "* You have detained %s.", PlayerName(giveplayerid));
                                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                                format(string, sizeof(string), "* %s grabs %s and throws him in the car.", sendername, PlayerName(giveplayerid));
                                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                                GameTextForPlayer(giveplayerid, "~r~Detained", 2500, 3);
                                ClearAnimations(giveplayerid);
                                TogglePlayerControllable(giveplayerid, 0);
                                if(IsInvalidDetainSeat(carid))
                                {
                                    PutPlayerInVehicle(giveplayerid,carid,1);
                                }
                                else
                                {
                                    PutPlayerInVehicle(giveplayerid,carid,seat);
                                }
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   That player needs to be restrained first !");
                                return 1;
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_GREY, "   That player is not near you !");
                            return 1;
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are not a Cop / FBI / SAST !");
            }
        }
        return 1;
    }
stock
pawn Код:
stock ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        new invehicle[MAX_PLAYERS];
        new virtualworld = GetPlayerVirtualWorld(playerid);
        new interior = GetPlayerInterior(playerid);
        new vehicleid = GetPlayerVehicleID(playerid);
        new ivehicleid;
        if(vehicleid)
        {
            GetVehiclePos(vehicleid,oldposx,oldposy,oldposz);
        }
        else
        {
            GetPlayerPos(playerid, oldposx, oldposy, oldposz);
            vehicleid = GetPlayerVehicleID(playerid);
        }
        for(new i; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(!BigEar[i])
                {
                    if(GetPlayerVirtualWorld(i) == virtualworld)
                    {
                        if((GetPlayerInterior(i) == interior))
                        {
                            if(vehicleid)
                            {
                                if(IsPlayerInVehicle(i,vehicleid))
                                {
                                    invehicle[i] = 1;
                                }
                            }
                            if(!invehicle[i])
                            {
                                if(IsPlayerInAnyVehicle(i))
                                {
                                    ivehicleid = GetPlayerVehicleID(i);
                                    GetVehiclePos(ivehicleid,posx,posy,posz);
                                } else {
                                    GetPlayerPos(i,posx,posy,posz);
                                }
                                tempposx = (oldposx -posx);
                                tempposy = (oldposy -posy);
                                tempposz = (oldposz -posz);
                                if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                                {
                                    SendClientMessage(i, col1, string);
                                }
                                else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                                {
                                    SendClientMessage(i, col2, string);
                                }
                                else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                                {
                                    SendClientMessage(i, col3, string);
                                }
                                else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                                {
                                    SendClientMessage(i, col4, string);
                                }
                                else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                                {
                                    SendClientMessage(i, col5, string);
                                }
                            }
                            else
                            {
                                SendClientMessage(i, col1, string);
                            }
                        }
                    }
                } else {
                    SendClientMessage(i, col1, string);
                }
            }
        }
    }
    return 1;
}


stock IsInvalidDetainSeat(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 528,601,599: return 1;
    }
    return 0;
}
and this as a public
// forward ProxDetectorS(Float:radi, playerid, targetid);
pawn Код:
public ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        GetPlayerPos(targetid, posx, posy, posz);
        tempposx = (oldposx -posx);
        tempposy = (oldposy -posy);
        tempposz = (oldposz -posz);
        if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)