DCMD:Nos/Repair
#1

anywone have the code for /nos and /repair pleas?
Reply
#2

BTW, You must learn scripting yourself, instead of making 3-4 command request thread everyday.

pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!PlayerInfo[playerid][pLoggedIn]) return 0;
pawn Код:
dcmd_fix(playerid, params[])
{
    new id;
    if (sscanf(params, "u", id)) { id = playerid; }

    if (id == INVALID_PLAYER_ID) { SendClientMessage(playerid, COLOR_RED, "* /repair: Invalid player"); }
    else
    {
        new veh = GetPlayerVehicleID(id);
        if (veh)
        {
            RepairVehicle(veh);
            if (playerid != id) { SendClientMessage(playerid, COLOR_GREEN, "Repaired vehicle"); }
            SendClientMessage(id, COLOR_GREEN, "Your vehicle was repaired");
        }
        else { SendClientMessage(playerid, COLOR_RED, "That player is currently not in a vehicle"); }
    }
    return 1;
}
pawn Код:
dcmd_nos(playerid, params[])
{
    new id;
    if (sscanf(params, "u", id)) { id = playerid; }

    if (id == INVALID_PLAYER_ID) { SendClientMessage(playerid, COLOR_RED, "* /nos: Invalid player"); }
    else
    {
        new veh = GetPlayerVehicleID(id);
        if (veh)
        {
            AddVehicleComponent(veh, 1010);
            if (playerid != id) { SendClientMessage(playerid, COLOR_GREEN, "Added nos to vehicle"); }
            SendClientMessage(id, COLOR_GREEN, "Added nos to vehicle");
        }
        else { SendClientMessage(playerid, COLOR_RED, "That player is currently not in a vehicle"); }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by RanSEE
Посмотреть сообщение
BTW, You must learn scripting yourself, instead of making 3-4 command request thread everyday.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!PlayerInfo[playerid][pLoggedIn]) return 0;


pawn Код:
dcmd_nos(playerid, params[])
{
    new id;
    if (sscanf(params, "u", id)) { id = playerid; }

    if (id == INVALID_PLAYER_ID) { SendClientMessage(playerid, COLOR_RED, "* /nos: Invalid player"); }
    else
    {
        new veh = GetPlayerVehicleID(id);
        if (veh)
        {
            AddVehicleComponent(veh, 1010);
            if (playerid != id) { SendClientMessage(playerid, COLOR_GREEN, "Added nos to vehicle"); }
            SendClientMessage(id, COLOR_GREEN, "Added nos to vehicle");
        }
        else { SendClientMessage(playerid, COLOR_RED, "That player is currently not in a vehicle"); }
    }
}
    return 1;
pawn Код:
dcmd_fix(playerid, params[])
{
    new id;
    if (sscanf(params, "u", id)) { id = playerid; }

    if (id == INVALID_PLAYER_ID) { SendClientMessage(playerid, COLOR_RED, "* /repair: Invalid player"); }
    else
    {
        new veh = GetPlayerVehicleID(id);
        if (veh)
        {
            RepairVehicle(veh);
            if (playerid != id) { SendClientMessage(playerid, COLOR_GREEN, "Repaired vehicle"); }
            SendClientMessage(id, COLOR_GREEN, "Your vehicle was repaired");
        }
        else { SendClientMessage(playerid, COLOR_RED, "That player is currently not in a vehicle"); }
    }
    return 1;
}
RanSEE, why do you need to use sscanf in that code? That's not needed at all, just making the code slower and longer. I'm not even sure if your code will work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)