PDA

View Full Version : Cmd to a dialog


alexanderjb918
17/10/2014, 04:43 PM
Hey guys is it possible to change this

CMD:car(playerid, params[])
{
if(isnull(params))
{
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /car [name]");
SendClientMessageEx(playerid, COLOR_GREY, "Available names: Status, Engine, Lights, Trunk, Hood, Fuel");
return 1;
}
if(strcmp(params, "engine", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new engine,lights,alarm,doors,bonnet,boot,objective,ve hicleid;
vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
if(engine == VEHICLE_PARAMS_ON)
{ new string[128];
format(string, sizeof(string), "* %s twists the key in the ignition, turning the engine off.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
SetVehicleEngine(vehicleid, playerid);
}
else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
{ new string[128];
SendClientMessageEx(playerid, COLOR_WHITE, "Vehicle engine starting, please wait...");
SetTimerEx("SetVehicleEngine", 1000, 0, "dd", vehicleid, playerid);
format(string, sizeof(string), "* %s twists the key in the ignition, turning the engine on.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
}
}
else if(strcmp(params, "lights", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
SetVehicleLights(vehicleid, playerid);
}
else if(strcmp(params, "hood", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510 || IsAPlane(vehicleid) || IsABike(vehicleid))
{
return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
}
SetVehicleHood(vehicleid, playerid);
}
else if(!IsPlayerInAnyVehicle(playerid))
{
new closestcar = GetClosestCar(playerid);
if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
{
if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510 || IsAPlane(closestcar) || IsABike(closestcar))
{
return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
}
SetVehicleHood(closestcar, playerid);
}
}
}
else if(strcmp(params, "trunk", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
{
return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
}
SetVehicleTrunk(vehicleid, playerid);
}
else if(!IsPlayerInAnyVehicle(playerid))
{
new closestcar = GetClosestCar(playerid);
if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
{
if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510)
{
return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
}
SetVehicleTrunk(closestcar, playerid);
}
}
}
/* else if(strcmp(params, "fuel", true) == 0 && IsPlayerInAnyVehicle(playerid))
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
if(GetPVarInt(playerid, "fuelonoff") == 0)
{
SendClientMessageEx(playerid, COLOR_WHITE, "You have turned on the fuel indicator (green bar).");
SetPVarInt(playerid, "fuelonoff", 1);
FuelBar[playerid] = CreateProgressBar(548.00, 26.00, 57.50, 3.20, 866792447, 100.0);
textdrawscount++;
SetProgressBarValue(FuelBar[playerid], VehicleFuel[GetPlayerVehicleID(playerid)]);
ShowProgressBarForPlayer(playerid, FuelBar[playerid]);
}
else
{
SendClientMessageEx(playerid, COLOR_WHITE, "You have turned off the fuel indicator (green bar).");
SetPVarInt(playerid, "fuelonoff", 0);
DestroyProgressBar(FuelBar[playerid]);
textdrawscount--;
FuelBar[playerid] = INVALID_BAR_ID;
}
} */
else if(strcmp(params, "status", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective,en ginestatus[4],lightstatus[4], string[48];
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
if(engine != VEHICLE_PARAMS_ON) format(enginestatus, sizeof(enginestatus), "OFF");
else format(enginestatus, sizeof(enginestatus), "ON");
if(lights != VEHICLE_PARAMS_ON) format(lightstatus, sizeof(lightstatus), "OFF");
else format(lightstatus, sizeof(lightstatus), "ON");
format(string, sizeof(string), "Engine: %s | Lights: %s | Fuel: %.2f.",enginestatus,lightstatus,VehicleFuel[vehicleid]);
SendClientMessageEx(playerid, COLOR_WHITE, string);
}
}
return 1;
}




Into a Dialog so like i type /car it comes up in a box and i click so engine and it turns on

DanishHaq
17/10/2014, 04:49 PM
Have a look, use this as a "guidance", i.e don't copy and paste it, else you won't learn anything.

#define DIALOG_CARCMD 6545

CMD:car(playerid, params[])
{
ShowPlayerDialog(playerid, DIALOG_CARCMD, DIALOG_STYLE_LIST, "Car control", "Status\nEngine\nLights\nTrunk\nHood\nFuel", "Select", "Cancel");
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_CARCMD:
{
switch(listitem)
{
case 0:
{
// code for status
}
case 1:
{
// code for engine
}
case 2:
{
// code for lights
}
case 3:
{
// code for trunk
}
case 4:
{
// code for hoof
}
case 5:
{
// code for fuel
}
}
}
}
return 1;
}

alexanderjb918
17/10/2014, 05:49 PM
it dosent look right like all my other dialogs look like this


if(dialogid == UNMODCARMENU)
{
if (response)
{
new count = GetPVarInt(playerid, "modCount");
new d;
for(new z = 0 ; z < MAX_PLAYERVEHICLES; z++)
{
if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[playerid][z][pvId]))
{
d = z;
break;
}
}
for (new i = 0; i < count; i++)
{
if(listitem == i)
{
format(string, sizeof(string), "partList%i", i);
new partID = GetPVarInt(playerid, string);
if (partID == 999)
{
for(new f = 0 ; f < MAX_MODS; f++)
{
RemoveVehicleComponent(PlayerVehicleInfo[playerid][d][pvId], GetVehicleComponentInSlot(PlayerVehicleInfo[playerid][d][pvId], f));
PlayerVehicleInfo[playerid][d][pvMods][f] = 0;
}
SendClientMessageEx(playerid, COLOR_WHITE, "All modifications have been removed from your vehicle.");
return 1;
}
RemoveVehicleComponent(GetPlayerVehicleID(playerid ), partID);
PlayerVehicleInfo[playerid][d][pvMods][GetVehicleComponentType(partID)] = 0;
SendClientMessageEx(playerid, COLOR_WHITE, "The modification you requested has been removed.");
return 1;
}
}
}
}