Enum help
#1

i thought of a cmd with enum but is this kind of enum valid??
pawn Код:
enum vInfo
{
    ModelId,
    MaxSpeedWithNitro,
    MaxSpeedWithoutNitro,
    EngineWeight,
    SpeedRank
};

new VehicleInfo [MAX_VEHICLES] [vInfo] = {
{400,bla}
{401,bla}
{402,bla}
.
.
.
{611,bla}
};
If its right how to add this to this when a player typed a cmd??
pawn Код:
CMD:vi(playerid, params[])
if(!IsPlayerInVehicle) return SCM(playerid, color, "You Need To Be In A Vehicle");
// whats the code to check whether he is driver?
GetPlayerVehicleModel(GetPlayerVehicleId)
if(GetPlayerVehicleModel(GetPlayerVehicleId) == VehicleInfo [] [ModelId]) Return // and what to do
I know im a nub ;(
Reply
#2

Yea you can do enum like that and...
pawn Код:
VehicleInfo [GetPlayervehicleID(playerid)] [ModelId]
or you can add like VehicleID to enum and when you create cars in a loop set them to that id
Reply
#3

Is that enum valid :O .

can u help me in that command??
Reply
#4

What the command must do?


You have to give info to any car model right? like Infernus have that and that?
Reply
#5

Yes like

if a player is in a infernus and types /vi
he must get this
"Max Speed (with nitro): %d
Max Speed (without nitro): %d
EngineWeight: %d
Speed Rank: %d"

should i use format??
and give an example in format with the enum
Reply
#6

So you want some info of the car will be displayed
Reply
#7

yes you are right , just say it in send client message
Reply
#8

pawn Код:
CMD:vi(playerid, params[])
{
    if( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SCM( playerid, color, "You Need To Be a driver" );
   
    new
        sz_Str[ 50 ],
        modelid = GetVehicleModel( GetPlayerVehicleID( playerid ) )
    ;
   
    format( sz_Str, sizeof( sz_Str ), "Max Speed (with nitro): %d", VehicleInfo[ modelid ][ MaxSpeedWithNitro ] );
    SendClientMessage( playerid, 0xFFFF00FF, sz_Str );
    format( sz_Str, sizeof( sz_Str ), "Max Speed (without nitro): %d", VehicleInfo[ modelid ][ MaxSpeedWithoutNitro ] );
    SendClientMessage( playerid, 0xFFFF00FF, sz_Str );
    format( sz_Str, sizeof( sz_Str ), "EngineWeight: %d", VehicleInfo[ modelid ][ EngineWeight ] );
    SendClientMessage( playerid, 0xFFFF00FF, sz_Str );
    format( sz_Str, sizeof( sz_Str ), "Speed Rank: %d", VehicleInfo[ modelid ][ SpeedRank ] );
    SendClientMessage( playerid, 0xFFFF00FF, sz_Str );
    return 1;
}
And change to:
pawn Код:
new VehicleInfo [212] [vInfo] = {
Reply
#9

If you dont want set all models of car in a right list you can do like that

pawn Код:
#include <a_samp>
#define MAX_VINFO 10
enum vInfo
{
    ModelId,
    MaxSpeedWithNitro,
    MaxSpeedWithoutNitro,
    EngineWeight,
    SpeedRank
}

new VehicleInfo[MAX_VINFO][vInfo] = {
    {411,200,170,500,10},//infernus
    {531,50,30,1200,1}//tractor
};

CMD:vi(playerid, params[])
{
    if(!IsPlayerInVehicle) return SendClientMessage(playerid, -1, "You Need To Be In A Vehicle");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You Need To Be Vehicle Driver");
    new vimodel = GetVehicleModel(GetPlayerVehicleID(playerid)),str[55];
    for(new i = 0; i != MAX_VINFO; i++) {
        if(VehicleInfo[i][ModelId] == vimodel) {
            format(str, sizeof(str), "Max Speed (with nitro): %d", VehicleInfo[i][MaxSpeedWithNitro]);
            SendClientMessage(playerid, -1, str);
            format(str, sizeof(str), "Max Speed (without nitro): %d", VehicleInfo[i][MaxSpeedWithoutNitro]);
            SendClientMessage(playerid, -1, str);
            format(str, sizeof(str), "EngineWeight: %d", VehicleInfo[i][EngineWeight]);
            SendClientMessage(playerid, -1, str);
            format(str, sizeof(str), "Speed Rank: %d", VehicleInfo[i][SpeedRank]);
            SendClientMessage(playerid, -1, str);
        }
    }
}
Reply
#10

Quote:
Originally Posted by iJumbo
Посмотреть сообщение
If you dont want set all models of car in a right list you can do like that

pawn Код:
#include <a_samp>
#define MAX_VINFO 10
enum vInfo
{
    ModelId,
    MaxSpeedWithNitro,
    MaxSpeedWithoutNitro,
    EngineWeight,
    SpeedRank
}

new VehicleInfo[MAX_VINFO][vInfo] = {
    {411,200,170,500,10},//infernus
    {531,50,30,1200,1}//tractor
};

CMD:vi(playerid, params[])
{
    if(!IsPlayerInVehicle) return SendClientMessage(playerid, -1, "You Need To Be In A Vehicle");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You Need To Be Vehicle Driver");
    new vimodel = GetVehicleModel(GetPlayerVehicleID(playerid)),str[55];
    for(new i = 0; i != MAX_VINFO; i++) {
        if(VehicleInfo[i][ModelId] == vimodel) {
            format(str, sizeof(str), "Max Speed (with nitro): %d", VehicleInfo[i][MaxSpeedWithNitro]);
            SendClientMessage(playerid, -1, str);
            format(str, sizeof(str), "Max Speed (without nitro): %d", VehicleInfo[i][MaxSpeedWithoutNitro]);
            SendClientMessage(playerid, -1, str);
            format(str, sizeof(str), "EngineWeight: %d", VehicleInfo[i][EngineWeight]);
            SendClientMessage(playerid, -1, str);
            format(str, sizeof(str), "Speed Rank: %d", VehicleInfo[i][SpeedRank]);
            SendClientMessage(playerid, -1, str);
        }
    }
}
I used this and also i did
Код:
 return 1;
, the results appear but after the result, Server:Unknown Command also appears.
pawn Код:
bla:1
bla:1
Server: Unknown Command
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)