Not getting pos properly..
#1

Код:
	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);
Tried printing the pos, just keeps printing 0.000000000

But for some reason this works..

Код:
	vInfo[v][posX] = 170.8668;
	vInfo[v][posY] = -16.1531;
	vInfo[v][posZ] = 1.5781;
	vInfo[v][posA] = 220.7102;
Reply
#2

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 Код:
new v = pInfo[playerid][VehicleOwner], currentveh = GetPlayerVehicleID(playerid), string[128];
Tip: use %f to print floats if you want the decimal places too to be printed.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
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 Код:
new v = pInfo[playerid][VehicleOwner], currentveh = GetPlayerVehicleID(playerid), string[128];
Tip: use %f to print floats if you want the decimal places too to be printed.
Also, when a player buys a newly spawned vehicle it says they're not a cop to enter it.. I've already defined my LeoVeh's 50 of them infact.. heres some code..

Код:
	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);
				}
			}
MY CREATE VEHICLE AFTER BUY:

Код:
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;
}
Reply
#4

The checking is incorrect. You need to check if a == b || a == c and using if a == b || c is not correct.

Although using a loop is easier instead of keep writing etc. I see you use the first 36 indexes, so something like:
PHP код:
new boolisequal;
for (new 
i!= 35; ++i)
{
    if (
vehicleid == LEOveh[i])
    {
        
isequal true;
        break;
    }
}
if (
equal && pInfo[playerid][Faction] != 1)
{
    
SendClientMessage(playeridCOLOR_LIGHTRED"SERVER:{FFFFFF} You need to be a police officer in order to operate this vehicle!");
    
RemovePlayerFromVehicle(playerid);

Reply
#5

So like

vehicleid == RANDveh[0] || RANDveh[1]

changed to

vehicleid == RANDveh[0] || vehicleid == RANDveh[1]
Reply
#6

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!
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
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!
Problem, I have 50 Leoveh's, and they all wont fit on 1 line, anyway to just check like [0-50] ?
Reply
#8

Using a loop:
PHP код:
new boolisequal;
for (new 
i!= sizeof (LEOveh); ++i)
{
    if (
vehicleid == LEOveh[i])
    {
        
isequal true;
        break;
    }
}

if (
equal && pInfo[playerid][Faction] != 1)
{
    
SendClientMessage(playeridCOLOR_LIGHTRED"SERVER:{FFFFFF} You need to be a police officer in order to operate this vehicle!");
    
RemovePlayerFromVehicle(playerid);

Reply


Forum Jump:


Users browsing this thread: