Why this won't work?
#1

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
     if(vehicleid == 448)
     {
         SendClientMessage(playerid, -1, "{CE0000}Job: You can start the Pizzaboy job by using {00FF00}/pizza");
     }
     else if(vehicleid == 596)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 597)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 598)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 599)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 497)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 523)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 490)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 601)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 528)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 427)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 470)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehicleid == 520 && pInfo[playerid][pArmy] == 0)
     {
        SCM(playerid,COLOR_RED,"You aren't in army");
        RemovePlayerFromVehicle(playerid);
     }
     else if(vehicleid == 432 && pInfo[playerid][pArmy] == 0)
     {
        SCM(playerid,COLOR_RED,"You aren't in army");
        RemovePlayerFromVehicle(playerid);
     }
     else if(vehicleid == 425 && pInfo[playerid][pArmy] == 0)
     {
        SCM(playerid,COLOR_RED,"You aren't in army");
        RemovePlayerFromVehicle(playerid);
     }
     return 0;
}
IT wont set the wanted level neither removes the player from the vehicle
Reply
#2

Vehicleid is not the same as modelid. Also you may want to use a switch to avoid repeating code.
Reply
#3

For example, you should use
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
     new vehiclemodel = GetVehicleModel(vehicleid);
     if(vehiclemodel == 448)
     {
         SendClientMessage(playerid, -1, "{CE0000}Job: You can start the Pizzaboy job by using {00FF00}/pizza");
     }
     else if(vehiclemodel == 596)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehiclemodel == 597)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     // rest of code, with vehiclemodel instead vehicleid
     else if(vehiclemodel == 425 && pInfo[playerid][pArmy] == 0)
     {
        SCM(playerid,COLOR_RED,"You aren't in army");
        RemovePlayerFromVehicle(playerid);
     }
     return 0;
}
Why that? You can check this simply by command /dl. Vehicle ID is ID of that current vehicle, assigned by SA:MP. Vehicle model is... model, like buffallo or fbi rancher.
Reply
#4

Quote:
Originally Posted by Desaint
Посмотреть сообщение
For example, you should use
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
     new vehiclemodel = GetVehicleModel(vehicleid);
     if(vehiclemodel == 448)
     {
         SendClientMessage(playerid, -1, "{CE0000}Job: You can start the Pizzaboy job by using {00FF00}/pizza");
     }
     else if(vehiclemodel == 596)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     else if(vehiclemodel == 597)
     {
        SetPlayerWantedLevelEx(playerid,GetPlayerWantedLevel(playerid)+3);
     }
     // rest of code, with vehiclemodel instead vehicleid
     else if(vehiclemodel == 425 && pInfo[playerid][pArmy] == 0)
     {
        SCM(playerid,COLOR_RED,"You aren't in army");
        RemovePlayerFromVehicle(playerid);
     }
     return 0;
}
Why that? You can check this simply by command /dl. Vehicle ID is ID of that current vehicle, assigned by SA:MP. Vehicle model is... model, like buffallo or fbi rancher.
I shouldn`t use if or else if in this case. To be correct, I should use switch because it`s faster then if second becouse code looks much clear then with this if`s. So your choice.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)