Making one command
#1

How can you make from this one command that you only need to do /dcam and it will be activated or disabled

pawn Код:
CMD:rdcam(playerid, params[])
{
    if (IsPlayerInAnyVehicle (playerid))
    {
  if(IsACop(playerid))
      {
            new vehid = GetPlayerVehicleID (playerid);
            if (VehRadarID [vehid] == -1) return 1;

            DestroyObject (VehRadarID [vehid]);
            SendClientMessage (playerid, COLOR_GREY, "You removed the radar from the dashboard(don't forget to do /stopchecking).");
            VehRadarID [vehid] = -1;
            KillTimer (CheckingSpeed [vehid]);
            CheckingSpeed [vehid] = -1;
            for (new i = 0; i < MAX_PLAYERS; i++)
            {
            if (IsPlayerInVehicle (i, vehid))
            {
            PlayerTextDrawHide (i, RadarHud[i]);
            PlayerTextDrawHide (i, VehicleModel[i]);
            PlayerTextDrawHide (i, DashCamText);
            }
        }
    }
}
return 1;
}

CMD:dcam(playerid, params[])
{
    if (IsPlayerInAnyVehicle (playerid))
    {
        if(IsACop(playerid))
        {
            new vehid = GetPlayerVehicleID (playerid);
            if (VehRadarID [vehid] > -1) return 1;

            new Float: x, Float: y, Float: z, Float: a;
            GetVehiclePos (vehid, x, y, z);
            GetVehicleZAngle (vehid, a);
            SendClientMessage (playerid, COLOR_GREY, "You have placed the radar(/checkspeed to check the speed).");
            VehRadarID [vehid] = CreateObject (367, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300.0);
            AttachObjectToVehicle (VehRadarID [vehid], vehid, 0.2, 0.50, 0.3, 0.0, 0.0, 90.0);
            for (new i = 0; i < MAX_PLAYERS; i++)
            {
            if (IsPlayerInVehicle (i, vehid))
            {
            PlayerTextDrawShow (i,RadarHud[i]);
            PlayerTextDrawShow (i,VehicleModel[i]);
            PlayerTextDrawShow (i,DashCamText);
            }
        }
    }
}
return 1;
}

CMD:record(playerid, params[])
{
    if (IsPlayerInAnyVehicle (playerid))
    {
        if(IsACop(playerid))
        {
        new vehid = GetPlayerVehicleID (playerid);
        if (VehRadarID [vehid] == -1) return 1;
        CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
        }
    }
    return 1;
}

CMD:srecord(playerid, params[])
{
    if(IsACop(playerid))
    if (IsPlayerInAnyVehicle (playerid))
    {
        new vehid = GetPlayerVehicleID (playerid);
        if (CheckingSpeed [vehid] > 0)
        {
            KillTimer (CheckingSpeed [vehid]);
            CheckingSpeed [vehid] = -1;
        }
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
             if (IsPlayerInVehicle (i, vehid))
        {
            PlayerTextDrawHide (i, RadarHud[i]);
            PlayerTextDrawHide (i, VehicleModel[i]);
            PlayerTextDrawHide (i, DashCamText);
        }
    }
}
return 1;
}
Reply
#2

Do you want to merge the two commands /dcam and /rdcam so that pawno will check if it is active or not and then make it active or not?
Reply
#3

pawn Код:
new bool:DashCamActivated[MAX_PLAYERS];
pawn Код:
CMD:dcam(playerid, params[])
{
    if(DashCamActivated[playerid] == false)
    {
        //do all stuff to turn it on
        DashCamActivated[playerid] = true;
    }
    else
    {
         DashCamActivated[playerid] = false;
          //do stuff to turn it off
     }
     return 1;
}
Reply
#4

