new policeInfernus[MAX_VEHICLES];
//in gamemodeinit
policeInfernus[1] = CreateVehicle(...);
//in the check.
if(vehicleid == policeInfernus[1])
...
new LEOveh[19];
public OnPlayerStateChange(playerid, newstate, oldstate) { new vehicleid = GetPlayerVehicleID(playerid); switch(newstate) { case PLAYER_STATE_DRIVER: { if(vehicleid >= LEOveh[0] && LEOveh[18] >= vehicleid) { if(PlayerInfo[playerid][Faction] != 1) { SendClientMessage(playerid, COLOR_WHITE, "You are not a Police Office and do not have the keys for this vehicle"); RemovePlayerFromVehicle(playerid); } }
LEOveh[0] = CreateVehicle(561,1530.7141,-1644.6859,5.5957,180.2718,0,0,2000); // Stratum LEOveh[1] = CreateVehicle(560,1534.6045,-1644.6677,5.5957,180.2718,0,0,2000); // Sultan LEOveh[2] = CreateVehicle(560,1538.8458,-1644.6477,5.5957,180.2718,0,0,2000); // Sultan LEOveh[3] = CreateVehicle(561,1526.9716,-1644.7039,5.5957,180.2718,0,0,2000); // Stratum LEOveh[4] = CreateVehicle(490,1528.9757,-1687.9369,6.0183,269.7481,0,0,2000); // F.B.I Rancher LEOveh[5] = CreateVehicle(490,1528.9938,-1683.8076,6.0182,269.7481,0,0,2000); // F.B.I Rancher LEOveh[6] = CreateVehicle(596,1544.8733,-1668.2935,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser LEOveh[7] = CreateVehicle(596,1544.8948,-1672.4688,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser LEOveh[8] = CreateVehicle(596,1544.9147,-1676.3838,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser LEOveh[9] = CreateVehicle(596,1544.9349,-1680.3630,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser LEOveh[10] = CreateVehicle(596,1544.9562,-1684.4753,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser
Thanks Meller. It works but not when "new policeInfernus[MAX_VEHICLES];" and using various types as policeInfernus[1] and so on. It stores "0" at place of vehicle id in policeInfernus[1].
When i did this > "new policeInfernus;" and store vehicle id in this, it stores the correct vehicle id. But i think it will be a big task to create these seperate variables for each car. Why "new policeInfernus[MAX_VEHICLES];" is not working? |
For the first care it's policeInfernus[0], the second policeInfernus[1], etc... |
new policeInfernus[MAX_VEHICLES]; //in gamemodeinit policeInfernus[0] = CreateVehicle(...); policeInfernus[1] = CreateVehicle(...); policeInfernus[2] = CreateVehicle(...); //in the check. if(vehicleid == policeInfernus[0],policeInfernus[1],policeInfernus[2]) ...
if(vehicleid == policeInfernus[0]||vehicleid == policeInfernus[1]||vehicleid == policeInfernus[2])
if(vehicleid >= LEOveh[0] && LEOveh[18] >= vehicleid)