CMD Help!
#1

pawn Код:
CMD:deploycam(playerid, params[])
{
    new string[128], limit;
    if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "d", limit)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /deploycam [speed]");
    for(new idx=1; idx<MAX_CAMS; idx++) //for(new idx=1; idx<MAX_GATES; idx++)
    {
        if(SpeedCams[idx][scX] == 0)
        {
            GetPlayerPos(playerid, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]);
            GetPlayerFacingAngle(playerid, SpeedCams[idx][fCamAngle]);
            SpeedCams[idx][scObjectID] = CreateDynamicObject(18880, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]-2.0, 0.0, 0.0, SpeedCams[idx][fCamAngle]);
            GetPlayer3DZone(playerid, SpeedCams[idx][scDeployedAt], MAX_ZONE_NAME);
            SpeedCams[idx][scDeployedBy] = RPN(playerid);
            SpeedCams[idx][scLimit] = limit;
            format(string,sizeof(string),"Speed Cam ID: %d successfully created [Speed Limit = %d].", idx, limit);
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), "HQ: A speeding camera has been deployed by %s at %s (%d).", RPN(playerid), SpeedCams[idx][scDeployedAt], SpeedCams[idx][scLimit]);
            foreach(Player, x)
            {
                if(IsACop(x))
                {
                    SendClientMessage(x, TRANSPARENT_BLUE, string);
                    if (PlayerInfo[x][pFacRank] >= 5)
                    {
                        SendClientMessage(x, COLOR_YELLOW, "You can remove a speed camera by typing /destroycam.");
                    }
                }
                return 1;
            }
        }
        return 1;
    }
    //SendClientMessage(playerid, COLOR_ORANGE, "Reached Maximum Cams [10].");
    return 1;
}
This code should generate a camera till it gets to the MAX_CAMS which is 10.

Ths problem is that the command doesn't work properly. when i use /deploycam , it will deploy 1 camera and afterward if i try to deploying another cam it wouldn't deploy the 2nd. Plus --> couldn't make this command to work with sending a message after the player gets to maximum cams... Please help me fix this cmd!
Reply
#2

Edit: Look at the next post..
Reply
#3

Try this code

pawn Код:
CMD:deploycam(playerid, params[])
{
    new string[128], limit;
    if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "d", limit)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /deploycam [speed]");
    for(new idx=1; idx<MAX_CAMS; idx++) //for(new idx=1; idx<MAX_GATES; idx++)
    {

            GetPlayerPos(playerid, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]);
            GetPlayerFacingAngle(playerid, SpeedCams[idx][fCamAngle]);
            SpeedCams[idx][scObjectID] = CreateDynamicObject(18880, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]-2.0, 0.0, 0.0, SpeedCams[idx][fCamAngle]);
            GetPlayer3DZone(playerid, SpeedCams[idx][scDeployedAt], MAX_ZONE_NAME);
            SpeedCams[idx][scDeployedBy] = RPN(playerid);
            SpeedCams[idx][scLimit] = limit;
            format(string,sizeof(string),"Speed Cam ID: %d successfully created [Speed Limit = %d].", idx, limit);
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), "HQ: A speeding camera has been deployed by %s at %s (%d).", RPN(playerid), SpeedCams[idx][scDeployedAt], SpeedCams[idx][scLimit]);
            foreach(Player, x)
            {
                if(IsACop(x))
                {
                    SendClientMessage(x, TRANSPARENT_BLUE, string);
                    if (PlayerInfo[x][pFacRank] >= 5)
                    {
                        SendClientMessage(x, COLOR_YELLOW, "You can remove a speed camera by typing /destroycam.");
                    }
                }
                return 1;
            }
       
    }
    SendClientMessage(playerid, COLOR_ORANGE, "Reached Maximum Cams [10].");
    return 1;
}
Reply
#4

Quote:
Originally Posted by Zamora
Посмотреть сообщение
Try this code

pawn Код:
CMD:deploycam(playerid, params[])
{
    new string[128], limit;
    if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "d", limit)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /deploycam [speed]");
    for(new idx=1; idx<MAX_CAMS; idx++) //for(new idx=1; idx<MAX_GATES; idx++)
    {

            GetPlayerPos(playerid, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]);
            GetPlayerFacingAngle(playerid, SpeedCams[idx][fCamAngle]);
            SpeedCams[idx][scObjectID] = CreateDynamicObject(18880, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]-2.0, 0.0, 0.0, SpeedCams[idx][fCamAngle]);
            GetPlayer3DZone(playerid, SpeedCams[idx][scDeployedAt], MAX_ZONE_NAME);
            SpeedCams[idx][scDeployedBy] = RPN(playerid);
            SpeedCams[idx][scLimit] = limit;
            format(string,sizeof(string),"Speed Cam ID: %d successfully created [Speed Limit = %d].", idx, limit);
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), "HQ: A speeding camera has been deployed by %s at %s (%d).", RPN(playerid), SpeedCams[idx][scDeployedAt], SpeedCams[idx][scLimit]);
            foreach(Player, x)
            {
                if(IsACop(x))
                {
                    SendClientMessage(x, TRANSPARENT_BLUE, string);
                    if (PlayerInfo[x][pFacRank] >= 5)
                    {
                        SendClientMessage(x, COLOR_YELLOW, "You can remove a speed camera by typing /destroycam.");
                    }
                }
                return 1;
            }
       
    }
    SendClientMessage(playerid, COLOR_ORANGE, "Reached Maximum Cams [10].");
    return 1;
}
This code gave the option to deploy more then 1 Camera.
But then all the others are stuck for CAM ID:1 ... every /deploycam makes another ID:1.

I want it work like this :

/deploycam
will send message (CAM ID:1 DEPLOYED)
/deploycam
will send message (CAM ID:2 DEPLOYED)

Untill it gets to the MAX_CAMS i defined above.


Any solution?
Reply
#5

NVM FIXED IT!

THANKS ALOT.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)