pawn Код:
CMD:dcam(playerid, params[])
{
    if(DashCamActivated[playerid] == false)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    new vehid = GetPlayerVehicleID (playerid);
    if(IsACop(playerid))
    {
        if (VehRadarID [vehid] == -1) return 1;
        foreach(Player, i)
        {
        CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
        PlayerTextDrawShow (i,RadarHud[i]);
        PlayerTextDrawShow (i,VehicleModel[i]);
        PlayerTextDrawShow (i,DashCamText);
        DashCamActivated[playerid] = true;
    }
    else
    {
        DashCamActivated[playerid] = false;
        if(CheckingSpeed[vehid] > 0)
        {
        foreach(Player, i)
        {
            KillTimer (CheckingSpeed [vehid]);
            CheckingSpeed [vehid] = -1;
            PlayerTextDrawHide (i, RadarHud[i]);
            PlayerTextDrawHide (i, VehicleModel[i]);
            PlayerTextDrawHide (i, DashCamText);
        }
    }
return 1;
}
its missing an bracked somewhere but i don't know where
Reply
#5

Here

pawn Код:
foreach(Player, i)
        {
            CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
            PlayerTextDrawShow (i,RadarHud[i]);
            PlayerTextDrawShow (i,VehicleModel[i]);
            PlayerTextDrawShow (i,DashCamText);
            DashCamActivated[playerid] = true;
        }
    }
    else
    {
Reply
#6

pawn Код:
CMD:dcam(playerid, params[])
{
    if(DashCamActivated[playerid] == false)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    new vehid = GetPlayerVehicleID (playerid);
    if(IsACop(playerid))
    {
        if (VehRadarID [vehid] == -1) return 1;
        foreach(Player, i)
        {
            CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
            PlayerTextDrawShow (i,RadarHud[i]);
            PlayerTextDrawShow (i,VehicleModel[i]);
            PlayerTextDrawShow (i,DashCamText);
            DashCamActivated[playerid] = true;
        }
    }
    else
    {
        DashCamActivated[playerid] = false;
        if(CheckingSpeed[vehid] > 0)
        {
        foreach(Player, i)
        {
            KillTimer (CheckingSpeed [vehid]);
            CheckingSpeed [vehid] = -1;
            PlayerTextDrawHide (i, RadarHud[i]);
            PlayerTextDrawHide (i, VehicleModel[i]);
            PlayerTextDrawHide (i, DashCamText);
        }
    }
return 1;
}
Still the same
Reply
#7

Quote:
Originally Posted by lulo356
Посмотреть сообщение
pawn Код:
CMD:dcam(playerid, params[])
{
    if(DashCamActivated[playerid] == false)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    new vehid = GetPlayerVehicleID (playerid);
    if(IsACop(playerid))
    {
        if (VehRadarID [vehid] == -1) return 1;
        foreach(Player, i)
        {
            CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
            PlayerTextDrawShow (i,RadarHud[i]);
            PlayerTextDrawShow (i,VehicleModel[i]);
            PlayerTextDrawShow (i,DashCamText);
            DashCamActivated[playerid] = true;
        }
    }
    else
    {
        DashCamActivated[playerid] = false;
        if(CheckingSpeed[vehid] > 0)
        {
        foreach(Player, i)
        {
            KillTimer (CheckingSpeed [vehid]);
            CheckingSpeed [vehid] = -1;
            PlayerTextDrawHide (i, RadarHud[i]);
            PlayerTextDrawHide (i, VehicleModel[i]);
            PlayerTextDrawHide (i, DashCamText);
        }
    }
return 1;
}
Still the same
Little question, Do i need to make it on a differance way or this way
Reply
#8

Sorry if it itches you, but I like to work with indentation.
pawn Код:
CMD:dcam(playerid, params[])
{
    if(DashCamActivated[playerid] == false)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehid = GetPlayerVehicleID (playerid);
            if(IsACop(playerid))
            {
                if (VehRadarID [vehid] == -1) return 1;
                foreach(Player, i)
                {
                    CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
                    PlayerTextDrawShow (i,RadarHud[i]);
                    PlayerTextDrawShow (i,VehicleModel[i]);
                    PlayerTextDrawShow (i,DashCamText);
                    DashCamActivated[playerid] = true;
                }
            }
            else
            {
                DashCamActivated[playerid] = false;
                if(CheckingSpeed[vehid] > 0)
                {
                    foreach(Player, i)
                    {
                        KillTimer (CheckingSpeed [vehid]);
                        CheckingSpeed [vehid] = -1;
                        PlayerTextDrawHide (i, RadarHud[i]);
                        PlayerTextDrawHide (i, VehicleModel[i]);
                        PlayerTextDrawHide (i, DashCamText);
                    }
                }
            }
        }
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by LivingLikeYouDo
Посмотреть сообщение
Sorry if it itches you, but I like to work with indentation.
pawn Код:
CMD:dcam(playerid, params[])
{
    if(DashCamActivated[playerid] == false)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehid = GetPlayerVehicleID (playerid);
            if(IsACop(playerid))
            {
                if (VehRadarID [vehid] == -1) return 1;
                foreach(Player, i)
                {
                    CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
                    PlayerTextDrawShow (i,RadarHud[i]);
                    PlayerTextDrawShow (i,VehicleModel[i]);
                    PlayerTextDrawShow (i,DashCamText);
                    DashCamActivated[playerid] = true;
                }
            }
            else
            {
                DashCamActivated[playerid] = false;
                if(CheckingSpeed[vehid] > 0)
                {
                    foreach(Player, i)
                    {
                        KillTimer (CheckingSpeed [vehid]);
                        CheckingSpeed [vehid] = -1;
                        PlayerTextDrawHide (i, RadarHud[i]);
                        PlayerTextDrawHide (i, VehicleModel[i]);
                        PlayerTextDrawHide (i, DashCamText);
                    }
                }
            }
        }
    }
    return 1;
}
It works but the textdraw is not going off..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)