Must be a constant expression; assumed zero
#5

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(playeridparams[])
{
    
// 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=0i<20i++)
             {
                
format(PMSGsizeof(PMSG), "%s%s - %i\n",PMSG,APlanes[i][PlaneName], APlanes[i][PlaneID]);
             }
             
ShowPlayerDialog(playeridDIALOG_PLANEDIALOG_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;

Usage:
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    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(PMSGsizeof(PMSG), "You have spawned %s"APlanes[listitem][PlaneName]);
            
SendClientMessage(playerid, -/*W/e Color*/PMSG);
            new 
Float:PlayerPos[4];
            
GetPlayerPos(playeridPlayerPos[0], PlayerPos[1], PlayerPos[2]);
            
GetPlayerFacingAngle(playeridPlayerPos[3]);
            new 
VID CreateVehicle(APlanes[listitem][PlaneID], PlayerPos[0], PlayerPos[1], PlayerPos[2], PlayerPos[3], random(254), random(254), 0);
            
PutPlayerInVehicle(playeridVID0);
        }
        return 
1// We handled a dialog, so return 1. Just like OnPlayerCommandText.
    
}
    return 
0// You MUST return 0 here! Just like OnPlayerCommandText.

Edit: Do ask me if you have any doubt regarding how I used something and why.. Ask - Learn - Improve.
Reply


Messages In This Thread
Must be a constant expression; assumed zero - by Jhony_Blaze - 13.12.2014, 15:29
Re: Must be a constant expression; assumed zero - by Jhony_Blaze - 13.12.2014, 17:19
AW: Must be a constant expression; assumed zero - by Nero_3D - 13.12.2014, 18:33
Re: AW: Must be a constant expression; assumed zero - by Jhony_Blaze - 13.12.2014, 18:41
Re: Must be a constant expression; assumed zero - by Mic_H - 13.12.2014, 21:07

Forum Jump:


Users browsing this thread: 2 Guest(s)