SA-MP Forums Archive
How to change this code to CMD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to change this code to CMD (/showthread.php?tid=553645)



How to change this code to CMD - lulo356 - 30.12.2014

How can you change this code to CMD:

pawn Код:
public OnPlayerCommandText (playerid, cmdtext[])
{
    if (!strcmp (cmdtext, "/placeradar"))
    {
        if (IsPlayerInAnyVehicle (playerid))
        if(IsCopSkin(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_WHITE, "Radar Placed.");
            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);
                    PlayerTextDrawShow (i,Textdraw1);
                    PlayerTextDrawShow (i,Textdraw2);
                }
            }
        }
        return 1;
    }

    if (!strcmp (cmdtext, "/removeradar"))
    {
        if (IsPlayerInAnyVehicle (playerid))
        if(IsCopSkin(playerid))
        {
            new vehid = GetPlayerVehicleID (playerid);
            if (VehRadarID [vehid] == -1) return 1;

            DestroyObject (VehRadarID [vehid]);
            SendClientMessage (playerid, COLOR_YELLOW, "Radar has been removed successfully.");
            VehRadarID [vehid] = -1;
            KillTimer (CheckingSpeed [vehid]);
            CheckingSpeed [vehid] = -1;

            for (new i = 0; i < MAX_PLAYERS; i++)
            {
                if (IsPlayerInVehicle (i, vehid))
                {
                    PlayerTextDrawHide (i, RadarHud);
                    PlayerTextDrawHide (i, Textdraw1);
                    PlayerTextDrawHide (i, Textdraw2);
                }
            }
        }
        return 1;
    }

    if (!strcmp (cmdtext, "/checkspeed"))
    {
        if (IsPlayerInAnyVehicle (playerid))
        if(IsCopSkin(playerid))
        {
            new vehid = GetPlayerVehicleID (playerid);
            if (VehRadarID [vehid] == -1) return 1;
            CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
        }
        return 1;
    }

    if (!strcmp (cmdtext, "/stopchecking"))
    if(IsCopSkin(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);
                   PlayerTextDrawHide (i, Textdraw1);
                   PlayerTextDrawHide (i, Textdraw2);
                }
            }
        }
        return 1;
    }
    return 0;
}



Re: How to change this code to CMD - Boot - 30.12.2014

DCMD or ZCMD ?

I will make using ZCMD for you.

pawn Код:
CMD:placeradar(playerid)
{
    if (IsPlayerInAnyVehicle (playerid))
    {
    if(IsCopSkin(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_WHITE, "Radar Planes.");
    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);
    PlayerTextDrawShow (i, Textdraw1);
    PlayerTextDrawShow (i, Textdraw2);
    }
    }
    }
    }
    return 1;
}

CMD:removeradar(playerid)
{
    if (IsPlayerInAnyVehicle (playerid))
    {
    if(IsCopSkin(playerid))
    {
    new vehid = GetPlayerVehicleID (playerid);
    if (VehRadarID [vehid] == -1) return 1;

    DestroyObject (VehRadarID [vehid]);
    SendClientMessage (playerid, COLOR_YELLOW, "Radar has been removed successfully.");
    VehRadarID [vehid] = -1;
    KillTimer (CheckingSpeed [vehid]);
    CheckingSpeed [vehid] = -1;
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
    if (IsPlayerInVehicle (i, vehid))
    {
    PlayerTextDrawHide (i, RadarHud);
    PlayerTextDrawHide (i, Textdraw1);
    PlayerTextDrawHide (i, Textdraw2);
    }
    }
    }
    }
    return 1;
}

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

CMD:stopchecking(playerid)
{
    if(IsCopSkin(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);
    PlayerTextDrawHide (i, Textdraw1);
    PlayerTextDrawHide (i, Textdraw2);
    }
    }
    }
    }
    return 1;
}
And don't forget to delete the OnPlayerCommandText callback if you are going to use ZCMD.


Re: How to change this code to CMD - lulo356 - 30.12.2014

Quote:
Originally Posted by Boot
Посмотреть сообщение
DCMD or ZCMD ?

I will make using ZCMD for you.

pawn Код:
CMD:placeradar(playerid)
{
    if (IsPlayerInAnyVehicle (playerid))
    {
    if(IsCopSkin(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_WHITE, "Radar Planes.");
    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);
    PlayerTextDrawShow (i, Textdraw1);
    PlayerTextDrawShow (i, Textdraw2);
    }
    }
    }
    }
    return 1;
}

CMD:removeradar(playerid)
{
    if (IsPlayerInAnyVehicle (playerid))
    {
    if(IsCopSkin(playerid))
    {
    new vehid = GetPlayerVehicleID (playerid);
    if (VehRadarID [vehid] == -1) return 1;

    DestroyObject (VehRadarID [vehid]);
    SendClientMessage (playerid, COLOR_YELLOW, "Radar has been removed successfully.");
    VehRadarID [vehid] = -1;
    KillTimer (CheckingSpeed [vehid]);
    CheckingSpeed [vehid] = -1;
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
    if (IsPlayerInVehicle (i, vehid))
    {
    PlayerTextDrawHide (i, RadarHud);
    PlayerTextDrawHide (i, Textdraw1);
    PlayerTextDrawHide (i, Textdraw2);
    }
    }
    }
    }
    return 1;
}

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

CMD:stopchecking(playerid)
{
    if(IsCopSkin(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);
    PlayerTextDrawHide (i, Textdraw1);
    PlayerTextDrawHide (i, Textdraw2);
    }
    }
    }
    }
    return 1;
}
And don't forget to delete the OnPlayerCommandText callback if you are going to use ZCMD.
You that was i meant ZCMD


Re: How to change this code to CMD - lulo356 - 30.12.2014

But the commands doesnt work for some reason.


Re: How to change this code to CMD - Boot - 30.12.2014

Quote:
Originally Posted by lulo356
Посмотреть сообщение
But the commands doesnt work for some reason.
Did you get errors when you have compiled or while testing them in-game ?


Re: How to change this code to CMD - iThePunisher - 30.12.2014

you should #include <zcmd>


Re: How to change this code to CMD - lulo356 - 30.12.2014

Quote:
Originally Posted by Boot
Посмотреть сообщение
Did you get errors when you have compiled or while testing them in-game ?
Just testing in game and its not working

Quote:
Originally Posted by iThePunisher
Посмотреть сообщение
you should #include <zcmd>
Im always using zcmd so its already included,


Re: How to change this code to CMD - iThePunisher - 30.12.2014

ok if it shows the unknown server command error then the problem is that you cannot use 2 command compressors you should work with one of them i recommand you to use ZCMD


Re: How to change this code to CMD - Boot - 30.12.2014

Quote:
Originally Posted by lulo356
Посмотреть сообщение
Just testing in game and its not working
Huum, this might be a silly question, but are these commands working without using ZCMD ?


Re: How to change this code to CMD - lulo356 - 30.12.2014

Quote:
Originally Posted by Boot
Посмотреть сообщение
Huum, this might be a silly question, but are these commands working without using ZCMD ?
Nope, But it doenst show that the command wasn't found,