Questions about DCMD
#1

Hi all, I have a car engine cmd, it is in dcmd. The cmd is /engine, but I wanna make it /car engine. How can I do that?

dcmd_engine(playerid, params[]) will be dcmd_car engine(playerid, params[])?

EDIT: How can I make if players entered a vehicle they will get a message ''To start the vehicle's engine, type /car engine"?
Reply
#2

For "To start the vehicle's engine, type /car engine" message use this: CLICK HERE

For /car engine:

pawn Код:
if(strcmp(params,"engine",true) == 0)
{
    // Turn on engine      
}
Reply
#3

Well it is DCMD not strcmp.
Reply
#4

Put it like this:

Код:
dcmd_car(playerid, params[])
{
    if(strcmp(params, "engine",true) == 0)
    {
        // Turn on engine       
    }
    return 1;
}
params is an "optional" text that player types with command.

At your case params is engine.

So when he types /car engine we use strcmp to check did he typed engine, if yes then start the engine. You got it?
Reply
#5

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
Put it like this:

Код:
dcmd_car(playerid, params[])
{
    if(strcmp(params, "engine",true) == 0)
    {
        // Turn on engine       
    }
    return 1;
}
params is an "optional" text that player types with command.

At your case params is engine.

So when he types /car engine we use strcmp to check did he typed engine, if yes then start the engine. You got it?
Alright, thanks.
Is this correct?
Quote:
Код:
dcmd_car(playerid, params[])
{
    #pragma unused params
    if(strcmp(params, "engine",true) == 0)
    {
        new vehicleid, engine,lights,alarm,doors,bonnet,boot,objective;
    vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in a vehicle in order to use this command.");
    if(GetPlayerVehicleSeat(playerid) != 0)
        return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in the driver seat in order to use this command.");
      if(engine == 1)
      {
        SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
        SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Engine shut off.");
      }
      else
      {
        SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
        SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Engine started.");
        }
      }
    return 1;
}
Oh and how do I make like '' ** Uberanwar has turned on the vehicle's ignition ** '' (Only the nearest players can see the text)
Reply
#6

For that message use:

Put this somewhere at your script.

pawn Код:
NearMessageSender(playerid, Float:radius, string[], COLOR1, COLOR2, COLOR3, COLOR4, COLOR5)
{
    new Float:Position[3], Float:iPosition[3], Float:cPosition[3];
    GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
    for (new i = 0; i != MAX_PLAYERS; ++i)
    {
        if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
        {
            GetPlayerPos(i, iPosition[0], iPosition[1], iPosition[2]);
            cPosition[0] = (Position[0] - iPosition[0]);
            cPosition[1] = (Position[1] - iPosition[1]);
            cPosition[2] = (Position[2] - iPosition[2]);
            if(((cPosition[0] < radius/16) && (cPosition[0] > -radius/16)) && ((cPosition[1] < radius/16) && (cPosition[1] > -radius/16)) && ((cPosition[2] < radius/16) && (cPosition[2] > -radius/16)))
            {
                SendClientMessage(i, COLOR1, string);
            }
            else if(((cPosition[0] < radius/8) && (cPosition[0] > -radius/8)) && ((cPosition[1] < radius/8) && (cPosition[1] > -radius/8)) && ((cPosition[2] < radius/8) && (cPosition[2] > -radius/8)))
            {
                SendClientMessage(i, COLOR2, string);
            }
                else if(((cPosition[0] < radius/4) && (cPosition[0] > -radius/4)) && ((cPosition[1] < radius/4) && (cPosition[1] > -radius/4)) && ((cPosition[2] < radius/4) && (cPosition[2] > -radius/4)))
            {
                SendClientMessage(i, COLOR3, string);
            }
            else if(((cPosition[0] < radius/2) && (cPosition[0] > -radius/2)) && ((cPosition[1] < radius/2) && (cPosition[1] > -radius/2)) && ((cPosition[2] < radius/2) && (cPosition[2] > -radius/2)))
            {
                SendClientMessage(i, COLOR4, string);
            }
            else if(((cPosition[0] < radius) && (cPosition[0] > -radius)) && ((cPosition[1] < radius) && (cPosition[1] > -radius)) && ((cPosition[2] < radius) && (cPosition[2] > -radius)))
            {
                SendClientMessage(i, COLOR5, string);
            }
        }
    }
    return 1;
}

Put this at the top of your script.

pawn Код:
#define FADE1 0xFFFFFFFF
#define FADE2 0xC8C8C8C8
#define FADE3 0xAAAAAAAA
#define FADE4 0x8C8C8C8C
#define FADE5 0x6E6E6E6E


