Hello , i'am a begginer scripter and i'am willing to learn but this CMD made me tired i really didn't know how to make it
i wanted to make all of the car CMDs like /lights /engine /trunk etc...into /car [engine - lights - trunk - hood]
pawn Код:
if(strcmp(cmd, "/trunk", true) == 0)
{
new counter = 0;
new vid;
new check = 0;
for(new i = 0; i < MAX_VEHICLES; i++)
{
new dist = CheckPlayerDistanceToVehicle(4, playerid, i);
if(dist)
{
vid = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, COLOR_GREY, "No cars with trunk near you");
}
case 1:
{
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] == vid)
{
check = 1;
CreatedCars[i] = INVALID_VEHICLE_ID;
break;
}
}
if(check == 1)
{
SendClientMessage(playerid, COLOR_RED, "This vehicle trunk is not available");
return 1;
}
if(IsAPlane(vid) || IsABike(vid) || IsAHelicopter(vid) || IsATrain(vid) || IsABoat(vid) || IsABus(vid) || GetVehicleModel(GetPlayerVehicleID(vid)) == 523)
{
SendClientMessage(playerid, COLOR_GREY, "This vehicle doesn't have a trunk");
return 1;
}
ShowPlayerDialog(playerid,TRUNKDIALOG,DIALOG_STYLE_LIST,"Trunk","Open / Close\nCheck\nPut stuff\nTake stuff","Ok","Cancel"); //Trunk
return 1;
}
default:
{
SendClientMessage(playerid, COLOR_GREY, "Found more then one car in range");
return 1;
}
}
if(strcmp(cmd, "/hood", true) == 0)
{
new vehid = gLastCar[playerid];
if(vehid == INVALID_VEHICLE_ID) { return 1; }
new Float:cx, Float:cy, Float:cz;
GetVehiclePos(vehid, cx, cy, cz);
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER || IsPlayerInRangeOfPoint(playerid, 4, cx, cy, cz) && !IsPlayerInAnyVehicle(playerid)) {
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehid,engine,lights,alarm,doors,bonnet,boot,objective);
if(hoodOpen[vehid] == 0) {
SetVehicleParamsEx(vehid,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
hoodOpen[vehid] = 1;
if(PlayerInfo[playerid][pMask]) {
ProxDetector(30.0, playerid, "* Stranger has opened their hood.", COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
} else {
format(string, sizeof(string), "* %s has opened their hood.", PlayerRPName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
} else {
SetVehicleParamsEx(vehid,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
hoodOpen[vehid] = 0;
if(PlayerInfo[playerid][pMask]) {
ProxDetector(30.0, playerid, "* Stranger has closed their hood.", COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
} else {
format(string, sizeof(string), "* %s has closed their hood.", PlayerRPName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
} else {
SendClientMessage(playerid,COLOR_GREY," You are not in a vehicle / in range of your last vehicle !");
}
if(strcmp(cmd, "/lights", true) == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,COLOR_GREY," You are not in a vehicle!");
return 1;
}
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { return 1; }
new vehid = GetPlayerVehicleID(playerid);
if(vehid != INVALID_VEHICLE_ID) {
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehid,engine,lights,alarm,doors,bonnet,boot,objective);
if(lightsOff[vehid] == 0) {
SetVehicleParamsEx(vehid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
lightsOff[vehid] = 1;
if(PlayerInfo[playerid][pMask]) {
ProxDetector(30.0, playerid, "* Stranger has turned their lights on.", COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
} else {
format(string, sizeof(string), "* %s has turned their lights on.", PlayerRPName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
} else {
SetVehicleParamsEx(vehid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
lightsOff[vehid] = 0;
if(PlayerInfo[playerid][pMask]) {
ProxDetector(30.0, playerid, "* Stranger has turned their lights off.", COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
} else {
format(string, sizeof(string), "* %s has turned their lights off.", PlayerRPName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
}
if(strcmp(cmd, "/engine", true) == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,COLOR_GREY," You are not in a vehicle!");
return 1;
}
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { return 1; }
new vehid = GetPlayerVehicleID(playerid);
if(vehid != INVALID_VEHICLE_ID) {
if(Gas[vehid] < 1) {
return SendClientMessage(playerid,COLOR_GREY," That vehicle is out of fuel !");
}
if(IsVehicleTotaled[GetPlayerVehicleID(playerid)] == 1) return SendClientMessage(playerid,COLOR_GREY," This vehicle is totaled!");
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engineOn[vehid] == 0) {
if(GetVehNeedHW(vehid, playerid)){
return SendClientMessage(playerid, COLOR_GRAD2," You do not have the key for this vehicle! ( /(h)ot(w)ire )");
}
SetVehicleParamsEx(vehid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
engineOn[vehid] = 1;
playerDisabledEngine[vehid] = 0;
if(PlayerInfo[playerid][pMask]) {
ProxDetector(30.0, playerid, "* Stranger has turned their engine on.", COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
} else {
format(string, sizeof(string), "* %s has turned their engine on.", PlayerRPName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
} else {
SetVehicleParamsEx(vehid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
engineOn[vehid] = 0;
playerDisabledEngine[vehid] = 1;
if(PlayerInfo[playerid][pMask]) {
ProxDetector(30.0, playerid, "* Stranger has turned their engine off.", COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
} else {
format(string, sizeof(string), "* %s has turned their engine off.", PlayerRPName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
}
You can add the normal /car command and use sscanf or strcmp to check his params/text he inputs. (By the way, zCMD is faster than strcmp for commands)
@MattTucker : Let him do as he want, I'm pretty sure he knows about zCMD but he could simply chose to not use.