"/lock" Doesn't want to work.
#1

Ok so, ive been browsing the forums for hours, got some code snippets and started making my /lock command. /lock will work inside the car, but not outside of it.

If anybody could help me out fixing this, I would appreciate it alot.

Код:
	if (strcmp("/lock", cmdtext, true, 5) == 0)
	{
	  GetPlayerName(playerid, sendername, sizeof(sendername));
		new carid=GetPlayerVehicleID(playerid);
		new carid1=GetClosestCar(playerid);
		if(IsPlayerInAnyVehicle(playerid))
		{
	    if(VehicleLocked[carid] == 0)
	 		{
				format(string, sizeof(string), "* %s presses a button inside his/her vehicle and locks their vehicle.", sendername);
	 			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				VehicleLocked[carid] = 1;
				VehicleLockedPlayer[playerid] = carid;
				
				new i;
				for (i=0;i<MAX_PLAYERS;i++)
				{
    		SetVehicleParamsForPlayer(carid,i,0,1);
    		}

			}
			else
			{
				format(string, sizeof(string), "* %s presses a button inside his/her vehicle and unlocks their vehicle.", sendername);
	 			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				VehicleLocked[VehicleLockedPlayer[playerid]] = 0;
				VehicleLockedPlayer[playerid] = 999;
				
				new i;
				for (i=0;i<MAX_PLAYERS;i++)
				{
    		SetVehicleParamsForPlayer(carid,i,0,0);
    		}
			}
		}
		else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
 			new Float:x2,Float:y2,Float:z2;
			GetVehiclePos(VehicleLockedPlayer[playerid], x2, y2, z2);
			
			if(VehicleLocked[carid] == 0)
			{
 				if(PlayerToPoint(5.0,playerid,x2,y2,z2))
			  {
 					format(string, sizeof(string), "* %s uses his/her key to lock their vehicle.", sendername);
	 				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					VehicleLocked[carid] = 1;
					VehicleLockedPlayer[playerid] = carid;

					
					new i;
					for (i=0;i<MAX_PLAYERS;i++)
					{
    				SetVehicleParamsForPlayer(carid,i,0,1);
 					}
				}
			}
			else if(VehicleLocked[carid1] == 0)
			{
			  if(PlayerToPoint(5.0,playerid,x2,y2,z2))
			  {
 					format(string, sizeof(string), "* %s uses his/her key to unlock their vehicle.", sendername);
	 				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					VehicleLocked[VehicleLockedPlayer[playerid]] = 0;
					VehicleLockedPlayer[playerid] = 999;

					new i;
					for (i=0;i<MAX_PLAYERS;i++)
					{
    				SetVehicleParamsForPlayer(carid,i,0,0);
    			}
  			}
			}
 		}
		return 1;
	}
EDIT:

Heres the pastebin if you guys prefer that
http://pastebin.com/m7123bd54
Reply


Messages In This Thread
"/lock" Doesn't want to work. - by Verlix - 07.05.2009, 21:54
Re: "/lock" Doesn't want to work. - by Xeretta - 07.05.2009, 22:08
Re: "/lock" Doesn't want to work. - by Verlix - 08.05.2009, 06:22
Re: "/lock" Doesn't want to work. - by Rks25 - 08.05.2009, 12:32
Re: "/lock" Doesn't want to work. - by Verlix - 11.05.2009, 07:02
Re: "/lock" Doesn't want to work. - by NeRoSiS - 11.05.2009, 07:11
Re: "/lock" Doesn't want to work. - by Verlix - 11.05.2009, 07:20
Re: "/lock" Doesn't want to work. - by devil614 - 13.05.2009, 01:42

Forum Jump:


Users browsing this thread: 2 Guest(s)