problem with my script when entering car
#1

Hey guys iv got this code for when a player enters a car:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_PASSENGER)
	{
	    SetPlayerArmedWeapon(playerid,0);
	}
	if(newstate == PLAYER_STATE_PASSENGER)
	{
	    if(newstate == PLAYER_STATE_PASSENGER)
	    {
	        new gun,tmp;
	        GetPlayerWeaponData(playerid,4,gun,tmp);
	        #pragma unused tmp
	        if(gun)SetPlayerArmedWeapon(playerid,gun);
	        else SetPlayerArmedWeapon(playerid,0);
	    }
	    if(GetPlayerVehicleID(playerid) == NPCBus)
	    {
	        new string[128], BusDriver = RPIDFN("BusDriver");
	        if(PlayerInfo[playerid][pMoney] < 2)
	        {
	            RemovePlayerFromVehicle(playerid);
	            format(string, sizeof(string), "Bus Driver shouts: Get out of the bus poor hobo!");
				SendNearbyMessage(BusDriver, 30, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
	            return 1;
	        }
	        format(string, sizeof(string), "Bus Driver says: The ticket costs $5, you will have to pay $2 everytime the bus stops.");
			SendNearbyMessage(BusDriver, 10, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
			format(string, sizeof(string), "* %s takes out $5, hands them to the bus driver and grabs a ticket.", RPN(playerid));
 			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	        GiveZaiatMoney(playerid, -5);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, " You will not recieve any playing minutes until you get out of the bus.");
	        SetTimerEx("BusTimer", 1000, false, "i", playerid);
	    }
	}
	if(newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER)//inside vehicle
	{
	    new vehicleid = GetPlayerVehicleID(playerid);
	    new engine, lights, alarm, doors, bonnet, boot, objective;
		GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
		if(!engine) SendClientMessage(playerid, COLOR_WHITE, "Type {FF6347}/engine{FFFFFF} to start the vehicle.");
		if(!PlayerInfo[playerid][pCarLic]) SendClientMessage(playerid, COLOR_LIGHTRED, " You don't have a drivers license, beware of cops.");
		if(IsATowTruck(vehicleid)) SendClientMessage(playerid, COLOR_WHITE, "You can tow a vehicle using {FF6347}/tow{FFFFFF}."); //cometow
		if(IsDMVCar(vehicleid))
		{
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "* GPS: Finish the test by driving through all of the checkpoints on your map.");
			SetPlayerCheckpoint(playerid,2040.7101,-1930.1340,13.4667,5);
			SendClientMessage(playerid, COLOR_RED, "If you exit the car your test will be failed and it will have to be re-done.");
		}
		else
		{
			if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pTPackages] >= 1 && PlayerInfo[playerid][pDeliverTruck] != GetPlayerVehicleID(playerid))
			{
				GameTextForPlayer(playerid, "~r~You have already loaded~n~a different truck",4000,3);
				DisablePlayerCheckpoint(playerid);
			}
			else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pTPackages] >= 1)
			{
				startingtruckjob[playerid] = 2;
				SetPlayerCheckpoint(playerid, 2222.5107,-2682.7368,13.5409, 5);
				GameTextForPlayer(playerid, "~g~This truck is loaded~n~take it to the marker",4000,3);
			}
			else if(IsTruckerVehicle(vehicleid)) 
			{	
				startingtruckjob[playerid] = 1;
				GameTextForPlayer(playerid, "~g~Drive to the marker to~n~load some packages",4000,3);
				SetPlayerCheckpoint(playerid,867.3699,-1209.2664,16.9766,5);
			}
		}
	}
	return 1;
}
My problem is. in this section:
Код:
	if(newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER)//inside vehicle
	{
	    new vehicleid = GetPlayerVehicleID(playerid);
	    new engine, lights, alarm, doors, bonnet, boot, objective;
		GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
		if(!engine) SendClientMessage(playerid, COLOR_WHITE, "Type {FF6347}/engine{FFFFFF} to start the vehicle.");
		if(!PlayerInfo[playerid][pCarLic]) SendClientMessage(playerid, COLOR_LIGHTRED, " You don't have a drivers license, beware of cops.");
		if(IsATowTruck(vehicleid)) SendClientMessage(playerid, COLOR_WHITE, "You can tow a vehicle using {FF6347}/tow{FFFFFF}."); //cometow
		if(IsDMVCar(vehicleid))
		{
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "* GPS: Finish the test by driving through all of the checkpoints on your map.");
			SetPlayerCheckpoint(playerid,2040.7101,-1930.1340,13.4667,5);
			SendClientMessage(playerid, COLOR_RED, "If you exit the car your test will be failed and it will have to be re-done.");
		}
		else
		{
			if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pTPackages] >= 1 && PlayerInfo[playerid][pDeliverTruck] != GetPlayerVehicleID(playerid))
			{
				GameTextForPlayer(playerid, "~r~You have already loaded~n~a different truck",4000,3);
				DisablePlayerCheckpoint(playerid);
			}
			else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pTPackages] >= 1)
			{
				startingtruckjob[playerid] = 2;
				SetPlayerCheckpoint(playerid, 2222.5107,-2682.7368,13.5409, 5);
				GameTextForPlayer(playerid, "~g~This truck is loaded~n~take it to the marker",4000,3);
			}
			else if(IsTruckerVehicle(vehicleid)) 
			{	
				startingtruckjob[playerid] = 1;
				GameTextForPlayer(playerid, "~g~Drive to the marker to~n~load some packages",4000,3);
				SetPlayerCheckpoint(playerid,867.3699,-1209.2664,16.9766,5);
			}
		}
	}
	return 1;
}
What im trying to do, is do all the checks like if engine is on blah blah, that all works. What isnt working is checking wether the vehicle entered is a DMV vehicle or a trucker vehicle. Im not sure what iv done wrong, i get no errors. But with the way it is right now only the DMV works and when getting in trucks that code doesnt process at all.
Please help me, I want the DMV code to work and the truck aswel. At the moment its either one or the other.
Thanks heaps, its probably a simple mistake on my behalf but i cant figure it out!
Reply
#2

