strange problem with stock
#1

Hello. I have this strange problem. I added 5 vehicles and a stock to check if vehicleid is equal to any of the vehicles. When I try to use this stock in any vehicle which isn't equal to created vehicles, the command won't perform, it just says that command isn't on the server.
This are vehicles:
Код:
JobInfo[JOB_TRUCKER][jCars][0] = CreateVehicle(515,-2117.6001000,-175.3000000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][1] = CreateVehicle(515,-2117.5000000,-165.3000000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][2] = CreateVehicle(515,-2117.5000000,-154.7998000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][3] = CreateVehicle(515,-2137.3000500,-131.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][4] = CreateVehicle(515,-2105.0000000,-186.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][5] = CreateVehicle(515,-2144.1999500,-131.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
this is stock:
Код:
stock IsTruckerVehicle(vehicleid)
{
	for(new i=0; i<20; i++)
	{
	    if(vehicleid == JobInfo[JOB_TRUCKER][jCars][i])
		return 1;
	}
	return 0;
}
and command for example:
Код:
CMD:istruckerveh(playerid, params[])
{
	if(IsPlayerInAnyVehicle(playerid))
	{
		new veh = GetPlayerVehicleID(playerid);
		if(IsTruckerVehicle(veh)) SendClientMessage(playerid, COLOR_PINK, "Yes.");
	    else SendClientMessage(playerid, COLOR_PINK, "Nope.");
	}
	else
	SendClientMessage(playerid, COLOR_WHITE, "You must be in vehicle to use this command.");
	return 1;
}
When I'm not in any vehicle, I get message you must be in veh... and when I go on some bike for example and try to enter the command, I command does not exist on the server. Please does anyone know why is this happening? I really don't know how to fix. Thank you
Reply
#2

pawn Код:
CMD:istruckerveh(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You must be in vehicle to use this command.");
else
{
    new veh = GetPlayerVehicleID(playerid);
        if(IsTruckerVehicle(veh)) SendClientMessage(playerid, COLOR_PINK, "Yes.");
        else SendClientMessage(playerid, COLOR_PINK, "Nope.");
}
return 1;
}
Reply
#3

Same thing, not working. You didn't change anything.
Reply
#4

pawn Код:
CMD:istruckerveh(playerid, params[])
{
    if(IsPlayerInVehicle(playerid, 515))
    {
        new veh = GetPlayerVehicleID(playerid);
        if(IsTruckerVehicle(veh)) SendClientMessage(playerid, COLOR_PINK, "Yes.");
        else SendClientMessage(playerid, COLOR_PINK, "Nope.");
    }
    else
    SendClientMessage(playerid, COLOR_WHITE, "You must be in vehicle to use this command.");
    return 1;
}
Hope that helps
Reply
#5

First of all i would check the enum size, max jobs etc.. then set the loop you are doing under the stock that it would match, so it would get the right data.
Reply
#6

I think you should revise the script by testing it as filterscript first.
Reply
#7

I got something which will help me I hope. When I start my server, it prints number of vehicle models. With this:
Код:
JobInfo[JOB_TRUCKER][jCars][0] = CreateVehicle(515,-2117.6001000,-175.3000000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][1] = CreateVehicle(515,-2117.5000000,-165.3000000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][2] = CreateVehicle(515,-2117.5000000,-154.7998000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][3] = CreateVehicle(515,-2137.3000500,-131.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][4] = CreateVehicle(515,-2105.0000000,-186.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][5] = CreateVehicle(515,-2144.1999500,-131.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
number of vehicle models is 20. But when I remove those lines, number is 19. How is that even possible? :/
Reply
#8

Quote:
Originally Posted by dominik523
Посмотреть сообщение
I got something which will help me I hope. When I start my server, it prints number of vehicle models. With this:
Код:
JobInfo[JOB_TRUCKER][jCars][0] = CreateVehicle(515,-2117.6001000,-175.3000000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][1] = CreateVehicle(515,-2117.5000000,-165.3000000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][2] = CreateVehicle(515,-2117.5000000,-154.7998000,36.5000000,270.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][3] = CreateVehicle(515,-2137.3000500,-131.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][4] = CreateVehicle(515,-2105.0000000,-186.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
	JobInfo[JOB_TRUCKER][jCars][5] = CreateVehicle(515,-2144.1999500,-131.8000000,36.5000000,0.0000000,6,0,300); //Roadtrain
number of vehicle models is 20. But when I remove those lines, number is 19. How is that even possible? :/
Just use printf or format on OnPlayerEnterVehicle. You can fix it from there.
Reply
#9

I tried to add a message when I enter vehicle to see if it will send a message which will say that its a truck. It didn't send anything and other code under onplayerentervehicle wasn't working because of that stock.
Reply
#10

Quote:
Originally Posted by dominik523
Посмотреть сообщение
I tried to add a message when I enter vehicle to see if it will send a message which will say that its a truck. It didn't send anything and other code under onplayerentervehicle wasn't working because of that stock.
What do you mean? Just try this...

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new vehid[128];
    format(vehid,sizeof(vehid),"Your are in vehicle ID: %d",vehicleid);
    SendClientMessage(playerid,-1,vehid);
    return 1;
}
Reply
#11

Change
Код:
for(new i=0; i<20; i++)
to
Код:
for(new i=0; i<6; i++)
*Note: You have 6 trucker vehicles. Not 20. Exceeding the array index will cause errors and return the command as 'unknown'.
Reply
#12

YEAH! it works now thanks to you Pleomax
Thank you guys for big help, I really appreciate it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)