/lock Help(rep)
#1

hi i have a problem i want the lock cmd so nobody can enter the personal car.not even owner of the car.if the car is unlocked then anybody enter if car is locked then nobody enters car!im romanian i hope u understand! please help i hope u understand!.Please help!fast

Код:
else if(strcmp(x_nr,"lock",true) == 0)
		        {
	                new keycar = PlayerInfo[playerid][pPcarkey];
	                if(keycar != 9999)
                    
					{
	                    new Float:X,Float:Y,Float:Z;
	                    GetVehiclePos(keycar,X,Y,Z);
	                    if(IsPlayerInRangeOfPoint(playerid, 25,X,Y,Z))
						{
		                    new locked[128];
		                    locked = strtok(cmdtext, idx);
		                    if(CarInfo[keycar][cLock] == 1)
		                    {
								format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
								GameTextForPlayer(playerid, string, 4000, 3);
								CarInfo[keycar][cLock] = 0;
								OnPropUpdate(4,keycar);
								return 1;
							}
							else if(CarInfo[keycar][cLock] == 0)
							{
								format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
								GameTextForPlayer(playerid, string, 4000, 3);
								CarInfo[keycar][cLock] = 1;
								OnPropUpdate(4,keycar);
								return 1;
							}
						}
	    				else
						{
						    SendClientMessage(playerid, COLOR_GREY,"* You must be Near or in Your car to lock it!");
						    return 1;
						}
	                }
	                else
	                {
	                    SendClientMessage(playerid, COLOR_GREY, "* You don't have a vehicle at slot 1");
	                    return 1;
	                }
		        }
		        else if(strcmp(x_nr,"lock2",true) == 0)
		        {
	                new keycar = PlayerInfo[playerid][pPcarkey2];
	                if(keycar != 9999)
	                {
	                    new Float:X,Float:Y,Float:Z;
	                    GetVehiclePos(keycar,X,Y,Z);
						if(IsPlayerInRangeOfPoint(playerid, 25,X,Y,Z))
						{
		                    new locked[128];
		                    locked = strtok(cmdtext, idx);
		                    if(CarInfo[keycar][cLock] == 1)
		                    {
								format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
								GameTextForPlayer(playerid, string, 4000, 3);
								CarInfo[keycar][cLock] = 0;
								OnPropUpdate(4,keycar);
								return 1;
							}
							else if(CarInfo[keycar][cLock] == 0)
							{
								format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
								GameTextForPlayer(playerid, string, 4000, 3);
								CarInfo[keycar][cLock] = 1;
								OnPropUpdate(4,keycar);
								return 1;
							}
						}
						else
						{
						    SendClientMessage(playerid, COLOR_GREY,"* You must be Near or in Your car to lock it!");
						    return 1;
						}
	                }
	                else
	                {
	                    SendClientMessage(playerid, COLOR_GREY, "  You don't have a vehicle at slot 2");
	                    return 1;
	                }
		        }
Reply
#2

i useing this Code:
pawn Код:
if (strcmp(cmdtext, "/lock", true)==0)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new State=GetPlayerState(playerid);
            if(State!=PLAYER_STATE_DRIVER)
            {
                SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
                return 1;
            }
            new i;
            for(i=0;i<MAX_PLAYERS;i++)
            {
                if(i != playerid)
                {
                    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
                }
            }
            SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
            new Float:pX, Float:pY, Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            PlayerPlaySound(playerid,1056,pX,pY,pZ);
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
        }
        return 1;
    }
AND UNLOCK

pawn Код:
if (strcmp(cmdtext, "/unlock", true)==0)
    {
        if(IsPlayerInAnyVehicle(playerid)){
            new State=GetPlayerState(playerid);
            if(State!=PLAYER_STATE_DRIVER){
                SendClientMessage(playerid, COLOR_GREY,"You can only unlock the doors as the driver.");
                return 1;
            }
            new i;
            for(i=0;i<MAX_PLAYERS;i++){
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
            }
            SendClientMessage(playerid, COLOR_GREY, "Vehicle unlocked!");
            new Float:pX, Float:pY, Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            PlayerPlaySound(playerid,1057,pX,pY,pZ);
        }else{
            SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
        }
        return 1;
    }
Btw +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)