if(strcmp(params,"engine",true) == 0)
{
// Turn on engine
}
dcmd_car(playerid, params[]) { if(strcmp(params, "engine",true) == 0) { // Turn on engine } return 1; }
Put it like this:
Код:
dcmd_car(playerid, params[]) { if(strcmp(params, "engine",true) == 0) { // Turn on engine } return 1; } 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? |
Код:
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; } |
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;
}
#define FADE1 0xFFFFFFFF
#define FADE2 0xC8C8C8C8
#define FADE3 0xAAAAAAAA
#define FADE4 0x8C8C8C8C
#define FADE5 0x6E6E6E6E
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;
}
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;
}
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 |
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;
}