The problem lies in the checking of wether its a dmv or a trucker vehicle. Please can someone help?
Код:
		if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pTPackages] >= 1 && PlayerInfo[playerid][pDeliverTruck] != GetPlayerVehicleID(playerid))
		{
			GameTextForPlayer(playerid, "~r~You have already loaded~n~a different truck",4000,3);
			DisablePlayerCheckpoint(playerid);
		}
		else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pTPackages] >= 1)
		{
			startingtruckjob[playerid] = 2;
			SetPlayerCheckpoint(playerid, 2222.5107,-2682.7368,13.5409, 5);
			GameTextForPlayer(playerid, "~g~This truck is loaded~n~take it to the marker",4000,3);
		}
		else if(IsTruckerVehicle(vehicleid)) 
		{	
			startingtruckjob[playerid] = 1;
			GameTextForPlayer(playerid, "~g~Drive to the marker to~n~load some packages",4000,3);
			SetPlayerCheckpoint(playerid,867.3699,-1209.2664,16.9766,5);
		}
		else if(IsDMVCar(vehicleid))
		{
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "* GPS: Finish the test by driving through all of the checkpoints on your map.");
			SetPlayerCheckpoint(playerid,2040.7101,-1930.1340,13.4667,5);
			SendClientMessage(playerid, COLOR_RED, "If you exit the car your test will be failed and it will have to be re-done.");
		}
	}
	return 1;
}
What am I doing wrong?
Reply
#3

Can you send me the functions for IsTruckerVehicle and IsDMVCar?
Reply
#4

sure tyvm
Truck:
Код:
stock IsTruckerVehicle(vehicleid)
{
	for(new i=0; i<10; i++)
	{
	    if(vehicleid == JobInfo[JOB_TRUCKER][jCars][i]) return 1;
	}
	return 0;
}
DMV:
Код:
stock IsDMVCar(vehicleid)
{
    for(new i=0; i<5; i++)
    {
        if(vehicleid == DMVCar[i]) return 1;
    }
    return 0;
}
Is this what you need?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)