SA-MP Forums Archive
Why this won't work? - 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: Why this won't work? (/showthread.php?tid=620901)



Why this won't work? - StrikerZ - 04.11.2016

Код:
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


Re: Why this won't work? - Vince - 04.11.2016

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


Re: Why this won't work? - Desaint - 04.11.2016

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.


Re: Why this won't work? - Sanady - 04.11.2016

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.