SA-MP Forums Archive
CMD Does not recognize car - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CMD Does not recognize car (/showthread.php?tid=401841)



CMD Does not recognize car - NicholasA - 24.12.2012

Hey guys so i got this cmd:

pawn Код:
COMMAND:startmech(playerid, params[]) // work at mechanic and receive $180
{
  if(!IsPlayerInRangeOfPoint(playerid, 30.0,2451.0056,-2118.1301,13.5469))return SendClientMessage(playerid, 0xE0313AFF, "(( [Mechanic]You are not at the mechanic HQ! ))");
  if(!IsPlayerInVehicle(playerid, 525)) return SendClientMessage(playerid, 0xE0313AFF, "(( [Mechanic] You are not in a mechanics vehicle! ))");
  SendClientMessage(playerid, 0x3524C9FF, "(( [Mechanic] Deliver the tires to the checkpoint and receive your paycheck! ))");
  SetPlayerCheckpoint(playerid, 848.1696,-1445.7803,13.5762, 5.0);
  return 1;
}
But when im in car id 525 (mech car) it still say you are not in a mechanics car!


Re: CMD Does not recognize car - Konstantinos - 24.12.2012

525 is the modelid, you need to use the vehicleid and in that case, you should create the vehicle with a name and use that in the function.
pawn Код:
// Example:

// Global variable
new
    mechanic_veh
;

// Somewhere you create the vehicle
mechanic_veh = CreateVehicle(525 ... /* rest of params */);

// to that command
if(!IsPlayerInVehicle(playerid, mechanic_veh)) return SendClientMessage(playerid, 0xE0313AFF, "(( [Mechanic] You are not in a mechanics vehicle! ))");
You should also check if he is driver to use the command, because he might be passenger.


Re: CMD Does not recognize car - Hiddos - 24.12.2012

Or, if you want it to apply to every mechanic car (which is what I'm thinking you're trying to do):
pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 525) // return wrong vehicle



Re: CMD Does not recognize car - NicholasA - 24.12.2012

Quote:
Originally Posted by Dwane
Посмотреть сообщение
525 is the modelid, you need to use the vehicleid and in that case, you should create the vehicle with a name and use that in the function.
pawn Код:
// Example:

// Global variable
new
    mechanic_veh
;

// Somewhere you create the vehicle
mechanic_veh = CreateVehicle(525 ... /* rest of params */);

// to that command
if(!IsPlayerInVehicle(playerid, mechanic_veh)) return SendClientMessage(playerid, 0xE0313AFF, "(( [Mechanic] You are not in a mechanics vehicle! ))");
You should also check if he is driver to use the command, because he might be passenger.
like this?

pawn Код:
new
    mechanic_veh
;

public OnFilterScriptInit()
{
    mechanic_veh = CreateVehicle(525,2475.3677,-2114.7422,13.3108,2.6581,129,135,60); // mechcar1
    mechanic_veh = CreateVehicle(525,2480.3181,-2114.5127,13.3162,2.6571,129,135,60); // mechcar2
    mechanic_veh = CreateVehicle(525,2485.0183,-2114.2949,13.3213,2.6560,129,135,60); // mechcar3
    mechanic_veh = CreateVehicle(525,2490.4072,-2114.0449,13.3223,2.6560,129,135,60); // mechcar4
    mechanic_veh = CreateVehicle(525,2497.4038,-2113.7207,13.3236,2.6560,129,135,60); // mechcar5
    mechanic_veh = CreateVehicle(525,2504.9688,-2113.3699,13.3250,2.6560,129,135,60); // mechcar6
    mechanic_veh = CreateVehicle(525,2511.7051,-2113.0574,13.3262,2.6560,129,135,60); // mechcar7
    CreatePickup(1239,1,2460.5691,-2118.7847,13.5530,0); // repair pickup
    Create3DTextLabel("(( Repair your vehicle here for $175, /repairvehicle ))", 0xEB0C0FFF, 2460.5691,-2118.7847,13.5530, 30.0, 0, 0); //repair label
    CreatePickup(1239,1,2451.0056,-2118.1301,13.5469,0); // startwork pickup
    Create3DTextLabel("(( Start working as mechanic, /startmech ))", 0xEB0C0FFF, 2451.0056,-2118.1301,13.5469, 30.0, 0, 0); //startwork label
}



Re: CMD Does not recognize car - Konstantinos - 24.12.2012

If there aren't more vehicle with modelid 525 in your server, then you can use what Hiddos said, but in case you have more vehicles with that modelid, then use what I gave you, but you need more.
pawn Код:
new
    mechanic_veh[ 7 ]
;

public OnFilterScriptInit()
{
    mechanic_veh[ 0 ] = CreateVehicle(525,2475.3677,-2114.7422,13.3108,2.6581,129,135,60); // mechcar1
    mechanic_veh[ 1 ] = CreateVehicle(525,2480.3181,-2114.5127,13.3162,2.6571,129,135,60); // mechcar2
    mechanic_veh[ 2 ] = CreateVehicle(525,2485.0183,-2114.2949,13.3213,2.6560,129,135,60); // mechcar3
    mechanic_veh[ 3 ] = CreateVehicle(525,2490.4072,-2114.0449,13.3223,2.6560,129,135,60); // mechcar4
    mechanic_veh[ 4 ] = CreateVehicle(525,2497.4038,-2113.7207,13.3236,2.6560,129,135,60); // mechcar5
    mechanic_veh[ 5 ] = CreateVehicle(525,2504.9688,-2113.3699,13.3250,2.6560,129,135,60); // mechcar6
    mechanic_veh[ 6 ] = CreateVehicle(525,2511.7051,-2113.0574,13.3262,2.6560,129,135,60); // mechcar7
    CreatePickup(1239,1,2460.5691,-2118.7847,13.5530,0); // repair pickup
    Create3DTextLabel("(( Repair your vehicle here for $175, /repairvehicle ))", 0xEB0C0FFF, 2460.5691,-2118.7847,13.5530, 30.0, 0, 0); //repair label
    CreatePickup(1239,1,2451.0056,-2118.1301,13.5469,0); // startwork pickup
    Create3DTextLabel("(( Start working as mechanic, /startmech ))", 0xEB0C0FFF, 2451.0056,-2118.1301,13.5469, 30.0, 0, 0); //startwork label
}
pawn Код:
// Command
if(!IsPlayerInVehicle(playerid, mechanic_veh[ 0 ]) || !IsPlayerInVehicle(playerid, mechanic_veh[ 1 ])
|| !IsPlayerInVehicle(playerid, mechanic_veh[ 2 ]) || !IsPlayerInVehicle(playerid, mechanic_veh[ 3 ])
|| !IsPlayerInVehicle(playerid, mechanic_veh[ 4 ]) || !IsPlayerInVehicle(playerid, mechanic_veh[ 5 ])
|| !IsPlayerInVehicle(playerid, mechanic_veh[ 6 ])) return SendClientMessage(playerid, 0xE0313AFF, "(( [Mechanic] You are not in a mechanics vehicle! ))");