Help CarLevel
#1

Hello

Can someone tell me how to make that

How to make that it will tipe the level who I tipe in stock?

pawn Код:
stock CarLevel(vehicleid)
{
if (vehicleid == 411) Level = 10;
}

format(string, sizeof(string), "Level:%i",CarLevel(vehicleid);//how to make that it will tipe the level who I tipe in stock
Reply
#2

Please help
Reply
#3

You have to return the number to do that.

pawn Код:
stock CarLevel(vehicleid)
{
    if(vehicleid == 411) return 10;

    return 0;
}
pawn Код:
format(string, sizeof(string), "Level:%i", CarLevel(vehicleid));
Reply
#4

Quote:
Originally Posted by Finn
Посмотреть сообщение
You have to return the number to do that.

pawn Код:
stock CarLevel(vehicleid)
{
    if(vehicleid == 411) return 10;

    return 0;
}
pawn Код:
format(string, sizeof(string), "Level:%i", CarLevel(vehicleid));
It should be:
pawn Код:
if(GetVehicleModel(vehicle) == 411) return 10;
Reply
#5

Thanks
Reply
#6

hey I have got 1 more problem level doesn't show

my code:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
stock CarLevel(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 411) return 10;
if(GetVehicleModel(vehicleid) == 451) return 2;
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
TextDrawShowForPlayer(playerid, carname);
new string[1000];
format(string, sizeof(string), "Car Name:%s~n~Max Speed:240~n~Level:%d", VehicleName[GetVehicleModel(vehicleid) - 400]),CarLevel(playerid);
TextDrawSetString(carname,string);
return 1;
}
Reply
#7

OnPlayerEnterVehicle is called when a player starts to enter a vehicle. In that time (the player is not in the vehicle yet), you call CarLevel that it tries to get the player's vehicleid however it returns -1 because they are not in vehicle yet.
pawn Код:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT )
    {
        TextDrawShowForPlayer(playerid, carname);
        new string[64];
        format(string, sizeof(string), "Car Name:%s~n~Max Speed:240~n~Level:%d", VehicleName[GetVehicleModel(vehicleid) - 400],CarLevel(playerid));
        TextDrawSetString(carname,string);
    }
    return 1;
}

stock CarLevel(playerid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 411) return 10;
    else if(GetVehicleModel(vehicleid) == 451) return 2;
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)