pawn Код:
dcmd_engine(playerid, params[])
{
    if(strcmp(params, "engine", true) == 0)
    {
        new vehicleid, engine, lights, alarm, doors, bonnet, boot, objective, message[43+MAX_PLAYER_NAME+1], playername[MAX_PLAYER_NAME+1];
        vehicleid = GetPlayerVehicleID(playerid);
        GetPlayerName(playerid, playername, sizeof(playername));
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in a vehicle in order to use this command.");
        if(GetPlayerVehicleSeat(playerid) != 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in the driver seat in order to use this command.");
        if(engine == 1)
        {
            SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
            SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Engine shut off.");
        }
        else
        {
            SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
            SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Engine started.");
            format(message, sizeof(message), "** %s has turned on the vehicle's ignition **", playername);
            for (new i = 0; i != MAX_PLAYERS; ++i)
            {
                NearMessageSender(i, 8, message, FADE1, FADE2, FADE3, FADE4, FADE5);
            }
        }
    }
    return 1;
}
I didn't tested it.
Reply
#7

[QUOTE=RedJohn;2658903]For that message use:

Put this somewhere at your script.

pawn Код:
NearMessageSender(playerid, Float:radius, string[], COLOR1, COLOR2, COLOR3, COLOR4, COLOR5)
{
    new Float:Position[3], Float:iPosition[3], Float:cPosition[3];
    GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
    for (new i = 0; i != MAX_PLAYERS; ++i)
    {
        if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
        {
            GetPlayerPos(i, iPosition[0], iPosition[1], iPosition[2]);
            cPosition[0] = (Position[0] - iPosition[0]);
            cPosition[1] = (Position[1] - iPosition[1]);
            cPosition[2] = (Position[2] - iPosition[2]);
            if(((cPosition[0] < radius/16) && (cPosition[0] > -radius/16)) && ((cPosition[1] < radius/16) && (cPosition[1] > -radius/16)) && ((cPosition[2] < radius/16) && (cPosition[2] > -radius/16)))
            {
                SendClientMessage(i, COLOR1, string);
            }
            else if(((cPosition[0] < radius/8) && (cPosition[0] > -radius/8)) && ((cPosition[1] < radius/8) && (cPosition[1] > -radius/8)) && ((cPosition[2] < radius/8) && (cPosition[2] > -radius/8)))
            {
                SendClientMessage(i, COLOR2, string);
            }
                else if(((cPosition[0] < radius/4) && (cPosition[0] > -radius/4)) && ((cPosition[1] < radius/4) && (cPosition[1] > -radius/4)) && ((cPosition[2] < radius/4) && (cPosition[2] > -radius/4)))
            {
                SendClientMessage(i, COLOR3, string);
            }
            else if(((cPosition[0] < radius/2) && (cPosition[0] > -radius/2)) && ((cPosition[1] < radius/2) && (cPosition[1] > -radius/2)) && ((cPosition[2] < radius/2) && (cPosition[2] > -radius/2)))
            {
                SendClientMessage(i, COLOR4, string);
            }
            else if(((cPosition[0] < radius) && (cPosition[0] > -radius)) && ((cPosition[1] < radius) && (cPosition[1] > -radius)) && ((cPosition[2] < radius) && (cPosition[2] > -radius)))
            {
                SendClientMessage(i, COLOR5, string);
            }
        }
    }
    return 1;
}
Is that a stock?
Reply
#8

Yes.
Reply
#9

Quote:

C:\Users\USER\Desktop\Street Kings Server\gamemodes\CNR.pwn(9636) : warning 219: local variable "Position" shadows a variable at a preceding level
C:\Users\USER\Desktop\Street Kings Server\gamemodes\CNR.pwn(9637) : error 028: invalid subscript (not an array or too many subscripts): "Position"
C:\Users\USER\Desktop\Street Kings Server\gamemodes\CNR.pwn(9637) : warning 215: expression has no effect
C:\Users\USER\Desktop\Street Kings Server\gamemodes\CNR.pwn(9637) : error 001: expected token: ";", but found "]"
C:\Users\USER\Desktop\Street Kings Server\gamemodes\CNR.pwn(9637) : error 029: invalid expression, assumed zero
C:\Users\USER\Desktop\Street Kings Server\gamemodes\CNR.pwn(9637) : fatal error 107: too many error messages on one line

(9637) - GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
((In NearMessageSender))
Reply
#10

pawn Код:
NearMessageSender(playerid, Float:radius, string[], COLOR1, COLOR2, COLOR3, COLOR4, COLOR5)
{
    new Float:PlayerIDNMSPosition[3], Float:PlayerIDNMSPosition[3], Float:PlayerIDNMSPosition[3];
    GetPlayerPos(playerid, PlayerIDNMSPosition[0], PlayerIDNMSPosition[1], PlayerIDNMSPosition[2]);
    for (new i = 0; i != MAX_PLAYERS; ++i)
    {
        if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
        {
            GetPlayerPos(i, iPosition[0], iPosition[1], iPosition[2]);
            cPosition[0] = (PlayerIDNMSPosition[0] - iPosition[0]);
            cPosition[1] = (PlayerIDNMSPosition[1] - iPosition[1]);
            cPosition[2] = (PlayerIDNMSPosition[2] - iPosition[2]);
            if(((cPosition[0] < radius/16) && (cPosition[0] > -radius/16)) && ((cPosition[1] < radius/16) && (cPosition[1] > -radius/16)) && ((cPosition[2] < radius/16) && (cPosition[2] > -radius/16)))
            {
                SendClientMessage(i, COLOR1, string);
            }
            else if(((cPosition[0] < radius/8) && (cPosition[0] > -radius/8)) && ((cPosition[1] < radius/8) && (cPosition[1] > -radius/8)) && ((cPosition[2] < radius/8) && (cPosition[2] > -radius/8)))
            {
                SendClientMessage(i, COLOR2, string);
            }
                else if(((cPosition[0] < radius/4) && (cPosition[0] > -radius/4)) && ((cPosition[1] < radius/4) && (cPosition[1] > -radius/4)) && ((cPosition[2] < radius/4) && (cPosition[2] > -radius/4)))
            {
                SendClientMessage(i, COLOR3, string);
            }
            else if(((cPosition[0] < radius/2) && (cPosition[0] > -radius/2)) && ((cPosition[1] < radius/2) && (cPosition[1] > -radius/2)) && ((cPosition[2] < radius/2) && (cPosition[2] > -radius/2)))
            {
                SendClientMessage(i, COLOR4, string);
            }
            else if(((cPosition[0] < radius) && (cPosition[0] > -radius)) && ((cPosition[1] < radius) && (cPosition[1] > -radius)) && ((cPosition[2] < radius) && (cPosition[2] > -radius)))
            {
                SendClientMessage(i, COLOR5, string);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)