SA-MP Forums Archive
Why this script dont work and all players can enter in the cars ? - 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 script dont work and all players can enter in the cars ? (/showthread.php?tid=490314)



Why this script dont work and all players can enter in the cars ? - barts - 26.01.2014

PHP код:
enum jobInfo2
{
    
jtCars[17]

PHP код:
new JobInfo2[MAX_JOBS][jobInfo2]; 
PHP код:
    JobInfo2[JOB_TAXIDRIVER][jtCars][0] = CreateVehicle(420, -304.87411582.225675.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][1] = CreateVehicle(420, -302.74241579.938575.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][2] = CreateVehicle(420, -300.11501577.480575.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][3] = CreateVehicle(420, -297.63671574.872775.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][4] = CreateVehicle(420, -295.07441572.385475.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][5] = CreateVehicle(420, -292.69531570.136575.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][6] = CreateVehicle(420, -290.10471567.647275.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][7] = CreateVehicle(420, -287.62071565.013575.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][8] = CreateVehicle(420, -285.14601562.537175.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][9] = CreateVehicle(420, -282.73101560.144775.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][10] = CreateVehicle(420, -280.24101557.377875.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][11] = CreateVehicle(420, -277.78271555.076775.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][12] = CreateVehicle(420, -275.39171552.376275.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][13] = CreateVehicle(420, -270.41981547.502675.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][14] = CreateVehicle(420, -273.04691549.863675.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][15] = CreateVehicle(420, -265.50281542.348075.0000, -45.000066100);
    
JobInfo2[JOB_TAXIDRIVER][jtCars][16] = CreateVehicle(420, -268.06581544.938875.0000, -45.000066100); 
PHP код:
stock IsTaxiVehicle(vehicleid)
{
    for(new 
i=0i<10i++)
    {
        if(
vehicleid == JobInfo2[JOB_TAXIDRIVER][jtCars][i]) return 1;
    }
    return 
0;

PHP код:
        else if(IsTaxiVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TAXIDRIVER)
        {
            new 
Float:pos[3];
            
GetPlayerPos(playeridpos[0], pos[1], pos[2]);
            
SetPlayerPos(playeridpos[0], pos[1], pos[2]);
            
SendClientMessage(playeridCOLOR_ORANGE" You can't start the engine as it belongs to the Taxi Drivers.");
        } 



Re: Why this script dont work and all players can enter in the cars ? - Sawalha - 26.01.2014

RemovePlayerFromVehicle?


Re: Why this script dont work and all players can enter in the cars ? - EiresJason - 26.01.2014

Is this called in this callback?
pawn Код:
OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
If it is, try this.

pawn Код:
else if(IsTaxiVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TAXIDRIVER)
        {
            ClearAnimations(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Taxi Drivers.");
        }



Re: Why this script dont work and all players can enter in the cars ? - barts - 26.01.2014

dont work and it is called in this callback


Re: Why this script dont work and all players can enter in the cars ? - Konstantinos - 26.01.2014

In the enum, jtCars can store 17 cars and in IsTaxiVehicle you loop only 10 times so if the car is one of the rest (7) cars, it will just ignore it.

pawn Код:
stock IsTaxiVehicle(vehicleid)
{
    for(new i=0; i<17; i++)
    {
        if(vehicleid == JobInfo2[JOB_TAXIDRIVER][jtCars][i]) return 1;
    }
    return 0;
}



Re: Why this script dont work and all players can enter in the cars ? - Don_Cage - 26.01.2014

Try this:
pawn Код:
else if(IsTaxiVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TAXIDRIVER)
        {
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(vehicleid,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Taxi Drivers.");
        }



Re: Why this script dont work and all players can enter in the cars ? - barts - 26.01.2014

@Konstantinos it dont work with your script....


Re: Why this script dont work and all players can enter in the cars ? - Konstantinos - 26.01.2014

Quote:
Originally Posted by barts
Посмотреть сообщение
@Konstantinos it dont work with your script....
Do you get the message " You can't start the engine as it belongs to the Taxi Drivers."? If not, there's another problem.


Re: Why this script dont work and all players can enter in the cars ? - Yashas - 26.01.2014

There are 16 cars and you are checking only the first 11 cars!


Re: Why this script dont work and all players can enter in the cars ? - barts - 26.01.2014

No i dont get message....