Job Error
#1

I did it so you have to do /engine to start the car but if you do not own the vehicle you cannot start it and only the owner can and this works but it stops factions/jobs employees from starting their vehicles.

Код:
CMD:engine(playerid, params[])
{
	new engine,lights,alarm,doors,bonnet,boot,objective,vehicleid, string[128];
	vehicleid = GetPlayerVehicleID(playerid);
	if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessage(playerid,COLOR_WHITE,"{F81414}[ERROR]: {FFFFFF}This command can't be used in this vehicle.");
	GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
	if(engine == VEHICLE_PARAMS_ON)
	{
		format(string, sizeof(string), "*[SERVER]: %s twists the key in the ignition, turning the engine off.", GetPlayerNameEx(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		SetVehicleEngine(vehicleid, playerid);
	}
	else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
	{
  {
		foreach(Player, i)
  		{
		  for(new d=0; d<MAX_PLAYERVEHICLES; d++)
		  {
		  	if(PlayerVehicleInfo[i][d][pvId] == vehicleid)
		  	{
     			if(i == playerid)
        		{
          			if(!IsABike(vehicleid))
             		{
						SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait...");
						SetTimerEx("SetVehicleEngine", 1000, 0, "dd",  vehicleid, playerid);
						format(string, sizeof(string), "* %s twists the key in the ignition, turning the engine on.", GetPlayerNameEx(playerid));
						ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						return 1;
        			}
					else
					{
	    				SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait...");
						SetTimerEx("SetVehicleEngine", 700, 0, "dd",  vehicleid, playerid);
						format(string, sizeof(string), "* %s flips the killswitch to the on position and depresses the ignition switch, turning the engine on.", GetPlayerNameEx(playerid));
						ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						return 1;
						}
					}
					else if(i == PlayerInfo[playerid][pVehicleKeysFrom])
					{
						if(!IsABike(vehicleid))
      					{
							SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait...");
							SetTimerEx("SetVehicleEngine", 1000, 0, "dd",  vehicleid, playerid);
							format(string, sizeof(string), "* %s twists the key in the ignition, turning the engine on.", GetPlayerNameEx(playerid));
							ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
							return 1;
        				}
						else
						{
		    				SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait...");
							SetTimerEx("SetVehicleEngine", 700, 0, "dd",  vehicleid, playerid);
							format(string, sizeof(string), "* %s flips the killswitch to the on position and depresses the ignition switch, turning the engine on.", GetPlayerNameEx(playerid));
							ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
							return 1;
							}
						}
						else
						{
							SendClientMessage(playerid, COLOR_GRAD2, "{F81414}[ERROR]: {FFFFFF}You do not have the keys for this vehicle / any car jacking items to start the ignition!");
							return 1;
						}
					}
				}
			}
		}
	}
	return 1;
}
Reply
#2

Anyone got any ideas?
Reply
#3

Remove this, Wrong thread.
Reply
#4

What do you mean?
Reply
#5

You should make a parameter for the job cars like JobCar and if its = with 1 you can start the engine, if it's = 0 you can't, after that u should verify if the player has the job.
Reply
#6

How do you know which one is a faction vehicle ?
Why are you looping thru players ? you should only check and see if (PlayerVehicleInfo[playerid][d][pvId] == vehicleid)

you can simply first check if(IsFactionVehicle(vehicleid)) {
SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait...");
SetTimerEx("SetVehicleEngine", 1000, 0, "dd", vehicleid, playerid);
format(string, sizeof(string), "* %s twists the key in the ignition, turning the engine on.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
return 1;
}

and make a function called IsFactionVehicle(veh) to return 1 if some vehicle is a faction one, return 0 if it's not.
Reply
#7

I've done this

Код:
					if(IsFactionVehicle(vehicleid))
					{
						SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait...");
						SetTimerEx("SetVehicleEngine", 1000, 0, "dd", vehicleid, playerid);
						format(string, sizeof(string), "* %s twists the key in the ignition, turning the engine on.", GetPlayerNameEx(playerid));
						ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						return 1;
					}
Onto the CMD:engine

and made:

Код:
IsFactionVehicle(carid) {
	switch(GetVehicleModel(carid))  {
	    case 598, 596, 490, 427, 601, 523: return 1;
	}
	return 0;
}
But I'm not sure this is right.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)