new v = pInfo[playerid][VehicleOwner], currentveh, string[128]; new Float:vehx, Float:vehy, Float:vehz; GetVehiclePos(currentveh, vehx, vehy, vehz); format(string, sizeof(string), "%d %d %d.", vehx, vehy, vehz); SendClientMessage(playerid, -1, string);
vInfo[v][posX] = 170.8668; vInfo[v][posY] = -16.1531; vInfo[v][posZ] = 1.5781; vInfo[v][posA] = 220.7102;
new v = pInfo[playerid][VehicleOwner], currentveh = GetPlayerVehicleID(playerid), string[128];
You're trying to get the position from a vehicle that does not exist because currentveh is 0 and you haven't assigned the currect vehicleid.
pawn Код:
|
if(vehicleid == LEOveh[0] || LEOveh[1] || LEOveh[2] || LEOveh[3] || LEOveh[4] || LEOveh[5] || LEOveh[6] || LEOveh[7] || LEOveh[8] || LEOveh[9] || LEOveh[10] || LEOveh[11] || LEOveh[12] || LEOveh[13] || LEOveh[14] || LEOveh[15] || LEOveh[16] || LEOveh[17] || LEOveh[18] || LEOveh[19] || LEOveh[20] || LEOveh[21] || LEOveh[22] || LEOveh[23] || LEOveh[24] || LEOveh[25] || LEOveh[26] || LEOveh[27] || LEOveh[28] || LEOveh[29] || LEOveh[30] || LEOveh[31] || LEOveh[32] || LEOveh[33] || LEOveh[34] || LEOveh[35]) { if(pInfo[playerid][Faction] != 1) { SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You need to be a police officer in order to operate this vehicle!"); RemovePlayerFromVehicle(playerid); } }
stock CreatePlayerVehicle(playerid, model) { new pname[30], file[64], playercar, v; GetPlayerName(playerid, pname, sizeof(pname)); playercar = CreateVehicle(model, 170.8668, -16.1531, 1.5781, 220.7102, random(5), random(5), -1); PutPlayerInVehicle(playerid, playercar, 0); new INI:File = INI_Open(VehiclePath(v)); vInfo[v][ModelID] = model; vInfo[v][NrPlate] = "DT-0000-RP"; vInfo[v][Owner] = pname; vInfo[v][posX] = 170.8668; vInfo[v][posY] = -16.1531; vInfo[v][posZ] = 1.5781; vInfo[v][posA] = 220.7102; vInfo[v][ColorA] = random(50); vInfo[v][ColorB] = random(50); vInfo[v][Locked] = 1; INI_Close(File); format(file, 64, "Vehicles/%d.ini", v); if(fexist(file)) { INI_ParseFile(VehiclePath(v), "LoadVehicleData", false, true, v, true, false ); } SaveVehicles(); pInfo[playerid][VehicleOwner] = playercar; vEngine[playercar] = 1; return 1; }
new bool: isequal;
for (new i; i != 35; ++i)
{
if (vehicleid == LEOveh[i])
{
isequal = true;
break;
}
}
if (equal && pInfo[playerid][Faction] != 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You need to be a police officer in order to operate this vehicle!");
RemovePlayerFromVehicle(playerid);
}
Yes.
With the incorrect way, you only checked if the vehicleid was equal to RANDveh[0] and not the rest of the vehicles - that's not what we want! |
new bool: isequal;
for (new i; i != sizeof (LEOveh); ++i)
{
if (vehicleid == LEOveh[i])
{
isequal = true;
break;
}
}
if (equal && pInfo[playerid][Faction] != 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You need to be a police officer in order to operate this vehicle!");
RemovePlayerFromVehicle(playerid);
}