[HELP] LOCK WORKING WRONG
#1

hi, my /lock command works for all cars, i wan't to make it to work only for my own car. if i don't got it it says like: you dont got car.
Код:
if(strcmpEx(cmd, "/lock", true) == 0)
	{
	  if(VehicleLockedPlayer[playerid] != 999)
	  {
	    SendClientMessage(playerid, COLOR_WHITE, "You must first unlock your previous vehicle.");
	    return 1;
	  }
		new carid = GetPlayerVehicleID(playerid);
		if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
	    if(VehicleLocked[carid] == 0)
	 		{
  			if(pStats[playerid][pSex] == 1)
			{
				PlayerActionMessage(playerid,15.0,"has just locked his vehicle.");
			}
			else
			{
				PlayerActionMessage(playerid,15.0,"has just locked her vehicle.");
			}
			SendClientMessage(playerid,COLOR_WHITE,"Vehicle Locked.");
			VehicleLocked[carid] = 1;
			VehicleLockedPlayer[playerid] = carid;
			}
			if(VehicleLocked[carid] == 1)
			{
  			if(pStats[playerid][pSex] == 1)
			{
				PlayerActionMessage(playerid,15.0,"has just unlocked his vehicle.");
			}
			else
			{
				PlayerActionMessage(playerid,15.0,"has just unlocked her vehicle.");
			}
			SendClientMessage(playerid,COLOR_WHITE,"Vehicle Unlocked.");
			VehicleLocked[carid] = 0;
			VehicleLockedPlayer[playerid] = 999;
			}
		}
		else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
  			new Float:x,Float:y,Float:z;
  			if(VehicleLockedPlayer[playerid] != 999)
  			{
				GetVehiclePos(VehicleLockedPlayer[playerid], x, y, z);
			}
			if(VehicleLocked[VehicleLockedPlayer[playerid]])
			{
  				if(PlayerToPoint(5.0,playerid,x,y,z) || GetPlayerVehicleID(playerid) == VehicleLockedPlayer[playerid])
			  {
					if(pStats[playerid][pSex] == 1)
					{
						PlayerActionMessage(playerid,15.0,"has just unlocked his vehicle.");
					}
					else
					{
						PlayerActionMessage(playerid,15.0,"has just unlocked her vehicle.");
					}
					SendClientMessage(playerid,COLOR_WHITE,"Vehicle Unlocked.");
					VehicleLocked[VehicleLockedPlayer[playerid]] = 0;
					VehicleLockedPlayer[playerid] = 999;
				}
				else
				{
				  SendClientMessage(playerid,COLOR_WHITE,"You're unable to (un)lock your feet.");
				}
			}
 		}
it should look like:
Код:
  if(pStats[playerid][pCarModel] == 0;)
  {
  SendClientMessage(playerid,COLOR_WHITE,"You don't have your own car");
  } else {
      if(VehicleLocked[carid] == 0)
      {
      VehicleLocked[carid] = 1;
      SendClientMessage(playerid,COLOR_WHITE,"Car has been locked");
      }
      if(VehicleLocked[carid] == 1)
      {
      VehicleLocked[carid] = 0;
      SendClientMessage(playerid,COLOR_WHITE,"Car has been unlocked");
      }
  }
The problem is i don't know how to get player's car... HELP ME !
Reply
#2

pawn Код:
new vehicle;
vehicle = GetPlayerVehicleID(playerid);//Gets the id of the vehicle the player is in
pawn Код:
new model;
model = GetVehicleModel(vehicle);//Gets the model of the vehicle the player is in, needs the function above
Reply
#3

You need to learn the difference of vehicleid and vehiclemodel.
id is the vehicles id on the server.
model is like 560 = sultan
Reply
#4

you didn't understood me, i wan't that the player can lock only his vehicle, what he bought from Car Shop etc. not which one he is in.

Here is my GM PasteBin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)