13.12.2014, 21:07
PHP код:
#define DIALOG_PLANE 1
enum APlaneInfo
{
PlaneName[20],
PlaneID
}
new APlanes[20][APlaneInfo] =
{
{"Andromada", 592}, {"AT400", 577}, {"Beagle", 511}, {"Cargobob", 548}, // ID 0, 1, 2, 3
{"Cropduster", 512}, {"Dodo", 593}, {"Hunter", 425}, {"Hydra", 520}, // ID 4, 5, 6, 7
{"Leviathan", 417}, {"Maverick", 487}, {"Nevada", 553}, {"Police Maverick", 497}, // ID 8, 9, 10, 11
{"Raindance", 563}, {"Rustler", 476}, {"SAN News Maverick", 488}, {"Seasparrow", 447}, // ID 12, 13, 14, 15
{"Shamal", 519}, {"Skimmer", 460}, {"Sparrow", 469}, {"Stuntplane", 513} // ID 16, 17, 18, 19
};
//==============================================================================
CMD:vplane(playerid, params[])
{
// Check if the player's admin-level is at least 1
if(PlayerInfo[playerid][pVIP] >= 2)
{
// Make sure the player isn't inside a vehicle
if (GetPlayerVehicleID(playerid) == 0)
{
// Ask which PLANE the player wants to have
new PMSG[1000];
for(new i=0; i<20; i++)
{
format(PMSG, sizeof(PMSG), "%s%s - %i\n",PMSG,APlanes[i][PlaneName], APlanes[i][PlaneID]);
}
ShowPlayerDialog(playerid, DIALOG_PLANE, DIALOG_STYLE_LIST, "Choose a plane:", PMSG, "Spawn", "Cancel");
// Let the server know that this was a valid command
return 1;
}
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_PLANE)
{
if(!response) // Pressed ESC or clicked cancel
{
//SendClientMessage(playerid, COLOR_GREEN, "Closed Dialog Message");
}
else
{
//Pressed Spawn
new PMSG[128];
format(PMSG, sizeof(PMSG), "You have spawned %s", APlanes[listitem][PlaneName]);
SendClientMessage(playerid, -1 /*W/e Color*/, PMSG);
new Float:PlayerPos[4];
GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
GetPlayerFacingAngle(playerid, PlayerPos[3]);
new VID = CreateVehicle(APlanes[listitem][PlaneID], PlayerPos[0], PlayerPos[1], PlayerPos[2], PlayerPos[3], random(254), random(254), 0);
PutPlayerInVehicle(playerid, VID, 0);
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}