SA-MP Forums Archive
[Command]/lock/unlock bugged - 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: [Command]/lock/unlock bugged (/showthread.php?tid=652205)



[Command]/lock/unlock bugged - Mike861 - 05.04.2018

Since now these two cmds were working fine, now for some reason they won't work now and server gives unknown cmd msg.Its pretty weird..

Код:
CMD:lock(playerid, params[])
{
	new string[100], playername[256], name[MAX_PLAYER_NAME];
	if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage2(playerid, COLOR_RED, "You must be the driver of a vehicle!");
	new moneys1 = GetPlayerVehicleID(playerid);
	if (plockedveh[playerid] == moneys1) return SendClientMessage2(playerid, COLOR_RED, "Error: You have already locked this vehicle.");
	if (vorgo[moneys1] != 0) return SendClientMessage2(playerid, COLOR_RED, "Error: You can't lock organization vehicles.");
	new giveplayerid = GetVehicleModel(moneys1);
	if (giveplayerid == 481 || giveplayerid == 509 || giveplayerid == 510) return SendClientMessage2(playerid, COLOR_RED, "Error: This vehicle doesn't have locks!");
	if (giveplayerid == 449 || giveplayerid == 537 || giveplayerid == 538 || cfs[moneys1][0] != 0) return SendClientMessage2(playerid, COLOR_RED, "Sorry this vehicles locking mechanisms have been disabled.");
	for (new i = 0, playercount=GetPlayerPoolSize(); i <= playercount; i++)
	{
		if (i != playerid)
		{
			if(plockedveh[i] == moneys1) {
				plockedveh[i] = 0;
			}
		}
	}
	for(new i = 0, playercount=GetPlayerPoolSize(); i <= playercount; i++)
	{
		if (PlayerVehicle(i, moneys1) != -1)
		{
		    GetPlayerName(i, playername, MAX_PLAYER_NAME);
		    GetPlayerName(playerid, name, sizeof(name));
		    if (plockedv[playerid][moneys1] == 1) return SendClientMessage2(playerid, COLOR_RED, "Error: You have already locked this vehicle.");
		    format(string, 50, "V_%s_%d", playername, PlayerVehicle(i, moneys1));
		    if (pvkeys[playerid][moneys1] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You dont have this vehicles keys.");
			dini_IntSet(AddDirFile(dir_carfiles, string), "locked", 1);
			SendClientMessage2(playerid, COLOR_YELLOW, "Vehicle locked!");
			plockedv[playerid][moneys1] = 1;
	  		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
			printf("[lock] %s (Id%d) has locked their %s.", name, playerid, vehName[giveplayerid-400]);
			return 1;
		}
	}
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	SendClientMessage2(playerid, COLOR_YELLOW, "Vehicle locked!");
	if (plockedveh[playerid] != 0)
	{
		SendPlayerFormattedText(playerid, COLOR_WHITE, "The %s that you locked previously has been unlocked.", vehName[GetVehicleModel(plockedveh[playerid])-400], "");
	}
	lockedveh[moneys1] = 1;
	plockedveh[playerid] = moneys1;
	PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
	printf("[lock] %s (Id%d) has locked their %s.", playername, playerid, vehName[giveplayerid-400]);
	return 1;
}

CMD:unlock(playerid, params[])
{
	new string[100], playername[256], name[MAX_PLAYER_NAME];
	if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage2(playerid, COLOR_RED, "You must be the driver of a vehicle!");
	new moneys1 = GetPlayerVehicleID(playerid);
	new giveplayerid = GetVehicleModel(moneys1);
	if (giveplayerid == 481 || giveplayerid == 509 || giveplayerid == 510) return SendClientMessage2(playerid, COLOR_RED, "Error: This vehicle doesn't have locks!");
	if (giveplayerid == 449 || giveplayerid == 537 || giveplayerid == 538 || cfs[moneys1][0] != 0) return SendClientMessage2(playerid, COLOR_RED, "Sorry this vehicles locking mechanisms have been disabled.");
	for (new i = 0, playercount=GetPlayerPoolSize(); i <= playercount; i++) {
	    if(plockedveh[i] == moneys1 && i!=playerid) {
	        plockedveh[i]=0;
	    }
	}
	for (new i = 0, playercount=GetPlayerPoolSize(); i <= playercount; i++)
	{
		if (PlayerVehicle(i, moneys1) != -1)
		{
		    GetPlayerName(i, playername, MAX_PLAYER_NAME);
		    GetPlayerName(playerid, name, sizeof(name));
		    if (plockedv[playerid][moneys1] == 0) return SendClientMessage2(playerid, COLOR_RED, "Error: This vehicle is already unlocked.");
		    format(string, 50, "V_%s_%d", playername, PlayerVehicle(i, moneys1));
		    if (pvkeys[playerid][moneys1] == 0) return SendClientMessage(playerid, COLOR_RED, "You dont have this vehicles keys.");
			dini_IntSet(AddDirFile(dir_carfiles, string), "locked", 0);
			SendClientMessage2(playerid, COLOR_YELLOW, "Vehicle unlocked!");
			plockedv[playerid][moneys1] = 0;
			PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
			printf("[unlock] %s (Id%d) has unlocked their %s.", name, playerid, vehName[giveplayerid-400]);
			return 1;
		}
	}
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	if (plockedveh[playerid] != moneys1) return SendClientMessage2(playerid, COLOR_RED, "Error: This vehicle is already unlocked.");
	lockedveh[moneys1] = 0;
	plockedveh[playerid] = 0;
	SendClientMessage2(playerid, COLOR_YELLOW, "Vehicle unlocked!");
	PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
	printf("[unlock] %s (Id%d) has unlocked their %s.", playername, playerid, vehName[giveplayerid-400]);
	return 1;
}