SA-MP Forums Archive
Help CarLevel - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help CarLevel (/showthread.php?tid=466547)



Help CarLevel - kalanerik99 - 28.09.2013

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



Re: Help CarLevel - kalanerik99 - 28.09.2013

Please help


Re: Help CarLevel - Finn - 28.09.2013

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));



Re: Help CarLevel - Konstantinos - 28.09.2013

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;



Re: Help CarLevel - kalanerik99 - 28.09.2013

Thanks


Re: Help CarLevel - kalanerik99 - 28.09.2013

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;
}



Re: Help CarLevel - Konstantinos - 28.09.2013

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;
}